Merge pull request #2036 from umbraco/v14/bugfix/block-grid-allow-at-root-checked
Make allowAtRoot preset for Block Grid Types
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
import type { UmbBlockGridTypeAreaType } from '../../../types.js';
|
||||
import type { UmbPropertyDatasetContext } from '@umbraco-cms/backoffice/property';
|
||||
import { UMB_PROPERTY_CONTEXT } from '@umbraco-cms/backoffice/property';
|
||||
import {
|
||||
type UmbInvariantDatasetWorkspaceContext,
|
||||
type UmbRoutableWorkspaceContext,
|
||||
type UmbWorkspaceContext,
|
||||
UmbWorkspaceRouteManager,
|
||||
import type {
|
||||
UmbInvariantDatasetWorkspaceContext,
|
||||
UmbRoutableWorkspaceContext,
|
||||
UmbWorkspaceContext,
|
||||
} from '@umbraco-cms/backoffice/workspace';
|
||||
import {
|
||||
UmbSubmittableWorkspaceContextBase,
|
||||
|
||||
@@ -17,14 +17,13 @@ import {
|
||||
} from '@umbraco-cms/backoffice/property-editor';
|
||||
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
|
||||
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
|
||||
import { UMB_BLOCK_GRID_TYPE, type UmbBlockGridTypeGroupType } from '@umbraco-cms/backoffice/block-grid';
|
||||
import { UMB_BLOCK_GRID_TYPE, UMB_BLOCK_GRID_TYPE_WORKSPACE_MODAL, type UmbBlockGridTypeGroupType } from '@umbraco-cms/backoffice/block-grid';
|
||||
import type { UUIInputEvent } from '@umbraco-cms/backoffice/external/uui';
|
||||
import {
|
||||
UMB_PROPERTY_CONTEXT,
|
||||
UMB_PROPERTY_DATASET_CONTEXT,
|
||||
type UmbPropertyDatasetContext,
|
||||
} from '@umbraco-cms/backoffice/property';
|
||||
import { UMB_WORKSPACE_MODAL } from '@umbraco-cms/backoffice/modal';
|
||||
import { UmbModalRouteRegistrationController } from '@umbraco-cms/backoffice/router';
|
||||
import { UmbSorterController } from '@umbraco-cms/backoffice/sorter';
|
||||
|
||||
@@ -61,8 +60,8 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement
|
||||
|
||||
#datasetContext?: UmbPropertyDatasetContext;
|
||||
#blockTypeWorkspaceModalRegistration?: UmbModalRouteRegistrationController<
|
||||
typeof UMB_WORKSPACE_MODAL.DATA,
|
||||
typeof UMB_WORKSPACE_MODAL.VALUE
|
||||
typeof UMB_BLOCK_GRID_TYPE_WORKSPACE_MODAL.DATA,
|
||||
typeof UMB_BLOCK_GRID_TYPE_WORKSPACE_MODAL.VALUE
|
||||
>;
|
||||
|
||||
#value: Array<UmbBlockTypeWithGroupKey> = [];
|
||||
@@ -105,11 +104,8 @@ export class UmbPropertyEditorUIBlockGridTypeConfigurationElement
|
||||
this.#observeBlockGroups();
|
||||
});
|
||||
|
||||
this.#blockTypeWorkspaceModalRegistration = new UmbModalRouteRegistrationController(this, UMB_WORKSPACE_MODAL)
|
||||
this.#blockTypeWorkspaceModalRegistration = new UmbModalRouteRegistrationController(this, UMB_BLOCK_GRID_TYPE_WORKSPACE_MODAL)
|
||||
.addAdditionalPath(UMB_BLOCK_GRID_TYPE)
|
||||
.onSetup(() => {
|
||||
return { data: { entityType: UMB_BLOCK_GRID_TYPE, preset: {} }, modal: { size: 'large' } };
|
||||
})
|
||||
.observeRouteBuilder((routeBuilder) => {
|
||||
const newpath = routeBuilder({});
|
||||
this._workspacePath = newpath;
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import { UMB_BLOCK_GRID_TYPE, type UmbBlockGridTypeModel } from '../types.js';
|
||||
import type { UmbWorkspaceModalData, UmbWorkspaceModalValue } from '@umbraco-cms/backoffice/modal';
|
||||
import { UmbModalToken } from '@umbraco-cms/backoffice/modal';
|
||||
|
||||
export type UmbBlockGridTypeWorkspaceData = UmbWorkspaceModalData<UmbBlockGridTypeModel>;
|
||||
|
||||
export const UMB_BLOCK_GRID_TYPE_WORKSPACE_MODAL = new UmbModalToken<UmbBlockGridTypeWorkspaceData, UmbWorkspaceModalValue>(
|
||||
'Umb.Modal.Workspace',
|
||||
{
|
||||
modal: {
|
||||
type: 'sidebar',
|
||||
size: 'large',
|
||||
},
|
||||
data: { entityType: UMB_BLOCK_GRID_TYPE, preset: {allowAtRoot: true} },
|
||||
},
|
||||
// Recast the type, so the entityType data prop is not required:
|
||||
) as UmbModalToken<Omit<UmbWorkspaceModalData, 'entityType' | 'preset'>, UmbWorkspaceModalValue>;
|
||||
@@ -18,6 +18,6 @@ export const UMB_BLOCK_GRID_WORKSPACE_MODAL = new UmbModalToken<UmbBlockGridWork
|
||||
size: 'medium',
|
||||
},
|
||||
data: { entityType: 'block', preset: {}, originData: { index: -1, parentUnique: null } },
|
||||
// Recast the type, so the entityType data prop is not required:
|
||||
},
|
||||
// Recast the type, so the entityType data prop is not required:
|
||||
) as UmbModalToken<Omit<UmbWorkspaceModalData, 'entityType'>, UmbWorkspaceModalValue>;
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
export const UMB_BLOCK_GRID_TYPE_WORKSPACE_ALIAS = 'Umb.Workspace.BlockGridType';
|
||||
export * from './block-grid-workspace.modal-token.js';
|
||||
export * from './block-grid-type-workspace.modal-token.js';
|
||||
|
||||
@@ -16,6 +16,6 @@ export const UMB_BLOCK_LIST_WORKSPACE_MODAL = new UmbModalToken<UmbBlockListWork
|
||||
size: 'medium',
|
||||
},
|
||||
data: { entityType: 'block', preset: {}, originData: { index: -1 } },
|
||||
// Recast the type, so the entityType data prop is not required:
|
||||
},
|
||||
// Recast the type, so the entityType data prop is not required:
|
||||
) as UmbModalToken<Omit<UmbWorkspaceModalData, 'entityType'>, UmbWorkspaceModalValue>;
|
||||
|
||||
@@ -12,6 +12,6 @@ export const UMB_BLOCK_RTE_WORKSPACE_MODAL = new UmbModalToken<UmbBlockRteWorksp
|
||||
size: 'medium',
|
||||
},
|
||||
data: { entityType: 'block', preset: {}, originData: {} },
|
||||
// Recast the type, so the entityType data prop is not required:
|
||||
},
|
||||
// Recast the type, so the entityType data prop is not required:
|
||||
) as UmbModalToken<Omit<UmbWorkspaceModalData, 'entityType'>, UmbWorkspaceModalValue>;
|
||||
|
||||
@@ -10,7 +10,6 @@ import {
|
||||
UmbSubmittableWorkspaceContextBase,
|
||||
UmbInvariantWorkspacePropertyDatasetContext,
|
||||
UmbWorkspaceIsNewRedirectController,
|
||||
UmbWorkspaceRouteManager,
|
||||
} from '@umbraco-cms/backoffice/workspace';
|
||||
import { UmbArrayState, UmbObjectState, appendToFrozenArray } from '@umbraco-cms/backoffice/observable-api';
|
||||
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
|
||||
@@ -99,12 +98,22 @@ export class UmbBlockTypeWorkspaceContext<BlockTypeData extends UmbBlockTypeWith
|
||||
|
||||
async create(contentElementTypeId: string, groupKey?: string | null) {
|
||||
this.resetState();
|
||||
//Only set groupKey property if it exists
|
||||
const data: BlockTypeData = {
|
||||
contentElementTypeKey: contentElementTypeId,
|
||||
...(groupKey && { groupKey: groupKey }),
|
||||
|
||||
|
||||
let data: BlockTypeData = {
|
||||
contentElementTypeKey: contentElementTypeId
|
||||
} as BlockTypeData;
|
||||
|
||||
// If we have a modal context, we blend in the modal preset data: [NL]
|
||||
if (this.modalContext) {
|
||||
data = { ...data, ...this.modalContext.data.preset };
|
||||
}
|
||||
|
||||
// Only set groupKey property if it has been parsed to this method
|
||||
if (groupKey) {
|
||||
data.groupKey = groupKey;
|
||||
}
|
||||
|
||||
this.setIsNew(true);
|
||||
this.#data.setValue(data);
|
||||
return { data };
|
||||
|
||||
@@ -13,6 +13,6 @@ export const UMB_BLOCK_WORKSPACE_MODAL = new UmbModalToken<UmbBlockWorkspaceData
|
||||
size: 'large',
|
||||
},
|
||||
data: { entityType: 'block', preset: {}, originData: {} },
|
||||
// Recast the type, so the entityType data prop is not required:
|
||||
},
|
||||
// Recast the type, so the entityType data prop is not required:
|
||||
) as UmbModalToken<Omit<UmbWorkspaceModalData, 'entityType'>, UmbWorkspaceModalValue>;
|
||||
|
||||
@@ -26,7 +26,7 @@ export type UmbModalContextClassArgs<
|
||||
|
||||
// TODO: consider splitting this into two separate handlers
|
||||
export class UmbModalContext<
|
||||
ModalPreset extends { [key: string]: any } = { [key: string]: any },
|
||||
ModalData extends { [key: string]: any } = { [key: string]: any },
|
||||
ModalValue = any,
|
||||
> extends UmbControllerBase {
|
||||
//
|
||||
@@ -35,19 +35,19 @@ export class UmbModalContext<
|
||||
#submitRejecter?: (reason?: UmbModalRejectReason) => void;
|
||||
|
||||
public readonly key: string;
|
||||
public readonly data: ModalPreset;
|
||||
public readonly data: ModalData;
|
||||
public readonly type: UmbModalType = 'dialog';
|
||||
public readonly size: UUIModalSidebarSize = 'small';
|
||||
public readonly backdropBackground?: string;
|
||||
public readonly router: IRouterSlot | null = null;
|
||||
public readonly alias: string | UmbModalToken<ModalPreset, ModalValue>;
|
||||
public readonly alias: string | UmbModalToken<ModalData, ModalValue>;
|
||||
|
||||
#value;
|
||||
public readonly value;
|
||||
|
||||
constructor(
|
||||
host: UmbControllerHost,
|
||||
modalAlias: string | UmbModalToken<ModalPreset, ModalValue>,
|
||||
modalAlias: string | UmbModalToken<ModalData, ModalValue>,
|
||||
args: UmbModalContextClassArgs<UmbModalToken>,
|
||||
) {
|
||||
super(host);
|
||||
@@ -69,9 +69,9 @@ export class UmbModalContext<
|
||||
this.data = Object.freeze(
|
||||
// If we have both data and defaultData perform a deep merge
|
||||
args.data && defaultData
|
||||
? (umbDeepMerge(args.data as UmbDeepPartialObject<ModalPreset>, defaultData) as ModalPreset)
|
||||
? (umbDeepMerge(args.data as UmbDeepPartialObject<ModalData>, defaultData) as ModalData)
|
||||
: // otherwise pick one of them:
|
||||
(args.data as ModalPreset) ?? defaultData,
|
||||
(args.data as ModalData) ?? defaultData,
|
||||
);
|
||||
|
||||
const initValue =
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { UmbDataTypeDetailModel } from '../types.js';
|
||||
import type { UmbWorkspaceModalData, UmbWorkspaceModalValue } from '@umbraco-cms/backoffice/modal';
|
||||
import { UmbModalToken } from '@umbraco-cms/backoffice/modal';
|
||||
import type { UmbDataTypeDetailModel } from '../types.js';
|
||||
|
||||
export const UMB_DATATYPE_WORKSPACE_MODAL = new UmbModalToken<
|
||||
UmbWorkspaceModalData<UmbDataTypeDetailModel>,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { UMB_DOCUMENT_TYPE_ENTITY_TYPE } from '../entity.js';
|
||||
import { UMB_WORKSPACE_MODAL, UmbModalToken } from '@umbraco-cms/backoffice/modal';
|
||||
import type { UmbDeepPartialObject } from '@umbraco-cms/backoffice/utils';
|
||||
import type { UmbWorkspaceModalData, UmbWorkspaceModalValue } from '@umbraco-cms/backoffice/modal';
|
||||
import { UMB_DOCUMENT_TYPE_ENTITY_TYPE } from '../entity.js';
|
||||
|
||||
export interface UmbDocumentTypeWorkspaceData extends UmbWorkspaceModalData {}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { UmbLanguageDetailModel } from '../../types.js';
|
||||
import type { UmbWorkspaceModalData, UmbWorkspaceModalValue } from '@umbraco-cms/backoffice/modal';
|
||||
import { UmbModalToken } from '@umbraco-cms/backoffice/modal';
|
||||
import type { UmbLanguageDetailModel } from '../../types.js';
|
||||
|
||||
export const UMB_LANGUAGE_WORKSPACE_MODAL = new UmbModalToken<
|
||||
UmbWorkspaceModalData<UmbLanguageDetailModel>,
|
||||
|
||||
Reference in New Issue
Block a user