add duplicate for document types
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import {
|
||||
DOCUMENT_TYPE_ITEM_REPOSITORY_ALIAS,
|
||||
UMB_DOCUMENT_TYPE_ITEM_REPOSITORY_ALIAS,
|
||||
type UmbDocumentTypeItemModel,
|
||||
} from '@umbraco-cms/backoffice/document-type';
|
||||
import { html, customElement, property, state, ifDefined } from '@umbraco-cms/backoffice/external/lit';
|
||||
@@ -11,7 +11,7 @@ export class UmbBlockTypeCardElement extends UmbLitElement {
|
||||
//
|
||||
#itemManager = new UmbRepositoryItemsManager<UmbDocumentTypeItemModel>(
|
||||
this,
|
||||
DOCUMENT_TYPE_ITEM_REPOSITORY_ALIAS,
|
||||
UMB_DOCUMENT_TYPE_ITEM_REPOSITORY_ALIAS,
|
||||
(x) => x.unique,
|
||||
);
|
||||
|
||||
|
||||
@@ -4,14 +4,14 @@ import { customElement, css, html, state, property } from '@umbraco-cms/backoffi
|
||||
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
|
||||
import { UmbRepositoryItemsManager } from '@umbraco-cms/backoffice/repository';
|
||||
import type { UmbDocumentTypeItemModel } from '@umbraco-cms/backoffice/document-type';
|
||||
import { DOCUMENT_TYPE_ITEM_REPOSITORY_ALIAS } from '@umbraco-cms/backoffice/document-type';
|
||||
import { UMB_DOCUMENT_TYPE_ITEM_REPOSITORY_ALIAS } from '@umbraco-cms/backoffice/document-type';
|
||||
|
||||
@customElement('umb-block-type-workspace-editor')
|
||||
export class UmbBlockTypeWorkspaceEditorElement extends UmbLitElement {
|
||||
//
|
||||
#itemManager = new UmbRepositoryItemsManager<UmbDocumentTypeItemModel>(
|
||||
this,
|
||||
DOCUMENT_TYPE_ITEM_REPOSITORY_ALIAS,
|
||||
UMB_DOCUMENT_TYPE_ITEM_REPOSITORY_ALIAS,
|
||||
(x) => x.unique,
|
||||
);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { UmbDocumentTypeItemModel } from '../../repository/index.js';
|
||||
import { DOCUMENT_TYPE_ITEM_REPOSITORY_ALIAS } from '../../repository/index.js';
|
||||
import { UMB_DOCUMENT_TYPE_ITEM_REPOSITORY_ALIAS } from '../../repository/index.js';
|
||||
import { UmbPickerInputContext } from '@umbraco-cms/backoffice/picker-input';
|
||||
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
|
||||
import { UMB_DOCUMENT_TYPE_PICKER_MODAL } from '@umbraco-cms/backoffice/document-type';
|
||||
@@ -8,6 +8,6 @@ export class UmbDocumentTypePickerContext extends UmbPickerInputContext<UmbDocum
|
||||
constructor(host: UmbControllerHost) {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
super(host, DOCUMENT_TYPE_ITEM_REPOSITORY_ALIAS, UMB_DOCUMENT_TYPE_PICKER_MODAL);
|
||||
super(host, UMB_DOCUMENT_TYPE_ITEM_REPOSITORY_ALIAS, UMB_DOCUMENT_TYPE_PICKER_MODAL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
export {
|
||||
UmbDuplicateDocumentTypeRepository,
|
||||
UMB_DUPLICATE_DOCUMENT_TYPE_REPOSITORY_ALIAS,
|
||||
} from './repository/index.js';
|
||||
@@ -0,0 +1,22 @@
|
||||
import { UMB_DOCUMENT_TYPE_ENTITY_TYPE } from '../../entity.js';
|
||||
import { UMB_DOCUMENT_TYPE_TREE_ALIAS, UMB_DOCUMENT_TYPE_TREE_REPOSITORY_ALIAS } from '../../tree/index.js';
|
||||
import { UMB_DUPLICATE_DOCUMENT_TYPE_REPOSITORY_ALIAS } from './repository/index.js';
|
||||
import { manifests as repositoryManifests } from './repository/manifests.js';
|
||||
import type { ManifestTypes } from '@umbraco-cms/backoffice/extension-registry';
|
||||
|
||||
const entityActions: Array<ManifestTypes> = [
|
||||
{
|
||||
type: 'entityAction',
|
||||
kind: 'duplicateTo',
|
||||
alias: 'Umb.EntityAction.DocumentType.DuplicateTo',
|
||||
name: 'Duplicate Document To Entity Action',
|
||||
forEntityTypes: [UMB_DOCUMENT_TYPE_ENTITY_TYPE],
|
||||
meta: {
|
||||
duplicateRepositoryAlias: UMB_DUPLICATE_DOCUMENT_TYPE_REPOSITORY_ALIAS,
|
||||
treeAlias: UMB_DOCUMENT_TYPE_TREE_ALIAS,
|
||||
treeRepositoryAlias: UMB_DOCUMENT_TYPE_TREE_REPOSITORY_ALIAS,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
export const manifests = [...entityActions, ...repositoryManifests];
|
||||
@@ -0,0 +1 @@
|
||||
export const UMB_DUPLICATE_DOCUMENT_TYPE_REPOSITORY_ALIAS = 'Umb.Repository.DocumentType.Duplicate';
|
||||
@@ -0,0 +1,20 @@
|
||||
import { UmbDuplicateDocumentTypeServerDataSource } from './document-type-duplicate.server.data-source.js';
|
||||
import { UMB_NOTIFICATION_CONTEXT } from '@umbraco-cms/backoffice/notification';
|
||||
import type { UmbDuplicateRepository, UmbDuplicateToRequestArgs } from '@umbraco-cms/backoffice/entity-action';
|
||||
import { UmbRepositoryBase } from '@umbraco-cms/backoffice/repository';
|
||||
|
||||
export class UmbDuplicateDocumentTypeRepository extends UmbRepositoryBase implements UmbDuplicateRepository {
|
||||
#duplicateSource = new UmbDuplicateDocumentTypeServerDataSource(this);
|
||||
|
||||
async requestDuplicateTo(args: UmbDuplicateToRequestArgs) {
|
||||
const { error } = await this.#duplicateSource.duplicateTo(args);
|
||||
|
||||
if (!error) {
|
||||
const notificationContext = await this.getContext(UMB_NOTIFICATION_CONTEXT);
|
||||
const notification = { data: { message: `Duplicated` } };
|
||||
notificationContext.peek('positive', notification);
|
||||
}
|
||||
|
||||
return { error };
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
import { DocumentTypeService } from '@umbraco-cms/backoffice/external/backend-api';
|
||||
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
|
||||
import { tryExecuteAndNotify } from '@umbraco-cms/backoffice/resources';
|
||||
import type { UmbDuplicateDataSource, UmbDuplicateToRequestArgs } from '@umbraco-cms/backoffice/entity-action';
|
||||
|
||||
/**
|
||||
* Duplicate Document Server Data Source
|
||||
* @export
|
||||
* @class UmbDuplicateDocumentTypeServerDataSource
|
||||
*/
|
||||
export class UmbDuplicateDocumentTypeServerDataSource implements UmbDuplicateDataSource {
|
||||
#host: UmbControllerHost;
|
||||
|
||||
/**
|
||||
* Creates an instance of UmbDuplicateDocumentTypeServerDataSource.
|
||||
* @param {UmbControllerHost} host
|
||||
* @memberof UmbDuplicateDocumentTypeServerDataSource
|
||||
*/
|
||||
constructor(host: UmbControllerHost) {
|
||||
this.#host = host;
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicate an item for the given id to the destination unique
|
||||
* @param {UmbDuplicateToRequestArgs} args
|
||||
* @return {*}
|
||||
* @memberof UmbDuplicateDocumentTypeServerDataSource
|
||||
*/
|
||||
async duplicateTo(args: UmbDuplicateToRequestArgs) {
|
||||
if (!args.unique) throw new Error('Unique is missing');
|
||||
if (args.destination.unique === undefined) throw new Error('Destination unique is missing');
|
||||
|
||||
return tryExecuteAndNotify(
|
||||
this.#host,
|
||||
DocumentTypeService.postDocumentTypeByIdCopy({
|
||||
id: args.unique,
|
||||
requestBody: {
|
||||
target: args.destination.unique ? { id: args.destination.unique } : null,
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
export { UmbDuplicateDocumentTypeRepository } from './document-type-duplicate.repository.js';
|
||||
export { UMB_DUPLICATE_DOCUMENT_TYPE_REPOSITORY_ALIAS } from './constants.js';
|
||||
@@ -0,0 +1,12 @@
|
||||
import { UMB_DUPLICATE_DOCUMENT_TYPE_REPOSITORY_ALIAS } from './constants.js';
|
||||
import { UmbDuplicateDocumentTypeRepository } from './document-type-duplicate.repository.js';
|
||||
import type { ManifestRepository } from '@umbraco-cms/backoffice/extension-registry';
|
||||
|
||||
const duplicateRepository: ManifestRepository = {
|
||||
type: 'repository',
|
||||
alias: UMB_DUPLICATE_DOCUMENT_TYPE_REPOSITORY_ALIAS,
|
||||
name: 'Duplicate Document Type Repository',
|
||||
api: UmbDuplicateDocumentTypeRepository,
|
||||
};
|
||||
|
||||
export const manifests = [duplicateRepository];
|
||||
@@ -1,8 +1,11 @@
|
||||
import { UMB_DOCUMENT_TYPE_ENTITY_TYPE } from '../entity.js';
|
||||
import { DOCUMENT_TYPE_DETAIL_REPOSITORY_ALIAS, DOCUMENT_TYPE_ITEM_REPOSITORY_ALIAS } from '../repository/index.js';
|
||||
import {
|
||||
UMB_DOCUMENT_TYPE_DETAIL_REPOSITORY_ALIAS,
|
||||
UMB_DOCUMENT_TYPE_ITEM_REPOSITORY_ALIAS,
|
||||
} from '../repository/index.js';
|
||||
import { manifests as createManifests } from './create/manifests.js';
|
||||
import { manifests as moveManifests } from './move-to/manifests.js';
|
||||
import { UMB_DOCUMENT_TYPE_PICKER_MODAL } from '@umbraco-cms/backoffice/document-type';
|
||||
import { manifests as duplicateManifests } from './duplicate/manifests.js';
|
||||
import type { ManifestTypes } from '@umbraco-cms/backoffice/extension-registry';
|
||||
|
||||
const entityActions: Array<ManifestTypes> = [
|
||||
@@ -13,22 +16,10 @@ const entityActions: Array<ManifestTypes> = [
|
||||
name: 'Delete Document-Type Entity Action',
|
||||
forEntityTypes: [UMB_DOCUMENT_TYPE_ENTITY_TYPE],
|
||||
meta: {
|
||||
itemRepositoryAlias: DOCUMENT_TYPE_ITEM_REPOSITORY_ALIAS,
|
||||
detailRepositoryAlias: DOCUMENT_TYPE_DETAIL_REPOSITORY_ALIAS,
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'entityAction',
|
||||
kind: 'duplicate',
|
||||
alias: 'Umb.EntityAction.DocumentType.Duplicate',
|
||||
name: 'Duplicate Document Type Entity Action',
|
||||
forEntityTypes: [UMB_DOCUMENT_TYPE_ENTITY_TYPE],
|
||||
meta: {
|
||||
itemRepositoryAlias: DOCUMENT_TYPE_ITEM_REPOSITORY_ALIAS,
|
||||
duplicateRepositoryAlias: DOCUMENT_TYPE_DETAIL_REPOSITORY_ALIAS,
|
||||
pickerModal: UMB_DOCUMENT_TYPE_PICKER_MODAL,
|
||||
itemRepositoryAlias: UMB_DOCUMENT_TYPE_ITEM_REPOSITORY_ALIAS,
|
||||
detailRepositoryAlias: UMB_DOCUMENT_TYPE_DETAIL_REPOSITORY_ALIAS,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
export const manifests = [...entityActions, ...createManifests, ...moveManifests];
|
||||
export const manifests = [...entityActions, ...createManifests, ...moveManifests, ...duplicateManifests];
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { UMB_DOCUMENT_TYPE_ENTITY_TYPE } from '../../entity.js';
|
||||
import { UMB_DOCUMENT_TYPE_TREE_REPOSITORY_ALIAS } from '../../tree/index.js';
|
||||
import { UMB_DOCUMENT_TYPE_TREE_ALIAS } from '../../tree/manifests.js';
|
||||
import { UMB_DOCUMENT_TYPE_TREE_REPOSITORY_ALIAS, UMB_DOCUMENT_TYPE_TREE_ALIAS } from '../../tree/index.js';
|
||||
import { UMB_MOVE_DOCUMENT_TYPE_REPOSITORY_ALIAS } from './repository/index.js';
|
||||
import { manifests as repositoryManifests } from './repository/manifests.js';
|
||||
import type { ManifestTypes } from '@umbraco-cms/backoffice/extension-registry';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { UMB_DOCUMENT_TYPE_TREE_ALIAS } from '../tree/manifests.js';
|
||||
import { UMB_DOCUMENT_TYPE_TREE_ALIAS } from '../tree/index.js';
|
||||
|
||||
export const manifests = [
|
||||
{
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
export { UmbDocumentTypeDetailRepository } from './document-type-detail.repository.js';
|
||||
export {
|
||||
UMB_DOCUMENT_TYPE_DETAIL_REPOSITORY_ALIAS as DOCUMENT_TYPE_DETAIL_REPOSITORY_ALIAS,
|
||||
UMB_DOCUMENT_TYPE_DETAIL_STORE_ALIAS as DOCUMENT_TYPE_DETAIL_STORE_ALIAS,
|
||||
} from './manifests.js';
|
||||
export { UMB_DOCUMENT_TYPE_DETAIL_REPOSITORY_ALIAS, UMB_DOCUMENT_TYPE_DETAIL_STORE_ALIAS } from './manifests.js';
|
||||
export { UMB_DOCUMENT_TYPE_DETAIL_STORE_CONTEXT } from './document-type-detail.store.js';
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
export { UmbDocumentTypeItemRepository } from './document-type-item.repository.js';
|
||||
export {
|
||||
UMB_DOCUMENT_TYPE_ITEM_REPOSITORY_ALIAS as DOCUMENT_TYPE_ITEM_REPOSITORY_ALIAS,
|
||||
UMB_DOCUMENT_TYPE_ITEM_STORE_ALIAS as DOCUMENT_TYPE_ITEM_STORE_ALIAS,
|
||||
} from './manifests.js';
|
||||
export { UMB_DOCUMENT_TYPE_ITEM_REPOSITORY_ALIAS, UMB_DOCUMENT_TYPE_ITEM_STORE_ALIAS } from './manifests.js';
|
||||
export * from './types.js';
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
export const UMB_DOCUMENT_TYPE_TREE_REPOSITORY_ALIAS = 'Umb.Repository.DocumentType.Tree';
|
||||
export const UMB_DOCUMENT_TYPE_TREE_STORE_ALIAS = 'Umb.Store.DocumentType.Tree';
|
||||
export const UMB_DOCUMENT_TYPE_TREE_ALIAS = 'Umb.Tree.DocumentType';
|
||||
@@ -1,3 +1,3 @@
|
||||
export { UMB_DOCUMENT_TYPE_TREE_STORE_CONTEXT } from './document-type.tree.store.js';
|
||||
export { UMB_DOCUMENT_TYPE_TREE_REPOSITORY_ALIAS } from './manifests.js';
|
||||
export { UMB_DOCUMENT_TYPE_TREE_REPOSITORY_ALIAS, UMB_DOCUMENT_TYPE_TREE_ALIAS } from './constants.js';
|
||||
export * from './folder/index.js';
|
||||
|
||||
@@ -3,6 +3,11 @@ import {
|
||||
UMB_DOCUMENT_TYPE_FOLDER_ENTITY_TYPE,
|
||||
UMB_DOCUMENT_TYPE_ROOT_ENTITY_TYPE,
|
||||
} from '../entity.js';
|
||||
import {
|
||||
UMB_DOCUMENT_TYPE_TREE_ALIAS,
|
||||
UMB_DOCUMENT_TYPE_TREE_REPOSITORY_ALIAS,
|
||||
UMB_DOCUMENT_TYPE_TREE_STORE_ALIAS,
|
||||
} from './constants.js';
|
||||
import { UmbDocumentTypeTreeRepository } from './document-type-tree.repository.js';
|
||||
import { UmbDocumentTypeTreeStore } from './document-type.tree.store.js';
|
||||
import { manifests as folderManifests } from './folder/manifests.js';
|
||||
@@ -14,10 +19,6 @@ import type {
|
||||
ManifestTreeStore,
|
||||
} from '@umbraco-cms/backoffice/extension-registry';
|
||||
|
||||
export const UMB_DOCUMENT_TYPE_TREE_REPOSITORY_ALIAS = 'Umb.Repository.DocumentType.Tree';
|
||||
export const UMB_DOCUMENT_TYPE_TREE_STORE_ALIAS = 'Umb.Store.DocumentType.Tree';
|
||||
export const UMB_DOCUMENT_TYPE_TREE_ALIAS = 'Umb.Tree.DocumentType';
|
||||
|
||||
const treeRepository: ManifestRepository = {
|
||||
type: 'repository',
|
||||
alias: UMB_DOCUMENT_TYPE_TREE_REPOSITORY_ALIAS,
|
||||
|
||||
Reference in New Issue
Block a user