Merge pull request #6131 from marshmalien/fix/autofillOrgInNotificationTemplate

Autofill organization in a new notification template
This commit is contained in:
Marliana Lara 2017-04-28 16:22:55 -04:00 committed by GitHub
commit 4ef057c4ee
3 changed files with 27 additions and 2 deletions

View File

@ -42,6 +42,23 @@ export default ['Rest', 'Wait', 'NotificationsFormObject',
});
}
if ($state.params && $state.params.organization_id) {
let id = $state.params.organization_id,
url = GetBasePath('organizations') + id + '/';
Rest.setUrl(url);
Rest.get()
.success(function(data) {
$scope.organization_name = data.name;
})
.error(function(data, status) {
ProcessErrors($scope, data, status, form, {
hdr: 'Error!',
msg: `Failed to retrieve organization. GET status: ${status}`
});
});
}
if ($scope.removeChoicesReady) {
$scope.removeChoicesReady();
}

View File

@ -52,6 +52,9 @@ angular.module('notifications', [
add: 'notificationsAddController',
edit: 'notificationsEditController'
},
urls: {
add: '/add?organization_id'
},
resolve: {
edit: {
notification_template: ['$state', '$stateParams', '$q',

View File

@ -30,8 +30,13 @@ export default ['Wait', 'GetBasePath', 'ProcessErrors', 'Rest', 'GetChoices',
scope.current_user_admin_orgs = data.results.map(i => i.name);
});
scope.addNotificationTemplate = function(){
$state.go('notifications.add');
scope.addNotificationTemplate = function() {
if (id) {
$state.go('notifications.add', {organization_id: id});
}
else {
$state.go('notifications.add');
}
};
if (scope.relatednotificationsRemove) {