Skip to content

Commit

Permalink
ELEMENTS:1721: rendering of newly added tag when sanitization is enab…
Browse files Browse the repository at this point in the history
…led server side
  • Loading branch information
Nishant0928 committed Mar 12, 2024
1 parent cbba002 commit 4a8be89
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions ui/widgets/nuxeo-tag-suggestion.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,26 @@ import { escapeHTML } from './nuxeo-selectivity.js';
_addedTagHandler(entry) {
if (this.document) {
this.$.addTagOp.params = { tags: entry.id };
this.$.addTagOp.execute().then(() => {
this.$.addTagOp.execute().then((response) => {
if (!response || response.properties['nxtag:tags'].length < 0) {
return;
}
const lenArr = response.properties['nxtag:tags'].length;
const { label } = response.properties['nxtag:tags'][lenArr - 1];
entry.item.displayLabel = label;
this.shadowRoot.querySelector('#s2').value[lenArr - 1] = label;
this.$.toast.hide();
this.$.toast.text = this.i18n('tags.addedToDocument', entry.id);
this.$.toast.text = this.i18n('tags.addedToDocument', label);
this.$.toast.open();
const lastSelectedItem = this.$.s2._selectivity.el.firstElementChild.querySelectorAll(
'.selectivity-multiple-selected-item',
)[lenArr - 1];
if (lastSelectedItem) {
const textNode = lastSelectedItem.childNodes[1];
if (textNode.nodeType === Node.TEXT_NODE) {
textNode.textContent = label;
}
}
});
}
}
Expand All @@ -256,7 +272,7 @@ import { escapeHTML } from './nuxeo-selectivity.js';
this.$.removeTagOp.params = { tags: entry.id };
this.$.removeTagOp.execute().then(() => {
this.$.toast.hide();
this.$.toast.text = this.i18n('tags.removedFromDocument', entry.id);
this.$.toast.text = this.i18n('tags.removedFromDocument', entry.item.displayLabel);
this.$.toast.open();
});
}
Expand Down

0 comments on commit 4a8be89

Please sign in to comment.