Fixed system jobs notifications route

This commit is contained in:
Michael Abashian
2016-12-16 11:48:17 -05:00
parent ae1155188c
commit 3f73e8f8d1
2 changed files with 54 additions and 124 deletions

View File

@@ -5,55 +5,33 @@
*************************************************/ *************************************************/
export default export default
[ '$rootScope','Wait', 'generateList', 'NotificationsList', [ 'NotificationsList', 'GetBasePath', 'ToggleNotification', 'NotificationsListInit',
'GetBasePath' , 'Rest' , '$stateParams', 'Dataset', '$scope',
'ProcessErrors', 'Prompt', '$state', 'GetChoices', 'Empty', 'Find',
'ngToast', '$compile', '$filter','ToggleNotification',
'NotificationsListInit', '$stateParams', 'management_job',
function( function(
$rootScope,Wait, GenerateList, NotificationsList, NotificationsList, GetBasePath, ToggleNotification, NotificationsListInit,
GetBasePath, Rest, $stateParams, Dataset, $scope) {
ProcessErrors, Prompt, $state, GetChoices, Empty, Find, ngToast, var defaultUrl = GetBasePath('system_job_templates'),
$compile, $filter, ToggleNotification, NotificationsListInit, list = NotificationsList,
$stateParams, management_job) {
var scope = $rootScope.$new(),
url = GetBasePath('notification_templates'),
defaultUrl = GetBasePath('system_job_templates'),
list,
view = GenerateList,
id = $stateParams.management_id; id = $stateParams.management_id;
list = _.cloneDeep(NotificationsList); function init() {
delete list.actions.add; $scope.list = list;
list.listTitle = `${management_job.name} <div class="List-titleLockup"></div> Notifications`; $scope[`${list.iterator}_dataset`] = Dataset.data;
list.searchSize = "col-lg-12 col-md-12 col-sm-12 col-xs-12"; $scope[list.name] = $scope[`${list.iterator}_dataset`].results;
list.searchRowActions = {
add: {
label: 'Add Notification',
mode: 'all', // One of: edit, select, all
ngClick: 'addNotificationTemplate()',
awToolTip: 'Create a new notification template',
actionClass: 'btn List-buttonSubmit',
buttonContent: '&#43; ADD NOTIFICATION TEMPLATE'
}
};
view.inject( list, {
mode: 'edit',
cancelButton: true,
scope: scope
});
NotificationsListInit({ NotificationsListInit({
scope: scope, scope: $scope,
url: defaultUrl, url: defaultUrl,
id: id id: id
}); });
scope.formCancel = function() { $scope.$watch(`${list.iterator}_dataset`, function() {
$state.go('managementJobsList'); // The list data has changed and we need to update which notifications are on/off
}; $scope.$emit('relatednotifications');
});
}
scope.toggleNotification = function(event, notifier_id, column) { $scope.toggleNotification = function(event, notifier_id, column) {
var notifier = this.notification; var notifier = this.notification;
try { try {
$(event.target).tooltip('hide'); $(event.target).tooltip('hide');
@@ -62,60 +40,15 @@ export default
// ignore // ignore
} }
ToggleNotification({ ToggleNotification({
scope: scope, scope: $scope,
url: defaultUrl, url: defaultUrl + id,
id: id,
notifier: notifier, notifier: notifier,
column: column, column: column,
callback: 'NotificationRefresh' callback: 'NotificationRefresh'
}); });
}; };
if (scope.removePostRefresh) { init();
scope.removePostRefresh();
}
scope.removePostRefresh = scope.$on('PostRefresh', function () {
scope.$emit('relatednotifications');
});
if (scope.removeChoicesHere) {
scope.removeChoicesHere();
}
scope.removeChoicesHere = scope.$on('choicesReadyNotifierList', function () {
list.fields.notification_type.searchOptions = scope.notification_type_options;
// @issue: OLD SEARCH
// SearchInit({
// scope: scope,
// set: 'notifications',
// list: list,
// url: url
// });
if ($rootScope.addedItem) {
scope.addedItem = $rootScope.addedItem;
delete $rootScope.addedItem;
}
// @issue: OLD SEARCH
// PaginateInit({
// scope: scope,
// list: list,
// url: url
// });
//
// scope.search(list.iterator);
});
GetChoices({
scope: scope,
url: url,
field: 'notification_type',
variable: 'notification_type_options',
callback: 'choicesReadyNotifierList'
});
} }
]; ];

View File

@@ -4,43 +4,40 @@
* All Rights Reserved * All Rights Reserved
*************************************************/ *************************************************/
import {templateUrl} from '../../shared/template-url/template-url.factory';
export default { export default {
name: 'managementJobsList.notifications', name: 'managementJobsList.notifications',
route: '/:management_id/notifications', route: '/:management_id/notifications',
templateUrl: templateUrl('management-jobs/notifications/notifications'), params: {
controller: 'managementJobsNotificationsController', notification_search: {}
params: {card: null}, },
resolve: { searchPrefix: 'notification',
management_job: views: {
[ '$stateParams', '@managementJobsList': {
'$q', controller: 'managementJobsNotificationsController',
'Rest', templateProvider: function(NotificationsList, generateList, ParentObject) {
'GetBasePath', // include name of parent resource in listTitle
'ProcessErrors', NotificationsList.listTitle = `${ParentObject.name}<div class='List-titleLockup'></div>Notifications`;
function($stateParams, $q, rest, getBasePath, ProcessErrors) { let html = generateList.build({
list: NotificationsList,
if ($stateParams.card) { mode: 'edit'
return $q.when($stateParams.card); });
} html = generateList.wrapPanel(html);
return generateList.insertFormView() + html;
var managementJobId = $stateParams.management_id;
var url = getBasePath('system_job_templates') + managementJobId + '/';
rest.setUrl(url);
return rest.get()
.then(function(data) {
return data.data;
}).catch(function (response) {
ProcessErrors(null, response.data, response.status, null, {
hdr: 'Error!',
msg: 'Failed to get management job info. GET returned status: ' +
response.status
});
});
} }
] }
},
resolve: {
Dataset: ['NotificationsList', 'QuerySet', '$stateParams', 'GetBasePath',
function(list, qs, $stateParams, GetBasePath) {
let path = `${GetBasePath('notification_templates')}`;
return qs.search(path, $stateParams[`${list.iterator}_search`]);
}
],
ParentObject: ['$stateParams', 'Rest', 'GetBasePath', function($stateParams, Rest, GetBasePath) {
let path = `${GetBasePath('system_job_templates')}${$stateParams.management_id}`;
Rest.setUrl(path);
return Rest.get(path).then((res) => res.data);
}]
}, },
ncyBreadcrumb: { ncyBreadcrumb: {
parent: 'managementJobsList', parent: 'managementJobsList',