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 ` -