open clipboard is boolean instead of magic string

This commit is contained in:
Lone Iversen
2024-01-12 09:45:25 +01:00
parent 896bb72f2c
commit 7c32773c2a
3 changed files with 10 additions and 17 deletions

View File

@@ -6,7 +6,6 @@ import { UmbLitElement } from '@umbraco-cms/internal/lit-element';
import type { UmbPropertyEditorConfigCollection } from '@umbraco-cms/backoffice/property-editor';
import {
UMB_BLOCK_CATALOGUE_MODAL,
UmbBlockCatalogueView,
UmbBlockLayoutBaseModel,
UmbBlockManagerContext,
UmbBlockTypeBase,
@@ -111,10 +110,10 @@ export class UmbPropertyEditorUIBlockListElement extends UmbLitElement implement
});
}
async #openBlockCatalogue(view?: UmbBlockCatalogueView) {
async #openBlockCatalogue(openClipboard: boolean = false) {
//Open modal
const modalContext = this.#modalContext?.open(UMB_BLOCK_CATALOGUE_MODAL, {
data: { blocks: this._blocks ?? [], view },
data: { blocks: this._blocks ?? [], openClipboard },
});
const data = await modalContext?.onSubmit();
@@ -151,13 +150,13 @@ export class UmbPropertyEditorUIBlockListElement extends UmbLitElement implement
id="add-button"
look="placeholder"
label=${this.localize.term('content_createEmpty')}
@click=${() => this.#openBlockCatalogue('createEmpty')}>
@click=${() => this.#openBlockCatalogue()}>
${this.localize.term('content_createEmpty')}
</uui-button>
<uui-button
label=${this.localize.term('content_createFromClipboard')}
look="placeholder"
@click=${() => this.#openBlockCatalogue('clipboard')}>
@click=${() => this.#openBlockCatalogue(true)}>
<uui-icon name="icon-paste-in"></uui-icon>
</uui-button>
</uui-button-group>`;

View File

@@ -1,7 +1,6 @@
import {
UmbBlockCatalogueModalData,
UmbBlockCatalogueModalValue,
UmbBlockCatalogueView,
UmbBlockTypeWithGroupKey,
} from '@umbraco-cms/backoffice/block';
import { UMB_DOCUMENT_WORKSPACE_CONTEXT } from '@umbraco-cms/backoffice/document';
@@ -21,13 +20,13 @@ export class UmbBlockCatalogueModalElement extends UmbModalBaseElement<
private _blockGroups: Array<{ key: string; name: string }> = [];
@state()
view?: UmbBlockCatalogueView;
openClipboard?: boolean;
connectedCallback() {
super.connectedCallback();
if (!this.data) return;
this.view = this.data.view ?? 'createEmpty';
this.openClipboard = this.data.openClipboard ?? false;
this._blocks = this.data.blocks ?? [];
this._blockGroups = this.data.blockGroups ?? [];
}
@@ -40,7 +39,7 @@ export class UmbBlockCatalogueModalElement extends UmbModalBaseElement<
render() {
return html`
<umb-body-layout headline="${this.localize.term('blockEditor_addBlock')}">
${this.#renderViews()} ${this.view === 'clipboard' ? this.#renderClipboard() : this.#renderCreateEmpty()}
${this.#renderViews()} ${this.openClipboard ? this.#renderClipboard() : this.#renderCreateEmpty()}
<div slot="actions">
<uui-button label=${this.localize.term('general_close')} @click=${this._rejectModal}></uui-button>
<uui-button
@@ -92,14 +91,11 @@ export class UmbBlockCatalogueModalElement extends UmbModalBaseElement<
#renderViews() {
return html`
<uui-tab-group slot="navigation">
<uui-tab
label="Create Empty"
?active=${this.view === 'createEmpty'}
@click=${() => (this.view = 'createEmpty')}>
<uui-tab label="Create Empty" ?active=${!this.openClipboard} @click=${() => (this.openClipboard = false)}>
Create Empty
<uui-icon slot="icon" name="icon-add"></uui-icon>
</uui-tab>
<uui-tab label="Clipboard" ?active=${this.view === 'clipboard'} @click=${() => (this.view = 'clipboard')}>
<uui-tab label="Clipboard" ?active=${this.openClipboard} @click=${() => (this.openClipboard = true)}>
Clipboard
<uui-icon slot="icon" name="icon-paste-in"></uui-icon>
</uui-tab>

View File

@@ -4,11 +4,9 @@ import { UmbModalToken } from '@umbraco-cms/backoffice/modal';
export interface UmbBlockCatalogueModalData {
blocks: Array<UmbBlockTypeBase>;
blockGroups?: Array<{ name: string; key: string }>;
view?: UmbBlockCatalogueView;
openClipboard?: boolean;
}
export type UmbBlockCatalogueView = 'clipboard' | 'createEmpty';
export interface UmbBlockCatalogueModalValue {
key: string;
}