pict-section-recordset 1.0.16 → 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 +163 -30
- 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 +2 -1
- 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 +9 -5
- 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
|
@@ -56,10 +56,6 @@ const _DEFAULT_CONFIGURATION__Dashboard = (
|
|
|
56
56
|
Template: /*html*/`
|
|
57
57
|
<!-- DefaultPackage end view template: [PRSP-Dashboard-Template] -->
|
|
58
58
|
`
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
Hash: 'PRSP-Dashboard-Filter-URL',
|
|
62
|
-
Template: /*html*/`#/PSRS/{~D:Record.Filter.RecordSet~}/DashboardFilteredTo/{~D:Record.Filter.FilterString~}`
|
|
63
59
|
}
|
|
64
60
|
],
|
|
65
61
|
|
|
@@ -98,8 +94,13 @@ class viewRecordSetDashboard extends libPictRecordSetRecordView
|
|
|
98
94
|
{
|
|
99
95
|
if (typeof(pRoutePayload) != 'object')
|
|
100
96
|
{
|
|
97
|
+
return;
|
|
101
98
|
throw new Error(`Pict RecordSet List view route handler called with invalid route payload.`);
|
|
102
99
|
}
|
|
100
|
+
if (!pRoutePayload.data || !pRoutePayload.data.RecordSet)
|
|
101
|
+
{
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
103
104
|
|
|
104
105
|
//_Pict.PictSectionRecordSet.recordSetProviderConfigurations['Book'], 'RSP-Provider-Book'
|
|
105
106
|
// FIXME: Not in love with this but good enough to start.
|
|
@@ -109,6 +110,12 @@ class viewRecordSetDashboard extends libPictRecordSetRecordView
|
|
|
109
110
|
// return false;
|
|
110
111
|
// }
|
|
111
112
|
const tmpProviderConfiguration = this.pict.PictSectionRecordSet.recordSetProviderConfigurations[pRoutePayload.data.RecordSet];
|
|
113
|
+
if (!tmpProviderConfiguration)
|
|
114
|
+
{
|
|
115
|
+
this.pict.log.error(`RecordSetDashboard: No record set configuration found for ${pRoutePayload.data.RecordSet}. List Render failed.`);
|
|
116
|
+
this.fable.providers.RecordSetRouter.pictRouter.navigate('/PSRS/404');
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
112
119
|
const tmpProviderHash = `RSP-Provider-${pRoutePayload.data.RecordSet}`;
|
|
113
120
|
|
|
114
121
|
const tmpFilterString = pRoutePayload.data.FilterString || '';
|
|
@@ -116,7 +123,11 @@ class viewRecordSetDashboard extends libPictRecordSetRecordView
|
|
|
116
123
|
const tmpOffset = pRoutePayload.data.Offset ? pRoutePayload.data.Offset : 0;
|
|
117
124
|
const tmpPageSize = pRoutePayload.data.PageSize ? pRoutePayload.data.PageSize : 100;
|
|
118
125
|
|
|
119
|
-
|
|
126
|
+
if (pRoutePayload.data.DashboardHash)
|
|
127
|
+
{
|
|
128
|
+
return this.renderSpecificDashboard(pRoutePayload.data.DashboardHash, tmpProviderConfiguration, tmpProviderHash, tmpFilterString, tmpOffset, tmpPageSize);
|
|
129
|
+
}
|
|
130
|
+
return this.renderDashboard(tmpProviderConfiguration, tmpProviderHash, tmpFilterString, tmpOffset, tmpPageSize);
|
|
120
131
|
}
|
|
121
132
|
|
|
122
133
|
/**
|
|
@@ -124,11 +135,17 @@ class viewRecordSetDashboard extends libPictRecordSetRecordView
|
|
|
124
135
|
*/
|
|
125
136
|
addRoutes(pPictRouter)
|
|
126
137
|
{
|
|
127
|
-
pPictRouter.router.on('/PSRS/:RecordSet/
|
|
128
|
-
pPictRouter.router.on('/PSRS/:RecordSet/
|
|
138
|
+
pPictRouter.router.on('/PSRS/:RecordSet/Dashboard/FilteredTo/:FilterString/:Offset/:PageSize', this.handleRecordSetDashboardRoute.bind(this));
|
|
139
|
+
pPictRouter.router.on('/PSRS/:RecordSet/Dashboard/FilteredTo/:FilterString', this.handleRecordSetDashboardRoute.bind(this));
|
|
129
140
|
pPictRouter.router.on('/PSRS/:RecordSet/Dashboard/:Offset/:PageSize', this.handleRecordSetDashboardRoute.bind(this));
|
|
130
141
|
pPictRouter.router.on('/PSRS/:RecordSet/Dashboard/:Offset', this.handleRecordSetDashboardRoute.bind(this));
|
|
131
142
|
pPictRouter.router.on('/PSRS/:RecordSet/Dashboard', this.handleRecordSetDashboardRoute.bind(this));
|
|
143
|
+
|
|
144
|
+
pPictRouter.router.on('/PSRS/:RecordSet/SpecificDashboard/:DashboardHash/FilteredTo/:FilterString/:Offset/:PageSize', this.handleRecordSetDashboardRoute.bind(this));
|
|
145
|
+
pPictRouter.router.on('/PSRS/:RecordSet/SpecificDashboard/:DashboardHash/FilteredTo/:FilterString', this.handleRecordSetDashboardRoute.bind(this));
|
|
146
|
+
pPictRouter.router.on('/PSRS/:RecordSet/SpecificDashboard/:DashboardHash/:Offset/:PageSize', this.handleRecordSetDashboardRoute.bind(this));
|
|
147
|
+
pPictRouter.router.on('/PSRS/:RecordSet/SpecificDashboard/:DashboardHash/:Offset', this.handleRecordSetDashboardRoute.bind(this));
|
|
148
|
+
pPictRouter.router.on('/PSRS/:RecordSet/SpecificDashboard/:DashboardHash', this.handleRecordSetDashboardRoute.bind(this));
|
|
132
149
|
pPictRouter.router.resolve();
|
|
133
150
|
return true;
|
|
134
151
|
}
|
|
@@ -165,8 +182,13 @@ class viewRecordSetDashboard extends libPictRecordSetRecordView
|
|
|
165
182
|
if (this.excludedByDefaultCells.includes(tmpColumn) === false)
|
|
166
183
|
{
|
|
167
184
|
pRecordListData.TableCells.push({
|
|
168
|
-
|
|
169
|
-
|
|
185
|
+
Key: tmpColumn,
|
|
186
|
+
DisplayName: tmpProperties?.[tmpColumn].title || tmpColumn,
|
|
187
|
+
ManifestHash: 'Default',
|
|
188
|
+
PictDashboard:
|
|
189
|
+
{
|
|
190
|
+
ValueTemplate: '{~DVBK:Record.Payload:Record.Data.Key~}',
|
|
191
|
+
},
|
|
170
192
|
});
|
|
171
193
|
}
|
|
172
194
|
}
|
|
@@ -174,18 +196,251 @@ class viewRecordSetDashboard extends libPictRecordSetRecordView
|
|
|
174
196
|
return pRecordListData;
|
|
175
197
|
}
|
|
176
198
|
|
|
177
|
-
|
|
199
|
+
/**
|
|
200
|
+
* @param {string} pDashboardHash
|
|
201
|
+
* @param {Record<string, any>} pRecordSetConfiguration
|
|
202
|
+
* @param {string} pProviderHash
|
|
203
|
+
* @param {string} pFilterString
|
|
204
|
+
* @param {number} pOffset
|
|
205
|
+
* @param {number} pPageSize
|
|
206
|
+
*
|
|
207
|
+
* @return {Promise<void>}
|
|
208
|
+
*/
|
|
209
|
+
async renderSpecificDashboard(pDashboardHash, pRecordSetConfiguration, pProviderHash, pFilterString, pOffset, pPageSize)
|
|
210
|
+
{
|
|
211
|
+
if (!pRecordSetConfiguration)
|
|
212
|
+
{
|
|
213
|
+
this.pict.log.error(`RecordSetDashboard: No record set configuration found for ${pDashboardHash}. List Render failed.`);
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
// Get the records
|
|
217
|
+
if (!(pProviderHash in this.pict.providers))
|
|
218
|
+
{
|
|
219
|
+
this.pict.log.error(`RecordSetDashboard: No provider found for ${pProviderHash} in ${pRecordSetConfiguration.RecordSet}. List Render failed.`);
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
let tmpManifest;
|
|
224
|
+
if (pDashboardHash)
|
|
225
|
+
{
|
|
226
|
+
tmpManifest = this.pict.PictSectionRecordSet.manifestDefinitions[pDashboardHash];
|
|
227
|
+
}
|
|
228
|
+
let tmpTitle = pRecordSetConfiguration.Title || pRecordSetConfiguration.RecordSet;
|
|
229
|
+
if (tmpManifest && tmpManifest.TitleTemplate)
|
|
230
|
+
{
|
|
231
|
+
tmpTitle = this.pict.parseTemplate(tmpManifest.TitleTemplate, pRecordSetConfiguration);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
let tmpRecordDashboardData =
|
|
235
|
+
{
|
|
236
|
+
"Title": tmpTitle,
|
|
237
|
+
|
|
238
|
+
"RecordSet": pRecordSetConfiguration.RecordSet,
|
|
239
|
+
"RecordSetConfiguration": pRecordSetConfiguration,
|
|
240
|
+
|
|
241
|
+
"RenderDestination": this.options.DefaultDestinationAddress,
|
|
242
|
+
|
|
243
|
+
"FilterString": pFilterString ? encodeURIComponent(pFilterString) : undefined,
|
|
244
|
+
|
|
245
|
+
"Records": { "Records": [] },
|
|
246
|
+
"TotalRecordCount": { "Count": -1 },
|
|
247
|
+
|
|
248
|
+
"Offset": pOffset || 0,
|
|
249
|
+
"PageSize": pPageSize || 100,
|
|
250
|
+
"DashboardHash": pDashboardHash,
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
// TODO: There are still problems with the way these have nested data. Discuss how we might move that around
|
|
254
|
+
// Fetch the records
|
|
255
|
+
tmpRecordDashboardData.Records = await this.pict.providers[pProviderHash].getDecoratedRecords(tmpRecordDashboardData);
|
|
256
|
+
// Get the total record count
|
|
257
|
+
tmpRecordDashboardData.TotalRecordCount = await this.pict.providers[pProviderHash].getRecordSetCount(tmpRecordDashboardData);
|
|
258
|
+
// Get the record schema
|
|
259
|
+
tmpRecordDashboardData.RecordSchema = await this.pict.providers[pProviderHash].getRecordSchema();
|
|
260
|
+
|
|
261
|
+
// TODO: This should be coming from the schema but that can come after we discuss how we deal with default routing
|
|
262
|
+
tmpRecordDashboardData.GUIDAddress = `GUID${this.pict.providers[pProviderHash].options.Entity}`;
|
|
263
|
+
|
|
264
|
+
// Get the "page end record number" for the current page (e.g. for messaging like Record 700 to 800 of 75,000)
|
|
265
|
+
tmpRecordDashboardData.PageEnd = parseInt(tmpRecordDashboardData.Offset) + tmpRecordDashboardData.Records.Records.length;
|
|
266
|
+
|
|
267
|
+
// Compute the number of pages total
|
|
268
|
+
tmpRecordDashboardData.PageCount = Math.ceil(tmpRecordDashboardData.TotalRecordCount.Count / tmpRecordDashboardData.PageSize);
|
|
269
|
+
|
|
270
|
+
// Generate each page's links.
|
|
271
|
+
// TODO: This is fast and cool; any reason not to?
|
|
272
|
+
// Get "bookmarks" as references to the array of page links.
|
|
273
|
+
tmpRecordDashboardData.PageLinkBookmarks = (
|
|
274
|
+
{
|
|
275
|
+
Current: Math.floor(tmpRecordDashboardData.Offset / tmpRecordDashboardData.PageSize)
|
|
276
|
+
});
|
|
277
|
+
tmpRecordDashboardData.PageLinks = [];
|
|
278
|
+
for (let i = 0; i < tmpRecordDashboardData.PageCount; i++)
|
|
279
|
+
{
|
|
280
|
+
if (tmpRecordDashboardData.FilterString)
|
|
281
|
+
{
|
|
282
|
+
tmpRecordDashboardData.PageLinks.push(
|
|
283
|
+
{
|
|
284
|
+
Page: i + 1,
|
|
285
|
+
RelativeOffset: i - tmpRecordDashboardData.PageLinkBookmarks.Current,
|
|
286
|
+
URL: `#/PSRS/${tmpRecordDashboardData.RecordSet}/SpecificDashboard/${pDashboardHash}/FilteredTo/${tmpRecordDashboardData.FilterString}/${i * tmpRecordDashboardData.PageSize}/${tmpRecordDashboardData.PageSize}`
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
else
|
|
290
|
+
{
|
|
291
|
+
tmpRecordDashboardData.PageLinks.push(
|
|
292
|
+
{
|
|
293
|
+
Page: i + 1,
|
|
294
|
+
RelativeOffset: i - tmpRecordDashboardData.PageLinkBookmarks.Current,
|
|
295
|
+
URL: `#/PSRS/${tmpRecordDashboardData.RecordSet}/SpecificDashboard/${pDashboardHash}/${i * tmpRecordDashboardData.PageSize}/${tmpRecordDashboardData.PageSize}`
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
//FIXME: short-term workaround to not blow up the tempplate rendering with way too many links
|
|
301
|
+
const linkRangeStart = Math.max(0, tmpRecordDashboardData.PageLinkBookmarks.Current - 10);
|
|
302
|
+
const linkRangeEnd = Math.min(tmpRecordDashboardData.PageLinks.length, tmpRecordDashboardData.PageLinkBookmarks.Current + 10);
|
|
303
|
+
tmpRecordDashboardData.PageLinksLimited = tmpRecordDashboardData.PageLinks.slice(linkRangeStart, linkRangeEnd);
|
|
304
|
+
if (linkRangeStart > 0)
|
|
305
|
+
{
|
|
306
|
+
if (tmpRecordDashboardData.FilterString)
|
|
307
|
+
{
|
|
308
|
+
tmpRecordDashboardData.PageLinksLimited.unshift(
|
|
309
|
+
{
|
|
310
|
+
Page: 1,
|
|
311
|
+
RelativeOffset: -tmpRecordDashboardData.PageLinkBookmarks.Current,
|
|
312
|
+
URL: `#/PSRS/${tmpRecordDashboardData.RecordSet}/SpecificDashboard/${pDashboardHash}/FilteredTo/${tmpRecordDashboardData.FilterString}/${tmpRecordDashboardData.PageSize}/${tmpRecordDashboardData.PageSize}`
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
else
|
|
316
|
+
{
|
|
317
|
+
tmpRecordDashboardData.PageLinksLimited.unshift(
|
|
318
|
+
{
|
|
319
|
+
Page: 1,
|
|
320
|
+
RelativeOffset: -tmpRecordDashboardData.PageLinkBookmarks.Current,
|
|
321
|
+
URL: `#/PSRS/${tmpRecordDashboardData.RecordSet}/SpecificDashboard/${pDashboardHash}/0/${tmpRecordDashboardData.PageSize}`
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
if (linkRangeEnd < tmpRecordDashboardData.PageLinks.length)
|
|
326
|
+
{
|
|
327
|
+
if (tmpRecordDashboardData.FilterString)
|
|
328
|
+
{
|
|
329
|
+
tmpRecordDashboardData.PageLinksLimited.push(
|
|
330
|
+
{
|
|
331
|
+
Page: tmpRecordDashboardData.PageCount,
|
|
332
|
+
RelativeOffset: (tmpRecordDashboardData.PageCount - 1) - tmpRecordDashboardData.PageLinkBookmarks.Current,
|
|
333
|
+
URL: `#/PSRS/${tmpRecordDashboardData.RecordSet}/SpecificDashboard/${pDashboardHash}/FilteredTo/${tmpRecordDashboardData.FilterString}/${(tmpRecordDashboardData.PageCount - 1) * tmpRecordDashboardData.PageSize}/${tmpRecordDashboardData.PageSize}`
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
else
|
|
337
|
+
{
|
|
338
|
+
tmpRecordDashboardData.PageLinksLimited.push(
|
|
339
|
+
{
|
|
340
|
+
Page: tmpRecordDashboardData.PageCount,
|
|
341
|
+
RelativeOffset: (tmpRecordDashboardData.PageCount - 1) - tmpRecordDashboardData.PageLinkBookmarks.Current,
|
|
342
|
+
URL: `#/PSRS/${tmpRecordDashboardData.RecordSet}/SpecificDashboard/${pDashboardHash}/${(tmpRecordDashboardData.PageCount - 1) * tmpRecordDashboardData.PageSize}/${tmpRecordDashboardData.PageSize}`
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
tmpRecordDashboardData.PageLinkBookmarks.Previous = tmpRecordDashboardData.PageLinkBookmarks.Current - 1;
|
|
348
|
+
tmpRecordDashboardData.PageLinkBookmarks.Next = tmpRecordDashboardData.PageLinkBookmarks.Current + 1;
|
|
349
|
+
tmpRecordDashboardData.PageLinkBookmarks.ShowPreviousLink = true;
|
|
350
|
+
tmpRecordDashboardData.PageLinkBookmarks.ShowNextLink = true;
|
|
351
|
+
if (tmpRecordDashboardData.PageLinkBookmarks.Previous < 0)
|
|
352
|
+
{
|
|
353
|
+
tmpRecordDashboardData.PageLinkBookmarks.PreviousLink = false;
|
|
354
|
+
tmpRecordDashboardData.PageLinkBookmarks.ShowPreviousLink = false;
|
|
355
|
+
}
|
|
356
|
+
else
|
|
357
|
+
{
|
|
358
|
+
tmpRecordDashboardData.PageLinkBookmarks.PreviousLink = tmpRecordDashboardData.PageLinks[tmpRecordDashboardData.PageLinkBookmarks.Previous];
|
|
359
|
+
}
|
|
360
|
+
if (tmpRecordDashboardData.PageLinkBookmarks.Next >= tmpRecordDashboardData.PageLinks.length)
|
|
361
|
+
{
|
|
362
|
+
tmpRecordDashboardData.PageLinkBookmarks.NextLink = false;
|
|
363
|
+
tmpRecordDashboardData.PageLinkBookmarks.ShowNextLink = false;
|
|
364
|
+
}
|
|
365
|
+
else
|
|
366
|
+
{
|
|
367
|
+
tmpRecordDashboardData.PageLinkBookmarks.NextLink = tmpRecordDashboardData.PageLinks[tmpRecordDashboardData.PageLinkBookmarks.Next];
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
if (pDashboardHash)
|
|
371
|
+
{
|
|
372
|
+
tmpRecordDashboardData.TableCells = tmpManifest?.TableCells;
|
|
373
|
+
}
|
|
374
|
+
if (!tmpRecordDashboardData.TableCells)
|
|
375
|
+
{
|
|
376
|
+
tmpRecordDashboardData.TableCells = [];
|
|
377
|
+
// Put code here to preprocess columns into other data parts.
|
|
378
|
+
/*
|
|
379
|
+
"RecordSetListManifestOnly": false,
|
|
380
|
+
|
|
381
|
+
"RecordSetListManifests": [ "Bestsellers", "Underdogs", "NewReleases" ],
|
|
382
|
+
"RecordSetDashboardManifests": [ "Bestsellers" ],
|
|
383
|
+
*/
|
|
384
|
+
if (tmpRecordDashboardData.RecordSetConfiguration.hasOwnProperty('RecordSetListColumns'))
|
|
385
|
+
{
|
|
386
|
+
tmpRecordDashboardData.TableCells = tmpRecordDashboardData.RecordSetConfiguration.RecordSetListColumns;
|
|
387
|
+
}
|
|
388
|
+
else
|
|
389
|
+
{
|
|
390
|
+
this.dynamicallyGenerateColumns(tmpRecordDashboardData);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
tmpRecordDashboardData = this.onBeforeRenderList(tmpRecordDashboardData);
|
|
395
|
+
|
|
396
|
+
this.pict.providers.DynamicSolver.solveDashboard(tmpManifest || { }, tmpRecordDashboardData.Records.Records);
|
|
397
|
+
|
|
398
|
+
this.renderAsync('PRSP_Renderable_List', tmpRecordDashboardData.RenderDestination, tmpRecordDashboardData,
|
|
399
|
+
function (pError)
|
|
400
|
+
{
|
|
401
|
+
if (pError)
|
|
402
|
+
{
|
|
403
|
+
this.pict.log.error(`RecordSetDashboard: Error rendering list ${pError}`, tmpRecordDashboardData);
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
if (this.pict.LogNoisiness > 0)
|
|
408
|
+
{
|
|
409
|
+
this.pict.log.info(`RecordSetDashboard: Rendered list ${tmpRecordDashboardData.RecordSet} with ${tmpRecordDashboardData.Records.Records.length} records.`, tmpRecordDashboardData);
|
|
410
|
+
}
|
|
411
|
+
else
|
|
412
|
+
{
|
|
413
|
+
this.pict.log.info(`RecordSetDashboard: Rendered list ${tmpRecordDashboardData.RecordSet} with ${tmpRecordDashboardData.Records.Records.length} records.`);
|
|
414
|
+
}
|
|
415
|
+
}.bind(this));
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* @param {Record<string, any>} pRecordSetConfiguration
|
|
420
|
+
* @param {string} pProviderHash
|
|
421
|
+
* @param {string} pFilterString
|
|
422
|
+
* @param {number} pOffset
|
|
423
|
+
* @param {number} pPageSize
|
|
424
|
+
*
|
|
425
|
+
* @return {Promise<void>}
|
|
426
|
+
*/
|
|
427
|
+
async renderDashboard(pRecordSetConfiguration, pProviderHash, pFilterString, pOffset, pPageSize)
|
|
178
428
|
{
|
|
429
|
+
if (!pRecordSetConfiguration)
|
|
430
|
+
{
|
|
431
|
+
this.pict.log.error(`RecordSetDashboard: No record set configuration found. List Render failed.`);
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
179
434
|
// Get the records
|
|
180
435
|
if (!(pProviderHash in this.pict.providers))
|
|
181
436
|
{
|
|
182
437
|
this.pict.log.error(`RecordSetDashboard: No provider found for ${pProviderHash} in ${pRecordSetConfiguration.RecordSet}. List Render failed.`);
|
|
183
|
-
return
|
|
438
|
+
return;
|
|
184
439
|
}
|
|
185
440
|
|
|
186
|
-
let
|
|
441
|
+
let tmpRecordDashboardData =
|
|
187
442
|
{
|
|
188
|
-
"Title": pRecordSetConfiguration.RecordSet,
|
|
443
|
+
"Title": pRecordSetConfiguration.Title || pRecordSetConfiguration.RecordSet,
|
|
189
444
|
|
|
190
445
|
"RecordSet": pRecordSetConfiguration.RecordSet,
|
|
191
446
|
"RecordSetConfiguration": pRecordSetConfiguration,
|
|
@@ -203,151 +458,169 @@ class viewRecordSetDashboard extends libPictRecordSetRecordView
|
|
|
203
458
|
|
|
204
459
|
// TODO: There are still problems with the way these have nested data. Discuss how we might move that around
|
|
205
460
|
// Fetch the records
|
|
206
|
-
|
|
461
|
+
const [ tmpRecords, tmpTotalRecordCount, tmpRecordSchema ] = await Promise.all([
|
|
462
|
+
this.pict.providers[pProviderHash].getRecords(tmpRecordDashboardData),
|
|
463
|
+
this.pict.providers[pProviderHash].getRecordSetCount(tmpRecordDashboardData),
|
|
464
|
+
this.pict.providers[pProviderHash].getRecordSchema(),
|
|
465
|
+
]);
|
|
466
|
+
tmpRecordDashboardData.Records = tmpRecords;
|
|
207
467
|
// Get the total record count
|
|
208
|
-
|
|
468
|
+
tmpRecordDashboardData.TotalRecordCount = tmpTotalRecordCount;
|
|
209
469
|
// Get the record schema
|
|
210
|
-
|
|
470
|
+
tmpRecordDashboardData.RecordSchema = tmpRecordSchema;
|
|
211
471
|
|
|
212
472
|
// TODO: This should be coming from the schema but that can come after we discuss how we deal with default routing
|
|
213
|
-
|
|
473
|
+
tmpRecordDashboardData.GUIDAddress = `GUID${this.pict.providers[pProviderHash].options.Entity}`;
|
|
214
474
|
|
|
215
475
|
// Get the "page end record number" for the current page (e.g. for messaging like Record 700 to 800 of 75,000)
|
|
216
|
-
|
|
476
|
+
tmpRecordDashboardData.PageEnd = parseInt(tmpRecordDashboardData.Offset) + tmpRecordDashboardData.Records.Records.length;
|
|
217
477
|
|
|
218
478
|
// Compute the number of pages total
|
|
219
|
-
|
|
479
|
+
tmpRecordDashboardData.PageCount = Math.ceil(tmpRecordDashboardData.TotalRecordCount.Count / tmpRecordDashboardData.PageSize);
|
|
220
480
|
|
|
221
481
|
// Generate each page's links.
|
|
222
482
|
// TODO: This is fast and cool; any reason not to?
|
|
223
483
|
// Get "bookmarks" as references to the array of page links.
|
|
224
|
-
|
|
484
|
+
tmpRecordDashboardData.PageLinkBookmarks = (
|
|
225
485
|
{
|
|
226
|
-
Current: Math.floor(
|
|
486
|
+
Current: Math.floor(tmpRecordDashboardData.Offset / tmpRecordDashboardData.PageSize)
|
|
227
487
|
});
|
|
228
|
-
|
|
229
|
-
for (let i = 0; i <
|
|
488
|
+
tmpRecordDashboardData.PageLinks = [];
|
|
489
|
+
for (let i = 0; i < tmpRecordDashboardData.PageCount; i++)
|
|
230
490
|
{
|
|
231
|
-
if (
|
|
491
|
+
if (tmpRecordDashboardData.FilterString)
|
|
232
492
|
{
|
|
233
|
-
|
|
493
|
+
tmpRecordDashboardData.PageLinks.push(
|
|
234
494
|
{
|
|
235
495
|
Page: i + 1,
|
|
236
|
-
RelativeOffset: i -
|
|
237
|
-
URL: `#/PSRS/${
|
|
496
|
+
RelativeOffset: i - tmpRecordDashboardData.PageLinkBookmarks.Current,
|
|
497
|
+
URL: `#/PSRS/${tmpRecordDashboardData.RecordSet}/Dashboard/FilteredTo/${tmpRecordDashboardData.FilterString}/${i * tmpRecordDashboardData.PageSize}/${tmpRecordDashboardData.PageSize}`
|
|
238
498
|
});
|
|
239
499
|
}
|
|
240
500
|
else
|
|
241
501
|
{
|
|
242
|
-
|
|
502
|
+
tmpRecordDashboardData.PageLinks.push(
|
|
243
503
|
{
|
|
244
504
|
Page: i + 1,
|
|
245
|
-
RelativeOffset: i -
|
|
246
|
-
URL: `#/PSRS/${
|
|
505
|
+
RelativeOffset: i - tmpRecordDashboardData.PageLinkBookmarks.Current,
|
|
506
|
+
URL: `#/PSRS/${tmpRecordDashboardData.RecordSet}/Dashboard/${i * tmpRecordDashboardData.PageSize}/${tmpRecordDashboardData.PageSize}`
|
|
247
507
|
});
|
|
248
508
|
}
|
|
249
509
|
}
|
|
250
510
|
|
|
251
511
|
//FIXME: short-term workaround to not blow up the tempplate rendering with way too many links
|
|
252
|
-
const linkRangeStart = Math.max(0,
|
|
253
|
-
const linkRangeEnd = Math.min(
|
|
254
|
-
|
|
512
|
+
const linkRangeStart = Math.max(0, tmpRecordDashboardData.PageLinkBookmarks.Current - 10);
|
|
513
|
+
const linkRangeEnd = Math.min(tmpRecordDashboardData.PageLinks.length, tmpRecordDashboardData.PageLinkBookmarks.Current + 10);
|
|
514
|
+
tmpRecordDashboardData.PageLinksLimited = tmpRecordDashboardData.PageLinks.slice(linkRangeStart, linkRangeEnd);
|
|
255
515
|
if (linkRangeStart > 0)
|
|
256
516
|
{
|
|
257
|
-
if (
|
|
517
|
+
if (tmpRecordDashboardData.FilterString)
|
|
258
518
|
{
|
|
259
|
-
|
|
519
|
+
tmpRecordDashboardData.PageLinksLimited.unshift(
|
|
260
520
|
{
|
|
261
521
|
Page: 1,
|
|
262
|
-
RelativeOffset: -
|
|
263
|
-
URL: `#/PSRS/${
|
|
522
|
+
RelativeOffset: -tmpRecordDashboardData.PageLinkBookmarks.Current,
|
|
523
|
+
URL: `#/PSRS/${tmpRecordDashboardData.RecordSet}/Dashboard/FilteredTo/${tmpRecordDashboardData.FilterString}/${tmpRecordDashboardData.PageSize}/${tmpRecordDashboardData.PageSize}`
|
|
264
524
|
});
|
|
265
525
|
}
|
|
266
526
|
else
|
|
267
527
|
{
|
|
268
|
-
|
|
528
|
+
tmpRecordDashboardData.PageLinksLimited.unshift(
|
|
269
529
|
{
|
|
270
530
|
Page: 1,
|
|
271
|
-
RelativeOffset: -
|
|
272
|
-
URL: `#/PSRS/${
|
|
531
|
+
RelativeOffset: -tmpRecordDashboardData.PageLinkBookmarks.Current,
|
|
532
|
+
URL: `#/PSRS/${tmpRecordDashboardData.RecordSet}/Dashboard/${0}/${tmpRecordDashboardData.PageSize}`
|
|
273
533
|
});
|
|
274
534
|
}
|
|
275
535
|
}
|
|
276
|
-
if (linkRangeEnd <
|
|
536
|
+
if (linkRangeEnd < tmpRecordDashboardData.PageLinks.length)
|
|
277
537
|
{
|
|
278
|
-
if (
|
|
538
|
+
if (tmpRecordDashboardData.FilterString)
|
|
279
539
|
{
|
|
280
|
-
|
|
540
|
+
tmpRecordDashboardData.PageLinksLimited.push(
|
|
281
541
|
{
|
|
282
|
-
Page:
|
|
283
|
-
RelativeOffset: (
|
|
284
|
-
URL: `#/PSRS/${
|
|
542
|
+
Page: tmpRecordDashboardData.PageCount,
|
|
543
|
+
RelativeOffset: (tmpRecordDashboardData.PageCount - 1) - tmpRecordDashboardData.PageLinkBookmarks.Current,
|
|
544
|
+
URL: `#/PSRS/${tmpRecordDashboardData.RecordSet}/Dashboard/FilteredTo/${tmpRecordDashboardData.FilterString}/${(tmpRecordDashboardData.PageCount - 1) * tmpRecordDashboardData.PageSize}/${tmpRecordDashboardData.PageSize}`
|
|
285
545
|
});
|
|
286
546
|
}
|
|
287
547
|
else
|
|
288
548
|
{
|
|
289
|
-
|
|
549
|
+
tmpRecordDashboardData.PageLinksLimited.push(
|
|
290
550
|
{
|
|
291
|
-
Page:
|
|
292
|
-
RelativeOffset: (
|
|
293
|
-
URL: `#/PSRS/${
|
|
551
|
+
Page: tmpRecordDashboardData.PageCount,
|
|
552
|
+
RelativeOffset: (tmpRecordDashboardData.PageCount - 1) - tmpRecordDashboardData.PageLinkBookmarks.Current,
|
|
553
|
+
URL: `#/PSRS/${tmpRecordDashboardData.RecordSet}/Dashboard/${(tmpRecordDashboardData.PageCount - 1) * tmpRecordDashboardData.PageSize}/${tmpRecordDashboardData.PageSize}`
|
|
294
554
|
});
|
|
295
555
|
}
|
|
296
556
|
}
|
|
297
557
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
if (
|
|
558
|
+
tmpRecordDashboardData.PageLinkBookmarks.Previous = tmpRecordDashboardData.PageLinkBookmarks.Current - 1;
|
|
559
|
+
tmpRecordDashboardData.PageLinkBookmarks.Next = tmpRecordDashboardData.PageLinkBookmarks.Current + 1;
|
|
560
|
+
tmpRecordDashboardData.PageLinkBookmarks.ShowPreviousLink = true;
|
|
561
|
+
tmpRecordDashboardData.PageLinkBookmarks.ShowNextLink = true;
|
|
562
|
+
if (tmpRecordDashboardData.PageLinkBookmarks.Previous < 0)
|
|
303
563
|
{
|
|
304
|
-
|
|
305
|
-
|
|
564
|
+
tmpRecordDashboardData.PageLinkBookmarks.PreviousLink = false;
|
|
565
|
+
tmpRecordDashboardData.PageLinkBookmarks.ShowPreviousLink = false;
|
|
306
566
|
}
|
|
307
567
|
else
|
|
308
568
|
{
|
|
309
|
-
|
|
569
|
+
tmpRecordDashboardData.PageLinkBookmarks.PreviousLink = tmpRecordDashboardData.PageLinks[tmpRecordDashboardData.PageLinkBookmarks.Previous];
|
|
310
570
|
}
|
|
311
|
-
if (
|
|
571
|
+
if (tmpRecordDashboardData.PageLinkBookmarks.Next >= tmpRecordDashboardData.PageLinks.length)
|
|
312
572
|
{
|
|
313
|
-
|
|
314
|
-
|
|
573
|
+
tmpRecordDashboardData.PageLinkBookmarks.NextLink = false;
|
|
574
|
+
tmpRecordDashboardData.PageLinkBookmarks.ShowNextLink = false;
|
|
315
575
|
}
|
|
316
576
|
else
|
|
317
577
|
{
|
|
318
|
-
|
|
578
|
+
tmpRecordDashboardData.PageLinkBookmarks.NextLink = tmpRecordDashboardData.PageLinks[tmpRecordDashboardData.PageLinkBookmarks.Next];
|
|
319
579
|
}
|
|
320
580
|
|
|
581
|
+
tmpRecordDashboardData.TableCells = [];
|
|
321
582
|
// Put code here to preprocess columns into other data parts.
|
|
322
|
-
|
|
583
|
+
/*
|
|
584
|
+
"RecordSetListManifestOnly": false,
|
|
585
|
+
|
|
586
|
+
"RecordSetListManifests": [ "Bestsellers", "Underdogs", "NewReleases" ],
|
|
587
|
+
"RecordSetDashboardManifests": [ "Bestsellers" ],
|
|
588
|
+
*/
|
|
589
|
+
if (tmpRecordDashboardData.RecordSetConfiguration.hasOwnProperty('RecordSetListColumns'))
|
|
323
590
|
{
|
|
324
|
-
|
|
591
|
+
tmpRecordDashboardData.TableCells = tmpRecordDashboardData.RecordSetConfiguration.RecordSetListColumns;
|
|
325
592
|
}
|
|
326
593
|
else
|
|
327
594
|
{
|
|
328
|
-
this.dynamicallyGenerateColumns(
|
|
595
|
+
this.dynamicallyGenerateColumns(tmpRecordDashboardData);
|
|
329
596
|
}
|
|
330
597
|
|
|
331
|
-
|
|
598
|
+
tmpRecordDashboardData = this.onBeforeRenderList(tmpRecordDashboardData);
|
|
599
|
+
|
|
600
|
+
const tmpManifest = { Scope: 'Default', Descriptors: { }, TableCells: tmpRecordDashboardData.TableCells };
|
|
601
|
+
for (const tmpCell of tmpRecordDashboardData.TableCells)
|
|
602
|
+
{
|
|
603
|
+
tmpManifest.Descriptors[tmpCell.Key] = { Hash: tmpCell.Key, PictDashboard: tmpCell.PictDashboard };
|
|
604
|
+
}
|
|
605
|
+
this.pict.providers.DynamicSolver.solveDashboard(tmpManifest, tmpRecordDashboardData.Records.Records);
|
|
332
606
|
|
|
333
|
-
this.renderAsync('PRSP_Renderable_List',
|
|
607
|
+
this.renderAsync('PRSP_Renderable_List', tmpRecordDashboardData.RenderDestination, tmpRecordDashboardData,
|
|
334
608
|
function (pError)
|
|
335
609
|
{
|
|
336
610
|
if (pError)
|
|
337
611
|
{
|
|
338
|
-
this.pict.log.error(`RecordSetDashboard: Error rendering list ${pError}`,
|
|
339
|
-
return
|
|
612
|
+
this.pict.log.error(`RecordSetDashboard: Error rendering list ${pError}`, tmpRecordDashboardData);
|
|
613
|
+
return;
|
|
340
614
|
}
|
|
341
615
|
|
|
342
616
|
if (this.pict.LogNoisiness > 0)
|
|
343
617
|
{
|
|
344
|
-
this.pict.log.info(`RecordSetDashboard: Rendered list ${
|
|
618
|
+
this.pict.log.info(`RecordSetDashboard: Rendered list ${tmpRecordDashboardData.RecordSet} with ${tmpRecordDashboardData.Records.Records.length} records.`, tmpRecordDashboardData);
|
|
345
619
|
}
|
|
346
620
|
else
|
|
347
621
|
{
|
|
348
|
-
this.pict.log.info(`RecordSetDashboard: Rendered list ${
|
|
622
|
+
this.pict.log.info(`RecordSetDashboard: Rendered list ${tmpRecordDashboardData.RecordSet} with ${tmpRecordDashboardData.Records.Records.length} records.`);
|
|
349
623
|
}
|
|
350
|
-
return true;
|
|
351
624
|
}.bind(this));
|
|
352
625
|
}
|
|
353
626
|
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"ViewIdentifier": "RecordSet-Error-NotFound-View",
|
|
3
|
+
|
|
4
|
+
"DefaultRenderable": "RecordSet-Error-NotFound",
|
|
5
|
+
"DefaultDestinationAddress": "#PRSP_Container",
|
|
6
|
+
|
|
7
|
+
"AutoRender": false,
|
|
8
|
+
|
|
9
|
+
"Templates":
|
|
10
|
+
[
|
|
11
|
+
{
|
|
12
|
+
"Hash": "RecordSet-Error-NotFound-Content",
|
|
13
|
+
"Template": "<div class=\"header\"><h1>404 - Our Legal Contract is <em>Your</em> Legal Contract</h1><h2>Feel safe in a space where nobody breaks the rules.</h2></div> <div class=\"content\"> <h2 class=\"content-subhead\">A Binding Agreement</h2><p>By using our postcard sending site, you agree to abide by the following terms and conditions:</p> <h2 class=\"content-subhead\">Intellectual Property Rights</h2><p>All content, including but not limited to text, images, graphics, logos, and software, provided on our site is the property of our company or its licensors and is protected by copyright, trademark, and other intellectual property laws. You may not reproduce, distribute, modify, or otherwise use any content without the prior written consent of the respective owners.</p> <h2 class=\"content-subhead\">User Content</h2><p>By uploading or submitting any content (such as text, images, or personal information) to our site, you grant us a worldwide, royalty-free, non-exclusive license to use, reproduce, modify, adapt, publish, translate, and distribute such content for the purpose of providing our services. You represent and warrant that you have the necessary rights to grant us this license.</p> <h2 class=\"content-subhead\">Privacy Policy</h2><p> We are committed to protecting your privacy. Our Privacy Policy outlines how we collect, use, and disclose your personal information. By using our site, you consent to the collection, use, and disclosure of your information as described in our Privacy Policy.</p> <h2 class=\"content-subhead\">Limitation of Liability</h2><p> We make every effort to ensure the accuracy and reliability of the information provided on our site. However, we cannot guarantee that our site will be error-free, uninterrupted, or free of viruses or other harmful components. In no event shall we be liable for any direct, indirect, incidental, special, or consequential damages arising out of or in any way connected with your use of our site.</p> <h2 class=\"content-subhead\">Governing Law</h2><p> These terms and conditions shall be governed by and construed in accordance with the laws of the world, without regard to its conflict of law provisions. Any disputes arising out of or relating to these terms and conditions shall be subject to the exclusive jurisdiction of the courts of the world.</p> <p>By using our postcard sending site, you acknowledge that you have read, understood, and agree to be bound by these terms and conditions. If you do not agree to these terms and conditions, please refrain from using our site.</p></div>"
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
"Renderables": [
|
|
17
|
+
{
|
|
18
|
+
"RenderableHash": "RecordSet-Error-NotFound",
|
|
19
|
+
"TemplateHash": "RecordSet-Error-NotFound-Content"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}
|
|
@@ -178,7 +178,7 @@ class viewRecordSetList extends libPictRecordSetRecordView
|
|
|
178
178
|
|
|
179
179
|
let tmpRecordListData =
|
|
180
180
|
{
|
|
181
|
-
"Title": pRecordSetConfiguration.RecordSet,
|
|
181
|
+
"Title": pRecordSetConfiguration.Title || pRecordSetConfiguration.RecordSet,
|
|
182
182
|
|
|
183
183
|
"RecordSet": pRecordSetConfiguration.RecordSet,
|
|
184
184
|
"RecordSetConfiguration": pRecordSetConfiguration,
|
|
@@ -196,11 +196,16 @@ class viewRecordSetList extends libPictRecordSetRecordView
|
|
|
196
196
|
|
|
197
197
|
// TODO: There are still problems with the way these have nested data. Discuss how we might move that around
|
|
198
198
|
// Fetch the records
|
|
199
|
-
|
|
199
|
+
const [ tmpRecords, tmpTotalRecordCount, tmpRecordSchema ] = await Promise.all([
|
|
200
|
+
this.pict.providers[pProviderHash].getRecords(tmpRecordListData),
|
|
201
|
+
this.pict.providers[pProviderHash].getRecordSetCount(tmpRecordListData),
|
|
202
|
+
this.pict.providers[pProviderHash].getRecordSchema(),
|
|
203
|
+
]);
|
|
204
|
+
tmpRecordListData.Records = tmpRecords;
|
|
200
205
|
// Get the total record count
|
|
201
|
-
tmpRecordListData.TotalRecordCount =
|
|
206
|
+
tmpRecordListData.TotalRecordCount = tmpTotalRecordCount;
|
|
202
207
|
// Get the record schema
|
|
203
|
-
tmpRecordListData.RecordSchema =
|
|
208
|
+
tmpRecordListData.RecordSchema = tmpRecordSchema;
|
|
204
209
|
|
|
205
210
|
// TODO: This should be coming from the schema but that can come after we discuss how we deal with default routing
|
|
206
211
|
tmpRecordListData.GUIDAddress = `GUID${this.pict.providers[pProviderHash].options.Entity}`;
|
|
@@ -320,7 +325,6 @@ class viewRecordSetList extends libPictRecordSetRecordView
|
|
|
320
325
|
{
|
|
321
326
|
this.dynamicallyGenerateColumns(tmpRecordListData);
|
|
322
327
|
}
|
|
323
|
-
|
|
324
328
|
tmpRecordListData = this.onBeforeRenderList(tmpRecordListData);
|
|
325
329
|
|
|
326
330
|
this.renderAsync('PRSP_Renderable_List', tmpRecordListData.RenderDestination, tmpRecordListData,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Pict-Application-RecordSet.d.ts","sourceRoot":"","sources":["../../source/application/Pict-Application-RecordSet.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"Pict-Application-RecordSet.d.ts","sourceRoot":"","sources":["../../source/application/Pict-Application-RecordSet.js"],"names":[],"mappings":";AAKA;;;;;;;GAOG;AACH;IAEC,2DASC;CAoBD;;;;;qCAIU,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC"}
|