mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-19 14:09:20 -04:00
start js for template folder form
have a bunch of separate elements within the sticky_template_forms div that we hide or show based on button presses and such. This commit just sets up the class - it doesn't actually deal with button presses or checkboxes etc yet.
This commit is contained in:
58
app/assets/javascripts/templateFolderForm.js
Normal file
58
app/assets/javascripts/templateFolderForm.js
Normal file
@@ -0,0 +1,58 @@
|
||||
(function(Modules) {
|
||||
"use strict";
|
||||
|
||||
Modules.TemplateFolderForm = function() {
|
||||
|
||||
this.start = function(templateFolderForm) {
|
||||
this.$form = $(templateFolderForm);
|
||||
|
||||
this.$stickyBottom = this.$form.find('#sticky_template_forms');
|
||||
|
||||
this.$stickyBottom.append(this.nothingSelectedButtons);
|
||||
this.$stickyBottom.append(this.itemsSelectedButtons);
|
||||
|
||||
// all the diff states that we want to show or hide
|
||||
this.states = {
|
||||
nothingSelectedButtons: this.$form.find('#nothing_selected'),
|
||||
itemsSelectedButtons: this.$form.find('#items_selected'),
|
||||
moveToFolderRadios: this.$form.find('#move_to_folder_radios'),
|
||||
addNewFolderName: this.$form.find('#add_new_folder_form'),
|
||||
moveToNewFolderName: this.$form.find('#move_to_new_folder_form'),
|
||||
};
|
||||
|
||||
this.render();
|
||||
};
|
||||
|
||||
this.countSelectedCheckboxes = function() {
|
||||
return this.$form.find('input[type=checkbox]:checked').length;
|
||||
};
|
||||
|
||||
this.render = function() {
|
||||
let numSelected = this.countSelectedCheckboxes();
|
||||
|
||||
// hide everything
|
||||
Object.values(this.states).forEach($el => $el.hide());
|
||||
|
||||
this.states.nothingSelectedButtons.show();
|
||||
};
|
||||
|
||||
this.nothingSelectedButtons = function() {
|
||||
return `
|
||||
<div id="nothing_selected">
|
||||
<button class="button-secondary" value="new_template">New template</button>
|
||||
<button class="button-secondary" value="new_folder">New folder</button>
|
||||
</div>
|
||||
`;
|
||||
};
|
||||
|
||||
this.itemsSelectedButtons = function() {
|
||||
return `
|
||||
<div id="items_selected">
|
||||
<button class="button-secondary" value="move_to_folder">Move</button>
|
||||
<button class="button-secondary" value="add_to_new_folder">Add to a new folder</button>
|
||||
</div>
|
||||
`;
|
||||
};
|
||||
};
|
||||
|
||||
})(window.GOVUK.Modules);
|
||||
Reference in New Issue
Block a user