diff --git a/app/assets/javascripts/templateFolderForm.js b/app/assets/javascripts/templateFolderForm.js index 8dc6a95eb..fde801504 100644 --- a/app/assets/javascripts/templateFolderForm.js +++ b/app/assets/javascripts/templateFolderForm.js @@ -41,8 +41,6 @@ this.addCancelButton = function($el) { let $cancel = $('') - // .addClass('api-key') - // .css('min-height', $component.height()) .html('Cancel') .click((event) => { event.preventDefault(); @@ -70,8 +68,10 @@ let numSelected = this.countSelectedCheckboxes(); if (this.currentState === 'nothingSelectedButtons' && numSelected !== 0) { + // user has just selected first item this.currentState = 'itemsSelectedButtons'; } else if (this.currentState === 'itemsSelectedButtons' && numSelected === 0) { + // user has just deselected last item this.currentState = 'nothingSelectedButtons'; } @@ -79,35 +79,29 @@ }; this.countSelectedCheckboxes = function() { - return this.$form.find('input[type=checkbox]:checked').length; + return this.$form.find('input:checkbox:checked').length; }; this.render = function() { - let numSelected = this.countSelectedCheckboxes(); - // detach everything, unless they are the currentState Object.entries(this.states).forEach( ([state, $el]) => (state === this.currentState ? this.$stickyBottom.append($el) : $el.detach()) ); }; - this.nothingSelectedButtons = function() { - return ` -
- - -
- `; - }; + this.nothingSelectedButtons = ` +
+ + +
+ `; - this.itemsSelectedButtons = function() { - return ` -
- - -
- `; - }; + this.itemsSelectedButtons = ` +
+ + +
+ `; }; })(window.GOVUK.Modules); diff --git a/app/templates/views/templates/choose.html b/app/templates/views/templates/choose.html index adb6b19c2..8ff03b7b3 100644 --- a/app/templates/views/templates/choose.html +++ b/app/templates/views/templates/choose.html @@ -60,8 +60,9 @@ {% if current_user.has_permissions('manage_templates') %}
+ {% if not can_manage_folders %} Add new template - + {% endif %} {% if can_manage_folders and current_template_folder_id %} Manage {% endif %} @@ -80,9 +81,7 @@ {% if can_manage_folders %} {% call form_wrapper(module='template-folder-form') %} {% include 'views/templates/_template_list.html' %} - {% with templates=templates, template_folders=template_folders, templates_and_folders_form=templates_and_folders_form %} - {% include 'views/templates/_move_to.html' %} - {% endwith %} + {% include 'views/templates/_move_to.html' %} {% endcall %} {% else %}