pict-section-recordset 1.0.16 → 1.0.19
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/example_applications/simple_entity/Simple-RecordSet-Application.js +167 -34
- package/package.json +3 -3
- package/source/application/Pict-Application-RecordSet.js +2 -0
- package/source/providers/RecordSet-DynamicSolver.js +305 -0
- package/source/providers/RecordSet-Router.js +2 -0
- package/source/services/RecordsSet-MetaController.js +68 -69
- package/source/templates/Pict-Template-FilterView.js +2 -2
- package/source/views/RecordSet-Filter.js +15 -6
- package/source/views/dashboard/RecordSet-Dashboard-RecordListEntry.js +1 -1
- package/source/views/dashboard/RecordSet-Dashboard-RecordListHeader.js +12 -0
- package/source/views/dashboard/RecordSet-Dashboard.js +345 -72
- package/source/views/error/RecordSet-Error-NotFound.json +22 -0
- package/source/views/list/RecordSet-List.js +14 -10
- package/types/application/Pict-Application-RecordSet.d.ts.map +1 -1
- package/types/providers/RecordSet-DynamicSolver.d.ts +158 -0
- package/types/providers/RecordSet-DynamicSolver.d.ts.map +1 -0
- package/types/providers/RecordSet-Router.d.ts.map +1 -1
- package/types/services/RecordsSet-MetaController.d.ts +12 -11
- package/types/services/RecordsSet-MetaController.d.ts.map +1 -1
- package/types/views/RecordSet-Filter.d.ts.map +1 -1
- package/types/views/dashboard/RecordSet-Dashboard-RecordListHeader.d.ts.map +1 -1
- package/types/views/dashboard/RecordSet-Dashboard.d.ts +22 -2
- package/types/views/dashboard/RecordSet-Dashboard.d.ts.map +1 -1
- package/types/views/list/RecordSet-List.d.ts.map +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const libFableServiceProviderBase = require('fable-serviceproviderbase');
|
|
2
2
|
|
|
3
|
+
const viewDefinitionRecordSetErrorNotFound = require('../views/error/RecordSet-Error-NotFound.json');
|
|
3
4
|
const viewRecordSetList = require('../views/list/RecordSet-List.js');
|
|
4
5
|
const viewRecordSetEdit = require('../views/edit/RecordSet-Edit.js');
|
|
5
6
|
const viewRecordSetRead = require('../views/read/RecordSet-Read.js');
|
|
@@ -26,7 +27,7 @@ class RecordSetMetacontroller extends libFableServiceProviderBase
|
|
|
26
27
|
let tmpOptions = Object.assign({}, _DEFAULT_CONFIGURATION, pOptions);
|
|
27
28
|
super(pFable, tmpOptions, pServiceHash);
|
|
28
29
|
|
|
29
|
-
/** @type {import('pict') & { addAndInstantiateSingletonService: (hash: string, options: any, prototype: any) => any }} */
|
|
30
|
+
/** @type {import('pict') & { addAndInstantiateSingletonService: (hash: string, options: any, prototype: any) => any, newManyfest: (rec: any) => any }} */
|
|
30
31
|
this.fable;
|
|
31
32
|
this.pict = this.fable;
|
|
32
33
|
/** @type {any} */
|
|
@@ -50,6 +51,9 @@ class RecordSetMetacontroller extends libFableServiceProviderBase
|
|
|
50
51
|
|
|
51
52
|
this.sessionProviders = [];
|
|
52
53
|
|
|
54
|
+
this.manifestDefinitions = {};
|
|
55
|
+
this.manifests = { Default: this.pict.manifest };
|
|
56
|
+
|
|
53
57
|
this.has_initialized = false;
|
|
54
58
|
}
|
|
55
59
|
|
|
@@ -201,72 +205,6 @@ class RecordSetMetacontroller extends libFableServiceProviderBase
|
|
|
201
205
|
}
|
|
202
206
|
}
|
|
203
207
|
|
|
204
|
-
/**
|
|
205
|
-
* @param {Array<Record<string, any>>} pDashboardConfigurationArray - An array of dashboard configurations.
|
|
206
|
-
*/
|
|
207
|
-
loadDashboardConfigurationArray(pDashboardConfigurationArray)
|
|
208
|
-
{
|
|
209
|
-
if (!Array.isArray(pDashboardConfigurationArray))
|
|
210
|
-
{
|
|
211
|
-
this.fable.log.error(`RecordSetMetacontroller: ${this.UUID} loadDashboardConfigurationArray called with invalid configuration.`);
|
|
212
|
-
return false;
|
|
213
|
-
}
|
|
214
|
-
if (pDashboardConfigurationArray.length === 0)
|
|
215
|
-
{
|
|
216
|
-
this.fable.log.warn(`RecordSetMetacontroller: ${this.UUID} loadDashboardConfigurationArray called with empty configuration.`);
|
|
217
|
-
return false;
|
|
218
|
-
}
|
|
219
|
-
for (const tmpDashboardConfiguration of pDashboardConfigurationArray)
|
|
220
|
-
{
|
|
221
|
-
if (tmpDashboardConfiguration.RecordDecorationConfiguration)
|
|
222
|
-
{
|
|
223
|
-
//TODO: register the record decoration configuration
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* TODO: This method is still incomplete.
|
|
230
|
-
*
|
|
231
|
-
* @param {Record<string, any>} pDashboardConfiguration - The dashboard configuration to add.
|
|
232
|
-
*/
|
|
233
|
-
addDashboardConfiguration(pDashboardConfiguration)
|
|
234
|
-
{
|
|
235
|
-
let tmpProvider = false;
|
|
236
|
-
|
|
237
|
-
if (this.recordSetProviders[pDashboardConfiguration.RecordSet])
|
|
238
|
-
{
|
|
239
|
-
this.pict.log.error(`RecordSetMetacontroller: ${this.UUID} addDashboardConfiguration called with invalid configuration. RecordSet ${pDashboardConfiguration.RecordSet} already exists.`);
|
|
240
|
-
return null;
|
|
241
|
-
}
|
|
242
|
-
const providerConfiguration = Object.assign({}, {Hash: `RSP-Provider-${pDashboardConfiguration.RecordSet}`}, pDashboardConfiguration);
|
|
243
|
-
this.dashboardConfigurations[providerConfiguration.RecordSet] = providerConfiguration;
|
|
244
|
-
|
|
245
|
-
// Create a Meadow Endpoints provider
|
|
246
|
-
// Allow the Record Set to optionally point to a different entity
|
|
247
|
-
if ('RecordSetCoreMeadowEntity' in pDashboardConfiguration)
|
|
248
|
-
{
|
|
249
|
-
providerConfiguration.Entity = pDashboardConfiguration.RecordSetCoreMeadowEntity;
|
|
250
|
-
}
|
|
251
|
-
else
|
|
252
|
-
{
|
|
253
|
-
this.pict.log.error(`RecordSetMetacontroller: ${this.UUID} addDashboardConfiguration called with invalid configuration. Missing RecordSetCoreMeadowEntity.`);
|
|
254
|
-
return null;
|
|
255
|
-
}
|
|
256
|
-
// Default the URLPrefix to the base URLPrefix
|
|
257
|
-
if ('RecordSetURLPrefix' in pDashboardConfiguration)
|
|
258
|
-
{
|
|
259
|
-
providerConfiguration.URLPrefix = pDashboardConfiguration.RecordSetURLPrefix;
|
|
260
|
-
}
|
|
261
|
-
else
|
|
262
|
-
{
|
|
263
|
-
providerConfiguration.URLPrefix = '/1.0/';
|
|
264
|
-
}
|
|
265
|
-
tmpProvider = this.recordSetProviders[pDashboardConfiguration.RecordSet] = this.fable.addProvider(providerConfiguration.Hash, providerConfiguration, providerMeadowEndpoints);
|
|
266
|
-
|
|
267
|
-
return tmpProvider;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
208
|
loadRecordSetDynamcally(pRecordSet, pEntity, pDefaultFilter)
|
|
271
209
|
{
|
|
272
210
|
if (typeof(pRecordSet) === 'object')
|
|
@@ -362,6 +300,7 @@ class RecordSetMetacontroller extends libFableServiceProviderBase
|
|
|
362
300
|
|
|
363
301
|
// Add the subviews internally and externally
|
|
364
302
|
this.pict.addTemplate(require('../templates/Pict-Template-FilterView.js'));
|
|
303
|
+
this.childViews.errorNotFound = this.fable.addView('RSP-RecordSet-Error-NotFound', viewDefinitionRecordSetErrorNotFound);
|
|
365
304
|
this.childViews.list = this.fable.addView('RSP-RecordSet-List', this.options, viewRecordSetList);
|
|
366
305
|
this.childViews.edit = this.fable.addView('RSP-RecordSet-Edit', this.options, viewRecordSetEdit);
|
|
367
306
|
this.childViews.read = this.fable.addView('RSP-RecordSet-Read', this.options, viewRecordSetRead);
|
|
@@ -380,9 +319,20 @@ class RecordSetMetacontroller extends libFableServiceProviderBase
|
|
|
380
319
|
this.loadRecordSetConfigurationArray(this.fable.settings.DefaultRecordSetConfigurations);
|
|
381
320
|
}
|
|
382
321
|
|
|
383
|
-
|
|
322
|
+
for (const [ tmpManifestKey, tmpManifest ] of Object.entries(this.fable.settings.Manifests || {}))
|
|
384
323
|
{
|
|
385
|
-
|
|
324
|
+
if (!tmpManifest || !tmpManifest.Scope || !tmpManifest.Descriptors)
|
|
325
|
+
{
|
|
326
|
+
this.pict.log.error(`RecordSetDashboard: Invalid manifest: ${tmpManifestKey}.`, tmpManifest);
|
|
327
|
+
continue;
|
|
328
|
+
}
|
|
329
|
+
if (tmpManifestKey !== tmpManifest.Scope)
|
|
330
|
+
{
|
|
331
|
+
this.pict.log.error(`RecordSetDashboard: Manifest key ${tmpManifestKey} does not match manifest scope ${tmpManifest.Scope}. This is bad. Fix it.`);
|
|
332
|
+
}
|
|
333
|
+
this.generateManifestTableCells(tmpManifest);
|
|
334
|
+
this.manifestDefinitions[tmpManifest.Scope] = tmpManifest;
|
|
335
|
+
this.manifests[tmpManifest.Scope] = this.pict.newManyfest(tmpManifest);
|
|
386
336
|
}
|
|
387
337
|
|
|
388
338
|
this.has_initialized = true;
|
|
@@ -396,6 +346,55 @@ class RecordSetMetacontroller extends libFableServiceProviderBase
|
|
|
396
346
|
|
|
397
347
|
return true;
|
|
398
348
|
}
|
|
349
|
+
|
|
350
|
+
getManifest(pScope)
|
|
351
|
+
{
|
|
352
|
+
return this.manifests[pScope];
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* @param {Record<string, any>} pManifest - The manifest to generate table cells for.
|
|
357
|
+
*/
|
|
358
|
+
generateManifestTableCells(pManifest)
|
|
359
|
+
{
|
|
360
|
+
if (!pManifest || !pManifest.Descriptors || !pManifest.Scope)
|
|
361
|
+
{
|
|
362
|
+
this.pict.log.error(`RecordSetDashboard: No manifest or descriptors found for ${pManifest}. Cannot generate table cells.`);
|
|
363
|
+
if (pManifest)
|
|
364
|
+
{
|
|
365
|
+
pManifest.TableCells = [];
|
|
366
|
+
}
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
const tmpTableCells = Object.entries(pManifest.Descriptors || {}).filter(([ key, descriptor ]) => descriptor.PictDashboard).map(([ key, descriptor ]) =>
|
|
370
|
+
{
|
|
371
|
+
const tmpPictDashboard = descriptor.PictDashboard;
|
|
372
|
+
if (tmpPictDashboard?.Equation && !tmpPictDashboard.ValueTemplate)
|
|
373
|
+
{
|
|
374
|
+
//FIXME: is this the right mapping?
|
|
375
|
+
if (tmpPictDashboard.EquationNamespaceScope === 'Full')
|
|
376
|
+
{
|
|
377
|
+
tmpPictDashboard.ValueTemplate = '{~SBR:Record.Data.PictDashboard.Equation::Pict.PictSectionRecordSet.getManifest(Record.Data.ManifestHash)~}';
|
|
378
|
+
}
|
|
379
|
+
else
|
|
380
|
+
{
|
|
381
|
+
tmpPictDashboard.ValueTemplate = '{~SBR:Record.Data.PictDashboard.Equation:Record.Payload:Pict.PictSectionRecordSet.getManifest(Record.Data.ManifestHash)~}';
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
if (!tmpPictDashboard.ValueTemplate)
|
|
385
|
+
{
|
|
386
|
+
tmpPictDashboard.ValueTemplate = '{~DVBK:Record.Payload:Record.Data.Key~}';
|
|
387
|
+
}
|
|
388
|
+
return {
|
|
389
|
+
Key: key,
|
|
390
|
+
DisplayName: descriptor.Name || key,
|
|
391
|
+
ManifestHash: pManifest.Scope,
|
|
392
|
+
PictDashboard: tmpPictDashboard,
|
|
393
|
+
};
|
|
394
|
+
});
|
|
395
|
+
pManifest.TableCells = tmpTableCells;
|
|
396
|
+
}
|
|
397
|
+
|
|
399
398
|
}
|
|
400
399
|
|
|
401
400
|
module.exports = RecordSetMetacontroller;
|
|
@@ -79,7 +79,7 @@ class PictTemplateFilterViewInstruction extends libPictTemplate
|
|
|
79
79
|
}
|
|
80
80
|
if (!pRecord.ViewContext)
|
|
81
81
|
{
|
|
82
|
-
pRecord.ViewContext = tmpViewContext;
|
|
82
|
+
pRecord.ViewContext = pRecord.DashboardHash ? `${tmpViewContext}-${pRecord.DashboardHash}` : tmpViewContext;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
let tmpRenderGUID = this.pict.getUUID();
|
|
@@ -144,7 +144,7 @@ class PictTemplateFilterViewInstruction extends libPictTemplate
|
|
|
144
144
|
}
|
|
145
145
|
if (!pRecord.ViewContext)
|
|
146
146
|
{
|
|
147
|
-
pRecord.ViewContext = tmpViewContext;
|
|
147
|
+
pRecord.ViewContext = pRecord.DashboardHash ? `${tmpViewContext}-${pRecord.DashboardHash}` : tmpViewContext;
|
|
148
148
|
}
|
|
149
149
|
let tmpRenderGUID = this.pict.getUUID();
|
|
150
150
|
|
|
@@ -109,18 +109,27 @@ class viewRecordSetSUBSETFilter extends libPictView
|
|
|
109
109
|
{
|
|
110
110
|
const tmpPictRouter = this.pict.providers.PictRouter;
|
|
111
111
|
const tmpProviderConfiguration = this.pict.PictSectionRecordSet.recordSetProviderConfigurations[pRecordSet];
|
|
112
|
-
let filterExpr = '
|
|
112
|
+
let filterExpr = '%20';
|
|
113
113
|
if (pFilterString)
|
|
114
114
|
{
|
|
115
|
+
/** @type {Array<string>} */
|
|
115
116
|
const searchFields = tmpProviderConfiguration?.SearchFields ?? [ 'Name' ];
|
|
116
117
|
filterExpr = searchFields.map((filterField) => `FBVOR~${filterField}~LK~${encodeURIComponent(`%${pFilterString}%`)}`).join('~');
|
|
117
118
|
}
|
|
118
119
|
let tmpURLTemplate = tmpProviderConfiguration[`RecordSetFilterURLTemplate-${pViewContext}`] || tmpProviderConfiguration[`RecordSetFilterURLTemplate-Default`];
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
120
|
+
let tmpURL;
|
|
121
|
+
if (tmpURLTemplate)
|
|
122
|
+
{
|
|
123
|
+
tmpURL = this.pict.parseTemplate(tmpURLTemplate,
|
|
124
|
+
{
|
|
125
|
+
RecordSet: pRecordSet,
|
|
126
|
+
FilterString: filterExpr,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
else
|
|
130
|
+
{
|
|
131
|
+
tmpURL = `/PSRS/${pRecordSet}/List/FilteredTo/${filterExpr}`;
|
|
132
|
+
}
|
|
124
133
|
tmpPictRouter.router.navigate(tmpURL);
|
|
125
134
|
}
|
|
126
135
|
|
|
@@ -60,7 +60,7 @@ const _DEFAULT_CONFIGURATION_List_RecordListEntry = (
|
|
|
60
60
|
Hash: 'PRSP-Dashboard-RecordListEntry-Template-Row-Cell',
|
|
61
61
|
Template: /*html*/`
|
|
62
62
|
<td style="border-bottom: 1px solid #ccc; padding: 5px;">
|
|
63
|
-
{~
|
|
63
|
+
{~TBDA:Record.Data.PictDashboard.ValueTemplate~}
|
|
64
64
|
</td>
|
|
65
65
|
`
|
|
66
66
|
},
|
|
@@ -37,6 +37,18 @@ const _DEFAULT_CONFIGURATION_List_RecordListHeader = (
|
|
|
37
37
|
{~T:PRSP-Dashboard-RecordListActions-Template-Header~}
|
|
38
38
|
</tr>
|
|
39
39
|
<!-- DefaultPackage end view template: [PRSP-Dashboard-RecordListHeader-Template] -->
|
|
40
|
+
`
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
Hash: 'PRSP-Dashboard-RecordListHeader-Manifest-Template',
|
|
44
|
+
Template: /*html*/`
|
|
45
|
+
<!-- DefaultPackage pict view template: [PRSP-Dashboard-RecordListHeader-Template] -->
|
|
46
|
+
<tr>
|
|
47
|
+
{~TS:PRSP-Dashboard-RecordListHeader-Template-Header:Record.ManifestOhz~}
|
|
48
|
+
{~T:PRSP-Dashboard-RecordListHeader-Template-Extra-Header~}
|
|
49
|
+
{~T:PRSP-Dashboard-RecordListActions-Template-Header~}
|
|
50
|
+
</tr>
|
|
51
|
+
<!-- DefaultPackage end view template: [PRSP-Dashboard-RecordListHeader-Template] -->
|
|
40
52
|
`
|
|
41
53
|
},
|
|
42
54
|
{
|