pass parent unique
This commit is contained in:
@@ -23,7 +23,6 @@ export class UmbContentTypePropertyStructureManager<T extends UmbContentTypeMode
|
||||
#init!: Promise<unknown>;
|
||||
|
||||
#contentTypeRepository: UmbDetailRepository<T>;
|
||||
#parentUnique: string | null = null;
|
||||
|
||||
#ownerContentTypeUnique?: string;
|
||||
#contentTypeObservers = new Array<UmbController>();
|
||||
@@ -70,11 +69,9 @@ export class UmbContentTypePropertyStructureManager<T extends UmbContentTypeMode
|
||||
return promiseResult;
|
||||
}
|
||||
|
||||
public async createScaffold(parentUnique: string | null) {
|
||||
public async createScaffold() {
|
||||
this._reset();
|
||||
|
||||
if (parentUnique === undefined) return {};
|
||||
|
||||
const { data } = await this.#contentTypeRepository.createScaffold();
|
||||
if (!data) return {};
|
||||
|
||||
@@ -106,11 +103,11 @@ export class UmbContentTypePropertyStructureManager<T extends UmbContentTypeMode
|
||||
* Create the owner content type. Notice this is for a Content Type that is NOT already stored on the server.
|
||||
* @returns
|
||||
*/
|
||||
public async create() {
|
||||
public async create(parentUnique: string | null) {
|
||||
const contentType = this.getOwnerContentType();
|
||||
if (!contentType || !contentType.unique) return false;
|
||||
|
||||
const { data } = await this.#contentTypeRepository.create(contentType, this.#parentUnique);
|
||||
const { data } = await this.#contentTypeRepository.create(contentType, parentUnique);
|
||||
if (!data) return false;
|
||||
|
||||
// Update state with latest version:
|
||||
|
||||
@@ -154,7 +154,7 @@ export class UmbDocumentTypeWorkspaceContext
|
||||
async create(parent: { entityType: string; unique: string | null }) {
|
||||
this.resetState();
|
||||
this.#parent = parent;
|
||||
const { data } = await this.structure.createScaffold(this.#parent.unique);
|
||||
const { data } = await this.structure.createScaffold();
|
||||
if (!data) return undefined;
|
||||
|
||||
this.setIsNew(true);
|
||||
@@ -182,9 +182,10 @@ export class UmbDocumentTypeWorkspaceContext
|
||||
if (data === undefined) throw new Error('Cannot save, no data');
|
||||
|
||||
if (this.getIsNew()) {
|
||||
if ((await this.structure.create()) === true) {
|
||||
if (!this.#parent) throw new Error('Parent is not set');
|
||||
|
||||
if ((await this.structure.create(this.#parent.unique)) === true) {
|
||||
// TODO: this might not be the right place to alert the tree, but it works for now
|
||||
if (!this.#parent) throw new Error('Parent is not set');
|
||||
const eventContext = await this.getContext(UMB_ACTION_EVENT_CONTEXT);
|
||||
const event = new UmbReloadTreeItemChildrenRequestEntityActionEvent({
|
||||
entityType: this.#parent.entityType,
|
||||
|
||||
@@ -117,7 +117,7 @@ export class UmbMediaTypeWorkspaceContext
|
||||
async create(parent: { entityType: string; unique: string | null }) {
|
||||
this.resetState();
|
||||
this.#parent = parent;
|
||||
const { data } = await this.structure.createScaffold(this.#parent.unique);
|
||||
const { data } = await this.structure.createScaffold();
|
||||
if (!data) return undefined;
|
||||
|
||||
this.setIsNew(true);
|
||||
@@ -148,7 +148,8 @@ export class UmbMediaTypeWorkspaceContext
|
||||
}
|
||||
|
||||
if (this.getIsNew()) {
|
||||
if ((await this.structure.create()) === true) {
|
||||
if (!this.#parent) throw new Error('Parent is not set');
|
||||
if ((await this.structure.create(this.#parent.unique)) === true) {
|
||||
if (!this.#parent) throw new Error('Parent is not set');
|
||||
const eventContext = await this.getContext(UMB_ACTION_EVENT_CONTEXT);
|
||||
const event = new UmbReloadTreeItemChildrenRequestEntityActionEvent({
|
||||
|
||||
Reference in New Issue
Block a user