Fixed group schedules and management jobs schedules

This commit is contained in:
Michael Abashian
2017-02-03 14:23:05 -05:00
parent 534db96a93
commit c9eccb315e
4 changed files with 41 additions and 17 deletions

View File

@@ -55,11 +55,11 @@ angular.module('inventory', [
url: '/schedules', url: '/schedules',
searchPrefix: 'schedule', searchPrefix: 'schedule',
ncyBreadcrumb: { ncyBreadcrumb: {
parent: 'inventoryManage.editGroup({group_id: parentObject.id})', parent: 'inventoryManage({group_id: parentObject.id})',
label: N_('SCHEDULES') label: N_('SCHEDULES')
}, },
resolve: { resolve: {
Dataset: ['SchedulesList', 'QuerySet', '$stateParams', 'GetBasePath', 'groupData', Dataset: ['ScheduleList', 'QuerySet', '$stateParams', 'GetBasePath', 'groupData',
function(list, qs, $stateParams, GetBasePath, groupData) { function(list, qs, $stateParams, GetBasePath, groupData) {
let path = `${groupData.related.inventory_source}schedules`; let path = `${groupData.related.inventory_source}schedules`;
return qs.search(path, $stateParams[`${list.iterator}_search`]); return qs.search(path, $stateParams[`${list.iterator}_search`]);
@@ -79,7 +79,14 @@ angular.module('inventory', [
val.reject(data); val.reject(data);
}); });
return val.promise; return val.promise;
}] }],
ScheduleList: ['SchedulesList', 'groupData',
(SchedulesList, groupData) => {
let list = _.cloneDeep(SchedulesList);
list.basePath = `${groupData.related.inventory_source}schedules`;
return list;
}
]
}, },
views: { views: {
// clear form template when views render in this substate // clear form template when views render in this substate
@@ -88,11 +95,11 @@ angular.module('inventory', [
}, },
// target the un-named ui-view @ root level // 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 // 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({ let html = generateList.build({
list: SchedulesList, list: ScheduleList,
mode: 'edit' mode: 'edit'
}); });
html = generateList.wrapPanel(html); html = generateList.wrapPanel(html);

View File

@@ -27,11 +27,11 @@ angular.module('managementJobScheduler', [])
}, },
views: { views: {
'@': { '@': {
templateProvider: function(SchedulesList, generateList, ParentObject) { templateProvider: function(ScheduleList, generateList, ParentObject) {
// include name of parent resource in listTitle // 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({ let html = generateList.build({
list: SchedulesList, list: ScheduleList,
mode: 'edit' mode: 'edit'
}); });
html = generateList.wrapPanel(html); html = generateList.wrapPanel(html);
@@ -41,7 +41,7 @@ angular.module('managementJobScheduler', [])
} }
}, },
resolve: { resolve: {
Dataset: ['SchedulesList', 'QuerySet', '$stateParams', 'GetBasePath', Dataset: ['ScheduleList', 'QuerySet', '$stateParams', 'GetBasePath',
function(list, qs, $stateParams, GetBasePath) { function(list, qs, $stateParams, GetBasePath) {
let path = `${GetBasePath('system_job_templates')}${$stateParams.id}/schedules`; let path = `${GetBasePath('system_job_templates')}${$stateParams.id}/schedules`;
return qs.search(path, $stateParams[`${list.iterator}_search`]); return qs.search(path, $stateParams[`${list.iterator}_search`]);
@@ -63,7 +63,14 @@ angular.module('managementJobScheduler', [])
val.reject(data); val.reject(data);
}); });
return val.promise; 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({ $stateExtender.addState({

View File

@@ -1,5 +1,5 @@
export default ['$scope', '$state', 'QuerySet', 'GetBasePath', export default ['$scope', '$state', 'QuerySet', 'GetBasePath', '$stateParams', '$interpolate',
function($scope, $state, qs, GetBasePath) { function($scope, $state, qs, GetBasePath, $stateParams, $interpolate) {
let queryset, path; let queryset, path;
@@ -52,7 +52,12 @@ export default ['$scope', '$state', 'QuerySet', 'GetBasePath',
else { else {
queryset = _.merge($state.params[`${$scope.columnIterator}_search`], { order_by: order_by }); 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) { if(!$scope.querySet) {
$state.go('.', { [$scope.columnIterator + '_search']: queryset }, {notify: false}); $state.go('.', { [$scope.columnIterator + '_search']: queryset }, {notify: false});
} }

View File

@@ -1,5 +1,5 @@
export default ['$scope', '$stateParams', '$state', '$filter', 'GetBasePath', 'QuerySet', export default ['$scope', '$stateParams', '$state', '$filter', 'GetBasePath', 'QuerySet', '$interpolate',
function($scope, $stateParams, $state, $filter, GetBasePath, qs) { function($scope, $stateParams, $state, $filter, GetBasePath, qs, $interpolate) {
let pageSize, let pageSize,
queryset, path; queryset, path;
@@ -27,7 +27,12 @@ export default ['$scope', '$stateParams', '$state', '$filter', 'GetBasePath', 'Q
if(page === 0) { if(page === 0) {
return; 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) { if($scope.querySet) {
// merging $scope.querySet seems to destroy our initial reference which // merging $scope.querySet seems to destroy our initial reference which
// kills the two-way binding here. To fix that, clone the queryset first // kills the two-way binding here. To fix that, clone the queryset first