update to fit new schema
This commit is contained in:
committed by
Jacob Overgaard
parent
3873cb6c68
commit
10aa17d6fa
@@ -1,5 +1,5 @@
|
||||
import { html, nothing, customElement, state, ifDefined } from '@umbraco-cms/backoffice/external/lit';
|
||||
import { UmbTextStyles } from "@umbraco-cms/backoffice/style";
|
||||
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
|
||||
import { UmbAllowedDocumentTypesModalData, UmbAllowedDocumentTypesModalResult } from '@umbraco-cms/backoffice/modal';
|
||||
import { UmbModalBaseElement } from '@umbraco-cms/internal/modal';
|
||||
import { DocumentTypeTreeItemResponseModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
@@ -48,7 +48,7 @@ export class UmbAllowedDocumentTypesModalElement extends UmbModalBaseElement<
|
||||
}
|
||||
|
||||
private async _retrieveAllowedChildrenOfRoot() {
|
||||
const { data } = await this.#documentRepository.requestAllowedDocumentTypesAtRoot();
|
||||
const { data } = await this.#documentRepository.requestAllowedDocumentTypesOf(null);
|
||||
|
||||
if (data) {
|
||||
// TODO: implement pagination, or get 1000?
|
||||
@@ -74,12 +74,11 @@ export class UmbAllowedDocumentTypesModalElement extends UmbModalBaseElement<
|
||||
<uui-box>
|
||||
${this._allowedDocumentTypes.length === 0 ? html`<p>No allowed types</p>` : nothing}
|
||||
${this._allowedDocumentTypes.map(
|
||||
(item) =>
|
||||
html`
|
||||
<uui-menu-item data-id=${ifDefined(item.id)} @click=${this.#onClick} label="${ifDefined(item.name)}">
|
||||
${item.icon ? html`<uui-icon slot="icon" name=${item.icon}></uui-icon>` : nothing}
|
||||
</uui-menu-item>
|
||||
`
|
||||
(item) => html`
|
||||
<uui-menu-item data-id=${ifDefined(item.id)} @click=${this.#onClick} label="${ifDefined(item.name)}">
|
||||
${item.icon ? html`<uui-icon slot="icon" name=${item.icon}></uui-icon>` : nothing}
|
||||
</uui-menu-item>
|
||||
`,
|
||||
)}
|
||||
</uui-box>
|
||||
<uui-button slot="actions" id="cancel" label="Cancel" @click="${this._handleCancel}">Cancel</uui-button>
|
||||
|
||||
@@ -97,12 +97,8 @@ export class UmbDocumentRepository
|
||||
}
|
||||
|
||||
// Structure permissions;
|
||||
|
||||
async requestAllowedDocumentTypesAtRoot() {
|
||||
return this.#detailDataSource.getAllowedDocumentTypesAtRoot();
|
||||
}
|
||||
async requestAllowedDocumentTypesOf(id: string) {
|
||||
if (!id) throw new Error('Id is missing');
|
||||
async requestAllowedDocumentTypesOf(id: string | null) {
|
||||
if (id === undefined) throw new Error('Id is missing');
|
||||
await this.#init;
|
||||
return this.#detailDataSource.getAllowedDocumentTypesOf(id);
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ export class UmbDocumentServerDataSource
|
||||
this.#host,
|
||||
DocumentResource.getDocumentById({
|
||||
id,
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ export class UmbDocumentServerDataSource
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
}) as any
|
||||
}) as any,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ export class UmbDocumentServerDataSource
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
}).then((res) => res.json())
|
||||
}).then((res) => res.json()),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -175,22 +175,9 @@ export class UmbDocumentServerDataSource
|
||||
* @return {*}
|
||||
* @memberof UmbDocumentTypeServerDataSource
|
||||
*/
|
||||
async getAllowedDocumentTypesOf(id: string) {
|
||||
if (!id) throw new Error('Id is missing');
|
||||
|
||||
async getAllowedDocumentTypesOf(id: string | null) {
|
||||
if (id === undefined) throw new Error('Id is missing');
|
||||
// TODO: Notice, here we need to implement pagination.
|
||||
return tryExecuteAndNotify(this.#host, DocumentResource.getDocumentByIdAllowedDocumentTypes({ id }));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the allowed document types for root
|
||||
* @param {string} id
|
||||
* @return {*}
|
||||
* @memberof UmbDocumentTypeServerDataSource
|
||||
*/
|
||||
async getAllowedDocumentTypesAtRoot() {
|
||||
console.log('source requestAllowedDocumentTypesAtRoot');
|
||||
// TODO: Notice, here we need to implement pagination.
|
||||
return tryExecuteAndNotify(this.#host, DocumentResource.getDocumentRootAllowedDocumentTypes({}));
|
||||
return tryExecuteAndNotify(this.#host, DocumentResource.getDocumentAllowedDocumentTypes({ parentId: id }));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user