mirror of
https://github.com/ansible/awx.git
synced 2026-01-20 14:11:24 -03:30
Merge pull request #5142 from mabashian/5042-fix-schedule-search-sorting
Fixed schedule sorting/search/pagination
This commit is contained in:
commit
409a9d2c1f
@ -55,11 +55,11 @@ angular.module('inventory', [
|
||||
url: '/schedules',
|
||||
searchPrefix: 'schedule',
|
||||
ncyBreadcrumb: {
|
||||
parent: 'inventoryManage.editGroup({group_id: parentObject.id})',
|
||||
parent: 'inventoryManage({group_id: parentObject.id})',
|
||||
label: N_('SCHEDULES')
|
||||
},
|
||||
resolve: {
|
||||
Dataset: ['SchedulesList', 'QuerySet', '$stateParams', 'GetBasePath', 'groupData',
|
||||
Dataset: ['ScheduleList', 'QuerySet', '$stateParams', 'GetBasePath', 'groupData',
|
||||
function(list, qs, $stateParams, GetBasePath, groupData) {
|
||||
let path = `${groupData.related.inventory_source}schedules`;
|
||||
return qs.search(path, $stateParams[`${list.iterator}_search`]);
|
||||
@ -79,7 +79,14 @@ angular.module('inventory', [
|
||||
val.reject(data);
|
||||
});
|
||||
return val.promise;
|
||||
}]
|
||||
}],
|
||||
ScheduleList: ['SchedulesList', 'groupData',
|
||||
(SchedulesList, groupData) => {
|
||||
let list = _.cloneDeep(SchedulesList);
|
||||
list.basePath = `${groupData.related.inventory_source}schedules`;
|
||||
return list;
|
||||
}
|
||||
]
|
||||
},
|
||||
views: {
|
||||
// clear form template when views render in this substate
|
||||
@ -88,11 +95,11 @@ angular.module('inventory', [
|
||||
},
|
||||
// target the un-named ui-view @ root level
|
||||
'@': {
|
||||
templateProvider: function(SchedulesList, generateList, ParentObject) {
|
||||
templateProvider: function(ScheduleList, generateList, ParentObject) {
|
||||
// include name of parent resource in listTitle
|
||||
SchedulesList.listTitle = `${ParentObject.name}<div class='List-titleLockup'></div>` + N_('Schedules');
|
||||
ScheduleList.listTitle = `${ParentObject.name}<div class='List-titleLockup'></div>` + N_('Schedules');
|
||||
let html = generateList.build({
|
||||
list: SchedulesList,
|
||||
list: ScheduleList,
|
||||
mode: 'edit'
|
||||
});
|
||||
html = generateList.wrapPanel(html);
|
||||
|
||||
@ -27,11 +27,11 @@ angular.module('managementJobScheduler', [])
|
||||
},
|
||||
views: {
|
||||
'@': {
|
||||
templateProvider: function(SchedulesList, generateList, ParentObject) {
|
||||
templateProvider: function(ScheduleList, generateList, ParentObject) {
|
||||
// include name of parent resource in listTitle
|
||||
SchedulesList.listTitle = `${ParentObject.name}<div class='List-titleLockup'></div>` + N_('Schedules');
|
||||
ScheduleList.listTitle = `${ParentObject.name}<div class='List-titleLockup'></div>` + N_('Schedules');
|
||||
let html = generateList.build({
|
||||
list: SchedulesList,
|
||||
list: ScheduleList,
|
||||
mode: 'edit'
|
||||
});
|
||||
html = generateList.wrapPanel(html);
|
||||
@ -41,7 +41,7 @@ angular.module('managementJobScheduler', [])
|
||||
}
|
||||
},
|
||||
resolve: {
|
||||
Dataset: ['SchedulesList', 'QuerySet', '$stateParams', 'GetBasePath',
|
||||
Dataset: ['ScheduleList', 'QuerySet', '$stateParams', 'GetBasePath',
|
||||
function(list, qs, $stateParams, GetBasePath) {
|
||||
let path = `${GetBasePath('system_job_templates')}${$stateParams.id}/schedules`;
|
||||
return qs.search(path, $stateParams[`${list.iterator}_search`]);
|
||||
@ -63,7 +63,14 @@ angular.module('managementJobScheduler', [])
|
||||
val.reject(data);
|
||||
});
|
||||
return val.promise;
|
||||
}]
|
||||
}],
|
||||
ScheduleList: ['SchedulesList', 'GetBasePath', '$stateParams',
|
||||
(SchedulesList, GetBasePath, $stateParams) => {
|
||||
let list = _.cloneDeep(SchedulesList);
|
||||
list.basePath = GetBasePath('system_job_templates') + $stateParams.id + '/schedules';
|
||||
return list;
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
$stateExtender.addState({
|
||||
|
||||
@ -36,7 +36,7 @@ export default
|
||||
label: N_('SCHEDULES')
|
||||
},
|
||||
resolve: {
|
||||
Dataset: ['SchedulesList', 'QuerySet', '$stateParams', 'GetBasePath',
|
||||
Dataset: ['ScheduleList', 'QuerySet', '$stateParams', 'GetBasePath',
|
||||
function(list, qs, $stateParams, GetBasePath) {
|
||||
let path = `${GetBasePath('job_templates')}${$stateParams.id}/schedules`;
|
||||
return qs.search(path, $stateParams[`${list.iterator}_search`]);
|
||||
@ -58,15 +58,22 @@ export default
|
||||
val.reject(data);
|
||||
});
|
||||
return val.promise;
|
||||
}]
|
||||
}],
|
||||
ScheduleList: ['SchedulesList', 'GetBasePath', '$stateParams',
|
||||
(SchedulesList, GetBasePath, $stateParams) => {
|
||||
let list = _.cloneDeep(SchedulesList);
|
||||
list.basePath = GetBasePath('job_templates') + $stateParams.id + '/schedules/';
|
||||
return list;
|
||||
}
|
||||
]
|
||||
},
|
||||
views: {
|
||||
'@': {
|
||||
templateProvider: function(SchedulesList, generateList, ParentObject){
|
||||
templateProvider: function(ScheduleList, generateList, ParentObject){
|
||||
// include name of parent resource in listTitle
|
||||
SchedulesList.listTitle = `${ParentObject.name}<div class='List-titleLockup'></div>` + N_('Schedules');
|
||||
ScheduleList.listTitle = `${ParentObject.name}<div class='List-titleLockup'></div>` + N_('Schedules');
|
||||
let html = generateList.build({
|
||||
list: SchedulesList,
|
||||
list: ScheduleList,
|
||||
mode: 'edit'
|
||||
});
|
||||
html = generateList.wrapPanel(html);
|
||||
@ -122,7 +129,7 @@ export default
|
||||
label: N_('SCHEDULES')
|
||||
},
|
||||
resolve: {
|
||||
Dataset: ['SchedulesList', 'QuerySet', '$stateParams', 'GetBasePath',
|
||||
Dataset: ['ScheduleList', 'QuerySet', '$stateParams', 'GetBasePath',
|
||||
function(list, qs, $stateParams, GetBasePath) {
|
||||
let path = `${GetBasePath('workflow_job_templates')}${$stateParams.id}/schedules`;
|
||||
return qs.search(path, $stateParams[`${list.iterator}_search`]);
|
||||
@ -144,15 +151,22 @@ export default
|
||||
val.reject(data);
|
||||
});
|
||||
return val.promise;
|
||||
}]
|
||||
}],
|
||||
ScheduleList: ['SchedulesList', 'GetBasePath', '$stateParams',
|
||||
(SchedulesList, GetBasePath, $stateParams) => {
|
||||
let list = _.cloneDeep(SchedulesList);
|
||||
list.basePath = GetBasePath('workflow_job_templates') + $stateParams.id + '/schedules/';
|
||||
return list;
|
||||
}
|
||||
]
|
||||
},
|
||||
views: {
|
||||
'@': {
|
||||
templateProvider: function(SchedulesList, generateList, ParentObject){
|
||||
templateProvider: function(ScheduleList, generateList, ParentObject){
|
||||
// include name of parent resource in listTitle
|
||||
SchedulesList.listTitle = `${ParentObject.name}<div class='List-titleLockup'></div>` + N_('Schedules');
|
||||
ScheduleList.listTitle = `${ParentObject.name}<div class='List-titleLockup'></div>` + N_('Schedules');
|
||||
let html = generateList.build({
|
||||
list: SchedulesList,
|
||||
list: ScheduleList,
|
||||
mode: 'edit'
|
||||
});
|
||||
html = generateList.wrapPanel(html);
|
||||
@ -205,7 +219,7 @@ export default
|
||||
label: N_('SCHEDULES')
|
||||
},
|
||||
resolve: {
|
||||
Dataset: ['SchedulesList', 'QuerySet', '$stateParams', 'GetBasePath',
|
||||
Dataset: ['ScheduleList', 'QuerySet', '$stateParams', 'GetBasePath',
|
||||
function(list, qs, $stateParams, GetBasePath) {
|
||||
let path = `${GetBasePath('projects')}${$stateParams.id}/schedules`;
|
||||
return qs.search(path, $stateParams[`${list.iterator}_search`]);
|
||||
@ -227,15 +241,22 @@ export default
|
||||
val.reject(data);
|
||||
});
|
||||
return val.promise;
|
||||
}]
|
||||
}],
|
||||
ScheduleList: ['SchedulesList', 'GetBasePath', '$stateParams',
|
||||
(SchedulesList, GetBasePath, $stateParams) => {
|
||||
let list = _.cloneDeep(SchedulesList);
|
||||
list.basePath = GetBasePath('projects') + $stateParams.id + '/schedules/';
|
||||
return list;
|
||||
}
|
||||
]
|
||||
},
|
||||
views: {
|
||||
'@': {
|
||||
templateProvider: function(SchedulesList, generateList, ParentObject){
|
||||
templateProvider: function(ScheduleList, generateList, ParentObject){
|
||||
// include name of parent resource in listTitle
|
||||
SchedulesList.listTitle = `${ParentObject.name}<div class='List-titleLockup'></div>` + N_('Schedules');
|
||||
ScheduleList.listTitle = `${ParentObject.name}<div class='List-titleLockup'></div>` + N_('Schedules');
|
||||
let html = generateList.build({
|
||||
list: SchedulesList,
|
||||
list: ScheduleList,
|
||||
mode: 'edit'
|
||||
});
|
||||
html = generateList.wrapPanel(html);
|
||||
@ -293,10 +314,10 @@ export default
|
||||
label: N_('SCHEDULED')
|
||||
},
|
||||
resolve: {
|
||||
SchedulesList: ['ScheduledJobsList', function(list){
|
||||
ScheduleList: ['ScheduledJobsList', function(list){
|
||||
return list;
|
||||
}],
|
||||
Dataset: ['SchedulesList', 'QuerySet', '$stateParams', 'GetBasePath',
|
||||
Dataset: ['ScheduleList', 'QuerySet', '$stateParams', 'GetBasePath',
|
||||
function(list, qs, $stateParams, GetBasePath) {
|
||||
let path = GetBasePath('schedules');
|
||||
return qs.search(path, $stateParams[`${list.iterator}_search`]);
|
||||
@ -318,9 +339,9 @@ export default
|
||||
},
|
||||
views: {
|
||||
'list@jobs': {
|
||||
templateProvider: function(SchedulesList, generateList){
|
||||
templateProvider: function(ScheduleList, generateList){
|
||||
let html = generateList.build({
|
||||
list: SchedulesList,
|
||||
list: ScheduleList,
|
||||
mode: 'edit',
|
||||
title: false
|
||||
});
|
||||
|
||||
@ -12,11 +12,11 @@
|
||||
|
||||
|
||||
export default [
|
||||
'$scope', '$compile', '$location', '$stateParams', 'SchedulesList', 'Rest',
|
||||
'$scope', '$compile', '$location', '$stateParams', 'ScheduleList', 'Rest',
|
||||
'ProcessErrors', 'ReturnToCaller', 'ClearScope', 'GetBasePath', 'Wait', 'rbacUiControlService',
|
||||
'Find', 'ToggleSchedule', 'DeleteSchedule', 'GetChoices', '$q', '$state', 'Dataset', 'ParentObject', 'UnifiedJobsOptions',
|
||||
function($scope, $compile, $location, $stateParams,
|
||||
SchedulesList, Rest, ProcessErrors, ReturnToCaller, ClearScope,
|
||||
ScheduleList, Rest, ProcessErrors, ReturnToCaller, ClearScope,
|
||||
GetBasePath, Wait, rbacUiControlService, Find,
|
||||
ToggleSchedule, DeleteSchedule, GetChoices,
|
||||
$q, $state, Dataset, ParentObject, UnifiedJobsOptions) {
|
||||
@ -24,7 +24,7 @@ export default [
|
||||
ClearScope();
|
||||
|
||||
var base, scheduleEndpoint,
|
||||
list = SchedulesList;
|
||||
list = ScheduleList;
|
||||
|
||||
init();
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
export default ['$scope', '$state', 'QuerySet', 'GetBasePath',
|
||||
function($scope, $state, qs, GetBasePath) {
|
||||
export default ['$scope', '$state', 'QuerySet', 'GetBasePath', '$stateParams', '$interpolate',
|
||||
function($scope, $state, qs, GetBasePath, $stateParams, $interpolate) {
|
||||
|
||||
let queryset, path;
|
||||
|
||||
@ -52,7 +52,12 @@ export default ['$scope', '$state', 'QuerySet', 'GetBasePath',
|
||||
else {
|
||||
queryset = _.merge($state.params[`${$scope.columnIterator}_search`], { order_by: order_by });
|
||||
}
|
||||
path = GetBasePath($scope.basePath) || $scope.basePath;
|
||||
if (GetBasePath($scope.basePath) || $scope.basePath) {
|
||||
path = GetBasePath($scope.basePath) || $scope.basePath;
|
||||
} else {
|
||||
let interpolator = $interpolate($scope.basePath);
|
||||
path = interpolator({ $stateParams: $stateParams });
|
||||
}
|
||||
if(!$scope.querySet) {
|
||||
$state.go('.', { [$scope.columnIterator + '_search']: queryset }, {notify: false});
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
export default ['$scope', '$stateParams', '$state', '$filter', 'GetBasePath', 'QuerySet',
|
||||
function($scope, $stateParams, $state, $filter, GetBasePath, qs) {
|
||||
export default ['$scope', '$stateParams', '$state', '$filter', 'GetBasePath', 'QuerySet', '$interpolate',
|
||||
function($scope, $stateParams, $state, $filter, GetBasePath, qs, $interpolate) {
|
||||
|
||||
let pageSize,
|
||||
queryset, path;
|
||||
@ -27,7 +27,12 @@ export default ['$scope', '$stateParams', '$state', '$filter', 'GetBasePath', 'Q
|
||||
if(page === 0) {
|
||||
return;
|
||||
}
|
||||
path = GetBasePath($scope.basePath) || $scope.basePath;
|
||||
if (GetBasePath($scope.basePath) || $scope.basePath) {
|
||||
path = GetBasePath($scope.basePath) || $scope.basePath;
|
||||
} else {
|
||||
let interpolator = $interpolate($scope.basePath);
|
||||
path = interpolator({ $stateParams: $stateParams });
|
||||
}
|
||||
if($scope.querySet) {
|
||||
// merging $scope.querySet seems to destroy our initial reference which
|
||||
// kills the two-way binding here. To fix that, clone the queryset first
|
||||
|
||||
@ -38,16 +38,17 @@ describe('Directive: column-sort', () =>{
|
||||
go: jasmine.createSpy('go')
|
||||
};
|
||||
|
||||
this.$stateParams = {};
|
||||
|
||||
angular.mock.module('ColumnSortModule', ($provide) =>{
|
||||
|
||||
|
||||
QuerySet = jasmine.createSpyObj('qs', ['search']);
|
||||
QuerySet.search.and.callFake(() => { return { then: function(){} } });
|
||||
GetBasePath = jasmine.createSpy('GetBasePath');
|
||||
$provide.value('QuerySet', QuerySet);
|
||||
$provide.value('GetBasePath', GetBasePath);
|
||||
$provide.value('$state', this.$state);
|
||||
QuerySet = jasmine.createSpyObj('qs', ['search']);
|
||||
QuerySet.search.and.callFake(() => { return { then: function(){} }; });
|
||||
GetBasePath = jasmine.createSpy('GetBasePath');
|
||||
$provide.value('QuerySet', QuerySet);
|
||||
$provide.value('GetBasePath', GetBasePath);
|
||||
$provide.value('$state', this.$state);
|
||||
$provide.value('$stateParams', this.$stateParams);
|
||||
|
||||
});
|
||||
});
|
||||
@ -55,7 +56,7 @@ describe('Directive: column-sort', () =>{
|
||||
beforeEach(angular.mock.inject(($templateCache, _$rootScope_, _$compile_) => {
|
||||
template = window.__html__['client/src/shared/column-sort/column-sort.partial.html'];
|
||||
$templateCache.put('/static/partials/shared/column-sort/column-sort.partial.html', template);
|
||||
|
||||
|
||||
$compile = _$compile_;
|
||||
$scope = _$rootScope_.$new();
|
||||
}));
|
||||
@ -67,11 +68,11 @@ describe('Directive: column-sort', () =>{
|
||||
};
|
||||
|
||||
$compile(this.name_field)($scope);
|
||||
$compile(this.idx_field)($scope)
|
||||
$compile(this.idx_field)($scope);
|
||||
|
||||
$scope.$digest();
|
||||
expect( $(this.name_field).find('.columnSortIcon').hasClass('fa-sort-up') ).toEqual(true);
|
||||
expect( $(this.idx_field).find('.columnSortIcon').hasClass('fa-sort') ).toEqual(true);
|
||||
expect( $(this.idx_field).find('.columnSortIcon').hasClass('fa-sort') ).toEqual(true);
|
||||
});
|
||||
|
||||
it('should toggle to ascending name order, then ascending idx, then descending idx', function(){
|
||||
@ -81,21 +82,21 @@ describe('Directive: column-sort', () =>{
|
||||
};
|
||||
|
||||
$compile(this.name_field)($scope);
|
||||
$compile(this.idx_field)($scope)
|
||||
$compile(this.idx_field)($scope);
|
||||
|
||||
$scope.$digest();
|
||||
|
||||
$(this.name_field).click();
|
||||
expect( $(this.name_field).find('.columnSortIcon').hasClass('fa-sort-up') ).toEqual(true);
|
||||
expect( $(this.idx_field).find('.columnSortIcon').hasClass('fa-sort') ).toEqual(true);
|
||||
expect( $(this.idx_field).find('.columnSortIcon').hasClass('fa-sort') ).toEqual(true);
|
||||
|
||||
$(this.idx_field).click();
|
||||
$(this.idx_field).click();
|
||||
expect( $(this.name_field).find('.columnSortIcon').hasClass('fa-sort') ).toEqual(true);
|
||||
expect( $(this.idx_field).find('.columnSortIcon').hasClass('fa-sort-up') ).toEqual(true);
|
||||
|
||||
$(this.idx_field).click();
|
||||
expect( $(this.name_field).find('.columnSortIcon').hasClass('fa-sort') ).toEqual(true);
|
||||
expect( $(this.idx_field).find('.columnSortIcon').hasClass('fa-sort-down') ).toEqual(true)
|
||||
expect( $(this.idx_field).find('.columnSortIcon').hasClass('fa-sort-down') ).toEqual(true);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user