add tag remove function

This commit is contained in:
Dennis Eichhorn 2020-03-01 16:53:20 +01:00
parent b3673209d7
commit 39cbafb6d2
3 changed files with 26 additions and 4 deletions

View File

@ -17,7 +17,7 @@ export class AdvancedInput
*
* @since 1.0.0
*/
constructor (e)
constructor (e, eventManager, observer)
{
this.id = e.id;
this.inputComponent = e;
@ -113,6 +113,25 @@ export class AdvancedInput
self.addToResultList(self, document.activeElement);
jsOMS.removeClass(self.dropdownElement, 'active');
});
observer.observe(this.tagElement, { childList: true, attributes: false, subtree: false });
eventManager.attach(this.id + '-tags-childList', function(data) {
const removes = data.target.querySelectorAll('.fa-times'),
removesLength = removes === null ? 0 : removes.length;
if (removesLength < 1) {
return;
}
removes[removesLength - 1].addEventListener('click', function(e) {
if (e.target.parentNode.parentNode === null) {
return;
}
e.target.parentNode.parentNode.removeChild(e.target.parentNode);
});
});
};
/**

View File

@ -15,11 +15,14 @@ export class GeneralUI
/**
* @constructor
*
* @param {Object} app Application object
*
* @since 1.0.0
*/
constructor ()
constructor (app)
{
this.visObs = null;
this.app = app;
};
/**
@ -130,7 +133,7 @@ export class GeneralUI
const length = e.length;
for (let i = 0; i < length; ++i) {
new AdvancedInput(e[i]);
new AdvancedInput(e[i], this.app.eventManager, this.app.uiManager.getDOMObserver());
}
};
};

View File

@ -30,7 +30,7 @@ export class UIManager
this.tableManager = new Table(this.app);
this.actionManager = new ActionManager(this.app);
this.dragNDrop = new DragNDrop(this.app);
this.generalUI = new GeneralUI();
this.generalUI = new GeneralUI(this.app);
const self = this;
/** global: MutationObserver */