extend base for data type item server source
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { UmbDataTypeItemServerDataSource } from './data-type-item.server.data.js';
|
||||
import { UmbDataTypeItemServerDataSource } from './data-type-item.server.data-source.js';
|
||||
import { UMB_DATA_TYPE_ITEM_STORE_CONTEXT } from './data-type-item.store.js';
|
||||
import type { UmbDataTypeItemModel } from './types.js';
|
||||
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
import type { UmbDataTypeItemModel } from './types.js';
|
||||
import { UmbItemServerDataSourceBase } from '@umbraco-cms/backoffice/repository';
|
||||
import type { DataTypeItemResponseModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
import { DataTypeResource } from '@umbraco-cms/backoffice/backend-api';
|
||||
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
|
||||
|
||||
/**
|
||||
* A server data source for Data Type items
|
||||
* @export
|
||||
* @class UmbDataTypeItemServerDataSource
|
||||
* @implements {DocumentTreeDataSource}
|
||||
*/
|
||||
export class UmbDataTypeItemServerDataSource extends UmbItemServerDataSourceBase<
|
||||
DataTypeItemResponseModel,
|
||||
UmbDataTypeItemModel
|
||||
> {
|
||||
/**
|
||||
* Creates an instance of UmbDataTypeItemServerDataSource.
|
||||
* @param {UmbControllerHost} host
|
||||
* @memberof UmbDataTypeItemServerDataSource
|
||||
*/
|
||||
constructor(host: UmbControllerHost) {
|
||||
super(host, {
|
||||
getItems,
|
||||
mapper,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/* eslint-disable local-rules/no-direct-api-import */
|
||||
const getItems = (uniques: Array<string>) => DataTypeResource.getDataTypeItem({ id: uniques });
|
||||
|
||||
const mapper = (item: DataTypeItemResponseModel): UmbDataTypeItemModel => {
|
||||
return {
|
||||
unique: item.id,
|
||||
name: item.name,
|
||||
propertyEditorUiAlias: item.editorUiAlias || '', // TODO: why can this be undefined or null on the server?
|
||||
};
|
||||
};
|
||||
@@ -1,40 +0,0 @@
|
||||
import type { UmbItemDataSource } from '@umbraco-cms/backoffice/repository';
|
||||
import type { DataTypeItemResponseModel} from '@umbraco-cms/backoffice/backend-api';
|
||||
import { DataTypeResource } from '@umbraco-cms/backoffice/backend-api';
|
||||
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
|
||||
import { tryExecuteAndNotify } from '@umbraco-cms/backoffice/resources';
|
||||
|
||||
/**
|
||||
* A data source for Data Type items that fetches data from the server
|
||||
* @export
|
||||
* @class UmbDataTypeItemServerDataSource
|
||||
* @implements {DocumentTreeDataSource}
|
||||
*/
|
||||
export class UmbDataTypeItemServerDataSource implements UmbItemDataSource<DataTypeItemResponseModel> {
|
||||
#host: UmbControllerHost;
|
||||
|
||||
/**
|
||||
* Creates an instance of UmbDataTypeItemServerDataSource.
|
||||
* @param {UmbControllerHost} host
|
||||
* @memberof UmbDataTypeItemServerDataSource
|
||||
*/
|
||||
constructor(host: UmbControllerHost) {
|
||||
this.#host = host;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the items for the given ids from the server
|
||||
* @param {Array<string>} ids
|
||||
* @return {*}
|
||||
* @memberof UmbDataTypeItemServerDataSource
|
||||
*/
|
||||
async getItems(ids: Array<string>) {
|
||||
if (!ids) throw new Error('Ids are missing');
|
||||
return tryExecuteAndNotify(
|
||||
this.#host,
|
||||
DataTypeResource.getDataTypeItem({
|
||||
id: ids,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,6 @@ export class UmbDocumentWorkspaceElement extends UmbLitElement {
|
||||
path: 'create/:parentId/:documentTypeKey',
|
||||
component: this.#editorElement,
|
||||
setup: async (_component, info) => {
|
||||
debugger;
|
||||
// TODO: Remember the perspective of permissions here, we need to check if the user has access to create a document of this type under this parent?
|
||||
const parentId = info.match.params.parentId === 'null' ? null : info.match.params.parentId;
|
||||
const documentTypeKey = info.match.params.documentTypeKey;
|
||||
|
||||
Reference in New Issue
Block a user