remove outdated half implementation of tree + workspace
This commit is contained in:
@@ -1,35 +0,0 @@
|
||||
import type { DocumentBlueprintDetails } from '../../packages/documents/document-blueprints/types.js';
|
||||
import { UmbEntityData } from './entity.data.js';
|
||||
|
||||
export const data: Array<DocumentBlueprintDetails> = [
|
||||
{
|
||||
name: 'Document Blueprint 1',
|
||||
type: 'document-blueprint',
|
||||
id: '3fa85f64-5717-4562-b3fc-2c963f66afa6',
|
||||
icon: 'icon-blueprint',
|
||||
documentTypeKey: 'd81c7957-153c-4b5a-aa6f-b434a4964624',
|
||||
properties: [],
|
||||
data: [],
|
||||
},
|
||||
{
|
||||
name: 'Document Blueprint 2',
|
||||
type: 'document-blueprint',
|
||||
id: '3fa85f64-5717-4562-b3qc-2c963f66afa6',
|
||||
icon: 'icon-blueprint',
|
||||
documentTypeKey: 'a99e4018-3ffc-486b-aa76-eecea9593d17',
|
||||
properties: [],
|
||||
data: [],
|
||||
},
|
||||
];
|
||||
|
||||
// Temp mocked database
|
||||
// TODO: all properties are optional in the server schema. I don't think this is correct.
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
class UmbDocumentBlueprintData extends UmbEntityData<DocumentBlueprintDetails> {
|
||||
constructor() {
|
||||
super(data);
|
||||
}
|
||||
}
|
||||
|
||||
export const umbDocumentBlueprintData = new UmbDocumentBlueprintData();
|
||||
@@ -1,101 +0,0 @@
|
||||
import type { DocumentBlueprintDetails } from './types.js';
|
||||
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
|
||||
import { UmbArrayState } from '@umbraco-cms/backoffice/observable-api';
|
||||
import { UmbStoreBase } from '@umbraco-cms/backoffice/store';
|
||||
import type { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api';
|
||||
|
||||
/**
|
||||
* @export
|
||||
* @class UmbDocumentBlueprintStore
|
||||
* @extends {UmbStoreBase}
|
||||
* @description - Data Store for Document Blueprints
|
||||
*/
|
||||
export class UmbDocumentBlueprintStore extends UmbStoreBase {
|
||||
constructor(host: UmbControllerHostElement) {
|
||||
super(
|
||||
host,
|
||||
UMB_DOCUMENT_BLUEPRINT_STORE_CONTEXT.toString(),
|
||||
// TODO: use the right type:
|
||||
|
||||
new UmbArrayState<DocumentBlueprintDetails>([], (x) => x.id),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description - Request a Data Type by id. The Data Type is added to the store and is returned as an Observable.
|
||||
* @param {string} id
|
||||
* @return {*} {(Observable<DocumentBlueprintDetails | undefined>)}
|
||||
* @memberof UmbDocumentBlueprintStore
|
||||
*/
|
||||
getById(id: string) {
|
||||
// TODO: use backend cli when available.
|
||||
fetch(`/umbraco/management/api/v1/document-blueprint/details/${id}`)
|
||||
.then((res) => res.json())
|
||||
.then((data) => {
|
||||
this._data.append(data);
|
||||
});
|
||||
|
||||
return this._data.asObservablePart((documents) => documents.find((document) => document.id === id));
|
||||
}
|
||||
|
||||
getScaffold(entityType: string, parentId: string | null) {
|
||||
return {} as DocumentBlueprintDetails;
|
||||
}
|
||||
|
||||
// TODO: make sure UI somehow can follow the status of this action.
|
||||
/**
|
||||
* @description - Save a DocumentBlueprint.
|
||||
* @param {Array<DocumentBlueprintDetails>} Dictionaries
|
||||
* @memberof UmbDocumentBlueprintStore
|
||||
* @return {*} {Promise<void>}
|
||||
*/
|
||||
save(data: DocumentBlueprintDetails[]) {
|
||||
// fetch from server and update store
|
||||
// TODO: use Fetcher API.
|
||||
let body: string;
|
||||
|
||||
try {
|
||||
body = JSON.stringify(data);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return Promise.reject();
|
||||
}
|
||||
|
||||
// TODO: use backend cli when available.
|
||||
return fetch('/umbraco/management/api/v1/document-blueprint/save', {
|
||||
method: 'POST',
|
||||
body: body,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then((data: Array<DocumentBlueprintDetails>) => {
|
||||
this._data.append(data);
|
||||
});
|
||||
}
|
||||
|
||||
// TODO: How can we avoid having this in both stores?
|
||||
/**
|
||||
* @description - Delete a Data Type.
|
||||
* @param {string[]} ids
|
||||
* @memberof UmbDocumentBlueprintStore
|
||||
* @return {*} {Promise<void>}
|
||||
*/
|
||||
async delete(ids: string[]) {
|
||||
// TODO: use backend cli when available.
|
||||
await fetch('/umbraco/backoffice/document-blueprint/delete', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(ids),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
});
|
||||
|
||||
this._data.remove(ids);
|
||||
}
|
||||
}
|
||||
|
||||
export const UMB_DOCUMENT_BLUEPRINT_STORE_CONTEXT = new UmbContextToken<UmbDocumentBlueprintStore>(
|
||||
'UmbDocumentBlueprintStore',
|
||||
);
|
||||
@@ -1,19 +0,0 @@
|
||||
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
|
||||
import { UmbEntityTreeStore } from '@umbraco-cms/backoffice/tree';
|
||||
import type { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api';
|
||||
|
||||
export const UMB_DOCUMENT_BLUEPRINT_TREE_STORE_CONTEXT = new UmbContextToken<UmbDocumentBlueprintTreeStore>(
|
||||
'UmbDocumentBlueprintTreeStore',
|
||||
);
|
||||
|
||||
/**
|
||||
* @export
|
||||
* @class UmbDocumentBlueprintTreeStore
|
||||
* @extends {UmbStoreBase}
|
||||
* @description - Tree Data Store for Document Blueprints
|
||||
*/
|
||||
export class UmbDocumentBlueprintTreeStore extends UmbEntityTreeStore {
|
||||
constructor(host: UmbControllerHostElement) {
|
||||
super(host, UMB_DOCUMENT_BLUEPRINT_TREE_STORE_CONTEXT.toString());
|
||||
}
|
||||
}
|
||||
@@ -1,24 +1,4 @@
|
||||
import { UmbDocumentBlueprintStore } from './document-blueprint.detail.store.js';
|
||||
import { UmbDocumentBlueprintTreeStore } from './document-blueprint.tree.store.js';
|
||||
import { manifests as menuItemManifests } from './menu-item/manifests.js';
|
||||
import { manifests as workspaceManifests } from './workspace/manifests.js';
|
||||
import type { ManifestStore, ManifestTreeStore } from '@umbraco-cms/backoffice/extension-registry';
|
||||
|
||||
export const UMB_DOCUMENT_BLUEPRINT_STORE_ALIAS = 'Umb.Store.DocumentBlueprint';
|
||||
export const UMB_DOCUMENT_BLUEPRINT_TREE_STORE_ALIAS = 'Umb.Store.DocumentBlueprintTree';
|
||||
|
||||
const store: ManifestStore = {
|
||||
type: 'store',
|
||||
alias: UMB_DOCUMENT_BLUEPRINT_STORE_ALIAS,
|
||||
name: 'Document Blueprint Store',
|
||||
api: UmbDocumentBlueprintStore,
|
||||
};
|
||||
|
||||
const treeStore: ManifestTreeStore = {
|
||||
type: 'treeStore',
|
||||
alias: UMB_DOCUMENT_BLUEPRINT_TREE_STORE_ALIAS,
|
||||
name: 'Document Blueprint Tree Store',
|
||||
api: UmbDocumentBlueprintTreeStore,
|
||||
};
|
||||
|
||||
export const manifests = [store, treeStore, ...menuItemManifests, ...workspaceManifests];
|
||||
export const manifests = [...menuItemManifests, ...workspaceManifests];
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
// Document Blueprint
|
||||
|
||||
export interface DocumentBlueprintDetails {
|
||||
id: string;
|
||||
name: string;
|
||||
type: 'document-blueprint';
|
||||
properties: Array<any>;
|
||||
data: Array<any>;
|
||||
icon: string;
|
||||
documentTypeKey: string;
|
||||
}
|
||||
Reference in New Issue
Block a user