From e42787bd9d1a15b42a8a2f287db2b48778b0be05 Mon Sep 17 00:00:00 2001 From: Lone Iversen <108085781+loivsen@users.noreply.github.com> Date: Wed, 6 Dec 2023 09:17:10 +0100 Subject: [PATCH] bulk action permission --- ...on-view-bulk-action-permissions.element.ts | 62 +++++++++++++++++-- 1 file changed, 58 insertions(+), 4 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/property-editor/uis/collection-view/config/bulk-action-permissions/property-editor-ui-collection-view-bulk-action-permissions.element.ts b/src/Umbraco.Web.UI.Client/src/packages/core/property-editor/uis/collection-view/config/bulk-action-permissions/property-editor-ui-collection-view-bulk-action-permissions.element.ts index 648d6bb8b5..6d0506b9fc 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/property-editor/uis/collection-view/config/bulk-action-permissions/property-editor-ui-collection-view-bulk-action-permissions.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/property-editor/uis/collection-view/config/bulk-action-permissions/property-editor-ui-collection-view-bulk-action-permissions.element.ts @@ -1,9 +1,28 @@ import { UmbPropertyEditorUiElement } from '@umbraco-cms/backoffice/extension-registry'; import { html, customElement, property } from '@umbraco-cms/backoffice/external/lit'; -import { UmbPropertyEditorConfigCollection } from '@umbraco-cms/backoffice/property-editor'; +import { UUIBooleanInputEvent } from '@umbraco-cms/backoffice/external/uui'; +import { + UmbPropertyEditorConfigCollection, + UmbPropertyValueChangeEvent, +} from '@umbraco-cms/backoffice/property-editor'; import { UmbTextStyles } from '@umbraco-cms/backoffice/style'; import { UmbLitElement } from '@umbraco-cms/internal/lit-element'; +type BulkActionPermissionType = + | 'allowBulkCopy' + | 'allowBulkDelete' + | 'allowBulkMove' + | 'allowBulkPublish' + | 'allowBulkUnpublish'; + +interface BulkActionPermissions { + allowBulkCopy?: boolean; + allowBulkDelete?: boolean; + allowBulkMove?: boolean; + allowBulkPublish?: boolean; + allowBulkUnpublish?: boolean; +} + /** * @element umb-property-editor-ui-collection-view-bulk-action-permissions */ @@ -12,14 +31,49 @@ export class UmbPropertyEditorUICollectionViewBulkActionPermissionsElement extends UmbLitElement implements UmbPropertyEditorUiElement { - @property() - value = ''; + @property({ type: Object }) + value: BulkActionPermissions = {}; @property({ type: Object, attribute: false }) public config?: UmbPropertyEditorConfigCollection; + #onChange(e: UUIBooleanInputEvent, type: BulkActionPermissionType) { + switch (type) { + case 'allowBulkPublish': + this.value.allowBulkPublish = e.target.checked; + break; + case 'allowBulkUnpublish': + this.value.allowBulkUnpublish = e.target.checked; + break; + case 'allowBulkMove': + this.value.allowBulkMove = e.target.checked; + break; + case 'allowBulkCopy': + this.value.allowBulkCopy = e.target.checked; + break; + case 'allowBulkDelete': + this.value.allowBulkDelete = e.target.checked; + break; + } + this.dispatchEvent(new UmbPropertyValueChangeEvent()); + } + render() { - return html`
umb-property-editor-ui-collection-view-bulk-action-permissions
`; + return html` this.#onChange(e, 'allowBulkPublish')} + label="Allow bulk publish (content only)"> + this.#onChange(e, 'allowBulkUnpublish')} + label="Allow bulk unpublish (content only)"> + this.#onChange(e, 'allowBulkCopy')} + label="Allow bulk copy (content only)"> + this.#onChange(e, 'allowBulkMove')} + label="Allow bulk move"> + this.#onChange(e, 'allowBulkDelete')} + label="Allow bulk delete"> `; } static styles = [UmbTextStyles];