diff --git a/app/assets/javascripts/templateFolderForm.js b/app/assets/javascripts/templateFolderForm.js index a9f2a4bfd..c7d804f4e 100644 --- a/app/assets/javascripts/templateFolderForm.js +++ b/app/assets/javascripts/templateFolderForm.js @@ -153,19 +153,20 @@ return changed; }; - this.$broadcastService = (document.querySelector('div[id=add_new_template_form]')).getAttribute("data-broadcast") + this.$singleNotificationChannel = (document.querySelector('div[id=add_new_template_form]')).getAttribute("data-channel"); + this.$singleChannelService = (document.querySelector('div[id=add_new_template_form]')).getAttribute("data-service"); this.actionButtonClicked = function(event) { event.preventDefault(); this.currentState = $(event.currentTarget).val(); - if (event.currentTarget.value === 'add-new-template' && this.$broadcastService) { - return window.location = "/services/" + this.$broadcastService + "/templates/add-broadcast"; + if (event.currentTarget.value === 'add-new-template' && this.$singleNotificationChannel) { + window.location = "/services/" + this.$singleChannelService + "/templates/add-" + this.$singleNotificationChannel; } else { if (this.stateChanged()) { this.render(); - }; - }; + } + } }; this.selectionStatus = { diff --git a/app/main/views/templates.py b/app/main/views/templates.py index fcd394f4e..384abda56 100644 --- a/app/main/views/templates.py +++ b/app/main/views/templates.py @@ -31,6 +31,7 @@ from app.models.service import Service from app.models.template_list import TemplateList, TemplateLists from app.template_previews import TemplatePreview, get_page_count_for_letter from app.utils import ( + NOTIFICATION_TYPES, get_template, should_skip_template_page, user_has_permissions, @@ -130,6 +131,11 @@ def choose_template(service_id, template_type='all', template_folder_id=None): ) option_hints = {template_folder_id: 'current folder'} + single_notification_channel = None + notification_channels = list(set(current_service.permissions).intersection(NOTIFICATION_TYPES)) + if len(notification_channels) == 1: + single_notification_channel = notification_channels[0] + if request.method == 'POST' and templates_and_folders_form.validate_on_submit(): if not current_user.has_permissions('manage_templates'): abort(403) @@ -168,6 +174,7 @@ def choose_template(service_id, template_type='all', template_folder_id=None): templates_and_folders_form=templates_and_folders_form, move_to_children=templates_and_folders_form.move_to.children(), user_has_template_folder_permission=user_has_template_folder_permission, + single_notification_channel=single_notification_channel, option_hints=option_hints ) diff --git a/app/templates/views/templates/_move_to.html b/app/templates/views/templates/_move_to.html index 09a69e186..103054d69 100644 --- a/app/templates/views/templates/_move_to.html +++ b/app/templates/views/templates/_move_to.html @@ -28,7 +28,7 @@ {{ page_footer('Add new folder', button_name='operation', button_value='add-new-folder') }} -