Bugfix: Composition Modal when document type isNew
This commit is contained in:
@@ -24,7 +24,7 @@ export class UmbCompositionPickerModalElement extends UmbModalBaseElement<
|
||||
> {
|
||||
// TODO: Loosen this from begin specific to Document Types, so we can have a general interface for composition repositories. [NL]
|
||||
#compositionRepository?: UmbDocumentTypeCompositionRepository;
|
||||
#unique?: string;
|
||||
#unique: string | null = null;
|
||||
#init?: Promise<void>;
|
||||
|
||||
@state()
|
||||
@@ -50,26 +50,24 @@ export class UmbCompositionPickerModalElement extends UmbModalBaseElement<
|
||||
this._selection = this.data?.selection ?? [];
|
||||
this.modalContext?.setValue({ selection: this._selection });
|
||||
|
||||
const isNew = this.data!.isNew;
|
||||
this.#unique = !isNew ? this.data!.unique : null;
|
||||
|
||||
this.#requestReference();
|
||||
this.#requestAvailableCompositions();
|
||||
}
|
||||
|
||||
async #requestReference() {
|
||||
await this.#init;
|
||||
this.#unique = this.data?.unique;
|
||||
if (!this.#unique || !this.#compositionRepository) return;
|
||||
|
||||
const { data } = await this.#compositionRepository.getReferences(this.#unique);
|
||||
|
||||
this._references = data ?? [];
|
||||
|
||||
if (!this._references.length) {
|
||||
this.#requestAvailableCompositions();
|
||||
}
|
||||
}
|
||||
|
||||
async #requestAvailableCompositions() {
|
||||
await this.#init;
|
||||
if (!this.#unique || !this.#compositionRepository) return;
|
||||
if (!this.#compositionRepository) return;
|
||||
|
||||
const isElement = this.data?.isElement;
|
||||
const currentPropertyAliases = this.data?.currentPropertyAliases;
|
||||
|
||||
@@ -4,10 +4,10 @@ import { UmbModalToken } from '@umbraco-cms/backoffice/modal';
|
||||
export interface UmbCompositionPickerModalData {
|
||||
compositionRepositoryAlias: string;
|
||||
selection: Array<string>;
|
||||
unique: string;
|
||||
//Do we really need to send this to the server - Why isn't unique enough?
|
||||
unique: string | null;
|
||||
isElement: boolean;
|
||||
currentPropertyAliases: Array<string>;
|
||||
isNew: boolean;
|
||||
}
|
||||
|
||||
export interface UmbCompositionPickerModalValue {
|
||||
|
||||
@@ -333,6 +333,7 @@ export class UmbContentTypeDesignEditorElement extends UmbLitElement implements
|
||||
selection: contentTypes.map((contentType) => contentType.unique).filter((id) => id !== unique),
|
||||
isElement: ownerContentType.isElement,
|
||||
currentPropertyAliases: [],
|
||||
isNew: this.#workspaceContext.getIsNew()!,
|
||||
};
|
||||
|
||||
const modalManagerContext = await this.getContext(UMB_MODAL_MANAGER_CONTEXT);
|
||||
|
||||
@@ -15,8 +15,7 @@ export type UmbDocumentTypeCleanupModel = {
|
||||
};
|
||||
|
||||
export interface UmbDocumentTypeCompositionRequestModel {
|
||||
unique: string;
|
||||
//Do we really need to send this to the server - Why isn't unique enough?
|
||||
unique: string | null;
|
||||
isElement: boolean;
|
||||
currentPropertyAliases: Array<string>;
|
||||
currentCompositeUniques: Array<string>;
|
||||
|
||||
Reference in New Issue
Block a user