1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 08:21:15 +03:00

Add toolbar sort configuration to project list

This commit is contained in:
Marliana Lara 2019-03-04 11:27:16 -05:00
parent 1525c6d97e
commit 8100fc1cfb
No known key found for this signature in database
GPG Key ID: 38C73B40DFA809EE
3 changed files with 54 additions and 13 deletions

View File

@ -46,6 +46,11 @@ function ProjectsStrings (BaseString) {
HEADER: this.error.HEADER, HEADER: this.error.HEADER,
CALL: this.error.CALL, CALL: this.error.CALL,
}; };
ns.sort = {
NAME_ASCENDING: t.s('Name (Ascending)'),
NAME_DESCENDING: t.s('Name (Descending)')
};
} }
ProjectsStrings.$inject = ['BaseStringService']; ProjectsStrings.$inject = ['BaseStringService'];

View File

@ -27,6 +27,8 @@ function projectsListController (
}; };
vm.dataset = Dataset.data; vm.dataset = Dataset.data;
vm.projects = Dataset.data.results; vm.projects = Dataset.data.results;
vm.querySet = $state.params.project_search;
$scope.$watch('vm.dataset.count', () => { $scope.$watch('vm.dataset.count', () => {
$scope.$emit('updateCount', vm.dataset.count, 'projects'); $scope.$emit('updateCount', vm.dataset.count, 'projects');
}); });
@ -48,6 +50,36 @@ function projectsListController (
} }
}, true); }, true);
const toolbarSortDefault = {
label: `${strings.get('sort.NAME_ASCENDING')}`,
value: 'name'
};
vm.toolbarSortOptions = [
toolbarSortDefault,
{
label: `${strings.get('sort.NAME_DESCENDING')}`,
value: '-name'
}
];
vm.toolbarSortValue = toolbarSortDefault;
vm.onToolbarSort = (sort) => {
vm.toolbarSortValue = sort;
const queryParams = Object.assign(
vm.querySet,
{ order_by: sort.value }
);
qs.search(GetBasePath(vm.list.basePath), queryParams)
.then(({ data }) => {
vm.dataset = data;
vm.projects = vm.dataset.results;
});
};
$scope.$on('ws-jobs', (e, data) => { $scope.$on('ws-jobs', (e, data) => {
$log.debug(data); $log.debug(data);
if (vm.projects) { if (vm.projects) {

View File

@ -21,10 +21,13 @@
</div> </div>
<at-list-toolbar <at-list-toolbar
ng-if="vm.projects.length > 0" ng-if="vm.projects.length > 0"
sort-only="false"
on-collapse="vm.onCollapse"
on-expand="vm.onExpand" on-expand="vm.onExpand"
is-collapsed="vm.isCollapsed"> on-collapse="vm.onCollapse"
is-collapsed="vm.isCollapsed"
sort-only="false"
sort-value="vm.toolbarSortValue"
sort-options="vm.toolbarSortOptions"
on-sort="vm.onToolbarSort">
</at-list-toolbar> </at-list-toolbar>
<at-list results="vm.projects"> <at-list results="vm.projects">
<at-row ng-repeat="project in vm.projects" <at-row ng-repeat="project in vm.projects"
@ -98,6 +101,7 @@
collection="vm.projects" collection="vm.projects"
dataset="vm.dataset" dataset="vm.dataset"
iterator="project" iterator="project"
base-path="projects"> base-path="projects"
query-set="vm.querySet">
</paginate> </paginate>
</at-panel-body> </at-panel-body>