add duplicate for data types
This commit is contained in:
@@ -0,0 +1 @@
|
||||
export { UmbDuplicateDataTypeRepository, UMB_DUPLICATE_DATA_TYPE_REPOSITORY_ALIAS } from './repository/index.js';
|
||||
@@ -0,0 +1,22 @@
|
||||
import { UMB_DATA_TYPE_ENTITY_TYPE } from '../../entity.js';
|
||||
import { UMB_DATA_TYPE_TREE_ALIAS, UMB_DATA_TYPE_TREE_REPOSITORY_ALIAS } from '../../tree/index.js';
|
||||
import { UMB_DUPLICATE_DATA_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.DataType.DuplicateTo',
|
||||
name: 'Duplicate Document To Entity Action',
|
||||
forEntityTypes: [UMB_DATA_TYPE_ENTITY_TYPE],
|
||||
meta: {
|
||||
duplicateRepositoryAlias: UMB_DUPLICATE_DATA_TYPE_REPOSITORY_ALIAS,
|
||||
treeAlias: UMB_DATA_TYPE_TREE_ALIAS,
|
||||
treeRepositoryAlias: UMB_DATA_TYPE_TREE_REPOSITORY_ALIAS,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
export const manifests = [...entityActions, ...repositoryManifests];
|
||||
@@ -0,0 +1 @@
|
||||
export const UMB_DUPLICATE_DATA_TYPE_REPOSITORY_ALIAS = 'Umb.Repository.DataType.Duplicate';
|
||||
@@ -0,0 +1,20 @@
|
||||
import { UmbDuplicateDataTypeServerDataSource } from './data-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 UmbDuplicateDataTypeRepository extends UmbRepositoryBase implements UmbDuplicateRepository {
|
||||
#duplicateSource = new UmbDuplicateDataTypeServerDataSource(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 { DataTypeService } 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 UmbDuplicateDataTypeServerDataSource
|
||||
*/
|
||||
export class UmbDuplicateDataTypeServerDataSource implements UmbDuplicateDataSource {
|
||||
#host: UmbControllerHost;
|
||||
|
||||
/**
|
||||
* Creates an instance of UmbDuplicateDataTypeServerDataSource.
|
||||
* @param {UmbControllerHost} host
|
||||
* @memberof UmbDuplicateDataTypeServerDataSource
|
||||
*/
|
||||
constructor(host: UmbControllerHost) {
|
||||
this.#host = host;
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicate an item for the given id to the destination unique
|
||||
* @param {UmbDuplicateToRequestArgs} args
|
||||
* @return {*}
|
||||
* @memberof UmbDuplicateDataTypeServerDataSource
|
||||
*/
|
||||
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,
|
||||
DataTypeService.postDataTypeByIdCopy({
|
||||
id: args.unique,
|
||||
requestBody: {
|
||||
target: args.destination.unique ? { id: args.destination.unique } : null,
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
export { UmbDuplicateDataTypeRepository } from './data-type-duplicate.repository.js';
|
||||
export { UMB_DUPLICATE_DATA_TYPE_REPOSITORY_ALIAS } from './constants.js';
|
||||
@@ -0,0 +1,12 @@
|
||||
import { UMB_DUPLICATE_DATA_TYPE_REPOSITORY_ALIAS } from './constants.js';
|
||||
import { UmbDuplicateDataTypeRepository } from './data-type-duplicate.repository.js';
|
||||
import type { ManifestRepository } from '@umbraco-cms/backoffice/extension-registry';
|
||||
|
||||
const duplicateRepository: ManifestRepository = {
|
||||
type: 'repository',
|
||||
alias: UMB_DUPLICATE_DATA_TYPE_REPOSITORY_ALIAS,
|
||||
name: 'Duplicate Data Type Repository',
|
||||
api: UmbDuplicateDataTypeRepository,
|
||||
};
|
||||
|
||||
export const manifests = [duplicateRepository];
|
||||
@@ -3,6 +3,7 @@ import { UMB_DATA_TYPE_DETAIL_REPOSITORY_ALIAS } from '../repository/detail/inde
|
||||
import { UMB_DATA_TYPE_ITEM_REPOSITORY_ALIAS } from '../repository/item/manifests.js';
|
||||
import { manifests as createManifests } from './create/manifests.js';
|
||||
import { manifests as moveManifests } from './move-to/manifests.js';
|
||||
import { manifests as duplicateManifests } from './duplicate/manifests.js';
|
||||
import type { ManifestTypes } from '@umbraco-cms/backoffice/extension-registry';
|
||||
|
||||
const entityActions: Array<ManifestTypes> = [
|
||||
@@ -19,4 +20,4 @@ const entityActions: Array<ManifestTypes> = [
|
||||
},
|
||||
];
|
||||
|
||||
export const manifests = [...entityActions, ...createManifests, ...moveManifests];
|
||||
export const manifests = [...entityActions, ...createManifests, ...moveManifests, ...duplicateManifests];
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { UMB_DATA_TYPE_ENTITY_TYPE } from '../../entity.js';
|
||||
import { UMB_DATA_TYPE_TREE_REPOSITORY_ALIAS } from '../../tree/index.js';
|
||||
import { UMB_DATA_TYPE_TREE_ALIAS } from '../../tree/manifests.js';
|
||||
import { UMB_DATA_TYPE_TREE_REPOSITORY_ALIAS, UMB_DATA_TYPE_TREE_ALIAS } from '../../tree/index.js';
|
||||
import { UMB_MOVE_DATA_TYPE_REPOSITORY_ALIAS } from './repository/index.js';
|
||||
import { manifests as repositoryManifests } from './repository/manifests.js';
|
||||
import type { ManifestTypes } from '@umbraco-cms/backoffice/extension-registry';
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
export const UMB_DATA_TYPE_TREE_REPOSITORY_ALIAS = 'Umb.Repository.DataType.Tree';
|
||||
export const UMB_DATA_TYPE_TREE_STORE_ALIAS = 'Umb.Store.DataType.Tree';
|
||||
export const UMB_DATA_TYPE_TREE_ALIAS = 'Umb.Tree.DataType';
|
||||
@@ -1,3 +1,3 @@
|
||||
export { UMB_DATA_TYPE_TREE_STORE_CONTEXT } from './data-type-tree.store.js';
|
||||
export { UMB_DATA_TYPE_TREE_REPOSITORY_ALIAS } from './manifests.js';
|
||||
export { UMB_DATA_TYPE_TREE_REPOSITORY_ALIAS, UMB_DATA_TYPE_TREE_ALIAS } from './constants.js';
|
||||
export * from './folder/index.js';
|
||||
|
||||
@@ -2,6 +2,11 @@ import { manifests as folderManifests } from './folder/manifests.js';
|
||||
import { manifests as reloadManifests } from './reload-tree-item-children/manifests.js';
|
||||
import { UmbDataTypeTreeRepository } from './data-type-tree.repository.js';
|
||||
import { UmbDataTypeTreeStore } from './data-type-tree.store.js';
|
||||
import {
|
||||
UMB_DATA_TYPE_TREE_ALIAS,
|
||||
UMB_DATA_TYPE_TREE_REPOSITORY_ALIAS,
|
||||
UMB_DATA_TYPE_TREE_STORE_ALIAS,
|
||||
} from './constants.js';
|
||||
import type {
|
||||
ManifestRepository,
|
||||
ManifestTree,
|
||||
@@ -9,10 +14,6 @@ import type {
|
||||
ManifestTreeStore,
|
||||
} from '@umbraco-cms/backoffice/extension-registry';
|
||||
|
||||
export const UMB_DATA_TYPE_TREE_REPOSITORY_ALIAS = 'Umb.Repository.DataType.Tree';
|
||||
export const UMB_DATA_TYPE_TREE_STORE_ALIAS = 'Umb.Store.DataType.Tree';
|
||||
export const UMB_DATA_TYPE_TREE_ALIAS = 'Umb.Tree.DataType';
|
||||
|
||||
const treeRepository: ManifestRepository = {
|
||||
type: 'repository',
|
||||
alias: UMB_DATA_TYPE_TREE_REPOSITORY_ALIAS,
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { UMB_DICTIONARY_TREE_ALIAS } from '../../tree/manifests.js';
|
||||
import { UmbDictionaryImportRepository } from '../../repository/index.js';
|
||||
import type { UmbImportDictionaryModalData, UmbImportDictionaryModalValue } from './import-dictionary-modal.token.js';
|
||||
import { css, html, customElement, query, state, when } from '@umbraco-cms/backoffice/external/lit';
|
||||
|
||||
Reference in New Issue
Block a user