From c0706b9cefe64ce90512e7f2fba8269ff5205692 Mon Sep 17 00:00:00 2001 From: Tom Byers Date: Tue, 8 Jan 2019 15:57:55 +0000 Subject: [PATCH] Split move_to forms into separate sticky elements --- app/assets/javascripts/templateFolderForm.js | 35 +++++++++++++------- app/templates/views/templates/_move_to.html | 14 ++++++-- 2 files changed, 34 insertions(+), 15 deletions(-) diff --git a/app/assets/javascripts/templateFolderForm.js b/app/assets/javascripts/templateFolderForm.js index 5f9079fbf..93bf26d80 100644 --- a/app/assets/javascripts/templateFolderForm.js +++ b/app/assets/javascripts/templateFolderForm.js @@ -13,22 +13,33 @@ this.$stickyBottom = this.$form.find('#sticky_template_forms'); this.$stickyBottom.append(this.nothingSelectedButtons); + GOVUK.stickAtBottomWhenScrolling.add(this.nothingSelectedButtons, true); this.$stickyBottom.append(this.itemsSelectedButtons); + GOVUK.stickAtBottomWhenScrolling.add(this.itemsSelectedButtons, true); // all the diff states that we want to show or hide this.states = [ - {key: 'nothing-selected-buttons', $el: this.$form.find('#nothing_selected'), cancellable: false}, - {key: 'items-selected-buttons', $el: this.$form.find('#items_selected'), cancellable: false}, - {key: 'move-to-existing-folder', $el: this.$form.find('#move_to_folder_radios'), cancellable: true}, - {key: 'move-to-new-folder', $el: this.$form.find('#move_to_new_folder_form'), cancellable: true}, - {key: 'add-new-folder', $el: this.$form.find('#add_new_folder_form'), cancellable: true}, - {key: 'add-new-template', $el: this.$form.find('#add_new_template_form'), cancellable: true} + {key: 'nothing-selected-buttons', $el: this.$form.find('#nothing_selected'), cancellable: false, isStickyGroup: false}, + {key: 'items-selected-buttons', $el: this.$form.find('#items_selected'), cancellable: false, isStickyGroup: false}, + {key: 'move-to-existing-folder', $el: this.$form.find('#move_to_folder_radios'), cancellable: true, isStickyGroup: true}, + {key: 'move-to-new-folder', $el: this.$form.find('#move_to_new_folder_form'), cancellable: true, isStickyGroup: false}, + {key: 'add-new-folder', $el: this.$form.find('#add_new_folder_form'), cancellable: true, isStickyGroup: false}, + {key: 'add-new-template', $el: this.$form.find('#add_new_template_form'), cancellable: true, isStickyGroup: true} ]; // cancel/clear buttons only relevant if JS enabled, so this.states.filter(state => state.cancellable).forEach((x) => this.addCancelButton(x)); this.states.filter(state => state.key === 'items-selected-buttons').forEach(x => this.addClearButton(x)); + // add all sticky elements from states + this.states.forEach(state => { + if (state.isStickyGroup) { + state.$el.find(".js-stick-at-bottom-when-scrolling").each((idx, el) => { + GOVUK.stickAtBottomWhenScrolling.add(el, false); + }); + } + }); + // first off show the new template / new folder buttons this.currentState = this.$form.data('prev-state') || 'unknown'; if (this.currentState === 'unknown') { @@ -135,25 +146,25 @@ } }; - this.nothingSelectedButtons = ` -
+ this.nothingSelectedButtons = $(` +
Nothing selected
- `; + `).get(0); - this.itemsSelectedButtons = ` -
+ this.itemsSelectedButtons = $(` +
1 selected
- `; + `).get(0); }; })(window.GOVUK.Modules); diff --git a/app/templates/views/templates/_move_to.html b/app/templates/views/templates/_move_to.html index 543905884..cf752d9b8 100644 --- a/app/templates/views/templates/_move_to.html +++ b/app/templates/views/templates/_move_to.html @@ -1,15 +1,19 @@ {% from "components/radios.html" import radios, radios_nested %} {% from "components/page-footer.html" import page_footer %} -
+
{% if templates_and_folders_form.move_to.choices and template_list.templates_to_show %}
+
{{ radios_nested(templates_and_folders_form.move_to, move_to_children, option_hints=option_hints) }} +
+
{{ page_footer('Move', button_name='operation', button_value='move-to-existing-folder') }} +
-
+
Move to a new folder {{ textbox(templates_and_folders_form.move_to_new_folder_name) }} @@ -17,7 +21,7 @@
{% endif %} -
+
Add a new folder {{ textbox(templates_and_folders_form.add_new_folder_name) }} @@ -27,8 +31,12 @@
Add a new template +
{{ radios(templates_and_folders_form.add_template_by_template_type) }} +
+
{{ page_footer('Continue', button_name='operation', button_value='add-new-template') }} +