add select all option to schedule
This commit is contained in:
@@ -6,6 +6,7 @@ import { UmbModalBaseElement } from '@umbraco-cms/backoffice/modal';
|
||||
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
|
||||
import { UmbSelectionManager } from '@umbraco-cms/backoffice/utils';
|
||||
import type { UmbInputDateElement } from '@umbraco-cms/backoffice/components';
|
||||
import type { UUIBooleanInputElement } from '@umbraco-cms/backoffice/external/uui';
|
||||
|
||||
@customElement('umb-document-schedule-modal')
|
||||
export class UmbDocumentScheduleModalElement extends UmbModalBaseElement<
|
||||
@@ -77,6 +78,25 @@ export class UmbDocumentScheduleModalElement extends UmbModalBaseElement<
|
||||
return this._selection.some((s) => s.unique === unique);
|
||||
}
|
||||
|
||||
#onSelectAllChange(event: Event) {
|
||||
const allUniques = this._options.map((o) => o.unique);
|
||||
const filter = this.#selectionManager.getAllowLimitation();
|
||||
const allowedUniques = allUniques.filter((unique) => filter(unique));
|
||||
|
||||
if ((event.target as UUIBooleanInputElement).checked) {
|
||||
this.#selectionManager.setSelection(allowedUniques);
|
||||
} else {
|
||||
this.#selectionManager.setSelection([]);
|
||||
}
|
||||
}
|
||||
|
||||
#isAllSelected() {
|
||||
const allUniques = this._options.map((o) => o.unique);
|
||||
const filter = this.#selectionManager.getAllowLimitation();
|
||||
const allowedUniques = allUniques.filter((unique) => filter(unique));
|
||||
return this._selection.length === allowedUniques.length;
|
||||
}
|
||||
|
||||
override render() {
|
||||
return html`<umb-body-layout headline=${this.localize.term('general_scheduledPublishing')}>
|
||||
<p id="subtitle">
|
||||
@@ -107,11 +127,18 @@ export class UmbDocumentScheduleModalElement extends UmbModalBaseElement<
|
||||
}
|
||||
|
||||
#renderOptions() {
|
||||
return repeat(
|
||||
this._options,
|
||||
(option) => option.unique,
|
||||
(option) => this.#renderItem(option),
|
||||
);
|
||||
return html`
|
||||
<uui-checkbox
|
||||
@change=${this.#onSelectAllChange}
|
||||
label="Select All"
|
||||
.checked=${this.#isAllSelected()}></uui-checkbox>
|
||||
|
||||
${repeat(
|
||||
this._options,
|
||||
(option) => option.unique,
|
||||
(option) => this.#renderItem(option),
|
||||
)}
|
||||
`;
|
||||
}
|
||||
|
||||
#renderItem(option: UmbDocumentVariantOptionModel) {
|
||||
@@ -210,6 +237,10 @@ export class UmbDocumentScheduleModalElement extends UmbModalBaseElement<
|
||||
border-right: 1px dashed var(--uui-color-border);
|
||||
}
|
||||
|
||||
uui-checkbox {
|
||||
margin-bottom: var(--uui-size-space-3);
|
||||
}
|
||||
|
||||
uui-menu-item {
|
||||
--uui-menu-item-flat-structure: 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user