fix: find the parent name to localize when creating a folder
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import { UMB_DOCUMENT_BLUEPRINT_FOLDER_REPOSITORY_ALIAS } from '../../../tree/folder/manifests.js';
|
||||
import { UmbDocumentBlueprintFolderRepository } from '../../../tree/index.js';
|
||||
import type {
|
||||
UmbDocumentBlueprintOptionsCreateModalData,
|
||||
UmbDocumentBlueprintOptionsCreateModalValue,
|
||||
} from './index.js';
|
||||
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
|
||||
import { html, customElement, css } from '@umbraco-cms/backoffice/external/lit';
|
||||
import { html, customElement, css, state } from '@umbraco-cms/backoffice/external/lit';
|
||||
import { UmbModalBaseElement } from '@umbraco-cms/backoffice/modal';
|
||||
import { type UmbSelectedEvent, UmbSelectionChangeEvent } from '@umbraco-cms/backoffice/event';
|
||||
import { UmbCreateFolderEntityAction, type UmbTreeElement } from '@umbraco-cms/backoffice/tree';
|
||||
@@ -14,12 +15,24 @@ export class UmbDocumentBlueprintOptionsCreateModalElement extends UmbModalBaseE
|
||||
UmbDocumentBlueprintOptionsCreateModalData,
|
||||
UmbDocumentBlueprintOptionsCreateModalValue
|
||||
> {
|
||||
@state()
|
||||
private _parentName?: string;
|
||||
|
||||
#createFolderAction?: UmbCreateFolderEntityAction;
|
||||
|
||||
override connectedCallback(): void {
|
||||
#itemRepository = new UmbDocumentBlueprintFolderRepository(this);
|
||||
|
||||
override async connectedCallback(): Promise<void> {
|
||||
super.connectedCallback();
|
||||
if (!this.data?.parent) throw new Error('A parent is required to create a folder');
|
||||
|
||||
if (this.data.parent.unique) {
|
||||
const { data: parent } = await this.#itemRepository.request(this.data.parent.unique.toString());
|
||||
this._parentName = parent?.name ?? this.localize.term('general_unknown');
|
||||
} else {
|
||||
this._parentName = this.localize.term('treeHeaders_contentBlueprints');
|
||||
}
|
||||
|
||||
// TODO: render the info from this instance in the list of actions
|
||||
this.#createFolderAction = new UmbCreateFolderEntityAction(this, {
|
||||
unique: this.data.parent.unique,
|
||||
@@ -54,7 +67,7 @@ export class UmbDocumentBlueprintOptionsCreateModalElement extends UmbModalBaseE
|
||||
override render() {
|
||||
return html`
|
||||
<umb-body-layout headline=${this.localize.term('actions_createblueprint')}>
|
||||
<uui-box headline="Create a folder under Content Templates">
|
||||
<uui-box headline=${this.localize.term('blueprints_createBlueprintFolderUnder', this._parentName)}>
|
||||
<uui-menu-item @click=${this.#onCreateFolderClick} label="New Folder...">
|
||||
<uui-icon slot="icon" name="icon-folder"></uui-icon>
|
||||
</uui-menu-item>
|
||||
|
||||
Reference in New Issue
Block a user