js: Support new input enrichment type `search-bar`
This commit is contained in:
parent
027e468943
commit
4366f93127
|
@ -8,6 +8,7 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
var SearchBar = require('icinga/ipl/widget/SearchBar');
|
||||||
var FilterInput = require('icinga/ipl/widget/FilterInput');
|
var FilterInput = require('icinga/ipl/widget/FilterInput');
|
||||||
var TermInput = require('icinga/ipl/widget/TermInput');
|
var TermInput = require('icinga/ipl/widget/TermInput');
|
||||||
var Completer = require('icinga/ipl/widget/Completer');
|
var Completer = require('icinga/ipl/widget/Completer');
|
||||||
|
@ -31,7 +32,7 @@
|
||||||
/**
|
/**
|
||||||
* Enriched inputs
|
* Enriched inputs
|
||||||
*
|
*
|
||||||
* @type {WeakMap<object, FilterInput|TermInput|Completer>}
|
* @type {WeakMap<object, SearchBar|FilterInput|TermInput|Completer>}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this._enrichments = new WeakMap();
|
this._enrichments = new WeakMap();
|
||||||
|
@ -71,7 +72,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
let _this = event.data.self;
|
let _this = event.data.self;
|
||||||
let inputs = event.currentTarget.querySelectorAll('input[data-enrichment-type]');
|
let inputs = event.currentTarget.querySelectorAll('[data-enrichment-type]');
|
||||||
|
|
||||||
// Remember current instances
|
// Remember current instances
|
||||||
inputs.forEach(function (input) {
|
inputs.forEach(function (input) {
|
||||||
|
@ -108,14 +109,22 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create new instances
|
// Create new instances
|
||||||
var inputs = container.querySelectorAll('input[data-enrichment-type]');
|
var inputs = container.querySelectorAll('[data-enrichment-type]');
|
||||||
inputs.forEach(function (input) {
|
inputs.forEach(function (input) {
|
||||||
var enrichment = _this._enrichments.get(input);
|
var enrichment = _this._enrichments.get(input);
|
||||||
if (! enrichment) {
|
if (! enrichment) {
|
||||||
switch (input.dataset.enrichmentType) {
|
switch (input.dataset.enrichmentType) {
|
||||||
|
case 'search-bar':
|
||||||
|
enrichment = (new SearchBar(input)).bind();
|
||||||
|
break;
|
||||||
case 'filter':
|
case 'filter':
|
||||||
enrichment = (new FilterInput(input)).bind();
|
enrichment = (new FilterInput(input)).bind();
|
||||||
enrichment.restoreTerms();
|
enrichment.restoreTerms();
|
||||||
|
|
||||||
|
if (_this._enrichments.has(input.form)) {
|
||||||
|
_this._enrichments.get(input.form).setFilterInput(enrichment);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'terms':
|
case 'terms':
|
||||||
enrichment = (new TermInput(input)).bind();
|
enrichment = (new TermInput(input)).bind();
|
||||||
|
|
Loading…
Reference in New Issue