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 syntaxHighlight from './syntax-highlight.directive';
// import strings from './syntax-highlight.strings';
const MODULE_NAME = 'at.syntax.highlight'; const MODULE_NAME = 'at.syntax.highlight';

View File

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

View File

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