tags are now provided from a selectable list

This commit is contained in:
Chris Caron 2020-01-15 17:41:05 -05:00
parent ff3e7c216e
commit c295291263

View File

@ -126,16 +126,24 @@ async function update() {
// Initialize our tags making it easy for an end user to // Initialize our tags making it easy for an end user to
// choose from. Tags are based off ones found in the saved // choose from. Tags are based off ones found in the saved
// configuration. // configuration.
let external_data = tags.concat(data.tags).reduce(function(result, item) {
result[item] = null;
return result;
}, {})
M.Chips.init(document.querySelectorAll('.chips'), { M.Chips.init(document.querySelectorAll('.chips'), {
placeholder: 'Optional Tag', placeholder: 'Optional Tag',
secondaryPlaceholder: 'Another Tag', secondaryPlaceholder: 'Another Tag',
autocompleteOptions: { autocompleteOptions: {
data: tags.concat(data.tags).reduce(function(result, item) { data: external_data,
result[item] = null; minLength: 0
return result; },
}, {}), onChipAdd: function(e, chip) {
limit: Infinity, var $this = this;
minLength: 1 $this.chipsData.forEach(function(e, index) {
if(!(e.tag in external_data))
$this.deleteChip(index);
})
} }
}); });