pict-section-recordset 1.0.15 → 1.0.18
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 +246 -0
- package/package.json +4 -4
- package/source/application/Pict-Application-RecordSet.js +2 -0
- package/source/providers/RecordSet-DynamicSolver.js +305 -0
- package/source/providers/RecordSet-RecordProvider-Base.js +28 -0
- package/source/providers/RecordSet-RecordProvider-MeadowEndpoints.js +53 -3
- package/source/providers/RecordSet-Router.js +2 -0
- package/source/services/RecordsSet-MetaController.js +84 -2
- package/source/templates/Pict-Template-FilterView.js +172 -0
- package/source/views/RecordSet-Filter.js +47 -9
- package/source/views/dashboard/RecordSet-Dashboard-HeaderDashboard.js +17 -17
- package/source/views/dashboard/RecordSet-Dashboard-PaginationBottom.js +68 -0
- package/source/views/dashboard/RecordSet-Dashboard-PaginationTop.js +128 -0
- package/source/views/dashboard/RecordSet-Dashboard-RecordList.js +80 -0
- package/source/views/dashboard/RecordSet-Dashboard-RecordListEntry.js +121 -0
- package/source/views/dashboard/RecordSet-Dashboard-RecordListHeader.js +111 -0
- package/source/views/dashboard/RecordSet-Dashboard-Title.js +67 -0
- package/source/views/dashboard/RecordSet-Dashboard.js +627 -37
- package/source/views/error/RecordSet-Error-NotFound.json +22 -0
- package/source/views/list/RecordSet-List.js +20 -39
- 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-RecordProvider-Base.d.ts +19 -0
- package/types/providers/RecordSet-RecordProvider-Base.d.ts.map +1 -1
- package/types/providers/RecordSet-RecordProvider-MeadowEndpoints.d.ts +38 -5
- package/types/providers/RecordSet-RecordProvider-MeadowEndpoints.d.ts.map +1 -1
- package/types/providers/RecordSet-Router.d.ts.map +1 -1
- package/types/services/RecordsSet-MetaController.d.ts +20 -2
- package/types/services/RecordsSet-MetaController.d.ts.map +1 -1
- package/types/templates/Pict-Template-FilterView.d.ts +18 -0
- package/types/templates/Pict-Template-FilterView.d.ts.map +1 -0
- package/types/views/RecordSet-Filter.d.ts +28 -2
- package/types/views/RecordSet-Filter.d.ts.map +1 -1
- package/types/views/dashboard/RecordSet-Dashboard-HeaderDashboard.d.ts +5 -5
- package/types/views/dashboard/RecordSet-Dashboard-HeaderDashboard.d.ts.map +1 -1
- package/types/views/dashboard/RecordSet-Dashboard-PaginationBottom.d.ts +11 -0
- package/types/views/dashboard/RecordSet-Dashboard-PaginationBottom.d.ts.map +1 -0
- package/types/views/dashboard/RecordSet-Dashboard-PaginationTop.d.ts +11 -0
- package/types/views/dashboard/RecordSet-Dashboard-PaginationTop.d.ts.map +1 -0
- package/types/views/dashboard/RecordSet-Dashboard-RecordList.d.ts +11 -0
- package/types/views/dashboard/RecordSet-Dashboard-RecordList.d.ts.map +1 -0
- package/types/views/dashboard/RecordSet-Dashboard-RecordListEntry.d.ts +11 -0
- package/types/views/dashboard/RecordSet-Dashboard-RecordListEntry.d.ts.map +1 -0
- package/types/views/dashboard/RecordSet-Dashboard-RecordListHeader.d.ts +11 -0
- package/types/views/dashboard/RecordSet-Dashboard-RecordListHeader.d.ts.map +1 -0
- package/types/views/dashboard/RecordSet-Dashboard-Title.d.ts +11 -0
- package/types/views/dashboard/RecordSet-Dashboard-Title.d.ts.map +1 -0
- package/types/views/dashboard/RecordSet-Dashboard.d.ts +38 -0
- package/types/views/dashboard/RecordSet-Dashboard.d.ts.map +1 -1
- package/types/views/list/RecordSet-List.d.ts +0 -1
- package/types/views/list/RecordSet-List.d.ts.map +1 -1
- package/source/views/dashboard/RecordSet-Dashboard-RecordSetDashboard.js +0 -64
|
@@ -10,7 +10,7 @@ const libRecordSetProviderBase = require('./RecordSet-RecordProvider-Base.js');
|
|
|
10
10
|
* Class representing a data change detection provider for Pict dynamic forms.
|
|
11
11
|
* @extends libRecordSetProviderBase
|
|
12
12
|
*/
|
|
13
|
-
class
|
|
13
|
+
class MeadowEndpointsRecordSetProvider extends libRecordSetProviderBase
|
|
14
14
|
{
|
|
15
15
|
/**
|
|
16
16
|
* Creates an instance of RecordSetProvider.
|
|
@@ -26,8 +26,21 @@ class RecordSetProvider extends libRecordSetProviderBase
|
|
|
26
26
|
this.options;
|
|
27
27
|
/** @type {import('fable')} */
|
|
28
28
|
this.fable;
|
|
29
|
-
/** @type {import('
|
|
29
|
+
/** @type {import('pict') & {
|
|
30
|
+
* log: any,
|
|
31
|
+
* services:
|
|
32
|
+
* {
|
|
33
|
+
* PictSectionRecordSet: InstanceType<import('../Pict-Section-RecordSet.js')>,
|
|
34
|
+
* [key: string]: any,
|
|
35
|
+
* },
|
|
36
|
+
* instantiateServiceProviderWithoutRegistration: (hash: String) => any,
|
|
37
|
+
* PictSectionRecordSet: InstanceType<import('../Pict-Section-RecordSet.js')>
|
|
38
|
+
* }} */
|
|
30
39
|
this.pict;
|
|
40
|
+
/** @type {string} */
|
|
41
|
+
this.Hash;
|
|
42
|
+
/** @type {string} */
|
|
43
|
+
this.UUID;
|
|
31
44
|
//TODO: make this typedef better
|
|
32
45
|
/** @type {Record<string, any>} */
|
|
33
46
|
this._Schema = { };
|
|
@@ -359,6 +372,43 @@ class RecordSetProvider extends libRecordSetProviderBase
|
|
|
359
372
|
}
|
|
360
373
|
return this._Schema;
|
|
361
374
|
}
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Abstract decoration method for core records. Subclasses should implement this method to decorate records with additional information.
|
|
378
|
+
*
|
|
379
|
+
* @param {Array<Record<string, any>>} pRecords - The records to decorate.
|
|
380
|
+
* @return {Promise<void>}
|
|
381
|
+
*/
|
|
382
|
+
async decorateCoreRecords(pRecords)
|
|
383
|
+
{
|
|
384
|
+
if (!this.options.RecordDecorationConfiguration)
|
|
385
|
+
{
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
if (!Array.isArray(this.options.RecordDecorationConfiguration))
|
|
389
|
+
{
|
|
390
|
+
this.pict.log.error('RecordDecorationConfiguration is not an array', { RecordDecorationConfiguration: this.options.RecordDecorationConfiguration });
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
this.pict.AppData[this.Hash] = { CoreEntityRecordSubset: pRecords };
|
|
394
|
+
const config = [{ Type: 'SetStateAddress', StateAddress: `AppData[${this.Hash}]` }].concat(this.options.RecordDecorationConfiguration);
|
|
395
|
+
|
|
396
|
+
try
|
|
397
|
+
{
|
|
398
|
+
await new Promise((resolve, reject) => this.pict.EntityProvider.gatherDataFromServer(config, (err) =>
|
|
399
|
+
{
|
|
400
|
+
if (err)
|
|
401
|
+
{
|
|
402
|
+
return reject(err);
|
|
403
|
+
}
|
|
404
|
+
resolve();
|
|
405
|
+
}));
|
|
406
|
+
}
|
|
407
|
+
catch (error)
|
|
408
|
+
{
|
|
409
|
+
this.pict.log.error(`MeadowEndpointsRecordSetProvider: Error gathering data from server for record decoration: ${error.message}`, { Stack: error.stack });
|
|
410
|
+
}
|
|
411
|
+
}
|
|
362
412
|
}
|
|
363
413
|
|
|
364
|
-
module.exports =
|
|
414
|
+
module.exports = MeadowEndpointsRecordSetProvider;
|
|
@@ -40,6 +40,8 @@ class PictRecordSetRouter extends libPictProvider
|
|
|
40
40
|
|
|
41
41
|
addRoutes(pRouter)
|
|
42
42
|
{
|
|
43
|
+
//FIXME: not working
|
|
44
|
+
this.pictRouter.addRoute('/PSRS/404', '{~D:Pict.views[RSP-RecordSet-Error-NotFound].render()~}');
|
|
43
45
|
// TODO: Create some kind of state tracking to see if these routes have already been added
|
|
44
46
|
//this.pictRouter.addRoute('/PSRS/:RecordSet/List/:Begin/:Cap', "{~LV:Record~}");
|
|
45
47
|
this.pict.views['RSP-RecordSet-List'].addRoutes(pRouter);
|
|
@@ -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,8 +27,9 @@ 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;
|
|
32
|
+
this.pict = this.fable;
|
|
31
33
|
/** @type {any} */
|
|
32
34
|
this.log;
|
|
33
35
|
/** @type {any} */
|
|
@@ -45,9 +47,13 @@ class RecordSetMetacontroller extends libFableServiceProviderBase
|
|
|
45
47
|
this.recordSetProviders = {};
|
|
46
48
|
this.recordSetProviderConfigurations = {};
|
|
47
49
|
|
|
48
|
-
this.
|
|
50
|
+
this.dashboardConfigurations = {};
|
|
51
|
+
|
|
49
52
|
this.sessionProviders = [];
|
|
50
53
|
|
|
54
|
+
this.manifestDefinitions = {};
|
|
55
|
+
this.manifests = { Default: this.pict.manifest };
|
|
56
|
+
|
|
51
57
|
this.has_initialized = false;
|
|
52
58
|
}
|
|
53
59
|
|
|
@@ -77,6 +83,15 @@ class RecordSetMetacontroller extends libFableServiceProviderBase
|
|
|
77
83
|
}
|
|
78
84
|
]
|
|
79
85
|
*/
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* @return {Record<string, any>} - The registered configuration for the RecordSet
|
|
89
|
+
*/
|
|
90
|
+
getRecordSetConfiguration(pRecordSet)
|
|
91
|
+
{
|
|
92
|
+
return this.recordSetProviderConfigurations[pRecordSet];
|
|
93
|
+
}
|
|
94
|
+
|
|
80
95
|
loadRecordSetConfiguration(pRecordSetConfiguration)
|
|
81
96
|
{
|
|
82
97
|
if (typeof pRecordSetConfiguration !== 'object')
|
|
@@ -284,6 +299,8 @@ class RecordSetMetacontroller extends libFableServiceProviderBase
|
|
|
284
299
|
this.fable.addProvider('RecordSetLinkManager', {}, providerLinkManager);
|
|
285
300
|
|
|
286
301
|
// Add the subviews internally and externally
|
|
302
|
+
this.pict.addTemplate(require('../templates/Pict-Template-FilterView.js'));
|
|
303
|
+
this.childViews.errorNotFound = this.fable.addView('RSP-RecordSet-Error-NotFound', viewDefinitionRecordSetErrorNotFound);
|
|
287
304
|
this.childViews.list = this.fable.addView('RSP-RecordSet-List', this.options, viewRecordSetList);
|
|
288
305
|
this.childViews.edit = this.fable.addView('RSP-RecordSet-Edit', this.options, viewRecordSetEdit);
|
|
289
306
|
this.childViews.read = this.fable.addView('RSP-RecordSet-Read', this.options, viewRecordSetRead);
|
|
@@ -302,6 +319,22 @@ class RecordSetMetacontroller extends libFableServiceProviderBase
|
|
|
302
319
|
this.loadRecordSetConfigurationArray(this.fable.settings.DefaultRecordSetConfigurations);
|
|
303
320
|
}
|
|
304
321
|
|
|
322
|
+
for (const [ tmpManifestKey, tmpManifest ] of Object.entries(this.fable.settings.Manifests || {}))
|
|
323
|
+
{
|
|
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);
|
|
336
|
+
}
|
|
337
|
+
|
|
305
338
|
this.has_initialized = true;
|
|
306
339
|
|
|
307
340
|
// Load pict-router if it isn't loaded
|
|
@@ -313,6 +346,55 @@ class RecordSetMetacontroller extends libFableServiceProviderBase
|
|
|
313
346
|
|
|
314
347
|
return true;
|
|
315
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
|
+
|
|
316
398
|
}
|
|
317
399
|
|
|
318
400
|
module.exports = RecordSetMetacontroller;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
const libPictTemplate = require('pict-template');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Specialized instruction for rendering the filter view and plumbing in required context.
|
|
5
|
+
*
|
|
6
|
+
* Based on the Pict base {~V:...~} template instruction.
|
|
7
|
+
*/
|
|
8
|
+
class PictTemplateFilterViewInstruction extends libPictTemplate
|
|
9
|
+
{
|
|
10
|
+
/**
|
|
11
|
+
* @param {Object} pFable - The Fable Framework instance
|
|
12
|
+
* @param {Object} pOptions - The options for the service
|
|
13
|
+
* @param {String} pServiceHash - The hash of the service
|
|
14
|
+
*/
|
|
15
|
+
constructor(pFable, pOptions, pServiceHash)
|
|
16
|
+
{
|
|
17
|
+
super(pFable, pOptions, pServiceHash);
|
|
18
|
+
|
|
19
|
+
/** @type {any} */
|
|
20
|
+
this.log;
|
|
21
|
+
|
|
22
|
+
this.addPattern('{~FV:', '~}');
|
|
23
|
+
this.addPattern('{~FilterView:', '~}');
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
if (!('__TemplateOutputCache' in this.pict))
|
|
27
|
+
{
|
|
28
|
+
this.pict.__TemplateOutputCache = {};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Render a template expression, returning a string with the resulting content.
|
|
34
|
+
*
|
|
35
|
+
* @param {string} pTemplateHash - The hash contents of the template (what's between the template start and stop tags)
|
|
36
|
+
* @param {any} pRecord - The json object to be used as the Record for the template render
|
|
37
|
+
* @param {Array<any>} pContextArray - An array of context objects accessible from the template; safe to leave empty
|
|
38
|
+
*
|
|
39
|
+
* @return {string} The rendered template
|
|
40
|
+
*/
|
|
41
|
+
render(pTemplateHash, pRecord, pContextArray)
|
|
42
|
+
{
|
|
43
|
+
let [ tmpViewHash, tmpViewContext ] = pTemplateHash.split(':');
|
|
44
|
+
tmpViewHash = tmpViewHash.trim();
|
|
45
|
+
const tmpRecordSet = pRecord.RecordSet || '';
|
|
46
|
+
if (!tmpRecordSet)
|
|
47
|
+
{
|
|
48
|
+
this.pict.log.error(`Pict: Filter View Template Render: No record set specified in template hash [${pTemplateHash}] for view [${tmpViewHash}]`);
|
|
49
|
+
return '';
|
|
50
|
+
}
|
|
51
|
+
const tmpRecordSetConfiguration = this.pict.PictSectionRecordSet.recordSetProviderConfigurations?.[tmpRecordSet];
|
|
52
|
+
if (!tmpRecordSetConfiguration)
|
|
53
|
+
{
|
|
54
|
+
this.pict.log.error(`Pict: Filter View Template Render: No record set configuration found for [${tmpRecordSet}] in template hash [${pTemplateHash}] for view [${tmpViewHash}]`);
|
|
55
|
+
return '';
|
|
56
|
+
}
|
|
57
|
+
if (tmpViewContext)
|
|
58
|
+
{
|
|
59
|
+
tmpViewContext = tmpViewContext.trim();
|
|
60
|
+
}
|
|
61
|
+
else
|
|
62
|
+
{
|
|
63
|
+
tmpViewContext = 'Default';
|
|
64
|
+
}
|
|
65
|
+
if (!(tmpViewHash in this.pict.views))
|
|
66
|
+
{
|
|
67
|
+
this.log.warn(`Pict: Filter View Template Render: View not found for [${tmpViewHash}]`);
|
|
68
|
+
return '';
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
pRecord = pRecord || {};
|
|
72
|
+
if (!pRecord.RecordSet)
|
|
73
|
+
{
|
|
74
|
+
pRecord.RecordSet = tmpRecordSet;
|
|
75
|
+
}
|
|
76
|
+
if (!pRecord.RecordSetConfiguration)
|
|
77
|
+
{
|
|
78
|
+
pRecord.RecordSetConfiguration = tmpRecordSetConfiguration;
|
|
79
|
+
}
|
|
80
|
+
if (!pRecord.ViewContext)
|
|
81
|
+
{
|
|
82
|
+
pRecord.ViewContext = pRecord.DashboardHash ? `${tmpViewContext}-${pRecord.DashboardHash}` : tmpViewContext;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
let tmpRenderGUID = this.pict.getUUID();
|
|
86
|
+
|
|
87
|
+
/** @type {import('pict-view')} */
|
|
88
|
+
const tmpView = this.pict.views[tmpViewHash];
|
|
89
|
+
|
|
90
|
+
tmpView.render('__Virtual', `__TemplateOutputCache.${tmpRenderGUID}`, pRecord);
|
|
91
|
+
|
|
92
|
+
let tmpResult = this.pict.__TemplateOutputCache[tmpRenderGUID];
|
|
93
|
+
// TODO: Uncomment this when we like how it's working
|
|
94
|
+
//delete this.pict.__TemplateOutputCache[tmpRenderGUID];
|
|
95
|
+
|
|
96
|
+
return tmpResult;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* @param {string} pTemplateHash - The hash contents of the template (what's between the template start and stop tags)
|
|
101
|
+
* @param {any} pRecord - The json object to be used as the Record for the template
|
|
102
|
+
* @param {(pError?: Error, pResult?: string) => void} fCallback - The callback function to call with the result
|
|
103
|
+
* @param {Array<any>} pContextArray - An array of context objects accessible from the template; safe to leave empty
|
|
104
|
+
* @return {void}
|
|
105
|
+
*/
|
|
106
|
+
renderAsync(pTemplateHash, pRecord, fCallback, pContextArray)
|
|
107
|
+
{
|
|
108
|
+
let [ tmpViewHash, tmpViewContext ] = pTemplateHash.split(':');
|
|
109
|
+
tmpViewHash = tmpViewHash.trim();
|
|
110
|
+
const tmpRecordSet = pRecord.RecordSet || '';
|
|
111
|
+
if (!tmpRecordSet)
|
|
112
|
+
{
|
|
113
|
+
this.pict.log.error(`Pict: Filter View Template Render: No record set specified in template hash [${pTemplateHash}] for view [${tmpViewHash}]`);
|
|
114
|
+
return fCallback(null, '');
|
|
115
|
+
}
|
|
116
|
+
const tmpRecordSetConfiguration = this.pict.PictSectionRecordSet.recordSetProviderConfigurations?.[tmpRecordSet];
|
|
117
|
+
if (!tmpRecordSetConfiguration)
|
|
118
|
+
{
|
|
119
|
+
this.pict.log.error(`Pict: Filter View Template Render: No record set configuration found for [${tmpRecordSet}] in template hash [${pTemplateHash}] for view [${tmpViewHash}]`);
|
|
120
|
+
return fCallback(null, '');
|
|
121
|
+
}
|
|
122
|
+
if (tmpViewContext)
|
|
123
|
+
{
|
|
124
|
+
tmpViewContext = tmpViewContext.trim();
|
|
125
|
+
}
|
|
126
|
+
else
|
|
127
|
+
{
|
|
128
|
+
tmpViewContext = 'Default';
|
|
129
|
+
}
|
|
130
|
+
if (!(tmpViewHash in this.pict.views))
|
|
131
|
+
{
|
|
132
|
+
this.log.warn(`Pict: Filter View Template Render: View not found for [${tmpViewHash}]`);
|
|
133
|
+
return fCallback(null, '');
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
pRecord = pRecord || {};
|
|
137
|
+
if (!pRecord.RecordSet)
|
|
138
|
+
{
|
|
139
|
+
pRecord.RecordSet = tmpRecordSet;
|
|
140
|
+
}
|
|
141
|
+
if (!pRecord.RecordSetConfiguration)
|
|
142
|
+
{
|
|
143
|
+
pRecord.RecordSetConfiguration = tmpRecordSetConfiguration;
|
|
144
|
+
}
|
|
145
|
+
if (!pRecord.ViewContext)
|
|
146
|
+
{
|
|
147
|
+
pRecord.ViewContext = pRecord.DashboardHash ? `${tmpViewContext}-${pRecord.DashboardHash}` : tmpViewContext;
|
|
148
|
+
}
|
|
149
|
+
let tmpRenderGUID = this.pict.getUUID();
|
|
150
|
+
|
|
151
|
+
/** @type {import('pict-view')} */
|
|
152
|
+
const tmpView = this.pict.views[tmpViewHash];
|
|
153
|
+
|
|
154
|
+
return tmpView.renderAsync('__Virtual', `__TemplateOutputCache.${tmpRenderGUID}`, pRecord,
|
|
155
|
+
(pError, pResult) =>
|
|
156
|
+
{
|
|
157
|
+
if (pError)
|
|
158
|
+
{
|
|
159
|
+
this.log.warn(`Pict: Filter View Template Render: Error rendering view [${tmpViewHash}]`, pError);
|
|
160
|
+
return fCallback(pError, '');
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
let tmpResult = this.pict.__TemplateOutputCache[tmpRenderGUID];
|
|
164
|
+
// TODO: Uncomment this when we like how it's working
|
|
165
|
+
//delete this.pict.__TemplateOutputCache[tmpRenderGUID];
|
|
166
|
+
|
|
167
|
+
return fCallback(null, tmpResult);
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
module.exports = PictTemplateFilterViewInstruction;
|
|
@@ -32,7 +32,7 @@ const _DEFAULT_CONFIGURATION_SUBSET_Filter =
|
|
|
32
32
|
Template: /*html*/`
|
|
33
33
|
<!-- DefaultPackage pict view template: [PRSP-SUBSET-Filter-Template] -->
|
|
34
34
|
<section id="PRSP_Filter_Container">
|
|
35
|
-
<form id="PRSP_Filter_Form" onsubmit="_Pict.views['PRSP-Filters'].handleSearch(event)">
|
|
35
|
+
<form id="PRSP_Filter_Form" onsubmit="_Pict.views['PRSP-Filters'].handleSearch(event, '{~D:Record.RecordSet~}', '{~D:Record.ViewContext~}'); return false;">
|
|
36
36
|
{~T:PRSP-SUBSET-Filter-Template-Input-Fieldset~}
|
|
37
37
|
{~T:PRSP-SUBSET-Filter-Template-Button-Fieldset~}
|
|
38
38
|
</form>
|
|
@@ -56,7 +56,7 @@ const _DEFAULT_CONFIGURATION_SUBSET_Filter =
|
|
|
56
56
|
Template: /*html*/`
|
|
57
57
|
<!-- DefaultPackage pict view template: [PRSP-SUBSET-Filter-Template-Button-Fieldset] -->
|
|
58
58
|
<fieldset>
|
|
59
|
-
<button type="button" id="PRSP_Filter_Button_Reset" onclick="_Pict.views['PRSP-Filters'].handleReset(event)">Reset</button>
|
|
59
|
+
<button type="button" id="PRSP_Filter_Button_Reset" onclick="_Pict.views['PRSP-Filters'].handleReset(event, '{~D:Record.RecordSet~}', '{~D:Record.ViewContext~}')">Reset</button>
|
|
60
60
|
<button type="submit" id="PRSP_Filter_Button_Apply">Apply</button>
|
|
61
61
|
</fieldset>
|
|
62
62
|
<!-- DefaultPackage end view template: [PRSP-SUBSET-Filter-Template-Button-Fieldset] -->
|
|
@@ -83,20 +83,58 @@ class viewRecordSetSUBSETFilter extends libPictView
|
|
|
83
83
|
{
|
|
84
84
|
let tmpOptions = Object.assign({}, _DEFAULT_CONFIGURATION_SUBSET_Filter, pOptions);
|
|
85
85
|
super(pFable, tmpOptions, pServiceHash);
|
|
86
|
+
/** @type {import('fable') & import('pict') & { PictSectionRecordSet: import('../Pict-Section-RecordSet.js') }} */
|
|
87
|
+
this.pict;
|
|
86
88
|
}
|
|
87
89
|
|
|
88
|
-
|
|
90
|
+
/**
|
|
91
|
+
* @param {Event} pEvent - The DOM event that triggered the search
|
|
92
|
+
* @param {string} pRecordSet - The record set being filtered
|
|
93
|
+
* @param {string} pViewContext - The view context for the filter (ex. List, Dashboard)
|
|
94
|
+
*/
|
|
95
|
+
handleSearch(pEvent, pRecordSet, pViewContext)
|
|
89
96
|
{
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
this.pict.
|
|
97
|
+
pEvent.preventDefault(); // don't submit the form
|
|
98
|
+
pEvent.stopPropagation();
|
|
99
|
+
const tmpSearchString = this.pict.ContentAssignment.readContent(`input[name="filter"]`);
|
|
100
|
+
this.performSearch(pRecordSet, pViewContext, tmpSearchString ? String(tmpSearchString) : ' ');
|
|
93
101
|
}
|
|
94
102
|
|
|
95
|
-
|
|
103
|
+
/**
|
|
104
|
+
* @param {string} pRecordSet - The record set being filtered
|
|
105
|
+
* @param {string} pViewContext - The view context for the filter (ex. List, Dashboard)
|
|
106
|
+
* @param {string} [pFilterString] - The filter string to apply, defaults to a single space if not provided
|
|
107
|
+
*/
|
|
108
|
+
performSearch(pRecordSet, pViewContext, pFilterString)
|
|
96
109
|
{
|
|
97
|
-
|
|
110
|
+
const tmpPictRouter = this.pict.providers.PictRouter;
|
|
111
|
+
const tmpProviderConfiguration = this.pict.PictSectionRecordSet.recordSetProviderConfigurations[pRecordSet];
|
|
112
|
+
let filterExpr = '%20';
|
|
113
|
+
if (pFilterString)
|
|
114
|
+
{
|
|
115
|
+
/** @type {Array<string>} */
|
|
116
|
+
const searchFields = tmpProviderConfiguration?.SearchFields ?? [ 'Name' ];
|
|
117
|
+
filterExpr = searchFields.map((filterField) => `FBVOR~${filterField}~LK~${encodeURIComponent(`%${pFilterString}%`)}`).join('~');
|
|
118
|
+
}
|
|
119
|
+
let tmpURLTemplate = tmpProviderConfiguration[`RecordSetFilterURLTemplate-${pViewContext}`] || tmpProviderConfiguration[`RecordSetFilterURLTemplate-Default`];
|
|
120
|
+
const tmpURL = this.pict.parseTemplate(tmpURLTemplate,
|
|
121
|
+
{
|
|
122
|
+
RecordSet: pRecordSet,
|
|
123
|
+
FilterString: filterExpr,
|
|
124
|
+
});
|
|
125
|
+
tmpPictRouter.router.navigate(tmpURL);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* @param {Event} pEvent - The DOM event that triggered the search
|
|
130
|
+
* @param {string} pRecordSet - The record set being filtered
|
|
131
|
+
* @param {string} pViewContext - The view context for the filter (ex. List, Dashboard)
|
|
132
|
+
*/
|
|
133
|
+
handleReset(pEvent, pRecordSet, pViewContext)
|
|
134
|
+
{
|
|
135
|
+
pEvent.preventDefault();
|
|
98
136
|
this.pict.ContentAssignment.assignContent('input[name="filter"]', '');
|
|
99
|
-
this.
|
|
137
|
+
this.performSearch(pRecordSet, pViewContext);
|
|
100
138
|
}
|
|
101
139
|
}
|
|
102
140
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
const libPictView = require('pict-view');
|
|
2
2
|
|
|
3
3
|
/** @type {Record<string, any>} */
|
|
4
|
-
const
|
|
4
|
+
const _DEFAULT_CONFIGURATION_Dashboard_HeaderList =
|
|
5
5
|
{
|
|
6
|
-
ViewIdentifier: 'PRSP-Dashboard-
|
|
6
|
+
ViewIdentifier: 'PRSP-Dashboard-HeaderList',
|
|
7
7
|
|
|
8
|
-
DefaultRenderable: '
|
|
9
|
-
DefaultDestinationAddress: '#
|
|
8
|
+
DefaultRenderable: 'PRSP_Renderable_HeaderList',
|
|
9
|
+
DefaultDestinationAddress: '#PRSP_HeaderList_Container',
|
|
10
10
|
DefaultTemplateRecordAddress: false,
|
|
11
11
|
|
|
12
12
|
// If this is set to true, when the App initializes this will.
|
|
@@ -28,37 +28,37 @@ const _DEFAULT_CONFIGURATION_Dashboard_HeaderDashboard =
|
|
|
28
28
|
Templates:
|
|
29
29
|
[
|
|
30
30
|
{
|
|
31
|
-
Hash: 'PRSP-Dashboard-
|
|
31
|
+
Hash: 'PRSP-Dashboard-HeaderList-Template',
|
|
32
32
|
Template: /*html*/`
|
|
33
|
-
<!-- DefaultPackage pict view template: [PRSP-Dashboard-
|
|
34
|
-
<!-- DefaultPackage end view template:
|
|
33
|
+
<!-- DefaultPackage pict view template: [PRSP-Dashboard-HeaderList-Template] -->
|
|
34
|
+
<!-- DefaultPackage end view template: [PRSP-Dashboard-HeaderList-Template] -->
|
|
35
35
|
`
|
|
36
|
-
}
|
|
36
|
+
},
|
|
37
37
|
],
|
|
38
38
|
|
|
39
39
|
Renderables:
|
|
40
40
|
[
|
|
41
41
|
{
|
|
42
|
-
RenderableHash: '
|
|
43
|
-
TemplateHash: 'PRSP-Dashboard-
|
|
44
|
-
DestinationAddress: '#
|
|
42
|
+
RenderableHash: 'PRSP_Renderable_HeaderList',
|
|
43
|
+
TemplateHash: 'PRSP-Dashboard-HeaderList-Template',
|
|
44
|
+
DestinationAddress: '#PRSP_HeaderList_Container',
|
|
45
45
|
RenderMethod: 'replace'
|
|
46
|
-
}
|
|
46
|
+
},
|
|
47
47
|
],
|
|
48
48
|
|
|
49
|
-
Manifests: {}
|
|
49
|
+
Manifests: {},
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
-
class
|
|
52
|
+
class viewRecordSetListHeaderList extends libPictView
|
|
53
53
|
{
|
|
54
54
|
constructor(pFable, pOptions, pServiceHash)
|
|
55
55
|
{
|
|
56
|
-
let tmpOptions = Object.assign({},
|
|
56
|
+
let tmpOptions = Object.assign({}, _DEFAULT_CONFIGURATION_Dashboard_HeaderList, pOptions);
|
|
57
57
|
super(pFable, tmpOptions, pServiceHash);
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
module.exports =
|
|
61
|
+
module.exports = viewRecordSetListHeaderList;
|
|
62
62
|
|
|
63
|
-
module.exports.default_configuration =
|
|
63
|
+
module.exports.default_configuration = _DEFAULT_CONFIGURATION_Dashboard_HeaderList;
|
|
64
64
|
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
const libPictView = require('pict-view');
|
|
2
|
+
|
|
3
|
+
/** @type {Record<string, any>} */
|
|
4
|
+
const _DEFAULT_CONFIGURATION_List_PaginationBottom = (
|
|
5
|
+
{
|
|
6
|
+
ViewIdentifier: 'PRSP-Dashboard-PaginationBottom',
|
|
7
|
+
|
|
8
|
+
DefaultRenderable: 'PRSP_Renderable_PaginationBottom',
|
|
9
|
+
DefaultDestinationAddress: '#PRSP_PaginationBottom_Container',
|
|
10
|
+
DefaultTemplateRecordAddress: false,
|
|
11
|
+
|
|
12
|
+
// If this is set to true, when the App initializes this will.
|
|
13
|
+
// While the App initializes, initialize will be called.
|
|
14
|
+
AutoInitialize: false,
|
|
15
|
+
AutoInitializeOrdinal: 0,
|
|
16
|
+
|
|
17
|
+
// If this is set to true, when the App autorenders (on load) this will.
|
|
18
|
+
// After the App initializes, render will be called.
|
|
19
|
+
AutoRender: false,
|
|
20
|
+
AutoRenderOrdinal: 0,
|
|
21
|
+
|
|
22
|
+
AutoSolveWithApp: false,
|
|
23
|
+
AutoSolveOrdinal: 0,
|
|
24
|
+
|
|
25
|
+
CSS: false,
|
|
26
|
+
CSSPriority: 500,
|
|
27
|
+
|
|
28
|
+
Templates:
|
|
29
|
+
[
|
|
30
|
+
{
|
|
31
|
+
Hash: 'PRSP-Dashboard-PaginationBottom-Template',
|
|
32
|
+
Template: /*html*/`
|
|
33
|
+
<!-- DefaultPackage pict view template: [PRSP-Dashboard-PaginationBottom-Template] -->
|
|
34
|
+
<nav id="RSP_Lower_Pagination_Container">
|
|
35
|
+
{~T:PRSP-Dashboard-Pagination-Template-Description~}
|
|
36
|
+
{~T:PRSP-Dashboard-Pagination-Template-Buttons~}
|
|
37
|
+
</nav>
|
|
38
|
+
<!-- DefaultPackage end view template: [PRSP-Dashboard-PaginationBottom-Template] -->
|
|
39
|
+
`
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
|
|
43
|
+
Renderables:
|
|
44
|
+
[
|
|
45
|
+
{
|
|
46
|
+
RenderableHash: 'PRSP_Renderable_PaginationBottom',
|
|
47
|
+
TemplateHash: 'PRSP-Dashboard-PaginationBottom-Template',
|
|
48
|
+
DestinationAddress: '#PRSP_PaginationBottom_Container',
|
|
49
|
+
RenderMethod: 'replace'
|
|
50
|
+
}
|
|
51
|
+
],
|
|
52
|
+
|
|
53
|
+
Manifests: {}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
class viewRecordSetListPaginationBottom extends libPictView
|
|
57
|
+
{
|
|
58
|
+
constructor(pFable, pOptions, pServiceHash)
|
|
59
|
+
{
|
|
60
|
+
let tmpOptions = Object.assign({}, _DEFAULT_CONFIGURATION_List_PaginationBottom, pOptions);
|
|
61
|
+
super(pFable, tmpOptions, pServiceHash);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
module.exports = viewRecordSetListPaginationBottom;
|
|
66
|
+
|
|
67
|
+
module.exports.default_configuration = _DEFAULT_CONFIGURATION_List_PaginationBottom;
|
|
68
|
+
|