fix template view for auditor/limited permissions

This commit is contained in:
Keith Grant 2019-07-11 10:41:00 -07:00 committed by Jim Ladd
parent 191d18cec0
commit 37b44fe77d
3 changed files with 21 additions and 8 deletions

View File

@ -1,6 +1,4 @@
// import 'codemirror/mode/jinja2/jinja2';
import syntaxHighlight from './syntax-highlight.directive';
// import strings from './syntax-highlight.strings';
const MODULE_NAME = 'at.syntax.highlight';

View File

@ -10,7 +10,7 @@ export default ['Rest', 'Wait',
'notification_template',
'$scope', '$state', 'GetChoices', 'CreateSelect2', 'Empty',
'NotificationsTypeChange', 'ParseTypeChange', 'i18n',
'MessageUtils', 'Alert',
'MessageUtils',
function(
Rest, Wait,
NotificationsFormObject, ProcessErrors, GetBasePath,
@ -18,7 +18,7 @@ export default ['Rest', 'Wait',
notification_template,
$scope, $state, GetChoices, CreateSelect2, Empty,
NotificationsTypeChange, ParseTypeChange, i18n,
MessageUtils, Alert
MessageUtils
) {
var generator = GenerateForm,
id = notification_template.id,
@ -41,11 +41,19 @@ export default ['Rest', 'Wait',
Rest.setUrl(GetBasePath('notification_templates'));
Rest.options()
.then(({data}) => {
if (!data.actions.POST) {
$state.go("^");
Alert('Permission Error', 'You do not have permission to add a notification template.', 'alert-info');
if (data.actions.POST) {
defaultMessages = data.actions.POST.messages.default;
} else {
const defaults = {
message: '<DEFAULT_MESSAGE>',
body: '<DEFAULT_BODY>',
};
defaultMessages = {
started: defaults,
success: defaults,
error: defaults,
};
}
defaultMessages = data.actions.POST.messages.default;
});
GetChoices({

View File

@ -587,6 +587,7 @@ export default ['i18n', function(i18n) {
type: 'checkbox',
class: 'Form-formGroup--fullWidth',
default: false,
ngDisabled: '!(notification_template.summary_fields.user_capabilities.edit || canAdd)',
},
started_message: {
label: i18n._('Start Message'),
@ -596,6 +597,7 @@ export default ['i18n', function(i18n) {
default: '',
ngShow: "customize_messages",
rows: 2,
ngDisabled: '!(notification_template.summary_fields.user_capabilities.edit || canAdd)',
},
started_body: {
label: i18n._('Start Expanded Message'),
@ -604,6 +606,7 @@ export default ['i18n', function(i18n) {
mode: 'jinja2',
default: '',
ngShow: "customize_messages && notification_type.value == 'email'",
ngDisabled: '!(notification_template.summary_fields.user_capabilities.edit || canAdd)',
},
success_message: {
label: i18n._('Success Message'),
@ -613,6 +616,7 @@ export default ['i18n', function(i18n) {
default: '',
ngShow: "customize_messages",
rows: 2,
ngDisabled: '!(notification_template.summary_fields.user_capabilities.edit || canAdd)',
},
success_body: {
label: i18n._('Success Expanded Message'),
@ -621,6 +625,7 @@ export default ['i18n', function(i18n) {
mode: 'jinja2',
default: '',
ngShow: "customize_messages && notification_type.value == 'email'",
ngDisabled: '!(notification_template.summary_fields.user_capabilities.edit || canAdd)',
},
error_message: {
label: i18n._('Error Message'),
@ -630,6 +635,7 @@ export default ['i18n', function(i18n) {
default: '',
ngShow: "customize_messages",
rows: 2,
ngDisabled: '!(notification_template.summary_fields.user_capabilities.edit || canAdd)',
},
error_body: {
label: i18n._('Error Expanded Message'),
@ -638,6 +644,7 @@ export default ['i18n', function(i18n) {
mode: 'jinja2',
default: '',
ngShow: "customize_messages && notification_type.value == 'email'",
ngDisabled: '!(notification_template.summary_fields.user_capabilities.edit || canAdd)',
},
},