setup common action and generic modal
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import { UMB_ENTITY_ACTION_DEFAULT_KIND_MANIFEST } from '../../default/default.action.kind.js';
|
||||
import type { UmbExtensionManifestKind } from '@umbraco-cms/backoffice/extension-registry';
|
||||
|
||||
export const manifest: UmbExtensionManifestKind = {
|
||||
type: 'kind',
|
||||
alias: 'Umb.Kind.EntityAction.Create',
|
||||
matchKind: 'create',
|
||||
matchType: 'entityAction',
|
||||
manifest: {
|
||||
...UMB_ENTITY_ACTION_DEFAULT_KIND_MANIFEST.manifest,
|
||||
type: 'entityAction',
|
||||
kind: 'create',
|
||||
api: () => import('./create.action.js'),
|
||||
weight: 1200,
|
||||
forEntityTypes: [],
|
||||
meta: {
|
||||
icon: 'icon-add',
|
||||
label: '#actions_create',
|
||||
additionalOptions: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,20 @@
|
||||
import { UmbEntityActionBase } from '../../entity-action-base.js';
|
||||
import type { MetaEntityActionCreateKind } from './types.js';
|
||||
import { UMB_ENTITY_CREATE_OPTION_ACTION_LIST_MODAL } from './modal/index.js';
|
||||
import { UMB_MODAL_MANAGER_CONTEXT } from '@umbraco-cms/backoffice/modal';
|
||||
|
||||
export class UmbCreateEntityAction extends UmbEntityActionBase<MetaEntityActionCreateKind> {
|
||||
override async execute() {
|
||||
const modalManager = await this.getContext(UMB_MODAL_MANAGER_CONTEXT);
|
||||
const modalContext = modalManager.open(this, UMB_ENTITY_CREATE_OPTION_ACTION_LIST_MODAL, {
|
||||
data: {
|
||||
unique: this.args.unique,
|
||||
entityType: this.args.entityType,
|
||||
},
|
||||
});
|
||||
|
||||
await modalContext.onSubmit();
|
||||
}
|
||||
}
|
||||
|
||||
export { UmbCreateEntityAction as api };
|
||||
@@ -0,0 +1 @@
|
||||
export { UmbCreateEntityAction } from './create.action.js';
|
||||
@@ -0,0 +1,4 @@
|
||||
import { manifest as createKindManifest } from './create.action.kind.js';
|
||||
import { manifests as modalManifests } from './modal/manifests.js';
|
||||
|
||||
export const manifests = [createKindManifest, ...modalManifests];
|
||||
@@ -0,0 +1 @@
|
||||
export const UMB_ENTITY_CREATE_OPTION_ACTION_LIST_MODAL_ALIAS = 'Umb.Modal.Entity.CreateOptionActionList';
|
||||
@@ -0,0 +1,37 @@
|
||||
import type {
|
||||
UmbEntityCreateOptionActionListModalData,
|
||||
UmbEntityCreateOptionActionListModalValue,
|
||||
} from './entity-create-option-action-list-modal.token.js';
|
||||
import { html, customElement } from '@umbraco-cms/backoffice/external/lit';
|
||||
import { UmbModalBaseElement } from '@umbraco-cms/backoffice/modal';
|
||||
|
||||
const elementName = 'umb-entity-create-option-action-list-modal';
|
||||
@customElement(elementName)
|
||||
export class UmbEntityCreateOptionActionListModalElement extends UmbModalBaseElement<
|
||||
UmbEntityCreateOptionActionListModalData,
|
||||
UmbEntityCreateOptionActionListModalValue
|
||||
> {
|
||||
override render() {
|
||||
return html`
|
||||
<umb-body-layout headline="${this.localize.term('user_createUser')}">
|
||||
<uui-box>
|
||||
<umb-entity-create-option-action-list
|
||||
.entityType=${this.data?.entityType}
|
||||
.unique=${this.data?.unique}></umb-entity-create-option-action-list>
|
||||
</uui-box>
|
||||
<uui-button
|
||||
slot="actions"
|
||||
label=${this.localize.term('general_cancel')}
|
||||
@click=${this._rejectModal}></uui-button>
|
||||
</umb-body-layout>
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
export { UmbEntityCreateOptionActionListModalElement as element };
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
[elementName]: UmbEntityCreateOptionActionListModalElement;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import { UMB_ENTITY_CREATE_OPTION_ACTION_LIST_MODAL_ALIAS } from './constants.js';
|
||||
import type { UmbEntityUnique } from '@umbraco-cms/backoffice/entity';
|
||||
import { UmbModalToken } from '@umbraco-cms/backoffice/modal';
|
||||
|
||||
export interface UmbEntityCreateOptionActionListModalData {
|
||||
unique: UmbEntityUnique;
|
||||
entityType: string;
|
||||
}
|
||||
|
||||
export type UmbEntityCreateOptionActionListModalValue = never;
|
||||
|
||||
export const UMB_ENTITY_CREATE_OPTION_ACTION_LIST_MODAL = new UmbModalToken<
|
||||
UmbEntityCreateOptionActionListModalData,
|
||||
UmbEntityCreateOptionActionListModalValue
|
||||
>(UMB_ENTITY_CREATE_OPTION_ACTION_LIST_MODAL_ALIAS, {
|
||||
modal: {
|
||||
type: 'sidebar',
|
||||
size: 'small',
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from './constants.js';
|
||||
export * from './entity-create-option-action-list-modal.token.js';
|
||||
@@ -0,0 +1,10 @@
|
||||
import { UMB_ENTITY_CREATE_OPTION_ACTION_LIST_MODAL_ALIAS } from './constants.js';
|
||||
|
||||
export const manifests: Array<UmbExtensionManifest> = [
|
||||
{
|
||||
type: 'modal',
|
||||
alias: UMB_ENTITY_CREATE_OPTION_ACTION_LIST_MODAL_ALIAS,
|
||||
name: 'Entity Create Option Action List Modal',
|
||||
element: () => import('./entity-create-option-action-list-modal.element.js'),
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,16 @@
|
||||
import type { MetaEntityActionDefaultKind } from '../../default/index.js';
|
||||
import type { ManifestEntityAction } from '../../entity-action.extension.js';
|
||||
|
||||
export interface ManifestEntityActionCreateKind extends ManifestEntityAction<MetaEntityActionCreateKind> {
|
||||
type: 'entityAction';
|
||||
kind: 'create';
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
||||
export interface MetaEntityActionCreateKind extends MetaEntityActionDefaultKind {}
|
||||
|
||||
declare global {
|
||||
interface UmbExtensionManifestMap {
|
||||
umbEntityActionCreateKind: ManifestEntityActionCreateKind;
|
||||
}
|
||||
}
|
||||
@@ -1,2 +1,3 @@
|
||||
export * from './duplicate/index.js';
|
||||
export * from './create/index.js';
|
||||
export * from './delete/index.js';
|
||||
export * from './duplicate/index.js';
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import { manifests as createEntityActionManifests } from './common/create/manifests.js';
|
||||
import { manifests as defaultEntityActionManifests } from './default/manifests.js';
|
||||
import { manifests as deleteEntityActionManifests } from './common/delete/manifests.js';
|
||||
import { manifests as duplicateEntityActionManifests } from './common/duplicate/manifests.js';
|
||||
|
||||
import type { UmbExtensionManifestKind } from '@umbraco-cms/backoffice/extension-registry';
|
||||
|
||||
export const manifests: Array<UmbExtensionManifest | UmbExtensionManifestKind> = [
|
||||
...createEntityActionManifests,
|
||||
...defaultEntityActionManifests,
|
||||
...deleteEntityActionManifests,
|
||||
...duplicateEntityActionManifests,
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
import { UMB_USER_CREATE_OPTIONS_MODAL } from './modal/index.js';
|
||||
import { UmbEntityActionBase } from '@umbraco-cms/backoffice/entity-action';
|
||||
import { UMB_MODAL_MANAGER_CONTEXT } from '@umbraco-cms/backoffice/modal';
|
||||
|
||||
export class UmbCreateUserEntityAction extends UmbEntityActionBase<never> {
|
||||
override async execute() {
|
||||
const modalManager = await this.getContext(UMB_MODAL_MANAGER_CONTEXT);
|
||||
const modalContext = modalManager.open(this, UMB_USER_CREATE_OPTIONS_MODAL, {
|
||||
data: {
|
||||
parent: {
|
||||
unique: this.args.unique,
|
||||
entityType: this.args.entityType,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
await modalContext.onSubmit();
|
||||
}
|
||||
}
|
||||
|
||||
export { UmbCreateUserEntityAction as api };
|
||||
@@ -1,26 +1,17 @@
|
||||
import { UMB_USER_ROOT_ENTITY_TYPE } from '../../entity.js';
|
||||
import { manifests as apiUser } from './api-user/manifests.js';
|
||||
import { manifests as defaultUser } from './default-user/manifests.js';
|
||||
import { manifests as modalManifests } from './modal/manifests.js';
|
||||
|
||||
import type { UmbExtensionManifestKind } from '@umbraco-cms/backoffice/extension-registry';
|
||||
|
||||
export const manifests: Array<UmbExtensionManifest | UmbExtensionManifestKind> = [
|
||||
{
|
||||
type: 'entityAction',
|
||||
kind: 'default',
|
||||
kind: 'create',
|
||||
alias: 'Umb.EntityAction.User.Create',
|
||||
name: 'Create User Entity Action',
|
||||
weight: 1200,
|
||||
api: () => import('./create-user-entity-action.js'),
|
||||
forEntityTypes: [UMB_USER_ROOT_ENTITY_TYPE],
|
||||
meta: {
|
||||
icon: 'icon-add',
|
||||
label: '#actions_create',
|
||||
additionalOptions: true,
|
||||
},
|
||||
},
|
||||
...apiUser,
|
||||
...defaultUser,
|
||||
...modalManifests,
|
||||
];
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
import { UmbModalToken } from '@umbraco-cms/backoffice/modal';
|
||||
|
||||
export const UMB_USER_CREATE_OPTIONS_MODAL = new UmbModalToken('Umb.Modal.User.CreateOptions', {
|
||||
modal: {
|
||||
type: 'sidebar',
|
||||
size: 'small',
|
||||
},
|
||||
});
|
||||
@@ -1,8 +0,0 @@
|
||||
export const manifests: Array<UmbExtensionManifest> = [
|
||||
{
|
||||
type: 'modal',
|
||||
alias: 'Umb.Modal.User.CreateOptions',
|
||||
name: 'User Create Options Modal',
|
||||
element: () => import('./user-create-options-modal.element.js'),
|
||||
},
|
||||
];
|
||||
@@ -1,49 +0,0 @@
|
||||
import { html, customElement, state } from '@umbraco-cms/backoffice/external/lit';
|
||||
import { UmbModalBaseElement } from '@umbraco-cms/backoffice/modal';
|
||||
import type { UmbEntityModel } from '@umbraco-cms/backoffice/entity';
|
||||
import { UMB_ENTITY_CONTEXT } from '@umbraco-cms/backoffice/entity';
|
||||
|
||||
const elementName = 'umb-user-create-options-modal';
|
||||
@customElement(elementName)
|
||||
export class UmbUserCreateOptionsModalElement extends UmbModalBaseElement {
|
||||
@state()
|
||||
entity: UmbEntityModel = {
|
||||
entityType: '',
|
||||
unique: '',
|
||||
};
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.consumeContext(UMB_ENTITY_CONTEXT, (context) => {
|
||||
this.entity = {
|
||||
entityType: context.getEntityType(),
|
||||
unique: context.getUnique(),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
override render() {
|
||||
return html`
|
||||
<umb-body-layout headline="${this.localize.term('user_createUser')}">
|
||||
<uui-box>
|
||||
<umb-entity-create-option-action-list
|
||||
.entityType=${this.entity.entityType}
|
||||
.unique=${this.entity.unique}></umb-entity-create-option-action-list>
|
||||
</uui-box>
|
||||
<uui-button
|
||||
slot="actions"
|
||||
label=${this.localize.term('general_cancel')}
|
||||
@click=${this._rejectModal}></uui-button>
|
||||
</umb-body-layout>
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
export { UmbUserCreateOptionsModalElement as element };
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
[elementName]: UmbUserCreateOptionsModalElement;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user