rename and move create document modal dialog to document-types silo
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
import { html } from 'lit';
|
||||
import { UUITextStyles } from '@umbraco-ui/uui-css/lib';
|
||||
import { customElement } from 'lit/decorators.js';
|
||||
import { UmbCreateDocumentModalData, UmbCreateDocumentModalResultData } from '.';
|
||||
import { UmbAllowedDocumentTypesModalData, UmbAllowedDocumentTypesModalResult } from '.';
|
||||
import { UmbModalBaseElement } from '@umbraco-cms/modal';
|
||||
|
||||
@customElement('umb-create-document-modal')
|
||||
export class UmbCreateDocumentModalElement extends UmbModalBaseElement<
|
||||
UmbCreateDocumentModalData,
|
||||
UmbCreateDocumentModalResultData
|
||||
@customElement('umb-allowed-document-types-modal')
|
||||
export class UmbAllowedDocumentTypesModalElement extends UmbModalBaseElement<
|
||||
UmbAllowedDocumentTypesModalData,
|
||||
UmbAllowedDocumentTypesModalResult
|
||||
> {
|
||||
static styles = [UUITextStyles];
|
||||
|
||||
@@ -25,7 +25,7 @@ export class UmbCreateDocumentModalElement extends UmbModalBaseElement<
|
||||
render() {
|
||||
return html`
|
||||
<umb-body-layout headline="Headline">
|
||||
<div>Render list of create options for ${this.data?.unique}</div>
|
||||
<div>Render list of create options for ${this.data?.key}</div>
|
||||
|
||||
<ul>
|
||||
<li><button type="button" value="1" @click=${this.#onClick}>Option 1</button></li>
|
||||
@@ -39,10 +39,10 @@ export class UmbCreateDocumentModalElement extends UmbModalBaseElement<
|
||||
}
|
||||
}
|
||||
|
||||
export default UmbCreateDocumentModalElement;
|
||||
export default UmbAllowedDocumentTypesModalElement;
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
'umb-create-document-modal': UmbCreateDocumentModalElement;
|
||||
'umb-allowed-document-types-modal': UmbAllowedDocumentTypesModalElement;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { UmbModalToken } from '@umbraco-cms/modal';
|
||||
|
||||
export interface UmbAllowedDocumentTypesModalData {
|
||||
key: string | null;
|
||||
}
|
||||
|
||||
export interface UmbAllowedDocumentTypesModalResult {
|
||||
documentTypeKey: string;
|
||||
}
|
||||
|
||||
export const UMB_ALLOWED_DOCUMENT_TYPES_MODAL_TOKEN = new UmbModalToken<
|
||||
UmbAllowedDocumentTypesModalData,
|
||||
UmbAllowedDocumentTypesModalResult
|
||||
>('Umb.Modal.AllowedDocumentTypes', {
|
||||
type: 'sidebar',
|
||||
size: 'small',
|
||||
});
|
||||
@@ -146,6 +146,21 @@ export class UmbDocumentTypeRepository implements UmbTreeRepository, UmbDetailRe
|
||||
return this.#detailStore!.byKey(key);
|
||||
}
|
||||
|
||||
async requestAllowedTypes(key: string) {
|
||||
await this.#init;
|
||||
|
||||
// TODO: should we show a notification if the key is missing?
|
||||
// Investigate what is best for Acceptance testing, cause in that perspective a thrown error might be the best choice?
|
||||
if (!key) {
|
||||
const error: ProblemDetailsModel = { title: 'Key is missing' };
|
||||
return { error };
|
||||
}
|
||||
|
||||
const { data, error } = await this.#detailDataSource.getAllowedChildrenOf(key);
|
||||
|
||||
return { data, error };
|
||||
}
|
||||
|
||||
// Could potentially be general methods:
|
||||
|
||||
async create(template: ItemType) {
|
||||
|
||||
@@ -186,4 +186,14 @@ export class UmbDocumentTypeServerDataSource implements RepositoryDetailDataSour
|
||||
);
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the allowed document types for a given parent key
|
||||
* @param {string} key
|
||||
* @return {*}
|
||||
* @memberof UmbDocumentTypeServerDataSource
|
||||
*/
|
||||
async getAllowedChildrenOf(key: string) {
|
||||
alert('get allowed children of', key);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
import { UMB_ALLOWED_DOCUMENT_TYPES_MODAL_TOKEN } from '../../../document-types/modals/allowed-document-types';
|
||||
import { UmbDocumentRepository } from '../../repository/document.repository';
|
||||
import type { UmbCreateDocumentModalResultData } from '.';
|
||||
import { UMB_CREATE_DOCUMENT_MODAL_TOKEN } from '.';
|
||||
import { UmbEntityActionBase } from '@umbraco-cms/entity-action';
|
||||
import { UmbControllerHostInterface } from '@umbraco-cms/controller';
|
||||
import { UmbModalContext, UMB_MODAL_CONTEXT_TOKEN } from '@umbraco-cms/modal';
|
||||
import { UmbContextConsumerController } from '@umbraco-cms/context-api';
|
||||
|
||||
// TODO: temp import
|
||||
import './create-document-modal.element.ts';
|
||||
|
||||
export class UmbCreateDocumentEntityAction extends UmbEntityActionBase<UmbDocumentRepository> {
|
||||
#modalContext?: UmbModalContext;
|
||||
|
||||
@@ -24,11 +20,11 @@ export class UmbCreateDocumentEntityAction extends UmbEntityActionBase<UmbDocume
|
||||
// TODO: what to do if modal service is not available?
|
||||
if (!this.#modalContext) return;
|
||||
|
||||
const modalHandler = this.#modalContext?.open(UMB_CREATE_DOCUMENT_MODAL_TOKEN, {
|
||||
unique: this.unique,
|
||||
const modalHandler = this.#modalContext?.open(UMB_ALLOWED_DOCUMENT_TYPES_MODAL_TOKEN, {
|
||||
key: this.unique,
|
||||
});
|
||||
|
||||
const { documentTypeKey }: UmbCreateDocumentModalResultData = await modalHandler.onSubmit();
|
||||
const { documentTypeKey } = await modalHandler.onSubmit();
|
||||
// TODO: how do we want to generate these urls?
|
||||
history.pushState(null, '', `/section/content/workspace/document/create/${this.unique}/${documentTypeKey}`);
|
||||
}
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
import { UmbModalToken } from '@umbraco-cms/modal';
|
||||
|
||||
export interface UmbCreateDocumentModalData {
|
||||
unique: string | null;
|
||||
}
|
||||
|
||||
export interface UmbCreateDocumentModalResultData {
|
||||
documentTypeKey: string;
|
||||
}
|
||||
|
||||
export const UMB_CREATE_DOCUMENT_MODAL_TOKEN = new UmbModalToken<
|
||||
UmbCreateDocumentModalData,
|
||||
UmbCreateDocumentModalResultData
|
||||
>('Umb.Modal.CreateDocument', {
|
||||
type: 'sidebar',
|
||||
size: 'small',
|
||||
});
|
||||
@@ -176,7 +176,7 @@ const modals: Array<ManifestModal> = [
|
||||
type: 'modal',
|
||||
alias: 'Umb.Modal.CreateDocument',
|
||||
name: 'Create Document Modal',
|
||||
loader: () => import('./create/create-document-modal.element'),
|
||||
loader: () => import('../../document-types/modals/allowed-document-types/allowed-document-types-modal.element'),
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user