diff --git a/awx/ui/client/src/inventories/main.js b/awx/ui/client/src/inventories/main.js index 4c1f9bc1e7..1c8a7654d1 100644 --- a/awx/ui/client/src/inventories/main.js +++ b/awx/ui/client/src/inventories/main.js @@ -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}
` + N_('Schedules'); + ScheduleList.listTitle = `${ParentObject.name}` + N_('Schedules'); let html = generateList.build({ - list: SchedulesList, + list: ScheduleList, mode: 'edit' }); html = generateList.wrapPanel(html); diff --git a/awx/ui/client/src/management-jobs/scheduler/main.js b/awx/ui/client/src/management-jobs/scheduler/main.js index 0f88330f0b..16078bae36 100644 --- a/awx/ui/client/src/management-jobs/scheduler/main.js +++ b/awx/ui/client/src/management-jobs/scheduler/main.js @@ -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}` + N_('Schedules'); + ScheduleList.listTitle = `${ParentObject.name}` + 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({ diff --git a/awx/ui/client/src/scheduler/main.js b/awx/ui/client/src/scheduler/main.js index d1c44f6e09..05960b13d6 100644 --- a/awx/ui/client/src/scheduler/main.js +++ b/awx/ui/client/src/scheduler/main.js @@ -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}` + N_('Schedules'); + ScheduleList.listTitle = `${ParentObject.name}` + 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}` + N_('Schedules'); + ScheduleList.listTitle = `${ParentObject.name}` + 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}` + N_('Schedules'); + ScheduleList.listTitle = `${ParentObject.name}` + 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 }); diff --git a/awx/ui/client/src/scheduler/schedulerList.controller.js b/awx/ui/client/src/scheduler/schedulerList.controller.js index 8652e8a2e6..c5e80ef0de 100644 --- a/awx/ui/client/src/scheduler/schedulerList.controller.js +++ b/awx/ui/client/src/scheduler/schedulerList.controller.js @@ -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(); diff --git a/awx/ui/client/src/shared/column-sort/column-sort.controller.js b/awx/ui/client/src/shared/column-sort/column-sort.controller.js index 9280926fd0..7336bacc93 100644 --- a/awx/ui/client/src/shared/column-sort/column-sort.controller.js +++ b/awx/ui/client/src/shared/column-sort/column-sort.controller.js @@ -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}); } diff --git a/awx/ui/client/src/shared/paginate/paginate.controller.js b/awx/ui/client/src/shared/paginate/paginate.controller.js index a4f45b7d5a..e8a5fc81f6 100644 --- a/awx/ui/client/src/shared/paginate/paginate.controller.js +++ b/awx/ui/client/src/shared/paginate/paginate.controller.js @@ -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 diff --git a/awx/ui/tests/spec/column-sort/column-sort.directive-test.js b/awx/ui/tests/spec/column-sort/column-sort.directive-test.js index 4cb1a3ec53..494f1d41d1 100644 --- a/awx/ui/tests/spec/column-sort/column-sort.directive-test.js +++ b/awx/ui/tests/spec/column-sort/column-sort.directive-test.js @@ -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); }); -}); \ No newline at end of file +});