mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-02 12:54:18 +01:00
Get taglist selected options showing up
Note the [internal] event listener bound in Et2Taglist.connectedCallback() that re-renders the TaglistSelection every time the taglist's [internal] value changes
This commit is contained in:
parent
2d3e3f86e1
commit
4bd4402e28
@ -11,22 +11,27 @@
|
|||||||
import {LionOption} from '@lion/listbox';
|
import {LionOption} from '@lion/listbox';
|
||||||
import {css, html} from "@lion/core";
|
import {css, html} from "@lion/core";
|
||||||
|
|
||||||
export class EgwOption extends LionOption {
|
export class EgwOption extends LionOption
|
||||||
|
{
|
||||||
|
|
||||||
static get properties() {
|
static get properties()
|
||||||
|
{
|
||||||
return {
|
return {
|
||||||
...super.properties,
|
...super.properties,
|
||||||
title: {type: String},
|
title: {type: String},
|
||||||
icon: {type: String}
|
icon: {type: String}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
constructor() {
|
|
||||||
|
constructor()
|
||||||
|
{
|
||||||
super();
|
super();
|
||||||
this.title = '';
|
this.title = '';
|
||||||
this.icon = '';
|
this.icon = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
static get styles() {
|
static get styles()
|
||||||
|
{
|
||||||
return [
|
return [
|
||||||
...super.styles,
|
...super.styles,
|
||||||
css`
|
css`
|
||||||
|
@ -14,9 +14,11 @@ import {Et2widgetWithSelectMixin} from "../Et2Select/Et2WidgetWithSelectMixin";
|
|||||||
import {LionCombobox} from "@lion/combobox";
|
import {LionCombobox} from "@lion/combobox";
|
||||||
import {SelectOption} from "../Et2Select/FindSelectOptions";
|
import {SelectOption} from "../Et2Select/FindSelectOptions";
|
||||||
import {EgwOption} from "./EgwOption";
|
import {EgwOption} from "./EgwOption";
|
||||||
|
import {TaglistSelection} from "./TaglistSelection";
|
||||||
|
|
||||||
// Force the include, we really need this and without it the file will be skipped
|
// Force the include, we really need this and without it the file will be skipped
|
||||||
const really_import_me = EgwOption;
|
const really_import_me = EgwOption;
|
||||||
|
const really_import_me2 = TaglistSelection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Taglist base class implementation
|
* Taglist base class implementation
|
||||||
@ -48,10 +50,11 @@ export class Et2Taglist extends Et2widgetWithSelectMixin(LionCombobox)
|
|||||||
get slots() {
|
get slots() {
|
||||||
return {
|
return {
|
||||||
...super.slots,
|
...super.slots,
|
||||||
"selection-display": () => {
|
"selection-display": () =>
|
||||||
return html `<taglist-selection
|
{
|
||||||
slot="selection-display"
|
let display = document.createElement("taglist-selection");
|
||||||
style="display: contents;"></taglist-selection>`;
|
display.setAttribute("slot", "selection-display");
|
||||||
|
return display;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -62,6 +65,13 @@ export class Et2Taglist extends Et2widgetWithSelectMixin(LionCombobox)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
connectedCallback()
|
||||||
|
{
|
||||||
|
super.connectedCallback();
|
||||||
|
this.addEventListener('model-value-changed', () => {this._selectionDisplayNode.requestUpdate();});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the node where we're putting the options
|
* Get the node where we're putting the options
|
||||||
*
|
*
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
|
|
||||||
import {css, html, LitElement} from "@lion/core";
|
import {css, html, LitElement} from "@lion/core";
|
||||||
import {TaglistComboBox} from "./TaglistComboBox";
|
|
||||||
import {taglistStyles} from "./TaglistStyles";
|
import {taglistStyles} from "./TaglistStyles";
|
||||||
|
|
||||||
|
|
||||||
@ -21,10 +20,9 @@ import {taglistStyles} from "./TaglistStyles";
|
|||||||
export class TaglistSelection extends LitElement {
|
export class TaglistSelection extends LitElement {
|
||||||
static get properties() {
|
static get properties() {
|
||||||
return {
|
return {
|
||||||
selectedTags: Array,
|
comboxElement: {type: Object},
|
||||||
comboxElement: TaglistComboBox,
|
canBeClosed: {type: Boolean},
|
||||||
canBeClosed: Boolean,
|
canBeEdited: {type: Boolean}
|
||||||
canBeEdited: Boolean
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -79,7 +77,8 @@ export class TaglistSelection extends LitElement {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
get _inputNode() {
|
get _inputNode()
|
||||||
|
{
|
||||||
return this._getComboBoxElement()._inputNode;
|
return this._getComboBoxElement()._inputNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,7 +89,7 @@ export class TaglistSelection extends LitElement {
|
|||||||
_getComboBoxElement()
|
_getComboBoxElement()
|
||||||
{
|
{
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
return this.comboboxElement;
|
return this.parentElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -112,7 +111,6 @@ export class TaglistSelection extends LitElement {
|
|||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.selectedTags = [];
|
|
||||||
this.__handleCloseBtn = this.__handleCloseBtn.bind(this);
|
this.__handleCloseBtn = this.__handleCloseBtn.bind(this);
|
||||||
this.__handleEditBtn = this.__handleEditBtn.bind(this);
|
this.__handleEditBtn = this.__handleEditBtn.bind(this);
|
||||||
this.__inputOnKeyup = this.__inputOnKeyup.bind(this);
|
this.__inputOnKeyup = this.__inputOnKeyup.bind(this);
|
||||||
@ -131,15 +129,6 @@ export class TaglistSelection extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param changedProperties
|
|
||||||
*/
|
|
||||||
onComboboxElementUpdated(changedProperties) {
|
|
||||||
if (changedProperties.has('modelValue')) {
|
|
||||||
this.selectedTags = this.__getSelectedTags();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
__handleEditBtn()
|
__handleEditBtn()
|
||||||
{
|
{
|
||||||
@ -155,12 +144,13 @@ export class TaglistSelection extends LitElement {
|
|||||||
*
|
*
|
||||||
* @param option
|
* @param option
|
||||||
*/
|
*/
|
||||||
_selectedTagTemplate(option) {
|
_selectedTagTemplate(option)
|
||||||
|
{
|
||||||
return html`
|
return html`
|
||||||
<div class="taglist-selection__tag">
|
<div class="taglist-selection__tag">
|
||||||
${this._canBeEdited? html`<span class="tag-editBtn" @click="${this.__handleEditBtn}"></span>`:''}
|
${this.canBeEdited ? html`<span class="tag-editBtn" @click="${this.__handleEditBtn}"></span>` : ''}
|
||||||
<span class="tag-label">${option.value}</span>
|
<span class="tag-label">${option.value}</span>
|
||||||
${this._canBeClosed? html`<span class="tag-closeBtn" @click="${this.__handleCloseBtn}"></span>`:''}
|
${this.canBeClosed ? html`<span class="tag-closeBtn" @click="${this.__handleCloseBtn}"></span>` : ''}
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
@ -171,7 +161,8 @@ export class TaglistSelection extends LitElement {
|
|||||||
_selectedTagsTemplate() {
|
_selectedTagsTemplate() {
|
||||||
return html`
|
return html`
|
||||||
<div class="taglist-selection__tags">
|
<div class="taglist-selection__tags">
|
||||||
${this.selectedTags.map((option) => {
|
${this.__getSelectedTags().map((option) =>
|
||||||
|
{
|
||||||
return this._selectedTagTemplate(option);
|
return this._selectedTagTemplate(option);
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user