mapping
This commit is contained in:
@@ -1,17 +1,13 @@
|
||||
import type { UmbDictionaryRepository } from '../../repository/dictionary.repository.js';
|
||||
import type { UmbDictionaryImportRepository } from '../../repository/index.js';
|
||||
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
|
||||
import { UmbEntityActionBase } from '@umbraco-cms/backoffice/entity-action';
|
||||
import type { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api';
|
||||
import type {
|
||||
UmbModalManagerContext} from '@umbraco-cms/backoffice/modal';
|
||||
import {
|
||||
UMB_MODAL_MANAGER_CONTEXT,
|
||||
UMB_IMPORT_DICTIONARY_MODAL,
|
||||
} from '@umbraco-cms/backoffice/modal';
|
||||
import type { UmbModalManagerContext } from '@umbraco-cms/backoffice/modal';
|
||||
import { UMB_MODAL_MANAGER_CONTEXT, UMB_IMPORT_DICTIONARY_MODAL } from '@umbraco-cms/backoffice/modal';
|
||||
import type { UmbDictionaryTreeStore } from '@umbraco-cms/backoffice/dictionary';
|
||||
import { UMB_DICTIONARY_TREE_STORE_CONTEXT } from '@umbraco-cms/backoffice/dictionary';
|
||||
|
||||
export default class UmbImportDictionaryEntityAction extends UmbEntityActionBase<UmbDictionaryRepository> {
|
||||
export default class UmbImportDictionaryEntityAction extends UmbEntityActionBase<UmbDictionaryImportRepository> {
|
||||
static styles = [UmbTextStyles];
|
||||
|
||||
#modalContext?: UmbModalManagerContext;
|
||||
|
||||
@@ -12,16 +12,15 @@ export class UmbDictionaryImportRepository extends UmbRepositoryBase {
|
||||
|
||||
/**
|
||||
* @description - Import a dictionary
|
||||
* @param {string} temporaryFileId
|
||||
* @param {string} temporaryFileUnique
|
||||
* @param {string} [parentUnique]
|
||||
* @return {*}
|
||||
* @memberof UmbDictionaryImportRepository
|
||||
*/
|
||||
import(temporaryFileId: string, parentUnique?: string) {
|
||||
if (!temporaryFileId) {
|
||||
throw new Error('Temporary file id is missing');
|
||||
}
|
||||
import(temporaryFileUnique: string, parentUnique: string | null) {
|
||||
if (!temporaryFileUnique) throw new Error('Temporary file unique is missing');
|
||||
if (parentUnique === undefined) throw new Error('Parent unique is missing');
|
||||
|
||||
return this.#importSource.import(temporaryFileId, parentUnique);
|
||||
return this.#importSource.import(temporaryFileUnique, parentUnique);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { ImportDictionaryRequestModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
import { DictionaryResource } from '@umbraco-cms/backoffice/backend-api';
|
||||
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
|
||||
import { tryExecuteAndNotify } from '@umbraco-cms/backoffice/resources';
|
||||
@@ -11,15 +12,25 @@ export class UmbDictionaryImportServerDataSource {
|
||||
|
||||
/**
|
||||
* @description - Import a dictionary
|
||||
* @param {string} temporaryFileId
|
||||
* @param {string} temporaryFileUnique
|
||||
* @param {string?} parentUnique
|
||||
* @returns {*}
|
||||
* @memberof UmbDictionaryImportServerDataSource
|
||||
*/
|
||||
import(temporaryFileId: string, parentUnique?: string) {
|
||||
import(temporaryFileUnique: string, parentUnique: string | null) {
|
||||
if (!temporaryFileUnique) throw new Error('temporaryFileUnique is required');
|
||||
if (parentUnique === undefined) throw new Error('parentUnique is required');
|
||||
|
||||
const requestBody: ImportDictionaryRequestModel = {
|
||||
temporaryFile: { id: temporaryFileUnique },
|
||||
parent: parentUnique ? { id: parentUnique } : null,
|
||||
};
|
||||
|
||||
return tryExecuteAndNotify(
|
||||
this.#host,
|
||||
DictionaryResource.postDictionaryImport({ requestBody: { temporaryFileId, parentId: parentUnique } }),
|
||||
DictionaryResource.postDictionaryImport({
|
||||
requestBody,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user