Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit c4e694f

Browse files
committed
Changes to Connect ID dropdown:
- only show project's name - list only active project - change field label
1 parent 595d71c commit c4e694f

File tree

4 files changed

+49
-14
lines changed

4 files changed

+49
-14
lines changed

src/front/src/app/projects/project.service.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,26 @@ angular.module('topcoderX')
154154
"Authorization": "Bearer " + AuthService.getTokenV3()
155155
},
156156
params: {
157-
fields: 'id,name,status',
157+
fields: 'id,name',
158158
sort: 'lastActivityAt desc',
159159
perPage: perPage,
160-
page: page
160+
page: page,
161+
status: 'active'
162+
}
163+
});
164+
};
165+
166+
/**
167+
* Get connect project by id
168+
* @param id the id
169+
*/
170+
ProjectService.getConnectProject = function(id) {
171+
return $http({
172+
method: 'GET',
173+
url: $rootScope.appConfig.TC_API_V5_URL + '/projects/' + id,
174+
headers: {
175+
"Content-Type": "application/json",
176+
"Authorization": "Bearer " + AuthService.getTokenV3()
161177
}
162178
});
163179
};

src/front/src/app/upsertproject/upsertproject.controller.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ angular.module('topcoderX').controller('ProjectController', ['currentUser', '$sc
2626
archived: false,
2727
createCopilotPayments: false
2828
};
29+
$scope.connectProjects = [];
2930
if ($rootScope.project) {
3031
$scope.title = 'Manage a Project';
3132
$scope.project = $rootScope.project;
@@ -34,14 +35,23 @@ angular.module('topcoderX').controller('ProjectController', ['currentUser', '$sc
3435
$scope.project.owner = $rootScope.project.owner;
3536
$scope.project.repoUrl = $rootScope.project.repoUrls.join(',');
3637
$scope.editing = true;
38+
if ($rootScope.project.tcDirectId) {
39+
ProjectService.getConnectProject($rootScope.project.tcDirectId).then(function (resp) {
40+
var connectProject = {
41+
id: resp.data.id,
42+
name: resp.data.name
43+
};
44+
$scope.connectProjects.unshift(connectProject);
45+
});
46+
}
3747
} else {
3848
$scope.title = 'Add a Project';
3949
$scope.editing = false;
4050
}
4151

4252
$scope.isAdminUser = Helper.isAdminUser(currentUser);
4353
$scope.loadingConnectProjects = true;
44-
$scope.connectProjects = [];
54+
4555
$scope.fetchConnectProjects = function($event) {
4656
if (!$event) {
4757
$scope.page = 1;
@@ -57,7 +67,10 @@ angular.module('topcoderX').controller('ProjectController', ['currentUser', '$sc
5767
}
5868
$scope.loadingConnectProjects = true;
5969
ProjectService.getConnectProjects(20, $scope.page).then(function(resp) {
60-
$scope.connectProjects = $scope.connectProjects.concat(resp.data);
70+
var projects = resp.data.filter(function (p) {
71+
return $rootScope.project && $rootScope.project.tcDirectId ? p.id !== $rootScope.project.tcDirectId : true;
72+
});
73+
$scope.connectProjects = $scope.connectProjects.concat(projects);
6174
})['finally'](function() {
6275
$scope.loadingConnectProjects = false;
6376
});

src/front/src/app/upsertproject/upsertproject.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,26 +55,26 @@ <h2>{{title}}</h2>
5555
project Title is required.</span>
5656
<br />
5757
<br />
58-
<label class="form-label">Connect ID:</label>
58+
<label class="form-label">Connect Project:</label>
5959
<ui-select ng-model="project.tcDirectId" theme="bootstrap">
6060
<ui-select-match placeholder="Select...">
61-
{{$select.selected.id}}
61+
{{$select.selected.name}}
6262
</ui-select-match>
6363
<ui-select-choices repeat="cp.id as cp in connectProjects | filter: $select.search">
64-
id: {{cp.id}}, name: {{cp.name}}, status: {{cp.status}}
64+
<span ng-bind-html="cp.name | highlight: $select.search"></span>
6565
<div ng-if="$index == $select.items.length-1">
6666
<button
6767
class="btn btn-xs btn-success"
68-
style="width: 100%; margin-top: 5px;"
68+
style="width: 100%; margin-top: 10px;"
6969
ng-click="fetchConnectProjects($event);"
7070
ng-disabled="loadingConnectProjects">Load more...</button>
7171
</div>
7272
</ui-select-choices>
7373
</ui-select>
74-
<small class="form-hint">Select the Topcoder Connect Project ID of the project. The above list contains all Topcoder Connect Projects
74+
<small class="form-hint">Select the Topcoder Connect Project to be associated with. The above list contains all Topcoder Connect Projects
7575
you have access to.</small>
7676
<span ng-show="projectForm.project.tcDirectId.$touched && projectForm.project.tcDirectId.$invalid">The
77-
TC Connect Project ID is required.</span>
77+
TC Connect Project is required.</span>
7878
<br />
7979
<br />
8080
<label class="form-label">Repo URLs:</label>

src/front/src/app/vendor.less

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,24 @@
1313
width: 300px;
1414
text-align: center;
1515
background-color: #fff;
16-
16+
1717
.logo-header {
1818
padding: 13px;
1919
border: solid 2px #fff;
2020
background-color: #3e3e3e
2121
}
22-
22+
2323
h3 {
2424
color: #4a4a4a;
2525
font-weight: 200;
2626
font-family: 'sofia-pro';
2727
text-transform: uppercase;
2828
}
29-
29+
3030
form {
3131
padding: 20px;
3232
}
33-
33+
3434
button {
3535
text-transform: uppercase;
3636
}
@@ -87,3 +87,9 @@ multiselect .btn-default {
8787
outline: 0;
8888
box-shadow: none;
8989
}
90+
.ui-select-bootstrap .ui-select-choices-row.active > span {
91+
background: #23c6c8 !important;
92+
}
93+
.ui-select-bootstrap .ui-select-choices-row.active:last-child > span {
94+
background: linear-gradient(180deg, #23c6c8 40%, transparent 0%) !important;
95+
}

0 commit comments

Comments
 (0)