pict-section-recordset 1.0.53 → 1.0.54

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.
Files changed (36) hide show
  1. package/example_applications/simple_entity/Simple-RecordSet-Application.js +221 -1
  2. package/example_applications/simple_entity/html/index.html +2 -0
  3. package/package.json +1 -1
  4. package/source/application/Pict-Application-RecordSet.js +2 -0
  5. package/source/providers/RecordSet-Link-Manager.js +1 -1
  6. package/source/providers/RecordSet-RecordProvider-Base.js +10 -0
  7. package/source/providers/RecordSet-RecordProvider-MeadowEndpoints.js +44 -14
  8. package/source/providers/RecordSet-Router.js +1 -1
  9. package/source/services/RecordsSet-MetaController.js +9 -6
  10. package/source/views/RecordSet-RecordBaseView.js +1 -1
  11. package/source/views/create/RecordSet-Create.js +344 -0
  12. package/source/views/dashboard/RecordSet-Dashboard.js +3 -2
  13. package/source/views/list/RecordSet-List.js +2 -2
  14. package/source/views/read/RecordSet-Read.js +760 -44
  15. package/types/application/Pict-Application-RecordSet.d.ts.map +1 -1
  16. package/types/providers/RecordSet-RecordProvider-Base.d.ts +2 -0
  17. package/types/providers/RecordSet-RecordProvider-Base.d.ts.map +1 -1
  18. package/types/providers/RecordSet-RecordProvider-MeadowEndpoints.d.ts +3 -5
  19. package/types/providers/RecordSet-RecordProvider-MeadowEndpoints.d.ts.map +1 -1
  20. package/types/services/RecordsSet-MetaController.d.ts +1 -1
  21. package/types/services/RecordsSet-MetaController.d.ts.map +1 -1
  22. package/types/views/create/RecordSet-Create.d.ts +39 -0
  23. package/types/views/create/RecordSet-Create.d.ts.map +1 -0
  24. package/types/views/dashboard/RecordSet-Dashboard.d.ts.map +1 -1
  25. package/types/views/read/RecordSet-Read.d.ts +65 -5
  26. package/types/views/read/RecordSet-Read.d.ts.map +1 -1
  27. package/source/views/edit/RecordSet-Edit-HeaderEdit.js +0 -64
  28. package/source/views/edit/RecordSet-Edit-RecordEdit.js +0 -64
  29. package/source/views/edit/RecordSet-Edit-RecordEditControls.js +0 -64
  30. package/source/views/edit/RecordSet-Edit-RecordEditExtra.js +0 -64
  31. package/source/views/edit/RecordSet-Edit-TabBarEdit.js +0 -64
  32. package/source/views/edit/RecordSet-Edit.js +0 -64
  33. package/source/views/read/RecordSet-Read-HeaderRead.js +0 -64
  34. package/source/views/read/RecordSet-Read-RecordRead.js +0 -78
  35. package/source/views/read/RecordSet-Read-RecordReadExtra.js +0 -64
  36. package/source/views/read/RecordSet-Read-TabBarRead.js +0 -64
@@ -0,0 +1,344 @@
1
+ const libPictRecordSetRecordView = require('../RecordSet-RecordBaseView.js');
2
+
3
+ /** @type {Record<string, any>} */
4
+ const _DEFAULT_CONFIGURATION__Create =
5
+ {
6
+ ViewIdentifier: 'PRSP-Create',
7
+
8
+ DefaultRenderable: 'PRSP_Renderable_Create',
9
+ DefaultDestinationAddress: '#PRSP_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-Create-Basic-Template',
32
+ Template: /*html*/`
33
+ <!-- DefaultPackage pict view template: [PRSP-Create-Basic-Template] -->
34
+ <h1>{~D:Record.RecordSet~} Create</h1>
35
+ <div>
36
+ {~T:PRSP-Create-RecordCreate-Template~}
37
+ </div>
38
+ {~T:PRSP-Create-RecordButtonBar-Template~}
39
+ <!-- DefaultPackage end view template: [PRSP-Create-Basic-Template] -->
40
+ `
41
+ },
42
+ {
43
+ Hash: 'PRSP-Create-RecordButtonBar-Template',
44
+ Template: /*html*/`
45
+ <style>
46
+ .record-button-bar-hidden
47
+ {
48
+ display: none;
49
+ }
50
+ .record-button-bar
51
+ {
52
+ display: flex;
53
+ margin-top: 15px;
54
+ }
55
+ .record-button-bar > button
56
+ {
57
+ margin-right: 10px;
58
+ }
59
+ </style>
60
+ <div class="record-button-bar">
61
+ <button id="PRSP-Create-ClearButton" type="button" onclick="_Pict.views['RSP-RecordSet-Create'].clear()">Clear</button>
62
+ <button id="PRSP-Create-SaveButton" type="button" onclick="_Pict.views['RSP-RecordSet-Create'].save()">Save</button>
63
+ </div>
64
+ `
65
+ },
66
+ {
67
+ Hash: 'PRSP-Create-Link-Name-Template',
68
+ Template: `Create`
69
+ },
70
+ {
71
+ Hash: 'PRSP-Create-Link-URL-Template',
72
+ Template: `#/PSRS/{~D:Record.Payload.Payload.RecordSet~}/Create`
73
+ },
74
+ ],
75
+
76
+ Renderables:
77
+ [
78
+ {
79
+ RenderableHash: 'PRSP_Renderable_Create_Basic',
80
+ TemplateHash: 'PRSP-Create-Basic-Template',
81
+ DestinationAddress: '#PRSP_Container',
82
+ RenderMethod: 'replace'
83
+ }
84
+ ],
85
+
86
+ Manifests: {},
87
+ };
88
+
89
+ class viewRecordSetCreate extends libPictRecordSetRecordView
90
+ {
91
+ constructor(pFable, pOptions, pServiceHash)
92
+ {
93
+ let tmpOptions = Object.assign({}, _DEFAULT_CONFIGURATION__Create, pOptions);
94
+
95
+ super(pFable, tmpOptions, pServiceHash);
96
+ this.RecordSet = null;
97
+ this.providerHash = null;
98
+ this.manifest = null;
99
+ this.defaultManifest = null;
100
+ }
101
+
102
+ handleRecordSetCreateRoute(pRoutePayload)
103
+ {
104
+ if (typeof(pRoutePayload) != 'object')
105
+ {
106
+ throw new Error(`Pict RecordSet Create view route handler called with invalid route payload.`);
107
+ }
108
+
109
+ const tmpProviderConfiguration = this.pict.PictSectionRecordSet.recordSetProviderConfigurations[pRoutePayload.data.RecordSet];
110
+ const tmpProviderHash = `RSP-Provider-${pRoutePayload.data.RecordSet}`;
111
+
112
+ tmpProviderConfiguration.RoutePayload = pRoutePayload;
113
+ tmpProviderConfiguration.RecordSet = pRoutePayload.data.RecordSet;
114
+
115
+ return this.renderCreate(tmpProviderConfiguration, tmpProviderHash);
116
+ }
117
+
118
+ async clear()
119
+ {
120
+ await this.onBeforeClear();
121
+ this.renderCreate(this.pict.PictSectionRecordSet.recordSetProviderConfigurations[this.RecordSet], this.providerHash);
122
+ }
123
+
124
+ async save()
125
+ {
126
+ await this.onBeforeSave();
127
+ const resultingRecord = await this.pict.providers[this.providerHash].createRecord(this.pict.AppData[`${ this.RecordSet }Details`]);
128
+
129
+ this.fable.providers.RecordSetRouter.pictRouter.navigate(`/PSRS/${ this.RecordSet }/View/${ resultingRecord[this.pict.providers[this.providerHash].getGUIDField()] }`);
130
+ }
131
+
132
+ async onBeforeClear()
133
+ {
134
+ // Hook that gets called before clear.
135
+ }
136
+
137
+ async onBeforeSave()
138
+ {
139
+ // Hook that gets called before save.
140
+ }
141
+
142
+ async onBeforeRenderCreate(pRecordConfiguration, pProviderHash)
143
+ {
144
+ // Hook that gets called before "renderCreate".
145
+ }
146
+
147
+ async renderCreate(pRecordConfiguration, pProviderHash)
148
+ {
149
+ await this.onBeforeRenderCreate(pRecordConfiguration, pProviderHash);
150
+ if (!(pProviderHash in this.pict.providers))
151
+ {
152
+ this.pict.log.error(`RecordSetCreate: No provider found for ${pProviderHash} in ${pRecordConfiguration.RecordSet}. Create Render failed.`);
153
+ return false;
154
+ }
155
+
156
+ let tmpRecordCreateData =
157
+ {
158
+ "RecordSet": pRecordConfiguration.RecordSet,
159
+
160
+ "RecordConfiguration": pRecordConfiguration,
161
+
162
+ "RenderDestination": this.options.DefaultDestinationAddress,
163
+ };
164
+
165
+ if (pRecordConfiguration.RecordSet !== this.RecordSet)
166
+ {
167
+ this.RecordSet = pRecordConfiguration.RecordSet;
168
+ }
169
+
170
+ this.pict.AppData[`${ this.RecordSet }Details`] = {};
171
+
172
+ this.providerHash = pProviderHash;
173
+ tmpRecordCreateData.RecordSchema = await this.pict.providers[pProviderHash].getRecordSchema();
174
+
175
+ if (pRecordConfiguration.RecordSetCreateManifestOnly)
176
+ {
177
+ this.pict.TemplateProvider.addTemplate(`PRSP-Create-RecordCreate-Template`, /*html*/`
178
+ <!-- Manifest dynamic pict template: [PRSP-Create-RecordCreate-Template] -->
179
+ <div>${ this._generateManifestTemplate(pRecordConfiguration, 'RecordCreate') }</div>
180
+ <!-- Manifest dynamic pict end template: [PRSP-Create-RecordCreate-Template] -->
181
+ `);
182
+ }
183
+ else
184
+ {
185
+ // Construct a default manifest based on the RecordSchema:
186
+ this.defaultManifest =
187
+ {
188
+ "Form": "DefaultManifest",
189
+ "Scope": "Default",
190
+ "Descriptors": {},
191
+ "Sections":
192
+ [
193
+ {
194
+ "Name": "",
195
+ "Hash": "DefaultSection",
196
+ "Solvers": [],
197
+ "ShowTitle": false,
198
+ "Groups": [
199
+ {
200
+ "Name": "",
201
+ "Hash": "DefaultGroup",
202
+ "Rows": [],
203
+ "RecordSetSolvers": [],
204
+ "ShowTitle": false
205
+ }
206
+ ]
207
+ }
208
+ ]
209
+ }
210
+ let rowCounter = 1;
211
+ for (const p of Object.keys(tmpRecordCreateData.RecordSchema.properties))
212
+ {
213
+ const exclusionSet = [this.pict.providers[this.providerHash].getIDField(), this.pict.providers[this.providerHash].getGUIDField(), 'CreatingIDUser', 'UpdatingIDUser', 'DeletingIDUser', 'Deleted', 'CreateDate', 'UpdateDate', 'DeleteDate', 'Deleted'];
214
+ if (exclusionSet.includes(p))
215
+ {
216
+ continue;
217
+ }
218
+ const tmpDescriptor =
219
+ {
220
+ "Name": `${ this.pict.providers[pProviderHash].getHumanReadableFieldName?.() || p }`,
221
+ "Hash": `${ tmpRecordCreateData.RecordSet }-${ p }`,
222
+ "DataType": "String",
223
+ "PictForm":
224
+ {
225
+ "Row": `${ rowCounter }`,
226
+ "Section": "DefaultSection",
227
+ "Group": "DefaultGroup"
228
+ }
229
+ };
230
+ rowCounter += 1;
231
+ switch (tmpRecordCreateData.RecordSchema.properties[p].type)
232
+ {
233
+ case 'string':
234
+ case 'autoguid':
235
+ tmpDescriptor.DataType = 'String';
236
+ break;
237
+ case 'datetime':
238
+ case 'date':
239
+ case 'createdate':
240
+ case 'updatedate':
241
+ tmpDescriptor.DataType = 'String';
242
+ tmpDescriptor.PictForm.InputType = 'DateTime'
243
+ break;
244
+ case 'boolean':
245
+ case 'deleted':
246
+ tmpDescriptor.DataType = 'Boolean';
247
+ case 'integer':
248
+ case 'decimal':
249
+ case 'autoidentity':
250
+ case 'createiduser':
251
+ case 'updateiduser':
252
+ case 'deleteiduser':
253
+ tmpDescriptor.DataType = 'Number';
254
+ break;
255
+ default:
256
+ tmpDescriptor.DataType = 'String';
257
+ }
258
+
259
+ this.defaultManifest.Descriptors[`${ tmpRecordCreateData.RecordSet }Details.${ p }`] = tmpDescriptor;
260
+ }
261
+ this.pict.TemplateProvider.addTemplate(`PRSP-Create-RecordCreate-Template`, /*html*/`
262
+ <!-- Manifest dynamic pict template: [PRSP-Create-RecordCreate-Template] -->
263
+ <div>${ this._generateManifestTemplate(pRecordConfiguration, 'RecordCreate', true) }</div>
264
+ <!-- Manifest dynamic pict end template: [PRSP-Create-RecordCreate-Template] -->
265
+ `);
266
+ }
267
+
268
+ this.renderAsync(`PRSP_Renderable_Create_Basic`, tmpRecordCreateData.RenderDestination, tmpRecordCreateData,
269
+ async function (pError)
270
+ {
271
+ if (pError)
272
+ {
273
+ this.pict.log.error(`RecordSetCreate: Error rendering create ${pError}`, tmpRecordCreateData);
274
+ return false;
275
+ }
276
+
277
+ if (this.pict.LogNoisiness > 0)
278
+ {
279
+ this.pict.log.info(`RecordSetCreate: Rendered create ${tmpRecordCreateData.RecordSet}`, tmpRecordCreateData);
280
+ }
281
+ else
282
+ {
283
+ this.pict.log.info(`RecordSetCreate: Rendered create ${tmpRecordCreateData.RecordSet}`);
284
+ }
285
+ for (const s of this.manifest?.Sections || [])
286
+ {
287
+ this.pict.views[`PictSectionForm-${ s.Hash }`].render();
288
+ this.pict.views[`PictSectionForm-${ s.Hash }`].marshalToView();
289
+ }
290
+ return true;
291
+ }.bind(this));
292
+ }
293
+
294
+ _generateManifestTemplate(config, section, useDefaultManifest)
295
+ {
296
+ const tmpManifestHash = config.RecordSetCreateDefaultManifest || config.RecordSetCreateManifests?.[0];
297
+ const tmpManifest = JSON.parse(JSON.stringify(useDefaultManifest ? this.defaultManifest : this.pict.PictSectionRecordSet.getManifest(tmpManifestHash)));
298
+ if (!tmpManifest)
299
+ {
300
+ this.pict.log.error(`RecordSetCreate: No manifest found for ${ config.RecordSet }. Create Render failed.`);
301
+ return '';
302
+ }
303
+ if (!tmpManifest.Descriptors)
304
+ {
305
+ this.pict.log.error(`RecordSetCreate: No manifest descriptors found for manifest ${ tmpManifestHash }. Create Render failed.`);
306
+ return '';
307
+ }
308
+
309
+ this.manifest = tmpManifest;
310
+ let sectionsTemplate = '';
311
+ for (const s of tmpManifest?.Sections || [])
312
+ {
313
+ delete this.pict.views[`PictSectionForm-${ s.Hash }`]
314
+ }
315
+ this.pict.views.PictFormMetacontroller.bootstrapPictFormViewsFromManifest(tmpManifest);
316
+
317
+ for (const pickList of tmpManifest?.PickLists || [])
318
+ {
319
+ this.pict.providers.DynamicMetaLists.rebuildListByHash(pickList.Hash);
320
+ }
321
+
322
+ for (const s of tmpManifest?.Sections || [])
323
+ {
324
+ const viewSectionID = `PSRS-Create-${ section }-Section-${ s.Hash }`;
325
+ sectionsTemplate += /*html*/`<div id="${ viewSectionID }"></div>`;
326
+ this.pict.views[`PictSectionForm-${ s.Hash }`].viewMarshalDestination = 'AppData';
327
+ this.pict.views[`PictSectionForm-${ s.Hash }`].options.DefaultDestinationAddress = `#${ viewSectionID }`;
328
+ this.pict.views[`PictSectionForm-${ s.Hash }`].rebuildCustomTemplate();
329
+ }
330
+ return sectionsTemplate
331
+ }
332
+
333
+
334
+ addRoutes(pPictRouter)
335
+ {
336
+ pPictRouter.addRoute('/PSRS/:RecordSet/Create', this.handleRecordSetCreateRoute.bind(this));
337
+ return true;
338
+ }
339
+ }
340
+
341
+ module.exports = viewRecordSetCreate;
342
+
343
+ module.exports.default_configuration = _DEFAULT_CONFIGURATION__Create;
344
+
@@ -279,7 +279,7 @@ class viewRecordSetDashboard extends libPictRecordSetRecordView
279
279
  tmpRecordDashboardData.RecordSchema = await this.pict.providers[pProviderHash].getRecordSchema();
280
280
 
281
281
  // TODO: This should be coming from the schema but that can come after we discuss how we deal with default routing
282
- tmpRecordDashboardData.GUIDAddress = `GUID${this.pict.providers[pProviderHash].options.Entity}`;
282
+ tmpRecordDashboardData.GUIDAddress = this.pict.providers[pProviderHash].getGUIDField();
283
283
 
284
284
  // Get the "page end record number" for the current page (e.g. for messaging like Record 700 to 800 of 75,000)
285
285
  const tmpOffset = Number(tmpRecordDashboardData.Offset);
@@ -423,6 +423,7 @@ class viewRecordSetDashboard extends libPictRecordSetRecordView
423
423
  }
424
424
  else
425
425
  {
426
+ // @ts-ignore
426
427
  tmpRecordDashboardData.TableCells = tmpManifest.TableCells;
427
428
  }
428
429
  }
@@ -570,7 +571,7 @@ class viewRecordSetDashboard extends libPictRecordSetRecordView
570
571
  tmpRecordDashboardData.RecordSchema = tmpRecordSchema;
571
572
 
572
573
  // TODO: This should be coming from the schema but that can come after we discuss how we deal with default routing
573
- tmpRecordDashboardData.GUIDAddress = `GUID${this.pict.providers[pProviderHash].options.Entity}`;
574
+ tmpRecordDashboardData.GUIDAddress = this.pict.providers[pProviderHash].getGUIDField();
574
575
 
575
576
  // Get the "page end record number" for the current page (e.g. for messaging like Record 700 to 800 of 75,000)
576
577
  const tmpOffset = Number(tmpRecordDashboardData.Offset);
@@ -253,7 +253,7 @@ class viewRecordSetList extends libPictRecordSetRecordView
253
253
  tmpRecordListData.RecordSchema = tmpRecordSchema;
254
254
 
255
255
  // TODO: This should be coming from the schema but that can come after we discuss how we deal with default routing
256
- tmpRecordListData.GUIDAddress = `GUID${this.pict.providers[pProviderHash].options.Entity}`;
256
+ tmpRecordListData.GUIDAddress = this.pict.providers[pProviderHash].getGUIDField();
257
257
 
258
258
  // Get the "page end record number" for the current page (e.g. for messaging like Record 700 to 800 of 75,000)
259
259
  tmpRecordListData.PageEnd = Number(tmpRecordListData.Offset) + tmpRecordListData.Records.Records.length;
@@ -504,7 +504,7 @@ class viewRecordSetList extends libPictRecordSetRecordView
504
504
  tmpRecordListData.RecordSchema = await this.pict.providers[pProviderHash].getRecordSchema();
505
505
 
506
506
  // TODO: This should be coming from the schema but that can come after we discuss how we deal with default routing
507
- tmpRecordListData.GUIDAddress = `GUID${this.pict.providers[pProviderHash].options.Entity}`;
507
+ tmpRecordListData.GUIDAddress = this.pict.providers[pProviderHash].getGUIDField();
508
508
 
509
509
  // Get the "page end record number" for the current page (e.g. for messaging like Record 700 to 800 of 75,000)
510
510
  const tmpOffset = Number(tmpRecordListData.Offset);