parse data path to workspace
This commit is contained in:
@@ -131,7 +131,7 @@ export class UmbBlockGridEntriesContext
|
||||
data: {
|
||||
entityType: 'block',
|
||||
preset: {},
|
||||
originData: { areaKey: this.#areaKey, parentUnique: this.#parentUnique },
|
||||
originData: { areaKey: this.#areaKey, parentUnique: this.#parentUnique, baseDataPath: this._dataPath },
|
||||
},
|
||||
modal: { size: 'medium' },
|
||||
};
|
||||
|
||||
@@ -46,7 +46,7 @@ export class UmbBlockListEntriesContext extends UmbBlockEntriesContext<
|
||||
.addUniquePaths(['propertyAlias', 'variantId'])
|
||||
.addAdditionalPath('block')
|
||||
.onSetup(() => {
|
||||
return { data: { entityType: 'block', preset: {} }, modal: { size: 'medium' } };
|
||||
return { data: { entityType: 'block', preset: {}, baseDataPath: this._dataPath }, modal: { size: 'medium' } };
|
||||
})
|
||||
.observeRouteBuilder((routeBuilder) => {
|
||||
const newPath = routeBuilder({});
|
||||
|
||||
@@ -15,7 +15,7 @@ export const UMB_BLOCK_LIST_WORKSPACE_MODAL = new UmbModalToken<UmbBlockListWork
|
||||
type: 'sidebar',
|
||||
size: 'medium',
|
||||
},
|
||||
data: { entityType: 'block', preset: {}, originData: { index: -1 } },
|
||||
data: { entityType: 'block', preset: {}, originData: { index: -1 }, baseDataPath: undefined as unknown as string },
|
||||
},
|
||||
// Recast the type, so the entityType data prop is not required:
|
||||
) as UmbModalToken<Omit<UmbWorkspaceModalData, 'entityType'>, UmbWorkspaceModalValue>;
|
||||
|
||||
@@ -47,7 +47,7 @@ export class UmbBlockRteEntriesContext extends UmbBlockEntriesContext<
|
||||
.addUniquePaths(['propertyAlias', 'variantId'])
|
||||
.addAdditionalPath('block')
|
||||
.onSetup(() => {
|
||||
return { data: { entityType: 'block', preset: {} }, modal: { size: 'medium' } };
|
||||
return { data: { entityType: 'block', preset: {}, baseDataPath: this._dataPath }, modal: { size: 'medium' } };
|
||||
})
|
||||
.observeRouteBuilder((routeBuilder) => {
|
||||
const newPath = routeBuilder({});
|
||||
|
||||
@@ -27,6 +27,8 @@ export abstract class UmbBlockEntriesContext<
|
||||
protected _workspacePath = new UmbStringState(undefined);
|
||||
workspacePath = this._workspacePath.asObservable();
|
||||
|
||||
protected _dataPath?: string;
|
||||
|
||||
public abstract readonly canCreate: Observable<boolean>;
|
||||
|
||||
protected _layoutEntries = new UmbArrayState<BlockLayoutType>([], (x) => x.contentUdi);
|
||||
@@ -48,6 +50,10 @@ export abstract class UmbBlockEntriesContext<
|
||||
return this._manager!;
|
||||
}
|
||||
|
||||
setDataPath(path: string) {
|
||||
this._dataPath = path;
|
||||
}
|
||||
|
||||
protected abstract _gotBlockManager(): void;
|
||||
|
||||
// Public methods:
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
export * from './context/index.js';
|
||||
export * from './modals/index.js';
|
||||
export * from './utils/data-path-content-data-filter.function.js';
|
||||
export * from './types.js';
|
||||
export * from './workspace/index.js';
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* Validation Data Path filter for Block Content Data.
|
||||
* write a JSON-Path filter similar to `?(@.udi = 'my-udi://1234')`
|
||||
* @param udi {string} - The udi of the block content data.
|
||||
* @returns
|
||||
*/
|
||||
export function UmbDataPathBlockContentDataFilter(udi: string): string {
|
||||
// write a array of strings for each property, where alias must be present and culture and segment are optional
|
||||
//const filters: Array<string> = [`@.udi = '${udi}'`];
|
||||
//return `?(${filters.join(' && ')})`;
|
||||
return `?(@.udi = '${udi}')`;
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import { UmbModalToken } from '@umbraco-cms/backoffice/modal';
|
||||
|
||||
export interface UmbBlockWorkspaceData<OriginDataType = unknown> extends UmbWorkspaceModalData {
|
||||
originData: OriginDataType;
|
||||
baseDataPath: string;
|
||||
}
|
||||
|
||||
export const UMB_BLOCK_WORKSPACE_MODAL = new UmbModalToken<UmbBlockWorkspaceData, UmbWorkspaceModalValue>(
|
||||
@@ -12,7 +13,7 @@ export const UMB_BLOCK_WORKSPACE_MODAL = new UmbModalToken<UmbBlockWorkspaceData
|
||||
type: 'sidebar',
|
||||
size: 'large',
|
||||
},
|
||||
data: { entityType: 'block', preset: {}, originData: {} },
|
||||
data: { entityType: 'block', preset: {}, originData: {}, baseDataPath: undefined as unknown as string },
|
||||
},
|
||||
// Recast the type, so the entityType data prop is not required:
|
||||
) as UmbModalToken<Omit<UmbWorkspaceModalData, 'entityType'>, UmbWorkspaceModalValue>;
|
||||
|
||||
@@ -2,6 +2,7 @@ import { UmbModalToken } from './modal-token.js';
|
||||
export interface UmbWorkspaceModalData<DataModelType = unknown> {
|
||||
entityType: string;
|
||||
preset: Partial<DataModelType>;
|
||||
baseDataPath?: string;
|
||||
}
|
||||
|
||||
// TODO: It would be good with a WorkspaceValueBaseType, to avoid the hardcoded type for unique here:
|
||||
|
||||
@@ -61,6 +61,14 @@ export abstract class UmbSubmittableWorkspaceContextBase<WorkspaceDataModelType>
|
||||
this.#isNew.setValue(isNew);
|
||||
}
|
||||
|
||||
/**
|
||||
* If a Workspace has multiple validation contexts, then this method can be overwritten to return the correct one.
|
||||
* @returns Promise that resolves to void when the validation is complete.
|
||||
*/
|
||||
async validate(): Promise<void> {
|
||||
return this.validation.validate();
|
||||
}
|
||||
|
||||
async requestSubmit(): Promise<void> {
|
||||
return this.validateAndSubmit(
|
||||
() => this.submit(),
|
||||
@@ -76,7 +84,7 @@ export abstract class UmbSubmittableWorkspaceContextBase<WorkspaceDataModelType>
|
||||
this.#submitResolve = resolve;
|
||||
this.#submitReject = reject;
|
||||
});
|
||||
this.validation.validate().then(
|
||||
this.validate().then(
|
||||
async () => {
|
||||
onValid().then(this.#completeSubmit, this.#rejectSubmit);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user