diff options
author | Clement Ho <ClemMakesApps@gmail.com> | 2017-01-31 01:53:18 +0300 |
---|---|---|
committer | Clement Ho <ClemMakesApps@gmail.com> | 2017-03-08 08:10:32 +0300 |
commit | f44fb5cfd0cc4baada4d88f9724c74fc44326637 (patch) | |
tree | e2ff8e5e9b0d14b87aad353abffdc9b7979d6a29 /spec/javascripts/helpers | |
parent | b5cb1115f4e3357118465ea4becf031b4ea598a6 (diff) |
Add filtered search visual tokens
Diffstat (limited to 'spec/javascripts/helpers')
-rw-r--r-- | spec/javascripts/helpers/filtered_search_spec_helper.js | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/spec/javascripts/helpers/filtered_search_spec_helper.js b/spec/javascripts/helpers/filtered_search_spec_helper.js new file mode 100644 index 00000000000..c891518fce9 --- /dev/null +++ b/spec/javascripts/helpers/filtered_search_spec_helper.js @@ -0,0 +1,52 @@ +class FilteredSearchSpecHelper { + static createFilterVisualTokenHTML(name, value, isSelected) { + return FilteredSearchSpecHelper.createFilterVisualToken(name, value, isSelected).outerHTML; + } + + static createFilterVisualToken(name, value, isSelected = false) { + const li = document.createElement('li'); + li.classList.add('js-visual-token', 'filtered-search-token'); + + li.innerHTML = ` + <div class="selectable ${isSelected ? 'selected' : ''}" role="button"> + <div class="name">${name}</div> + <div class="value">${value}</div> + </div> + `; + + return li; + } + + static createNameFilterVisualTokenHTML(name) { + return ` + <li class="js-visual-token filtered-search-token"> + <div class="name">${name}</div> + </li> + `; + } + + static createSearchVisualTokenHTML(name) { + return ` + <li class="js-visual-token filtered-search-term"> + <div class="name">${name}</div> + </li> + `; + } + + static createInputHTML(placeholder = '') { + return ` + <li class="input-token"> + <input type='text' class='filtered-search' placeholder='${placeholder}' /> + </li> + `; + } + + static createTokensContainerHTML(html, inputPlaceholder) { + return ` + ${html} + ${FilteredSearchSpecHelper.createInputHTML(inputPlaceholder)} + `; + } +} + +module.exports = FilteredSearchSpecHelper; |