Commit cd5b36d0 authored by Kushal Pandya's avatar Kushal Pandya

Add constructor doc, toggle helper

parent 3c414a9f
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) {
this.onSelect = options.onSelect;
this.$dropdown = options.$dropdown;
......@@ -10,7 +16,7 @@ export default class ProtectedTagDropdown {
this.bindEvents();
// Hide footer
this.$dropdownFooter.addClass('hidden');
this.toggleFooter(true);
}
buildDropdown() {
......@@ -58,18 +64,22 @@ export default class ProtectedTagDropdown {
}
toggleCreateNewButton(tagName) {
this.selectedTag = {
title: tagName,
id: tagName,
text: tagName,
};
if (tagName) {
this.selectedTag = {
title: tagName,
id: tagName,
text: tagName,
};
this.$dropdownContainer
.find('.create-new-protected-tag code')
.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