@umbraco-cms/backoffice 14.0.0-a8030000 → 14.0.0-abd22b1c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-cms/packages/core/content-type/content-type-container-structure-helper.class.js +2 -2
- package/dist-cms/packages/core/content-type/content-type-property-structure-helper.class.js +1 -1
- package/dist-cms/packages/core/content-type/content-type-structure-manager.class.d.ts +15 -15
- package/dist-cms/packages/core/content-type/content-type-structure-manager.class.js +79 -103
- package/dist-cms/packages/documents/document-types/entity-actions/manifests.js +1 -1
- package/dist-cms/packages/documents/document-types/repository/document-type-item.store.d.ts +20 -0
- package/dist-cms/packages/documents/document-types/repository/document-type-item.store.js +23 -0
- package/dist-cms/packages/documents/document-types/repository/document-type.repository.d.ts +5 -21
- package/dist-cms/packages/documents/document-types/repository/document-type.repository.js +26 -20
- package/dist-cms/packages/documents/document-types/repository/manifests.d.ts +3 -2
- package/dist-cms/packages/documents/document-types/repository/manifests.js +9 -1
- package/dist-cms/packages/documents/document-types/repository/sources/document-type-item.server.data.d.ts +25 -0
- package/dist-cms/packages/documents/document-types/repository/sources/document-type-item.server.data.js +32 -0
- package/dist-cms/packages/documents/document-types/repository/sources/document-type.server.data.js +1 -12
- package/dist-cms/packages/documents/document-types/workspace/document-type-workspace.context.js +27 -27
- package/dist-cms/packages/documents/document-types/workspace/views/design/document-type-workspace-view-edit.element.js +8 -4
- package/dist-cms/packages/settings/dashboards/performance-profiling/dashboard-performance-profiling.element.d.ts +3 -1
- package/dist-cms/packages/settings/dashboards/performance-profiling/dashboard-performance-profiling.element.js +26 -40
- package/dist-cms/tsconfig.build.tsbuildinfo +1 -1
- package/dist-cms/vscode-html-custom-data.json +1 -1
- package/package.json +1 -1
package/dist-cms/packages/core/content-type/content-type-container-structure-helper.class.js
CHANGED
|
@@ -14,7 +14,7 @@ export class UmbContentTypeContainerStructureHelper {
|
|
|
14
14
|
// Containers defined in data might be more than actual containers to display as we merge them by name.
|
|
15
15
|
// Direct containers are the containers defining the total of this container(Multiple containers with the same name and type)
|
|
16
16
|
this._ownerAlikeContainers = [];
|
|
17
|
-
// Owner containers are containers owned by the owner
|
|
17
|
+
// Owner containers are containers owned by the owner Content Type (The specific one up for editing)
|
|
18
18
|
this._ownerContainers = [];
|
|
19
19
|
// State containing the merged containers (only one pr. name):
|
|
20
20
|
this.#containers = new UmbArrayState([], (x) => x.id);
|
|
@@ -172,7 +172,7 @@ export class UmbContentTypeContainerStructureHelper {
|
|
|
172
172
|
await this.#init;
|
|
173
173
|
if (!this.#structure)
|
|
174
174
|
return;
|
|
175
|
-
const newName = this.#structure.
|
|
175
|
+
const newName = this.#structure.makeContainerNameUniqueForOwnerContentType(name, this._childType, containerParentId) ?? name;
|
|
176
176
|
return await this.partialUpdateContainer(containerId, { name: newName });
|
|
177
177
|
}
|
|
178
178
|
}
|
|
@@ -16,7 +16,7 @@ export class UmbContentTypePropertyStructureHelper {
|
|
|
16
16
|
this.#propertyStructure.sortBy((a, b) => (a.sortOrder ?? 0) - (b.sortOrder ?? 0));
|
|
17
17
|
}
|
|
18
18
|
get ownerDocumentTypes() {
|
|
19
|
-
return this.#structure?.
|
|
19
|
+
return this.#structure?.contentTypes;
|
|
20
20
|
}
|
|
21
21
|
setStructureManager(structure) {
|
|
22
22
|
this.#structure = structure;
|
|
@@ -6,8 +6,8 @@ export type PropertyContainerTypes = 'Group' | 'Tab';
|
|
|
6
6
|
type T = DocumentTypeResponseModel;
|
|
7
7
|
export declare class UmbContentTypePropertyStructureManager<R extends UmbDetailRepository<T> = UmbDetailRepository<T>> {
|
|
8
8
|
#private;
|
|
9
|
-
readonly
|
|
10
|
-
private readonly
|
|
9
|
+
readonly contentTypes: import("rxjs").Observable<DocumentTypeResponseModel[]>;
|
|
10
|
+
private readonly _contentTypeContainers;
|
|
11
11
|
constructor(host: UmbControllerHostElement, typeRepository: R);
|
|
12
12
|
/**
|
|
13
13
|
* loadType will load the node type and all inherited and composed types.
|
|
@@ -27,26 +27,26 @@ export declare class UmbContentTypePropertyStructureManager<R extends UmbDetailR
|
|
|
27
27
|
create(): Promise<boolean>;
|
|
28
28
|
private _ensureType;
|
|
29
29
|
private _loadType;
|
|
30
|
-
|
|
31
|
-
private
|
|
30
|
+
_observeContentType(data: T): Promise<void>;
|
|
31
|
+
private _loadContentTypeCompositions;
|
|
32
32
|
/** Public methods for consuming structure: */
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
ownerContentType(): import("rxjs").Observable<DocumentTypeResponseModel | undefined>;
|
|
34
|
+
getOwnerContentType(): DocumentTypeResponseModel | undefined;
|
|
35
|
+
updateOwnerContentType(entry: T): void;
|
|
36
36
|
createContainer(contentTypeId: string | null, parentId?: string | null, type?: PropertyContainerTypes, sortOrder?: number): Promise<PropertyTypeContainerModelBaseModel>;
|
|
37
|
-
|
|
38
|
-
updateContainer(
|
|
39
|
-
removeContainer(
|
|
37
|
+
makeContainerNameUniqueForOwnerContentType(newName: string, containerType?: PropertyContainerTypes, parentId?: string | null): string | null;
|
|
38
|
+
updateContainer(contentTypeId: string | null, containerId: string, partialUpdate: Partial<PropertyTypeContainerModelBaseModel>): Promise<void>;
|
|
39
|
+
removeContainer(contentTypeId: string | null, containerId?: string | null): Promise<void>;
|
|
40
40
|
createPropertyScaffold(containerId?: string | null, sortOrder?: number): PropertyTypeModelBaseModel;
|
|
41
|
-
createProperty(
|
|
42
|
-
insertProperty(
|
|
43
|
-
removeProperty(
|
|
44
|
-
updateProperty(
|
|
41
|
+
createProperty(contentTypeId: string | null, containerId?: string | null, sortOrder?: number): Promise<PropertyTypeModelBaseModel>;
|
|
42
|
+
insertProperty(contentTypeId: string | null, property: PropertyTypeModelBaseModel): Promise<void>;
|
|
43
|
+
removeProperty(contentTypeId: string | null, propertyId: string): Promise<void>;
|
|
44
|
+
updateProperty(contentTypeId: string | null, propertyId: string, partialUpdate: Partial<PropertyTypeModelBaseModel>): Promise<void>;
|
|
45
45
|
propertyStructureById(propertyId: string): Promise<import("rxjs").Observable<PropertyTypeModelBaseModel | undefined>>;
|
|
46
46
|
propertyStructureByAlias(propertyAlias: string): Promise<import("rxjs").Observable<PropertyTypeModelBaseModel | undefined>>;
|
|
47
47
|
getPropertyStructureById(propertyId: string): Promise<PropertyTypeModelBaseModel | undefined>;
|
|
48
48
|
getPropertyStructureByAlias(propertyAlias: string): Promise<PropertyTypeModelBaseModel | undefined>;
|
|
49
|
-
|
|
49
|
+
ownerContentTypeObservablePart<PartResult>(mappingFunction: MappingFunction<T, PartResult>): import("rxjs").Observable<PartResult | undefined>;
|
|
50
50
|
hasPropertyStructuresOf(containerId: string | null): import("rxjs").Observable<boolean>;
|
|
51
51
|
rootPropertyStructures(): import("rxjs").Observable<PropertyTypeModelBaseModel[]>;
|
|
52
52
|
propertyStructuresOf(containerId: string | null): import("rxjs").Observable<PropertyTypeModelBaseModel[]>;
|
|
@@ -6,25 +6,25 @@ export class UmbContentTypePropertyStructureManager {
|
|
|
6
6
|
#host;
|
|
7
7
|
#init;
|
|
8
8
|
#contentTypeRepository;
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
9
|
+
#ownerContentTypeId;
|
|
10
|
+
#contentTypeObservers;
|
|
11
|
+
#contentTypes;
|
|
12
12
|
#containers;
|
|
13
13
|
constructor(host, typeRepository) {
|
|
14
|
-
this.#
|
|
15
|
-
this.#
|
|
16
|
-
this.
|
|
17
|
-
this.
|
|
14
|
+
this.#contentTypeObservers = new Array();
|
|
15
|
+
this.#contentTypes = new UmbArrayState([], (x) => x.id);
|
|
16
|
+
this.contentTypes = this.#contentTypes.asObservable();
|
|
17
|
+
this._contentTypeContainers = this.#contentTypes.asObservablePart((x) => x.flatMap((x) => x.containers ?? []));
|
|
18
18
|
this.#containers = new UmbArrayState([], (x) => x.id);
|
|
19
19
|
this.#host = host;
|
|
20
20
|
this.#contentTypeRepository = typeRepository;
|
|
21
|
-
new UmbObserverController(host, this.
|
|
22
|
-
|
|
23
|
-
this.
|
|
21
|
+
new UmbObserverController(host, this.contentTypes, (contentTypes) => {
|
|
22
|
+
contentTypes.forEach((contentType) => {
|
|
23
|
+
this._loadContentTypeCompositions(contentType);
|
|
24
24
|
});
|
|
25
25
|
});
|
|
26
|
-
new UmbObserverController(host, this.
|
|
27
|
-
this.#containers.next(
|
|
26
|
+
new UmbObserverController(host, this._contentTypeContainers, (contentTypeContainers) => {
|
|
27
|
+
this.#containers.next(contentTypeContainers);
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
@@ -33,7 +33,7 @@ export class UmbContentTypePropertyStructureManager {
|
|
|
33
33
|
*/
|
|
34
34
|
async loadType(id) {
|
|
35
35
|
this._reset();
|
|
36
|
-
this.#
|
|
36
|
+
this.#ownerContentTypeId = id;
|
|
37
37
|
const promiseResult = this._loadType(id);
|
|
38
38
|
this.#init = promiseResult;
|
|
39
39
|
await this.#init;
|
|
@@ -46,24 +46,23 @@ export class UmbContentTypePropertyStructureManager {
|
|
|
46
46
|
const { data } = await this.#contentTypeRepository.createScaffold(parentId);
|
|
47
47
|
if (!data)
|
|
48
48
|
return {};
|
|
49
|
-
this.#
|
|
50
|
-
this.#init = this.
|
|
49
|
+
this.#ownerContentTypeId = data.id;
|
|
50
|
+
this.#init = this._observeContentType(data);
|
|
51
51
|
await this.#init;
|
|
52
52
|
return { data };
|
|
53
53
|
}
|
|
54
54
|
async save() {
|
|
55
|
-
const
|
|
56
|
-
if (!
|
|
55
|
+
const contentType = this.getOwnerContentType();
|
|
56
|
+
if (!contentType || !contentType.id)
|
|
57
57
|
return false;
|
|
58
|
-
await this.#contentTypeRepository.save(
|
|
58
|
+
await this.#contentTypeRepository.save(contentType.id, contentType);
|
|
59
59
|
return true;
|
|
60
60
|
}
|
|
61
61
|
async create() {
|
|
62
|
-
const
|
|
63
|
-
if (!
|
|
62
|
+
const contentType = this.getOwnerContentType();
|
|
63
|
+
if (!contentType || !contentType.id)
|
|
64
64
|
return false;
|
|
65
|
-
|
|
66
|
-
const { data } = await this.#contentTypeRepository.create(documentType);
|
|
65
|
+
const { data } = await this.#contentTypeRepository.create(contentType);
|
|
67
66
|
if (!data)
|
|
68
67
|
return false;
|
|
69
68
|
await this.loadType(data.id);
|
|
@@ -72,7 +71,7 @@ export class UmbContentTypePropertyStructureManager {
|
|
|
72
71
|
async _ensureType(id) {
|
|
73
72
|
if (!id)
|
|
74
73
|
return;
|
|
75
|
-
if (this.#
|
|
74
|
+
if (this.#contentTypes.getValue().find((x) => x.id === id))
|
|
76
75
|
return;
|
|
77
76
|
await this._loadType(id);
|
|
78
77
|
}
|
|
@@ -82,50 +81,43 @@ export class UmbContentTypePropertyStructureManager {
|
|
|
82
81
|
const { data } = await this.#contentTypeRepository.requestById(id);
|
|
83
82
|
if (!data)
|
|
84
83
|
return {};
|
|
85
|
-
await this.
|
|
84
|
+
await this._observeContentType(data);
|
|
86
85
|
return { data };
|
|
87
86
|
}
|
|
88
|
-
async
|
|
87
|
+
async _observeContentType(data) {
|
|
89
88
|
if (!data.id)
|
|
90
89
|
return;
|
|
91
90
|
// Load inherited and composed types:
|
|
92
|
-
this.
|
|
93
|
-
this.#
|
|
91
|
+
this._loadContentTypeCompositions(data);
|
|
92
|
+
this.#contentTypeObservers.push(new UmbObserverController(this.#host, await this.#contentTypeRepository.byId(data.id), (docType) => {
|
|
94
93
|
if (docType) {
|
|
95
94
|
// TODO: Handle if there was changes made to the owner document type in this context.
|
|
96
95
|
/*
|
|
97
96
|
possible easy solutions could be to notify user wether they want to update(Discard the changes to accept the new ones).
|
|
98
97
|
*/
|
|
99
|
-
this.#
|
|
98
|
+
this.#contentTypes.appendOne(docType);
|
|
100
99
|
}
|
|
101
100
|
}));
|
|
102
101
|
}
|
|
103
|
-
async
|
|
104
|
-
|
|
102
|
+
async _loadContentTypeCompositions(contentType) {
|
|
103
|
+
contentType.compositions?.forEach((composition) => {
|
|
105
104
|
this._ensureType(composition.id);
|
|
106
105
|
});
|
|
107
106
|
}
|
|
108
|
-
/*
|
|
109
|
-
private async _initDocumentTypeContainers(documentType: T) {
|
|
110
|
-
documentType.containers?.forEach((container) => {
|
|
111
|
-
this.#containers.appendOne({ ...container, _ownerDocumentTypeKey: documentType.id });
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
*/
|
|
115
107
|
/** Public methods for consuming structure: */
|
|
116
|
-
|
|
117
|
-
return this.#
|
|
108
|
+
ownerContentType() {
|
|
109
|
+
return this.#contentTypes.asObservablePart((x) => x.find((y) => y.id === this.#ownerContentTypeId));
|
|
118
110
|
}
|
|
119
|
-
|
|
120
|
-
return this.#
|
|
111
|
+
getOwnerContentType() {
|
|
112
|
+
return this.#contentTypes.getValue().find((y) => y.id === this.#ownerContentTypeId);
|
|
121
113
|
}
|
|
122
|
-
|
|
123
|
-
this.#
|
|
114
|
+
updateOwnerContentType(entry) {
|
|
115
|
+
this.#contentTypes.updateOne(this.#ownerContentTypeId, entry);
|
|
124
116
|
}
|
|
125
117
|
// We could move the actions to another class?
|
|
126
118
|
async createContainer(contentTypeId, parentId = null, type = 'Group', sortOrder) {
|
|
127
119
|
await this.#init;
|
|
128
|
-
contentTypeId = contentTypeId ?? this.#
|
|
120
|
+
contentTypeId = contentTypeId ?? this.#ownerContentTypeId;
|
|
129
121
|
const container = {
|
|
130
122
|
id: UmbId.new(),
|
|
131
123
|
parentId: parentId ?? null,
|
|
@@ -133,12 +125,12 @@ export class UmbContentTypePropertyStructureManager {
|
|
|
133
125
|
type: type,
|
|
134
126
|
sortOrder: sortOrder ?? 0,
|
|
135
127
|
};
|
|
136
|
-
const containers = [...(this.#
|
|
128
|
+
const containers = [...(this.#contentTypes.getValue().find((x) => x.id === contentTypeId)?.containers ?? [])];
|
|
137
129
|
containers.push(container);
|
|
138
|
-
this.#
|
|
130
|
+
this.#contentTypes.updateOne(contentTypeId, { containers });
|
|
139
131
|
return container;
|
|
140
132
|
}
|
|
141
|
-
|
|
133
|
+
makeContainerNameUniqueForOwnerContentType(newName, containerType = 'Tab', parentId = null) {
|
|
142
134
|
const ownerRootContainers = this.getOwnerContainers(containerType); //getRootContainers() can't differentiates between compositions and locals
|
|
143
135
|
let changedName = newName;
|
|
144
136
|
if (ownerRootContainers) {
|
|
@@ -149,19 +141,19 @@ export class UmbContentTypePropertyStructureManager {
|
|
|
149
141
|
}
|
|
150
142
|
return null;
|
|
151
143
|
}
|
|
152
|
-
async updateContainer(
|
|
144
|
+
async updateContainer(contentTypeId, containerId, partialUpdate) {
|
|
153
145
|
await this.#init;
|
|
154
|
-
|
|
155
|
-
const frozenContainers = this.#
|
|
146
|
+
contentTypeId = contentTypeId ?? this.#ownerContentTypeId;
|
|
147
|
+
const frozenContainers = this.#contentTypes.getValue().find((x) => x.id === contentTypeId)?.containers ?? [];
|
|
156
148
|
const containers = partialUpdateFrozenArray(frozenContainers, partialUpdate, (x) => x.id === containerId);
|
|
157
|
-
this.#
|
|
149
|
+
this.#contentTypes.updateOne(contentTypeId, { containers });
|
|
158
150
|
}
|
|
159
|
-
async removeContainer(
|
|
151
|
+
async removeContainer(contentTypeId, containerId = null) {
|
|
160
152
|
await this.#init;
|
|
161
|
-
|
|
162
|
-
const frozenContainers = this.#
|
|
153
|
+
contentTypeId = contentTypeId ?? this.#ownerContentTypeId;
|
|
154
|
+
const frozenContainers = this.#contentTypes.getValue().find((x) => x.id === contentTypeId)?.containers ?? [];
|
|
163
155
|
const containers = frozenContainers.filter((x) => x.id !== containerId);
|
|
164
|
-
this.#
|
|
156
|
+
this.#contentTypes.updateOne(contentTypeId, { containers });
|
|
165
157
|
}
|
|
166
158
|
createPropertyScaffold(containerId = null, sortOrder) {
|
|
167
159
|
const property = {
|
|
@@ -186,40 +178,40 @@ export class UmbContentTypePropertyStructureManager {
|
|
|
186
178
|
}; // Sort order was not allowed when this was written.
|
|
187
179
|
return property;
|
|
188
180
|
}
|
|
189
|
-
async createProperty(
|
|
181
|
+
async createProperty(contentTypeId, containerId = null, sortOrder) {
|
|
190
182
|
await this.#init;
|
|
191
|
-
|
|
183
|
+
contentTypeId = contentTypeId ?? this.#ownerContentTypeId;
|
|
192
184
|
const property = this.createPropertyScaffold(containerId, sortOrder);
|
|
193
|
-
const properties = [...(this.#
|
|
185
|
+
const properties = [...(this.#contentTypes.getValue().find((x) => x.id === contentTypeId)?.properties ?? [])];
|
|
194
186
|
properties.push(property);
|
|
195
|
-
this.#
|
|
187
|
+
this.#contentTypes.updateOne(contentTypeId, { properties });
|
|
196
188
|
return property;
|
|
197
189
|
}
|
|
198
|
-
async insertProperty(
|
|
190
|
+
async insertProperty(contentTypeId, property) {
|
|
199
191
|
await this.#init;
|
|
200
|
-
|
|
201
|
-
const frozenProperties = this.#
|
|
192
|
+
contentTypeId = contentTypeId ?? this.#ownerContentTypeId;
|
|
193
|
+
const frozenProperties = this.#contentTypes.getValue().find((x) => x.id === contentTypeId)?.properties ?? [];
|
|
202
194
|
const properties = appendToFrozenArray(frozenProperties, property, (x) => x.id === property.id);
|
|
203
|
-
this.#
|
|
195
|
+
this.#contentTypes.updateOne(contentTypeId, { properties });
|
|
204
196
|
}
|
|
205
|
-
async removeProperty(
|
|
197
|
+
async removeProperty(contentTypeId, propertyId) {
|
|
206
198
|
await this.#init;
|
|
207
|
-
|
|
208
|
-
const frozenProperties = this.#
|
|
199
|
+
contentTypeId = contentTypeId ?? this.#ownerContentTypeId;
|
|
200
|
+
const frozenProperties = this.#contentTypes.getValue().find((x) => x.id === contentTypeId)?.properties ?? [];
|
|
209
201
|
const properties = filterFrozenArray(frozenProperties, (x) => x.id !== propertyId);
|
|
210
|
-
this.#
|
|
202
|
+
this.#contentTypes.updateOne(contentTypeId, { properties });
|
|
211
203
|
}
|
|
212
|
-
async updateProperty(
|
|
204
|
+
async updateProperty(contentTypeId, propertyId, partialUpdate) {
|
|
213
205
|
await this.#init;
|
|
214
|
-
|
|
215
|
-
const frozenProperties = this.#
|
|
206
|
+
contentTypeId = contentTypeId ?? this.#ownerContentTypeId;
|
|
207
|
+
const frozenProperties = this.#contentTypes.getValue().find((x) => x.id === contentTypeId)?.properties ?? [];
|
|
216
208
|
const properties = partialUpdateFrozenArray(frozenProperties, partialUpdate, (x) => x.id === propertyId);
|
|
217
|
-
this.#
|
|
209
|
+
this.#contentTypes.updateOne(contentTypeId, { properties });
|
|
218
210
|
}
|
|
219
211
|
// TODO: Refactor: These property methods, should maybe be named without structure in their name.
|
|
220
212
|
async propertyStructureById(propertyId) {
|
|
221
213
|
await this.#init;
|
|
222
|
-
return this.#
|
|
214
|
+
return this.#contentTypes.asObservablePart((docTypes) => {
|
|
223
215
|
for (const docType of docTypes) {
|
|
224
216
|
const foundProp = docType.properties?.find((property) => property.id === propertyId);
|
|
225
217
|
if (foundProp) {
|
|
@@ -231,7 +223,7 @@ export class UmbContentTypePropertyStructureManager {
|
|
|
231
223
|
}
|
|
232
224
|
async propertyStructureByAlias(propertyAlias) {
|
|
233
225
|
await this.#init;
|
|
234
|
-
return this.#
|
|
226
|
+
return this.#contentTypes.asObservablePart((docTypes) => {
|
|
235
227
|
for (const docType of docTypes) {
|
|
236
228
|
const foundProp = docType.properties?.find((property) => property.alias === propertyAlias);
|
|
237
229
|
if (foundProp) {
|
|
@@ -243,7 +235,7 @@ export class UmbContentTypePropertyStructureManager {
|
|
|
243
235
|
}
|
|
244
236
|
async getPropertyStructureById(propertyId) {
|
|
245
237
|
await this.#init;
|
|
246
|
-
for (const docType of this.#
|
|
238
|
+
for (const docType of this.#contentTypes.getValue()) {
|
|
247
239
|
const foundProp = docType.properties?.find((property) => property.id === propertyId);
|
|
248
240
|
if (foundProp) {
|
|
249
241
|
return foundProp;
|
|
@@ -253,7 +245,7 @@ export class UmbContentTypePropertyStructureManager {
|
|
|
253
245
|
}
|
|
254
246
|
async getPropertyStructureByAlias(propertyAlias) {
|
|
255
247
|
await this.#init;
|
|
256
|
-
for (const docType of this.#
|
|
248
|
+
for (const docType of this.#contentTypes.getValue()) {
|
|
257
249
|
const foundProp = docType.properties?.find((property) => property.alias === propertyAlias);
|
|
258
250
|
if (foundProp) {
|
|
259
251
|
return foundProp;
|
|
@@ -261,30 +253,14 @@ export class UmbContentTypePropertyStructureManager {
|
|
|
261
253
|
}
|
|
262
254
|
return undefined;
|
|
263
255
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
const docType = docTypes.find((x) => x.id === this.#rootDocumentTypeKey);
|
|
268
|
-
return docType?.name ?? '';
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
*/
|
|
272
|
-
ownerDocumentTypeObservablePart(mappingFunction) {
|
|
273
|
-
return this.#documentTypes.asObservablePart((docTypes) => {
|
|
274
|
-
const docType = docTypes.find((x) => x.id === this.#ownerDocumentTypeId);
|
|
256
|
+
ownerContentTypeObservablePart(mappingFunction) {
|
|
257
|
+
return this.#contentTypes.asObservablePart((docTypes) => {
|
|
258
|
+
const docType = docTypes.find((x) => x.id === this.#ownerContentTypeId);
|
|
275
259
|
return docType ? mappingFunction(docType) : undefined;
|
|
276
260
|
});
|
|
277
261
|
}
|
|
278
|
-
/*
|
|
279
|
-
nameOfDocumentType(id: string) {
|
|
280
|
-
return this.#documentTypes.asObservablePart((docTypes) => {
|
|
281
|
-
const docType = docTypes.find((x) => x.id === id);
|
|
282
|
-
return docType?.name ?? '';
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
*/
|
|
286
262
|
hasPropertyStructuresOf(containerId) {
|
|
287
|
-
return this.#
|
|
263
|
+
return this.#contentTypes.asObservablePart((docTypes) => {
|
|
288
264
|
return (docTypes.find((docType) => {
|
|
289
265
|
return docType.properties?.find((property) => property.containerId === containerId);
|
|
290
266
|
}) !== undefined);
|
|
@@ -294,7 +270,7 @@ export class UmbContentTypePropertyStructureManager {
|
|
|
294
270
|
return this.propertyStructuresOf(null);
|
|
295
271
|
}
|
|
296
272
|
propertyStructuresOf(containerId) {
|
|
297
|
-
return this.#
|
|
273
|
+
return this.#contentTypes.asObservablePart((docTypes) => {
|
|
298
274
|
const props = [];
|
|
299
275
|
docTypes.forEach((docType) => {
|
|
300
276
|
docType.properties?.forEach((property) => {
|
|
@@ -320,13 +296,13 @@ export class UmbContentTypePropertyStructureManager {
|
|
|
320
296
|
});
|
|
321
297
|
}
|
|
322
298
|
ownerContainersOf(containerType) {
|
|
323
|
-
return this.
|
|
299
|
+
return this.ownerContentTypeObservablePart((x) => x.containers?.filter((x) => x.type === containerType) ?? []);
|
|
324
300
|
}
|
|
325
301
|
getOwnerContainers(containerType, parentId = null) {
|
|
326
|
-
return this.
|
|
302
|
+
return this.getOwnerContentType()?.containers?.filter((x) => x.parentId === parentId && x.type === containerType);
|
|
327
303
|
}
|
|
328
304
|
isOwnerContainer(containerId) {
|
|
329
|
-
return this.
|
|
305
|
+
return this.getOwnerContentType()?.containers?.filter((x) => x.id === containerId);
|
|
330
306
|
}
|
|
331
307
|
containersOfParentKey(parentId, containerType) {
|
|
332
308
|
return this.#containers.asObservablePart((data) => {
|
|
@@ -340,14 +316,14 @@ export class UmbContentTypePropertyStructureManager {
|
|
|
340
316
|
});
|
|
341
317
|
}
|
|
342
318
|
_reset() {
|
|
343
|
-
this.#
|
|
344
|
-
this.#
|
|
345
|
-
this.#
|
|
319
|
+
this.#contentTypeObservers.forEach((observer) => observer.destroy());
|
|
320
|
+
this.#contentTypeObservers = [];
|
|
321
|
+
this.#contentTypes.next([]);
|
|
346
322
|
this.#containers.next([]);
|
|
347
323
|
}
|
|
348
324
|
destroy() {
|
|
349
325
|
this._reset();
|
|
350
|
-
this.#
|
|
326
|
+
this.#contentTypes.complete();
|
|
351
327
|
this.#containers.complete();
|
|
352
328
|
}
|
|
353
329
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { DocumentTypeItemResponseModel } from '../../../../external/backend-api/index.js';
|
|
2
|
+
import { UmbContextToken } from '../../../../libs/context-api/index.js';
|
|
3
|
+
import { UmbControllerHostElement } from '../../../../libs/controller-api/index.js';
|
|
4
|
+
import { UmbItemStore, UmbStoreBase } from '../../../core/store/index.js';
|
|
5
|
+
/**
|
|
6
|
+
* @export
|
|
7
|
+
* @class UmbDocumentTypeItemStore
|
|
8
|
+
* @extends {UmbStoreBase}
|
|
9
|
+
* @description - Data Store for Document Type items
|
|
10
|
+
*/
|
|
11
|
+
export declare class UmbDocumentTypeItemStore extends UmbStoreBase<DocumentTypeItemResponseModel> implements UmbItemStore<DocumentTypeItemResponseModel> {
|
|
12
|
+
/**
|
|
13
|
+
* Creates an instance of UmbDocumentTypeItemStore.
|
|
14
|
+
* @param {UmbControllerHostElement} host
|
|
15
|
+
* @memberof UmbDocumentTypeItemStore
|
|
16
|
+
*/
|
|
17
|
+
constructor(host: UmbControllerHostElement);
|
|
18
|
+
items(ids: Array<string>): import("rxjs").Observable<DocumentTypeItemResponseModel[]>;
|
|
19
|
+
}
|
|
20
|
+
export declare const UMB_DOCUMENT_TYPE_ITEM_STORE_CONTEXT_TOKEN: UmbContextToken<UmbDocumentTypeItemStore, UmbDocumentTypeItemStore>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { UmbContextToken } from '../../../../libs/context-api/index.js';
|
|
2
|
+
import { UmbStoreBase } from '../../../core/store/index.js';
|
|
3
|
+
import { UmbArrayState } from '../../../../libs/observable-api/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* @export
|
|
6
|
+
* @class UmbDocumentTypeItemStore
|
|
7
|
+
* @extends {UmbStoreBase}
|
|
8
|
+
* @description - Data Store for Document Type items
|
|
9
|
+
*/
|
|
10
|
+
export class UmbDocumentTypeItemStore extends UmbStoreBase {
|
|
11
|
+
/**
|
|
12
|
+
* Creates an instance of UmbDocumentTypeItemStore.
|
|
13
|
+
* @param {UmbControllerHostElement} host
|
|
14
|
+
* @memberof UmbDocumentTypeItemStore
|
|
15
|
+
*/
|
|
16
|
+
constructor(host) {
|
|
17
|
+
super(host, UMB_DOCUMENT_TYPE_ITEM_STORE_CONTEXT_TOKEN.toString(), new UmbArrayState([], (x) => x.id));
|
|
18
|
+
}
|
|
19
|
+
items(ids) {
|
|
20
|
+
return this._data.asObservablePart((items) => items.filter((item) => ids.includes(item.id ?? '')));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export const UMB_DOCUMENT_TYPE_ITEM_STORE_CONTEXT_TOKEN = new UmbContextToken('UmbDocumentTypeItemStore');
|
|
@@ -24,6 +24,11 @@ export declare class UmbDocumentTypeRepository implements UmbTreeRepository<Enti
|
|
|
24
24
|
error: import("../../../../external/backend-api/index.js").ApiError | import("../../../../external/backend-api/index.js").CancelError | undefined;
|
|
25
25
|
asObservable: () => import("rxjs").Observable<EntityTreeItemResponseModel[]>;
|
|
26
26
|
}>;
|
|
27
|
+
requestItems(ids: Array<string>): Promise<{
|
|
28
|
+
data: import("../../../../external/backend-api/index.js").DocumentTypeItemResponseModel[] | undefined;
|
|
29
|
+
error: import("../../../../external/backend-api/index.js").ApiError | import("../../../../external/backend-api/index.js").CancelError | undefined;
|
|
30
|
+
asObservable: () => import("rxjs").Observable<import("../../../../external/backend-api/index.js").DocumentTypeItemResponseModel[]>;
|
|
31
|
+
}>;
|
|
27
32
|
requestItemsLegacy(ids: Array<string>): Promise<{
|
|
28
33
|
data: any[] | undefined;
|
|
29
34
|
error: import("../../../../external/backend-api/index.js").ApiError | import("../../../../external/backend-api/index.js").CancelError | undefined;
|
|
@@ -43,28 +48,7 @@ export declare class UmbDocumentTypeRepository implements UmbTreeRepository<Enti
|
|
|
43
48
|
byId(id: string): Promise<import("rxjs").Observable<DocumentTypeResponseModel | undefined>>;
|
|
44
49
|
requestAllowedChildTypesOf(id: string): Promise<import("../../../../shared/repository/index.js").DataSourceResponse<any>>;
|
|
45
50
|
create(documentType: ItemType): Promise<{
|
|
46
|
-
data: {
|
|
47
|
-
alias?: string | undefined;
|
|
48
|
-
name?: string | undefined;
|
|
49
|
-
description?: string | null | undefined;
|
|
50
|
-
icon?: string | undefined;
|
|
51
|
-
allowedAsRoot?: boolean | undefined;
|
|
52
|
-
variesByCulture?: boolean | undefined;
|
|
53
|
-
variesBySegment?: boolean | undefined;
|
|
54
|
-
isElement?: boolean | undefined;
|
|
55
|
-
properties?: import("../../../../external/backend-api/index.js").PropertyTypeModelBaseModel[] | undefined;
|
|
56
|
-
containers?: import("../../../../external/backend-api/index.js").PropertyTypeContainerModelBaseModel[] | undefined;
|
|
57
|
-
allowedContentTypes?: import("../../../../external/backend-api/index.js").ContentTypeSortModel[] | undefined;
|
|
58
|
-
compositions?: import("../../../../external/backend-api/index.js").ContentTypeCompositionModel[] | undefined;
|
|
59
|
-
id?: string | undefined;
|
|
60
|
-
allowedTemplateIds?: string[] | undefined;
|
|
61
|
-
defaultTemplateId?: string | null | undefined;
|
|
62
|
-
cleanup?: import("../../../../external/backend-api/index.js").ContentTypeCleanupModel | undefined;
|
|
63
|
-
};
|
|
64
|
-
error?: undefined;
|
|
65
|
-
} | {
|
|
66
51
|
error: import("../../../../external/backend-api/index.js").ApiError | import("../../../../external/backend-api/index.js").CancelError | undefined;
|
|
67
|
-
data?: undefined;
|
|
68
52
|
}>;
|
|
69
53
|
save(id: string, item: UpdateDocumentTypeRequestModel): Promise<{
|
|
70
54
|
error: import("../../../../external/backend-api/index.js").ApiError | import("../../../../external/backend-api/index.js").CancelError | undefined;
|
|
@@ -2,6 +2,8 @@ import { UmbDocumentTypeTreeServerDataSource } from './sources/document-type.tre
|
|
|
2
2
|
import { UmbDocumentTypeServerDataSource } from './sources/document-type.server.data.js';
|
|
3
3
|
import { UMB_DOCUMENT_TYPE_TREE_STORE_CONTEXT_TOKEN } from './document-type.tree.store.js';
|
|
4
4
|
import { UMB_DOCUMENT_TYPE_STORE_CONTEXT_TOKEN } from './document-type.store.js';
|
|
5
|
+
import { UMB_DOCUMENT_TYPE_ITEM_STORE_CONTEXT_TOKEN } from './document-type-item.store.js';
|
|
6
|
+
import { UmbDocumentTypeItemServerDataSource } from './sources/document-type-item.server.data.js';
|
|
5
7
|
import { UmbContextConsumerController } from '../../../../libs/context-api/index.js';
|
|
6
8
|
import { UMB_NOTIFICATION_CONTEXT_TOKEN } from '../../../core/notification/index.js';
|
|
7
9
|
export class UmbDocumentTypeRepository {
|
|
@@ -11,12 +13,15 @@ export class UmbDocumentTypeRepository {
|
|
|
11
13
|
#treeStore;
|
|
12
14
|
#detailDataSource;
|
|
13
15
|
#detailStore;
|
|
16
|
+
#itemSource;
|
|
17
|
+
#itemStore;
|
|
14
18
|
#notificationContext;
|
|
15
19
|
constructor(host) {
|
|
16
20
|
this.#host = host;
|
|
17
21
|
// TODO: figure out how spin up get the correct data source
|
|
18
22
|
this.#treeSource = new UmbDocumentTypeTreeServerDataSource(this.#host);
|
|
19
23
|
this.#detailDataSource = new UmbDocumentTypeServerDataSource(this.#host);
|
|
24
|
+
this.#itemSource = new UmbDocumentTypeItemServerDataSource(this.#host);
|
|
20
25
|
this.#init = Promise.all([
|
|
21
26
|
new UmbContextConsumerController(this.#host, UMB_DOCUMENT_TYPE_TREE_STORE_CONTEXT_TOKEN, (instance) => {
|
|
22
27
|
this.#treeStore = instance;
|
|
@@ -24,12 +29,14 @@ export class UmbDocumentTypeRepository {
|
|
|
24
29
|
new UmbContextConsumerController(this.#host, UMB_DOCUMENT_TYPE_STORE_CONTEXT_TOKEN, (instance) => {
|
|
25
30
|
this.#detailStore = instance;
|
|
26
31
|
}),
|
|
32
|
+
new UmbContextConsumerController(this.#host, UMB_DOCUMENT_TYPE_ITEM_STORE_CONTEXT_TOKEN, (instance) => {
|
|
33
|
+
this.#itemStore = instance;
|
|
34
|
+
}),
|
|
27
35
|
new UmbContextConsumerController(this.#host, UMB_NOTIFICATION_CONTEXT_TOKEN, (instance) => {
|
|
28
36
|
this.#notificationContext = instance;
|
|
29
37
|
}),
|
|
30
38
|
]);
|
|
31
39
|
}
|
|
32
|
-
// TODO: Trash
|
|
33
40
|
// TODO: Move
|
|
34
41
|
async requestTreeRoot() {
|
|
35
42
|
await this.#init;
|
|
@@ -60,6 +67,16 @@ export class UmbDocumentTypeRepository {
|
|
|
60
67
|
}
|
|
61
68
|
return { data, error, asObservable: () => this.#treeStore.childrenOf(parentId) };
|
|
62
69
|
}
|
|
70
|
+
async requestItems(ids) {
|
|
71
|
+
if (!ids)
|
|
72
|
+
throw new Error('Document Type Ids are missing');
|
|
73
|
+
await this.#init;
|
|
74
|
+
const { data, error } = await this.#itemSource.getItems(ids);
|
|
75
|
+
if (data) {
|
|
76
|
+
this.#itemStore?.appendItems(data);
|
|
77
|
+
}
|
|
78
|
+
return { data, error, asObservable: () => this.#itemStore.items(ids) };
|
|
79
|
+
}
|
|
63
80
|
async requestItemsLegacy(ids) {
|
|
64
81
|
await this.#init;
|
|
65
82
|
if (!ids) {
|
|
@@ -117,25 +134,13 @@ export class UmbDocumentTypeRepository {
|
|
|
117
134
|
// Could potentially be general methods:
|
|
118
135
|
async create(documentType) {
|
|
119
136
|
if (!documentType || !documentType.id)
|
|
120
|
-
throw new Error('
|
|
137
|
+
throw new Error('Document Type is missing');
|
|
121
138
|
await this.#init;
|
|
122
|
-
const { error
|
|
123
|
-
if (!error
|
|
124
|
-
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
// Temporary hack while we are not in control of IDs:
|
|
128
|
-
const newDocument = { ...(await this.requestById(newId)).data };
|
|
129
|
-
if (newDocument) {
|
|
130
|
-
const notification = { data: { message: `Document Type created` } };
|
|
131
|
-
this.#notificationContext?.peek('positive', notification);
|
|
132
|
-
await this.requestRootTreeItems();
|
|
133
|
-
// TODO: currently we cannot put this data into our store, cause we don't have the right ID, as the server currently changes it (and other ids of it, container-id and property-id)
|
|
134
|
-
//this.#detailStore?.append(newDocument);
|
|
135
|
-
//const treeItem = createTreeItem(newDocument);
|
|
136
|
-
//this.#treeStore?.appendItems([treeItem]);
|
|
137
|
-
return { data: newDocument };
|
|
138
|
-
}
|
|
139
|
+
const { error } = await this.#detailDataSource.insert(documentType);
|
|
140
|
+
if (!error) {
|
|
141
|
+
this.#detailStore?.append(documentType);
|
|
142
|
+
const treeItem = createTreeItem(documentType);
|
|
143
|
+
this.#treeStore?.appendItems([treeItem]);
|
|
139
144
|
}
|
|
140
145
|
return { error };
|
|
141
146
|
}
|
|
@@ -170,9 +175,10 @@ export class UmbDocumentTypeRepository {
|
|
|
170
175
|
// TODO: we currently don't use the detail store for anything.
|
|
171
176
|
// Consider to look up the data before fetching from the server.
|
|
172
177
|
// Consider notify a workspace if a template is deleted from the store while someone is editing it.
|
|
178
|
+
// TODO: would be nice to align the stores on methods/methodNames.
|
|
173
179
|
this.#detailStore?.remove([id]);
|
|
174
180
|
this.#treeStore?.removeItem(id);
|
|
175
|
-
|
|
181
|
+
this.#itemStore?.removeItem(id);
|
|
176
182
|
}
|
|
177
183
|
return { error };
|
|
178
184
|
}
|