mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-29 11:23:54 +01:00
EgwMenuShoelace on checkboxes use a toggle icon to indicate checked state instead of an icon
This commit is contained in:
parent
7d2e84feea
commit
85137fd4d7
@ -4,6 +4,7 @@ import {egwMenuItem} from "./egw_menu";
|
|||||||
import {customElement} from "lit/decorators/custom-element.js";
|
import {customElement} from "lit/decorators/custom-element.js";
|
||||||
import {repeat} from "lit/directives/repeat.js";
|
import {repeat} from "lit/directives/repeat.js";
|
||||||
import {classMap} from "lit/directives/class-map.js";
|
import {classMap} from "lit/directives/class-map.js";
|
||||||
|
import {state} from "lit/decorators/state.js";
|
||||||
|
|
||||||
@customElement("egw-menu-shoelace")
|
@customElement("egw-menu-shoelace")
|
||||||
export class EgwMenuShoelace extends LitElement
|
export class EgwMenuShoelace extends LitElement
|
||||||
@ -38,7 +39,7 @@ export class EgwMenuShoelace extends LitElement
|
|||||||
/* Customise checkbox menuitem */
|
/* Customise checkbox menuitem */
|
||||||
|
|
||||||
sl-menu-item[type="checkbox"]::part(checked-icon) {
|
sl-menu-item[type="checkbox"]::part(checked-icon) {
|
||||||
visibility: visible;
|
visibility: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
sl-menu-item[type="checkbox"]:not([checked])::part(checked-icon) {
|
sl-menu-item[type="checkbox"]:not([checked])::part(checked-icon) {
|
||||||
@ -179,9 +180,9 @@ export class EgwMenuShoelace extends LitElement
|
|||||||
// Update our internal data
|
// Update our internal data
|
||||||
item.data.checked = item.checked = event.detail.item.checked;
|
item.data.checked = item.checked = event.detail.item.checked;
|
||||||
|
|
||||||
// Update icon since updated won't fire
|
// Update image of a checkbox item to be toggle on or off
|
||||||
const icon : SlIcon = event.detail.item.shadowRoot.querySelector("[part=\"checked-icon\"] sl-icon");
|
// this happens by requesting an update because item.checked has changed
|
||||||
icon.name = item.checked ? "check-square" : "square";
|
this.requestUpdate("structure")
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(typeof item.onClick == "function")
|
if(typeof item.onClick == "function")
|
||||||
@ -239,6 +240,12 @@ export class EgwMenuShoelace extends LitElement
|
|||||||
<sl-divider></sl-divider>`;
|
<sl-divider></sl-divider>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//if we have a checkbox, change the icon to be a toggle slider. Either on or off
|
||||||
|
if (item.checkbox)
|
||||||
|
{
|
||||||
|
item.iconUrl = item.checked ? "toggle-on" : "toggle-off";
|
||||||
|
}
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<sl-menu-item
|
<sl-menu-item
|
||||||
class=${classMap({
|
class=${classMap({
|
||||||
|
Loading…
Reference in New Issue
Block a user