From c9eccb315eed0337af1e98ac955026620d7b1105 Mon Sep 17 00:00:00 2001 From: Michael Abashian Date: Fri, 3 Feb 2017 14:23:05 -0500 Subject: [PATCH] Fixed group schedules and management jobs schedules --- awx/ui/client/src/inventories/main.js | 19 +++++++++++++------ .../src/management-jobs/scheduler/main.js | 17 ++++++++++++----- .../column-sort/column-sort.controller.js | 11 ++++++++--- .../shared/paginate/paginate.controller.js | 11 ++++++++--- 4 files changed, 41 insertions(+), 17 deletions(-) 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/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