Fix: remember validation state when creating (#18432)
* only reset state and load if its a new unique * related clean up * return response promise
This commit is contained in:
@@ -92,4 +92,9 @@ export class UmbStateManager<StateType extends UmbState = UmbState> extends UmbC
|
||||
clear() {
|
||||
this._states.setValue([]);
|
||||
}
|
||||
|
||||
override destroy() {
|
||||
super.destroy();
|
||||
this._states.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ export class UmbWorkspaceIsNewRedirectController extends UmbControllerBase {
|
||||
id: unique,
|
||||
});
|
||||
this.destroy();
|
||||
window.history.replaceState({}, '', newPath);
|
||||
window.history.replaceState(null, '', newPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,6 +167,9 @@ export abstract class UmbEntityDetailWorkspaceContextBase<
|
||||
}
|
||||
|
||||
async load(unique: string) {
|
||||
if (unique === this.getUnique() && this._getDataPromise) {
|
||||
return (await this._getDataPromise) as GetDataType;
|
||||
}
|
||||
this.resetState();
|
||||
this.#entityContext.setUnique(unique);
|
||||
this.loading.addState({ unique: LOADING_STATE_UNIQUE, message: `Loading ${this.getEntityType()} Details` });
|
||||
@@ -389,8 +392,10 @@ export abstract class UmbEntityDetailWorkspaceContextBase<
|
||||
|
||||
override resetState() {
|
||||
super.resetState();
|
||||
this.loading.clear();
|
||||
this._data.clear();
|
||||
this.#allowNavigateAway = false;
|
||||
this._getDataPromise = undefined;
|
||||
}
|
||||
|
||||
#checkIfInitialized() {
|
||||
@@ -447,6 +452,7 @@ export abstract class UmbEntityDetailWorkspaceContextBase<
|
||||
);
|
||||
this._detailRepository?.destroy();
|
||||
this.#entityContext.destroy();
|
||||
this._getDataPromise = undefined;
|
||||
super.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,6 @@ export abstract class UmbSubmittableWorkspaceContextBase<WorkspaceDataModelType>
|
||||
}
|
||||
|
||||
protected resetState() {
|
||||
//this.validation.reset();
|
||||
this.#validationContexts.forEach((context) => context.reset());
|
||||
this.#isNew.setValue(undefined);
|
||||
}
|
||||
|
||||
@@ -177,10 +177,15 @@ export class UmbDocumentWorkspaceContext
|
||||
]);
|
||||
}
|
||||
|
||||
override resetState(): void {
|
||||
super.resetState();
|
||||
this.#isTrashedContext.setIsTrashed(false);
|
||||
}
|
||||
|
||||
override async load(unique: string) {
|
||||
const response = await super.load(unique);
|
||||
|
||||
if (response.data) {
|
||||
if (response?.data) {
|
||||
this.#isTrashedContext.setIsTrashed(response.data.isTrashed);
|
||||
}
|
||||
|
||||
|
||||
@@ -89,13 +89,14 @@ export class UmbMediaWorkspaceContext
|
||||
|
||||
public override resetState() {
|
||||
super.resetState();
|
||||
this.#isTrashedContext.setIsTrashed(false);
|
||||
this.removeUmbControllerByAlias(UmbWorkspaceIsNewRedirectControllerAlias);
|
||||
}
|
||||
|
||||
public override async load(unique: string) {
|
||||
const response = await super.load(unique);
|
||||
|
||||
if (response.data) {
|
||||
if (response?.data) {
|
||||
this.#isTrashedContext.setIsTrashed(response.data.isTrashed);
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ export class UmbMemberWorkspaceContext
|
||||
preset: {
|
||||
memberType: {
|
||||
unique: memberTypeUnique,
|
||||
icon: "icon-user"
|
||||
icon: 'icon-user',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user