This commit is contained in:
Mads Rasmussen
2024-02-03 21:22:05 +01:00
parent 846cf4539a
commit 2991b66031
7 changed files with 25 additions and 23 deletions

View File

@@ -54,6 +54,7 @@ const createMockMapper = (request: CreateDictionaryItemRequestModel): UmbMockDic
parent: request.parent,
translations: request.translations,
hasChildren: false,
translatedIsoCodes: [],
};
};

View File

@@ -14,14 +14,15 @@ const importResponse: UmbMockDictionaryModel = {
name: 'Uploaded dictionary',
id: 'b7e7d0ab-53ba-485d-dddd-12537f9925cb',
hasChildren: false,
translatedIsoCodes: ['en', 'da'],
translations: [
{
isoCode: 'en',
translation: 'I am an imported US value',
},
{
isoCode: 'fr',
translation: 'I am an imported French value',
isoCode: 'da',
translation: 'I am an imported Danish value',
},
],
};
@@ -49,14 +50,12 @@ export const importExportHandlers = [
statusCode: 200,
};
*/
debugger;
return res(ctx.status(200), ctx.json(contentResult));
}),
// TODO => handle properly, querystring breaks handler
rest.get(umbracoPath(`${UMB_SLUG}/:id/export`), (req, res, ctx) => {
debugger;
const id = req.params.id as string;
if (!id) return;

View File

@@ -81,6 +81,9 @@ export class UmbVariantSelectorElement extends UmbLitElement {
workspaceContext.variants,
(variants) => {
if (variants) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
// TODO: figure out what we do with the different variant models. Document has a state, but the variant model does not.
this._variants = variants;
}
},

View File

@@ -4,14 +4,11 @@ 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 { UmbDictionaryTreeStore } from 'src/packages/dictionary/index.js';
import { UMB_DICTIONARY_TREE_STORE_CONTEXT } from 'src/packages/dictionary/index.js';
export default class UmbImportDictionaryEntityAction extends UmbEntityActionBase<UmbDictionaryImportRepository> {
static styles = [UmbTextStyles];
#modalContext?: UmbModalManagerContext;
#treeStore?: UmbDictionaryTreeStore;
constructor(host: UmbControllerHostElement, repositoryAlias: string, unique: string, entityType: string) {
super(host, repositoryAlias, unique, entityType);
@@ -19,22 +16,14 @@ export default class UmbImportDictionaryEntityAction extends UmbEntityActionBase
this.consumeContext(UMB_MODAL_MANAGER_CONTEXT, (instance) => {
this.#modalContext = instance;
});
this.consumeContext(UMB_DICTIONARY_TREE_STORE_CONTEXT, (instance) => {
this.#treeStore = instance;
});
}
async execute() {
if (!this.#modalContext) return;
const modalContext = this.#modalContext?.open(UMB_IMPORT_DICTIONARY_MODAL, { data: { unique: this.unique } });
const { entityItems, parentId } = await modalContext.onSubmit();
if (!entityItems?.length) return;
this.#treeStore?.appendItems(entityItems);
if (parentId) this.#treeStore?.updateItem(parentId, { hasChildren: true });
}
}

View File

@@ -80,7 +80,14 @@ export class UmbDocumentServerDataSource implements UmbDetailDataSource<UmbDocum
entityType: UMB_DOCUMENT_ENTITY_TYPE,
unique: data.id,
parentUnique: null, // TODO: this is not correct. It will be solved when we know where to get the parent from
values: data.values,
values: data.values.map((value) => {
return {
alias: value.alias,
culture: value.culture || null,
segment: value.segment || null,
value: value.value,
};
}),
variants: data.variants.map((variant) => {
return {
state: variant.state,
@@ -92,7 +99,12 @@ export class UmbDocumentServerDataSource implements UmbDetailDataSource<UmbDocum
updateDate: variant.updateDate,
};
}),
urls: data.urls,
urls: data.urls.map((url) => {
return {
culture: url.culture || null,
url: url.url,
};
}),
template: data.template ? { unique: data.template.id } : null,
documentType: { unique: data.documentType.id },
isTrashed: data.isTrashed,

View File

@@ -86,13 +86,11 @@ export default class UmbTemplateQueryBuilderModalElement extends UmbModalBaseEle
}
async #getTemplateQuerySettings() {
debugger;
const { data, error } = await this.#templateQueryRepository.getTemplateQuerySettings();
if (data) this._queryBuilderSettings = data;
}
#executeTemplateQuery = async () => {
debugger;
const { data, error } = await this.#templateQueryRepository.executeTemplateQuery();
if (data) {
this._templateQuery = { ...data };
@@ -206,11 +204,11 @@ export default class UmbTemplateQueryBuilderModalElement extends UmbModalBaseEle
<umb-localize key="template_iWant">I want</umb-localize>
<umb-dropdown look="outline" id="content-type-dropdown" label="Choose content type">
<span slot="label">
${this._queryRequest?.contentTypeAlias ?? this.localize.term('template_allContent')}
${this._queryRequest?.documentTypeAlias ?? this.localize.term('template_allContent')}
</span>
<uui-combobox-list @change=${this.#setContentType} class="options-list">
<uui-combobox-list-option value="">all content</uui-combobox-list-option>
${this._queryBuilderSettings?.contentTypeAliases?.map(
${this._queryBuilderSettings?.documentTypeAliases?.map(
(alias) =>
html`<uui-combobox-list-option .value=${alias}>
<umb-localize key="template_contentOfType" .args=${[alias]}>

View File

@@ -47,8 +47,8 @@ export class UmbTemplateQueryServerDataSource {
*/
async executeTemplateQuery(args: any) {
const requestBody: TemplateQueryExecuteModel = {
rootContentId: args.rootContentUnique,
contentTypeAlias: args.contentTypeAlias,
rootDocument: { id: args.rootContentUnique },
documentTypeAlias: args.contentTypeAlias,
filters: args.filters,
sort: args.sort,
take: args.take,