@acorex/modules 19.4.12 → 19.4.14
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/content-management/index.d.ts +2 -0
- package/content-management/lib/entities/index.d.ts +1 -0
- package/content-management/lib/entities/promotion/index.d.ts +5 -0
- package/content-management/lib/features/index.d.ts +1 -0
- package/content-management/lib/features/promotion/components/index.d.ts +1 -0
- package/content-management/lib/features/promotion/index.d.ts +1 -0
- package/fesm2022/acorex-modules-content-management.mjs +1288 -1
- package/fesm2022/acorex-modules-content-management.mjs.map +1 -1
- package/fesm2022/{acorex-modules-platform-management-acorex-modules-platform-management-B8aACrqL.mjs → acorex-modules-platform-management-acorex-modules-platform-management-CzMi7CBH.mjs} +17 -31
- package/fesm2022/acorex-modules-platform-management-acorex-modules-platform-management-CzMi7CBH.mjs.map +1 -0
- package/fesm2022/{acorex-modules-platform-management-list-version.component-DhSicYd3.mjs → acorex-modules-platform-management-list-version.component-DfbMc2hn.mjs} +2 -2
- package/fesm2022/{acorex-modules-platform-management-list-version.component-DhSicYd3.mjs.map → acorex-modules-platform-management-list-version.component-DfbMc2hn.mjs.map} +1 -1
- package/fesm2022/{acorex-modules-platform-management-settings.provider-CnGAUpof.mjs → acorex-modules-platform-management-settings.provider-B-19OJn0.mjs} +2 -2
- package/fesm2022/{acorex-modules-platform-management-settings.provider-CnGAUpof.mjs.map → acorex-modules-platform-management-settings.provider-B-19OJn0.mjs.map} +1 -1
- package/fesm2022/acorex-modules-platform-management.mjs +1 -1
- package/package.json +1 -1
- package/platform-management/lib/entities/data-source/datasource-provider.dynamic.d.ts +2 -0
- package/fesm2022/acorex-modules-content-management-acorex-modules-content-management-C23PlUCn.mjs +0 -392
- package/fesm2022/acorex-modules-content-management-acorex-modules-content-management-C23PlUCn.mjs.map +0 -1
- package/fesm2022/acorex-modules-content-management-promotion.entity-D3qRwZhQ.mjs +0 -892
- package/fesm2022/acorex-modules-content-management-promotion.entity-D3qRwZhQ.mjs.map +0 -1
- package/fesm2022/acorex-modules-platform-management-acorex-modules-platform-management-B8aACrqL.mjs.map +0 -1
@@ -1,892 +0,0 @@
|
|
1
|
-
import { AXPFileStorageService, createAllQueryView, createQueryView, AXPEntityCommandScope, AXPEntityQueryType } from '@acorex/platform/common';
|
2
|
-
import { AXPWidgetsCatalog } from '@acorex/platform/layout/builder';
|
3
|
-
import { A as AXMAppPromotionService, R as RootConfig } from './acorex-modules-content-management-acorex-modules-content-management-C23PlUCn.mjs';
|
4
|
-
|
5
|
-
/**
|
6
|
-
* Deeply sanitizes an object for storage in IndexedDB by removing non-serializable content
|
7
|
-
*/
|
8
|
-
function sanitizeForStorage(obj) {
|
9
|
-
if (!obj) {
|
10
|
-
return obj;
|
11
|
-
}
|
12
|
-
// Handle primitive values
|
13
|
-
if (typeof obj !== 'object') {
|
14
|
-
return obj;
|
15
|
-
}
|
16
|
-
// Handle arrays
|
17
|
-
if (Array.isArray(obj)) {
|
18
|
-
return obj.map(item => sanitizeForStorage(item));
|
19
|
-
}
|
20
|
-
// Handle Date objects
|
21
|
-
if (obj instanceof Date) {
|
22
|
-
return obj;
|
23
|
-
}
|
24
|
-
// Handle File objects specially
|
25
|
-
if (obj instanceof File) {
|
26
|
-
// File objects are handled separately, return as is
|
27
|
-
return obj;
|
28
|
-
}
|
29
|
-
// Handle Blob objects
|
30
|
-
if (obj instanceof Blob) {
|
31
|
-
// Blob objects are handled separately
|
32
|
-
return obj;
|
33
|
-
}
|
34
|
-
// Handle regular objects
|
35
|
-
const cleanedObj = {};
|
36
|
-
for (const [key, value] of Object.entries(obj)) {
|
37
|
-
// Skip functions, symbols and other non-serializable types
|
38
|
-
if (typeof value === 'function' || typeof value === 'symbol') {
|
39
|
-
continue;
|
40
|
-
}
|
41
|
-
// Handle null values
|
42
|
-
if (value === null) {
|
43
|
-
cleanedObj[key] = null;
|
44
|
-
continue;
|
45
|
-
}
|
46
|
-
// Recursively sanitize objects
|
47
|
-
if (typeof value === 'object') {
|
48
|
-
cleanedObj[key] = sanitizeForStorage(value);
|
49
|
-
}
|
50
|
-
else {
|
51
|
-
cleanedObj[key] = value;
|
52
|
-
}
|
53
|
-
}
|
54
|
-
return cleanedObj;
|
55
|
-
}
|
56
|
-
async function promotionEntityFactory(injector) {
|
57
|
-
const dataService = injector.get(AXMAppPromotionService);
|
58
|
-
const fileStorageService = injector.get(AXPFileStorageService);
|
59
|
-
const i18n = RootConfig.config.i18n;
|
60
|
-
const entityDef = {
|
61
|
-
module: RootConfig.module.name,
|
62
|
-
name: RootConfig.entities.promotion.name,
|
63
|
-
source: '',
|
64
|
-
title: RootConfig.entities.promotion.title,
|
65
|
-
formats: {
|
66
|
-
individual: RootConfig.entities.promotion.title,
|
67
|
-
plural: RootConfig.entities.promotion.titlePlural,
|
68
|
-
searchResult: {
|
69
|
-
title: '{{ title }}',
|
70
|
-
description: RootConfig.module.title,
|
71
|
-
},
|
72
|
-
},
|
73
|
-
relatedEntities: [],
|
74
|
-
groups: [
|
75
|
-
{
|
76
|
-
id: 'promotion',
|
77
|
-
title: 'Promotion',
|
78
|
-
},
|
79
|
-
],
|
80
|
-
properties: [
|
81
|
-
{
|
82
|
-
name: 'id',
|
83
|
-
title: 'ID',
|
84
|
-
schema: {
|
85
|
-
dataType: 'uuid',
|
86
|
-
hidden: true,
|
87
|
-
nullable: false,
|
88
|
-
readonly: true,
|
89
|
-
unique: {
|
90
|
-
enabled: true,
|
91
|
-
},
|
92
|
-
},
|
93
|
-
options: {
|
94
|
-
sort: {
|
95
|
-
enabled: true,
|
96
|
-
},
|
97
|
-
},
|
98
|
-
},
|
99
|
-
{
|
100
|
-
name: 'title',
|
101
|
-
title: `t("title", { scope: "common" })`,
|
102
|
-
groupId: 'promotion',
|
103
|
-
schema: {
|
104
|
-
dataType: 'string',
|
105
|
-
interface: {
|
106
|
-
type: AXPWidgetsCatalog.text,
|
107
|
-
},
|
108
|
-
},
|
109
|
-
options: {
|
110
|
-
sort: {
|
111
|
-
enabled: true,
|
112
|
-
},
|
113
|
-
filter: {
|
114
|
-
advance: {
|
115
|
-
enabled: true,
|
116
|
-
},
|
117
|
-
inline: {
|
118
|
-
enabled: true,
|
119
|
-
},
|
120
|
-
},
|
121
|
-
},
|
122
|
-
validations: [
|
123
|
-
{
|
124
|
-
rule: 'required',
|
125
|
-
},
|
126
|
-
],
|
127
|
-
},
|
128
|
-
{
|
129
|
-
name: 'body',
|
130
|
-
title: `t("body", { scope: "${i18n}" })`,
|
131
|
-
groupId: 'promotion',
|
132
|
-
schema: {
|
133
|
-
dataType: 'string',
|
134
|
-
interface: {
|
135
|
-
type: AXPWidgetsCatalog.richText,
|
136
|
-
},
|
137
|
-
},
|
138
|
-
validations: [
|
139
|
-
{
|
140
|
-
rule: 'required',
|
141
|
-
},
|
142
|
-
],
|
143
|
-
},
|
144
|
-
{
|
145
|
-
name: 'imageId',
|
146
|
-
title: `t("Gallery", { scope: "${i18n}" })`,
|
147
|
-
groupId: 'promotion',
|
148
|
-
schema: {
|
149
|
-
dataType: 'string',
|
150
|
-
interface: {
|
151
|
-
type: AXPWidgetsCatalog.fileUploader,
|
152
|
-
options: {
|
153
|
-
multiple: true,
|
154
|
-
},
|
155
|
-
},
|
156
|
-
},
|
157
|
-
},
|
158
|
-
{
|
159
|
-
name: 'contentType',
|
160
|
-
title: `t("contentType", { scope: "${i18n}" })`,
|
161
|
-
groupId: 'promotion',
|
162
|
-
schema: {
|
163
|
-
dataType: 'string',
|
164
|
-
interface: {
|
165
|
-
type: AXPWidgetsCatalog.select,
|
166
|
-
options: {
|
167
|
-
valueField: 'name',
|
168
|
-
textField: 'title',
|
169
|
-
dataSource: [
|
170
|
-
{ title: 'Media', name: 'media' },
|
171
|
-
{ title: 'Text', name: 'text' },
|
172
|
-
],
|
173
|
-
direction: 'horizontal',
|
174
|
-
multiple: false,
|
175
|
-
},
|
176
|
-
},
|
177
|
-
},
|
178
|
-
options: {
|
179
|
-
sort: {
|
180
|
-
enabled: true,
|
181
|
-
},
|
182
|
-
filter: {
|
183
|
-
advance: {
|
184
|
-
enabled: true,
|
185
|
-
},
|
186
|
-
},
|
187
|
-
},
|
188
|
-
validations: [
|
189
|
-
{
|
190
|
-
rule: 'required',
|
191
|
-
},
|
192
|
-
],
|
193
|
-
},
|
194
|
-
// {
|
195
|
-
// name: 'shape',
|
196
|
-
// title: `t("shape", { scope: "${i18n}" })`,
|
197
|
-
// groupId: 'promotion',
|
198
|
-
// schema: {
|
199
|
-
// dataType: 'string',
|
200
|
-
// interface: {
|
201
|
-
// type: AXPWidgetsCatalog.select,
|
202
|
-
// options: {
|
203
|
-
// valueField: 'name',
|
204
|
-
// textField: 'title',
|
205
|
-
// dataSource: [
|
206
|
-
// { title: 'Circle', name: 'circle' },
|
207
|
-
// { title: 'Square', name: 'square' },
|
208
|
-
// ],
|
209
|
-
// direction: 'horizontal',
|
210
|
-
// multiple: false,
|
211
|
-
// accept: '',
|
212
|
-
// },
|
213
|
-
// },
|
214
|
-
// },
|
215
|
-
// validations: [
|
216
|
-
// {
|
217
|
-
// rule: 'required',
|
218
|
-
// },
|
219
|
-
// ],
|
220
|
-
// },
|
221
|
-
{
|
222
|
-
name: 'placement',
|
223
|
-
title: `t("placement", { scope: "${i18n}" })`,
|
224
|
-
groupId: 'promotion',
|
225
|
-
schema: {
|
226
|
-
dataType: 'string',
|
227
|
-
interface: {
|
228
|
-
type: AXPWidgetsCatalog.select,
|
229
|
-
options: {
|
230
|
-
valueField: 'name',
|
231
|
-
textField: 'title',
|
232
|
-
dataSource: [
|
233
|
-
{
|
234
|
-
title: 'Side Menu Footer',
|
235
|
-
name: 'side-menu-footer',
|
236
|
-
options: [
|
237
|
-
{
|
238
|
-
type: 'text-editor',
|
239
|
-
mode: 'edit',
|
240
|
-
path: 'name',
|
241
|
-
options: {
|
242
|
-
placeholder: 'Name',
|
243
|
-
defaultValue: 'test',
|
244
|
-
},
|
245
|
-
},
|
246
|
-
],
|
247
|
-
},
|
248
|
-
{
|
249
|
-
title: 'Side Menu Header',
|
250
|
-
name: 'side-menu-header',
|
251
|
-
options: [
|
252
|
-
{
|
253
|
-
type: 'text-editor',
|
254
|
-
mode: 'edit',
|
255
|
-
path: 'name',
|
256
|
-
options: {
|
257
|
-
placeholder: 'Name',
|
258
|
-
defaultValue: 'test',
|
259
|
-
},
|
260
|
-
},
|
261
|
-
],
|
262
|
-
},
|
263
|
-
],
|
264
|
-
direction: 'horizontal',
|
265
|
-
multiple: false,
|
266
|
-
},
|
267
|
-
},
|
268
|
-
},
|
269
|
-
validations: [
|
270
|
-
{
|
271
|
-
rule: 'required',
|
272
|
-
},
|
273
|
-
],
|
274
|
-
},
|
275
|
-
// {
|
276
|
-
// name: "metadaata",
|
277
|
-
// title: "Meta Data",
|
278
|
-
// groupId: 'promotion',
|
279
|
-
// schema: {
|
280
|
-
// dataType: 'object',
|
281
|
-
// interface: {
|
282
|
-
// type: AXPWidgetsCatalog.text,
|
283
|
-
// // children: "{{ context.eval('placement').options }}" as any,
|
284
|
-
// },
|
285
|
-
// }
|
286
|
-
//},
|
287
|
-
// {
|
288
|
-
// name: 'metadata',
|
289
|
-
// title: `Meta Data`,
|
290
|
-
// groupId: 'promotion',
|
291
|
-
// schema: {
|
292
|
-
// dataType: 'object',
|
293
|
-
// interface: {
|
294
|
-
// type: AXPWidgetsCatalog.blockLayout,
|
295
|
-
// children: "{{ context.eval('placement')?.options ?? [] }}" as any,
|
296
|
-
// },
|
297
|
-
// },
|
298
|
-
// },
|
299
|
-
],
|
300
|
-
columns: [{ name: 'title' }, { name: 'placement' }, { name: 'imageId' }],
|
301
|
-
commands: {
|
302
|
-
create: {
|
303
|
-
execute: async (data) => {
|
304
|
-
data = sanitizeForStorage(data);
|
305
|
-
const entityPayload = { ...data };
|
306
|
-
const filesToUploadAfterSave = [];
|
307
|
-
// const originalImageIdArray = Array.isArray(entityPayload.imageId) ? [...entityPayload.imageId] : [];
|
308
|
-
if (entityPayload.imageId && Array.isArray(entityPayload.imageId)) {
|
309
|
-
const processedImageIdForEntitySave = [];
|
310
|
-
for (const fileItem of entityPayload.imageId) {
|
311
|
-
if (fileItem.source?.kind === 'blob' && fileItem.source.value instanceof Blob) {
|
312
|
-
filesToUploadAfterSave.push({ fileItem, blob: fileItem.source.value });
|
313
|
-
processedImageIdForEntitySave.push({
|
314
|
-
tempId: fileItem.id,
|
315
|
-
name: fileItem.name,
|
316
|
-
size: fileItem.size,
|
317
|
-
type: fileItem.source.value.type, // Type from blob is reliable
|
318
|
-
status: 'pending_upload'
|
319
|
-
});
|
320
|
-
}
|
321
|
-
else if (fileItem.source?.kind === 'fileId' && fileItem.id && typeof fileItem.source.value === 'string') {
|
322
|
-
// If it's a fileId, we assume it's already processed. We don't have type directly on AXPFileListItem.
|
323
|
-
// We'll reconstruct it from fileStorageService or it should be part of what's saved if needed.
|
324
|
-
processedImageIdForEntitySave.push({
|
325
|
-
id: fileItem.id,
|
326
|
-
name: fileItem.name,
|
327
|
-
size: fileItem.size,
|
328
|
-
// type: fileItem.type, // Removed: AXPFileListItem does not have .type
|
329
|
-
status: 'uploaded',
|
330
|
-
source: { kind: 'fileId', value: fileItem.source.value }
|
331
|
-
});
|
332
|
-
}
|
333
|
-
else if (fileItem.id && fileItem.name) { // Fallback for items that might be from a previous save
|
334
|
-
processedImageIdForEntitySave.push({
|
335
|
-
id: fileItem.id,
|
336
|
-
name: fileItem.name,
|
337
|
-
size: fileItem.size,
|
338
|
-
// type: fileItem.type, // Removed: AXPFileListItem does not have .type
|
339
|
-
status: fileItem.status, // Preserve existing status
|
340
|
-
source: fileItem.source ? { kind: fileItem.source.kind, value: fileItem.source.value } : undefined
|
341
|
-
});
|
342
|
-
}
|
343
|
-
}
|
344
|
-
entityPayload.imageId = processedImageIdForEntitySave;
|
345
|
-
}
|
346
|
-
const savedEntityId = await dataService.insertOne(entityPayload);
|
347
|
-
// const entityId = savedEntity.id; // Corrected based on typical service return
|
348
|
-
const finalImageIdReferences = (entityPayload.imageId || [])
|
349
|
-
.filter((f) => f.status !== 'pending_upload');
|
350
|
-
for (const { fileItem, blob } of filesToUploadAfterSave) {
|
351
|
-
try {
|
352
|
-
if (!fileStorageService) {
|
353
|
-
throw new Error('fileStorageService is not available.');
|
354
|
-
}
|
355
|
-
const fileStorageInfo = await fileStorageService.save({
|
356
|
-
file: blob,
|
357
|
-
refId: savedEntityId,
|
358
|
-
refType: `${RootConfig.module.name}.${RootConfig.entities.promotion.name}`,
|
359
|
-
category: '',
|
360
|
-
name: blob.name,
|
361
|
-
});
|
362
|
-
finalImageIdReferences.push({
|
363
|
-
id: fileStorageInfo.fileId,
|
364
|
-
name: fileStorageInfo.name || blob.name,
|
365
|
-
size: fileStorageInfo.size || blob.size,
|
366
|
-
type: fileStorageInfo.mimeType || blob.type,
|
367
|
-
status: 'uploaded',
|
368
|
-
source: { kind: 'fileId', value: fileStorageInfo.fileId }
|
369
|
-
});
|
370
|
-
}
|
371
|
-
catch (err) { // Typed error
|
372
|
-
console.error('Error uploading file to FileStorage for entityId:', savedEntityId, 'file:', fileItem.name, err);
|
373
|
-
finalImageIdReferences.push({
|
374
|
-
tempId: fileItem.id,
|
375
|
-
name: fileItem.name,
|
376
|
-
size: fileItem.size,
|
377
|
-
type: blob.type, // Correctly access type from Blob/File
|
378
|
-
status: 'upload_failed',
|
379
|
-
error: err.message
|
380
|
-
});
|
381
|
-
}
|
382
|
-
}
|
383
|
-
if (filesToUploadAfterSave.length > 0) {
|
384
|
-
let needsUpdate = true;
|
385
|
-
if (entityPayload.imageId && entityPayload.imageId.length === finalImageIdReferences.length) {
|
386
|
-
const oldIds = entityPayload.imageId.map((f) => f.id || f.tempId).sort().join(',');
|
387
|
-
const newIds = finalImageIdReferences.map((f) => f.id || f.tempId).sort().join(',');
|
388
|
-
if (oldIds === newIds && !finalImageIdReferences.some((f) => f.status === 'upload_failed')) {
|
389
|
-
needsUpdate = false;
|
390
|
-
}
|
391
|
-
}
|
392
|
-
if (needsUpdate) {
|
393
|
-
// Assuming updateOne takes the ID and an object of fields to update
|
394
|
-
await dataService.updateOne(savedEntityId, { imageId: finalImageIdReferences });
|
395
|
-
}
|
396
|
-
}
|
397
|
-
return { id: savedEntityId };
|
398
|
-
},
|
399
|
-
},
|
400
|
-
delete: {
|
401
|
-
execute: async (id) => {
|
402
|
-
return await dataService.deleteOne(id);
|
403
|
-
},
|
404
|
-
},
|
405
|
-
update: {
|
406
|
-
execute: async (data) => {
|
407
|
-
const entityId = data.id;
|
408
|
-
const filesToUpload = [];
|
409
|
-
const processedImageReferences = []; // Will hold final file objects for DB
|
410
|
-
// Ensure fileStorageService is available (it's injected at the factory level)
|
411
|
-
// const fileStorageService = injector.get(AXPFileStorageService); // Already available in this scope from factory
|
412
|
-
if (data.imageId && Array.isArray(data.imageId)) {
|
413
|
-
for (const fileItem of data.imageId) {
|
414
|
-
if (fileItem.status === 'deleted') {
|
415
|
-
// File marked for deletion. Skip.
|
416
|
-
// Optionally, you might want to call fileStorageService.delete(fileId) here
|
417
|
-
// if fileItem.id points to an existing stored file and actual deletion is needed.
|
418
|
-
// For now, we just disassociate it from the entity.
|
419
|
-
continue;
|
420
|
-
}
|
421
|
-
if (fileItem.source?.kind === 'blob' && fileItem.source.value instanceof Blob) {
|
422
|
-
filesToUpload.push({ fileItem, blob: fileItem.source.value });
|
423
|
-
// Actual reference will be added to processedImageReferences after successful upload.
|
424
|
-
}
|
425
|
-
else if (fileItem.source?.kind === 'fileId' && fileItem.id && typeof fileItem.source.value === 'string') {
|
426
|
-
// This is an existing file, keep its reference.
|
427
|
-
processedImageReferences.push({
|
428
|
-
id: fileItem.id,
|
429
|
-
name: fileItem.name,
|
430
|
-
size: fileItem.size,
|
431
|
-
status: fileItem.status || 'uploaded', // Default to 'uploaded' if status is missing
|
432
|
-
source: { kind: 'fileId', value: fileItem.source.value }
|
433
|
-
// 'type' is not typically part of AXPFileListItem for existing fileIds in 'create'
|
434
|
-
});
|
435
|
-
}
|
436
|
-
else if (fileItem.id && fileItem.name) {
|
437
|
-
// Fallback for items that might be from a previous save state (already processed)
|
438
|
-
// These are likely already processed files that are being kept.
|
439
|
-
processedImageReferences.push({
|
440
|
-
id: fileItem.id,
|
441
|
-
name: fileItem.name,
|
442
|
-
size: fileItem.size,
|
443
|
-
status: fileItem.status || 'uploaded',
|
444
|
-
source: fileItem.source ? { kind: fileItem.source.kind, value: fileItem.source.value } : undefined
|
445
|
-
});
|
446
|
-
}
|
447
|
-
// Else: unknown fileItem structure, it will be ignored or you can log an error.
|
448
|
-
}
|
449
|
-
}
|
450
|
-
// Upload new files and add their successful/failed info to processedImageReferences
|
451
|
-
for (const { fileItem, blob } of filesToUpload) {
|
452
|
-
try {
|
453
|
-
if (!fileStorageService) {
|
454
|
-
throw new Error('fileStorageService is not available.');
|
455
|
-
}
|
456
|
-
const fileStorageInfo = await fileStorageService.save({
|
457
|
-
file: blob,
|
458
|
-
refId: entityId, // ID of the entity being updated
|
459
|
-
refType: `${RootConfig.module.name}.${RootConfig.entities.promotion.name}`,
|
460
|
-
category: '', // Add category if applicable
|
461
|
-
name: blob.name,
|
462
|
-
});
|
463
|
-
processedImageReferences.push({
|
464
|
-
id: fileStorageInfo.fileId,
|
465
|
-
name: fileStorageInfo.name || blob.name,
|
466
|
-
size: fileStorageInfo.size || blob.size,
|
467
|
-
type: fileStorageInfo.mimeType || blob.type, // Store MIME type
|
468
|
-
status: 'uploaded',
|
469
|
-
source: { kind: 'fileId', value: fileStorageInfo.fileId }
|
470
|
-
});
|
471
|
-
}
|
472
|
-
catch (err) {
|
473
|
-
console.error('Error uploading file to FileStorage during update for entityId:', entityId, 'file:', fileItem.name, err);
|
474
|
-
processedImageReferences.push({
|
475
|
-
tempId: fileItem.id, // Use fileItem.id if it's a unique temp client-side ID, or generate one
|
476
|
-
name: fileItem.name,
|
477
|
-
size: fileItem.size,
|
478
|
-
type: blob.type,
|
479
|
-
status: 'upload_failed',
|
480
|
-
error: err.message
|
481
|
-
});
|
482
|
-
}
|
483
|
-
}
|
484
|
-
// Construct the final data payload for the update.
|
485
|
-
// Create a mutable copy of the input data.
|
486
|
-
const finalUpdatePayload = { ...data };
|
487
|
-
// Replace the original imageId array with the newly processed one.
|
488
|
-
finalUpdatePayload.imageId = processedImageReferences;
|
489
|
-
// Sanitize the entire payload before sending it to dataService.updateOne.
|
490
|
-
// This ensures that the processedImageReferences (which are plain objects)
|
491
|
-
// and all other fields in the payload are clean and serializable.
|
492
|
-
const fullySanitizedPayload = sanitizeForStorage(finalUpdatePayload);
|
493
|
-
return await dataService.updateOne(entityId, fullySanitizedPayload);
|
494
|
-
},
|
495
|
-
},
|
496
|
-
},
|
497
|
-
queries: {
|
498
|
-
byKey: {
|
499
|
-
execute: async (id) => {
|
500
|
-
try {
|
501
|
-
// Debug the incoming ID parameter
|
502
|
-
console.log('byKey original id parameter:', id, typeof id);
|
503
|
-
// Ensure id is a valid key for IndexedDB - needs to be string or number
|
504
|
-
let validId;
|
505
|
-
// If id is an object (e.g., from router params or complex structure)
|
506
|
-
if (typeof id === 'object' && id !== null) {
|
507
|
-
if ('id' in id) {
|
508
|
-
validId = String(id.id);
|
509
|
-
}
|
510
|
-
else {
|
511
|
-
validId = String(id);
|
512
|
-
}
|
513
|
-
console.warn('Converted object id to string:', validId);
|
514
|
-
}
|
515
|
-
else if (id === undefined || id === null) {
|
516
|
-
console.error('Invalid id parameter: null or undefined');
|
517
|
-
return null;
|
518
|
-
}
|
519
|
-
else {
|
520
|
-
// Convert to string to ensure consistency
|
521
|
-
validId = String(id);
|
522
|
-
}
|
523
|
-
// Log the ID being used for the query
|
524
|
-
console.log('Fetching record with id:', validId, typeof validId);
|
525
|
-
try {
|
526
|
-
const data = await dataService.getOne(validId);
|
527
|
-
console.log('getOne result:', data ? 'Data found' : 'No data found');
|
528
|
-
// If no data was found
|
529
|
-
if (!data) {
|
530
|
-
console.warn(`No record found with id: ${validId}`);
|
531
|
-
return null;
|
532
|
-
}
|
533
|
-
return data;
|
534
|
-
}
|
535
|
-
catch (error) {
|
536
|
-
console.error(`Error fetching data with ID ${validId}:`, error);
|
537
|
-
// Return null instead of throwing to avoid cascading errors
|
538
|
-
return null;
|
539
|
-
}
|
540
|
-
}
|
541
|
-
catch (error) {
|
542
|
-
console.error('Critical error in byKey query:', error);
|
543
|
-
return null; // Return null instead of throwing to avoid UI errors
|
544
|
-
}
|
545
|
-
},
|
546
|
-
type: AXPEntityQueryType.Single,
|
547
|
-
},
|
548
|
-
list: {
|
549
|
-
execute: async (e) => {
|
550
|
-
return await dataService.query({ skip: e.skip, take: e.take, filter: e.filter });
|
551
|
-
},
|
552
|
-
type: AXPEntityQueryType.List,
|
553
|
-
},
|
554
|
-
},
|
555
|
-
interfaces: {
|
556
|
-
master: {
|
557
|
-
create: {
|
558
|
-
sections: [
|
559
|
-
{
|
560
|
-
id: 'promotion',
|
561
|
-
},
|
562
|
-
],
|
563
|
-
properties: [
|
564
|
-
{
|
565
|
-
name: 'title',
|
566
|
-
layout: {
|
567
|
-
positions: {
|
568
|
-
lg: {
|
569
|
-
colSpan: 6,
|
570
|
-
order: 1,
|
571
|
-
},
|
572
|
-
},
|
573
|
-
},
|
574
|
-
},
|
575
|
-
{
|
576
|
-
name: 'body',
|
577
|
-
layout: {
|
578
|
-
positions: {
|
579
|
-
lg: {
|
580
|
-
colSpan: 12,
|
581
|
-
order: 5,
|
582
|
-
},
|
583
|
-
},
|
584
|
-
},
|
585
|
-
},
|
586
|
-
{
|
587
|
-
name: 'imageId',
|
588
|
-
layout: {
|
589
|
-
positions: {
|
590
|
-
lg: {
|
591
|
-
colSpan: 12,
|
592
|
-
order: 6,
|
593
|
-
},
|
594
|
-
},
|
595
|
-
},
|
596
|
-
},
|
597
|
-
{
|
598
|
-
name: 'contentType',
|
599
|
-
layout: {
|
600
|
-
positions: {
|
601
|
-
lg: {
|
602
|
-
colSpan: 6,
|
603
|
-
order: 2,
|
604
|
-
},
|
605
|
-
},
|
606
|
-
},
|
607
|
-
},
|
608
|
-
{
|
609
|
-
name: 'shape',
|
610
|
-
layout: {
|
611
|
-
positions: {
|
612
|
-
lg: {
|
613
|
-
colSpan: 6,
|
614
|
-
order: 3,
|
615
|
-
},
|
616
|
-
},
|
617
|
-
},
|
618
|
-
},
|
619
|
-
{
|
620
|
-
name: 'placement',
|
621
|
-
layout: {
|
622
|
-
positions: {
|
623
|
-
lg: {
|
624
|
-
colSpan: 6,
|
625
|
-
order: 4,
|
626
|
-
},
|
627
|
-
},
|
628
|
-
},
|
629
|
-
},
|
630
|
-
{
|
631
|
-
name: 'metadata',
|
632
|
-
layout: {
|
633
|
-
positions: {
|
634
|
-
lg: {
|
635
|
-
colSpan: 12,
|
636
|
-
order: 10,
|
637
|
-
},
|
638
|
-
},
|
639
|
-
},
|
640
|
-
},
|
641
|
-
],
|
642
|
-
},
|
643
|
-
update: {
|
644
|
-
sections: [
|
645
|
-
{
|
646
|
-
id: 'promotion',
|
647
|
-
},
|
648
|
-
],
|
649
|
-
properties: [
|
650
|
-
{
|
651
|
-
name: 'title',
|
652
|
-
layout: {
|
653
|
-
positions: {
|
654
|
-
lg: {
|
655
|
-
colSpan: 6,
|
656
|
-
order: 1,
|
657
|
-
},
|
658
|
-
},
|
659
|
-
},
|
660
|
-
},
|
661
|
-
{
|
662
|
-
name: 'body',
|
663
|
-
layout: {
|
664
|
-
positions: {
|
665
|
-
lg: {
|
666
|
-
colSpan: 12,
|
667
|
-
order: 5,
|
668
|
-
},
|
669
|
-
},
|
670
|
-
},
|
671
|
-
},
|
672
|
-
{
|
673
|
-
name: 'imageId',
|
674
|
-
layout: {
|
675
|
-
positions: {
|
676
|
-
lg: {
|
677
|
-
colSpan: 12,
|
678
|
-
order: 6,
|
679
|
-
},
|
680
|
-
},
|
681
|
-
},
|
682
|
-
},
|
683
|
-
{
|
684
|
-
name: 'contentType',
|
685
|
-
layout: {
|
686
|
-
positions: {
|
687
|
-
lg: {
|
688
|
-
colSpan: 6,
|
689
|
-
order: 2,
|
690
|
-
},
|
691
|
-
},
|
692
|
-
},
|
693
|
-
},
|
694
|
-
{
|
695
|
-
name: 'shape',
|
696
|
-
layout: {
|
697
|
-
positions: {
|
698
|
-
lg: {
|
699
|
-
colSpan: 6,
|
700
|
-
order: 3,
|
701
|
-
},
|
702
|
-
},
|
703
|
-
},
|
704
|
-
},
|
705
|
-
{
|
706
|
-
name: 'placement',
|
707
|
-
layout: {
|
708
|
-
positions: {
|
709
|
-
lg: {
|
710
|
-
colSpan: 6,
|
711
|
-
order: 4,
|
712
|
-
},
|
713
|
-
},
|
714
|
-
},
|
715
|
-
},
|
716
|
-
// {
|
717
|
-
// name: 'metadata',
|
718
|
-
// layout: {
|
719
|
-
// positions: {
|
720
|
-
// lg: {
|
721
|
-
// colSpan: 12,
|
722
|
-
// order: 10,
|
723
|
-
// },
|
724
|
-
// },
|
725
|
-
// },
|
726
|
-
// },
|
727
|
-
],
|
728
|
-
},
|
729
|
-
single: {
|
730
|
-
title: '{{title}}',
|
731
|
-
sections: [
|
732
|
-
{
|
733
|
-
id: 'promotion',
|
734
|
-
},
|
735
|
-
],
|
736
|
-
properties: [
|
737
|
-
{
|
738
|
-
name: 'title',
|
739
|
-
layout: {
|
740
|
-
positions: {
|
741
|
-
lg: {
|
742
|
-
colSpan: 6,
|
743
|
-
},
|
744
|
-
},
|
745
|
-
},
|
746
|
-
},
|
747
|
-
{
|
748
|
-
name: 'body',
|
749
|
-
layout: {
|
750
|
-
positions: {
|
751
|
-
lg: {
|
752
|
-
colSpan: 6,
|
753
|
-
},
|
754
|
-
},
|
755
|
-
},
|
756
|
-
},
|
757
|
-
{
|
758
|
-
name: 'imageId',
|
759
|
-
layout: {
|
760
|
-
positions: {
|
761
|
-
lg: {
|
762
|
-
colSpan: 12,
|
763
|
-
order: 2,
|
764
|
-
},
|
765
|
-
},
|
766
|
-
},
|
767
|
-
},
|
768
|
-
{
|
769
|
-
name: 'contentType',
|
770
|
-
layout: {
|
771
|
-
positions: {
|
772
|
-
lg: {
|
773
|
-
colSpan: 4,
|
774
|
-
order: 4,
|
775
|
-
},
|
776
|
-
},
|
777
|
-
},
|
778
|
-
},
|
779
|
-
{
|
780
|
-
name: 'shape',
|
781
|
-
layout: {
|
782
|
-
positions: {
|
783
|
-
lg: {
|
784
|
-
colSpan: 4,
|
785
|
-
order: 5,
|
786
|
-
},
|
787
|
-
},
|
788
|
-
},
|
789
|
-
},
|
790
|
-
{
|
791
|
-
name: 'placement',
|
792
|
-
layout: {
|
793
|
-
positions: {
|
794
|
-
lg: {
|
795
|
-
colSpan: 4,
|
796
|
-
order: 6,
|
797
|
-
},
|
798
|
-
},
|
799
|
-
},
|
800
|
-
},
|
801
|
-
],
|
802
|
-
actions: [],
|
803
|
-
},
|
804
|
-
list: {
|
805
|
-
actions: [
|
806
|
-
{
|
807
|
-
title: `t("create", { scope: "common" })`,
|
808
|
-
command: 'create-entity',
|
809
|
-
priority: 'primary',
|
810
|
-
type: 'create',
|
811
|
-
scope: AXPEntityCommandScope.TypeLevel,
|
812
|
-
},
|
813
|
-
{
|
814
|
-
title: 't("deleteItems", { scope: "common" })',
|
815
|
-
command: 'delete-entity',
|
816
|
-
priority: 'primary',
|
817
|
-
type: 'delete',
|
818
|
-
scope: AXPEntityCommandScope.Selected,
|
819
|
-
},
|
820
|
-
{
|
821
|
-
title: 't("detail", { scope: "common" })',
|
822
|
-
command: 'open-entity',
|
823
|
-
priority: 'primary',
|
824
|
-
type: 'view',
|
825
|
-
scope: AXPEntityCommandScope.Individual,
|
826
|
-
},
|
827
|
-
{
|
828
|
-
title: 't("delete", { scope: "common" })',
|
829
|
-
command: 'delete-entity',
|
830
|
-
priority: 'primary',
|
831
|
-
type: 'delete',
|
832
|
-
scope: AXPEntityCommandScope.Individual,
|
833
|
-
},
|
834
|
-
{
|
835
|
-
title: 't("entity.modify", { scope: "common" })',
|
836
|
-
command: 'quick-modify-entity',
|
837
|
-
priority: 'secondary',
|
838
|
-
type: 'update',
|
839
|
-
scope: AXPEntityCommandScope.Individual,
|
840
|
-
},
|
841
|
-
//TODO: add this to the entity
|
842
|
-
{
|
843
|
-
title: 't("upload.title", { scope: "common" })',
|
844
|
-
command: {
|
845
|
-
name: 'show-file-uploader-popup',
|
846
|
-
options: {
|
847
|
-
id: '{{ context.eval("id") }}',
|
848
|
-
files: '{{ context.eval("imageId") }}',
|
849
|
-
multiple: true,
|
850
|
-
accept: '.jpg,.jpeg,.png,.gif,.webp',
|
851
|
-
key: 'imageId',
|
852
|
-
}
|
853
|
-
},
|
854
|
-
priority: 'secondary',
|
855
|
-
type: 'update',
|
856
|
-
scope: AXPEntityCommandScope.Individual,
|
857
|
-
},
|
858
|
-
],
|
859
|
-
views: [
|
860
|
-
createAllQueryView({ sorts: [{ name: 'title', dir: 'asc' }] }),
|
861
|
-
createQueryView('media', `t("media", { scope: "${i18n}" })`, true, {
|
862
|
-
conditions: [
|
863
|
-
{
|
864
|
-
name: 'contentType.name',
|
865
|
-
operator: {
|
866
|
-
type: 'equal',
|
867
|
-
},
|
868
|
-
value: 'media',
|
869
|
-
},
|
870
|
-
],
|
871
|
-
}),
|
872
|
-
createQueryView('text', `t("text", { scope: "${i18n}" })`, true, {
|
873
|
-
conditions: [
|
874
|
-
{
|
875
|
-
name: 'contentType.name',
|
876
|
-
operator: {
|
877
|
-
type: 'equal',
|
878
|
-
},
|
879
|
-
value: 'text',
|
880
|
-
},
|
881
|
-
],
|
882
|
-
}),
|
883
|
-
],
|
884
|
-
},
|
885
|
-
},
|
886
|
-
},
|
887
|
-
};
|
888
|
-
return entityDef;
|
889
|
-
}
|
890
|
-
|
891
|
-
export { promotionEntityFactory };
|
892
|
-
//# sourceMappingURL=acorex-modules-content-management-promotion.entity-D3qRwZhQ.mjs.map
|