BigW Consortium Gitlab

Commit cd5b36d0 by Kushal Pandya

Add constructor doc, toggle helper

parent 3c414a9f
export default class ProtectedTagDropdown { export default class ProtectedTagDropdown {
/**
* @param {Object} options containing
* `$dropdown` target element
* `onSelect` event callback
* $dropdown must be an element created using `dropdown_tag()` rails helper
*/
constructor(options) { constructor(options) {
this.onSelect = options.onSelect; this.onSelect = options.onSelect;
this.$dropdown = options.$dropdown; this.$dropdown = options.$dropdown;
...@@ -10,7 +16,7 @@ export default class ProtectedTagDropdown { ...@@ -10,7 +16,7 @@ export default class ProtectedTagDropdown {
this.bindEvents(); this.bindEvents();
// Hide footer // Hide footer
this.$dropdownFooter.addClass('hidden'); this.toggleFooter(true);
} }
buildDropdown() { buildDropdown() {
...@@ -58,18 +64,22 @@ export default class ProtectedTagDropdown { ...@@ -58,18 +64,22 @@ export default class ProtectedTagDropdown {
} }
toggleCreateNewButton(tagName) { toggleCreateNewButton(tagName) {
if (tagName) {
this.selectedTag = { this.selectedTag = {
title: tagName, title: tagName,
id: tagName, id: tagName,
text: tagName, text: tagName,
}; };
if (tagName) {
this.$dropdownContainer this.$dropdownContainer
.find('.create-new-protected-tag code') .find('.create-new-protected-tag code')
.text(tagName); .text(tagName);
} }
this.$dropdownFooter.toggleClass('hidden', !tagName); this.toggleFooter(!tagName);
}
toggleFooter(toggleState) {
this.$dropdownFooter.toggleClass('hidden', toggleState);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment