headline for modal

This commit is contained in:
Niels Lyngsø
2023-05-31 20:23:36 +02:00
parent 562f4c7d4c
commit 24459584e4
3 changed files with 23 additions and 9 deletions

View File

@@ -1,7 +1,8 @@
import { UmbModalToken } from '@umbraco-cms/backoffice/modal';
export interface UmbAllowedDocumentTypesModalData {
id: string | null;
parentId: string | null;
parentName?: string;
}
export interface UmbAllowedDocumentTypesModalResult {

View File

@@ -15,12 +15,23 @@ export class UmbAllowedDocumentTypesModalElement extends UmbModalBaseElement<
@state()
private _allowedDocumentTypes: DocumentTypeTreeItemResponseModel[] = [];
@state()
private _headline?: string;
public connectedCallback() {
super.connectedCallback();
// TODO: Support root aka. id of null? or maybe its an active prop, like 'atRoot'.
// TODO: show error
if (this.data?.id) {
this._retrieveAllowedChildrenOf(this.data.id);
const parentName = this.data?.parentName;
if (parentName) {
this._headline = `Create at '${parentName}'`;
} else {
this._headline = `Create`;
}
if (this.data?.parentId) {
// TODO: Support root aka. id of null? or maybe its an active prop, like 'atRoot'.
// TODO: show error
this._retrieveAllowedChildrenOf(this.data.parentId);
}
}
@@ -46,7 +57,7 @@ export class UmbAllowedDocumentTypesModalElement extends UmbModalBaseElement<
render() {
return html`
<umb-body-layout headline="Create">
<umb-body-layout headline=${this._headline}>
<uui-box>
${this._allowedDocumentTypes.length === 0 ? html`<p>No allowed types</p>` : nothing}
${this._allowedDocumentTypes.map(

View File

@@ -34,7 +34,8 @@ export class UmbCreateDocumentEntityAction extends UmbEntityActionBase<UmbDocume
const { data } = await this.repository.requestById(this.unique);
if (data && data.contentTypeId) {
this._openModal(data.contentTypeId);
// TODO: We need to get the APP language context, use its VariantId to retrieve the right variant. The variant of which we get the name from.
this._openModal(data.contentTypeId, data.variants?.[0]?.name);
}
}
@@ -42,10 +43,11 @@ export class UmbCreateDocumentEntityAction extends UmbEntityActionBase<UmbDocume
this._openModal(null);
}
private async _openModal(documentId: string | null) {
private async _openModal(parentId: string | null, parentName?: string) {
if (!this.#modalContext) return;
const modalHandler = this.#modalContext.open(UMB_ALLOWED_DOCUMENT_TYPES_MODAL, {
id: documentId,
parentId: parentId,
parentName: parentName,
});
const { documentTypeKey } = await modalHandler.onSubmit();