pict-section-recordset 1.0.1 → 1.0.3

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 (54) hide show
  1. package/example_applications/ServeExamples.js +1 -1
  2. package/example_applications/mocks/book-edit-view.html +145 -0
  3. package/example_applications/mocks/book-read-view.html +139 -0
  4. package/example_applications/simple_entity/Simple-RecordSet-Application.js +3 -3
  5. package/example_applications/simple_entity/html/index.html +1 -1
  6. package/package.json +7 -6
  7. package/source/application/Pict-Application-RecordSet.js +12 -4
  8. package/source/providers/RecordSet-Link-Manager.js +52 -0
  9. package/source/providers/RecordSet-RecordProvider-MeadowEndpoints.js +1 -0
  10. package/source/providers/RecordSet-Router.js +64 -0
  11. package/source/services/RecordsSet-MetaController.js +99 -16
  12. package/source/views/RecordSet-RecordBaseView.js +84 -0
  13. package/source/views/RecordsSet-MacroView.js +63 -0
  14. package/source/views/dashboard/RecordSet-Dashboard.js +2 -2
  15. package/source/views/edit/RecordSet-Edit.js +2 -2
  16. package/source/views/list/RecordSet-List-PaginationBottom.js +42 -42
  17. package/source/views/list/RecordSet-List-PaginationTop.js +102 -90
  18. package/source/views/list/RecordSet-List-RecordList.js +3 -3
  19. package/source/views/list/RecordSet-List-RecordListEntry.js +86 -69
  20. package/source/views/list/RecordSet-List-RecordListHeader.js +65 -64
  21. package/source/views/list/RecordSet-List-Title.js +0 -1
  22. package/source/views/list/RecordSet-List.js +168 -22
  23. package/source/views/read/RecordSet-Read-RecordRead.js +62 -48
  24. package/source/views/read/RecordSet-Read.js +193 -51
  25. package/test/PictSectionRecordSet-Basic_tests.js +5 -1
  26. package/test/PictSectionRecordSet-RecordProvider-Meadow_tests.js +1 -1
  27. package/types/Pict-Section-RecordSet.d.ts +5 -1
  28. package/types/application/Pict-Application-RecordSet.d.ts +5 -5
  29. package/types/application/Pict-Application-RecordSet.d.ts.map +1 -1
  30. package/types/providers/RecordSet-Link-Manager.d.ts +23 -0
  31. package/types/providers/RecordSet-Link-Manager.d.ts.map +1 -0
  32. package/types/providers/RecordSet-RecordProvider-MeadowEndpoints.d.ts.map +1 -1
  33. package/types/providers/RecordSet-Router.d.ts +36 -0
  34. package/types/providers/RecordSet-Router.d.ts.map +1 -0
  35. package/types/services/RecordsSet-MetaController.d.ts +13 -6
  36. package/types/services/RecordsSet-MetaController.d.ts.map +1 -1
  37. package/types/views/RecordSet-RecordBaseView.d.ts +53 -0
  38. package/types/views/RecordSet-RecordBaseView.d.ts.map +1 -0
  39. package/types/views/RecordsSet-MacroView.d.ts +33 -0
  40. package/types/views/RecordsSet-MacroView.d.ts.map +1 -1
  41. package/types/views/dashboard/RecordSet-Dashboard.d.ts +2 -3
  42. package/types/views/dashboard/RecordSet-Dashboard.d.ts.map +1 -1
  43. package/types/views/edit/RecordSet-Edit.d.ts +2 -3
  44. package/types/views/edit/RecordSet-Edit.d.ts.map +1 -1
  45. package/types/views/list/RecordSet-List-PaginationBottom.d.ts.map +1 -1
  46. package/types/views/list/RecordSet-List-PaginationTop.d.ts.map +1 -1
  47. package/types/views/list/RecordSet-List-RecordListEntry.d.ts.map +1 -1
  48. package/types/views/list/RecordSet-List-RecordListHeader.d.ts.map +1 -1
  49. package/types/views/list/RecordSet-List.d.ts +7 -3
  50. package/types/views/list/RecordSet-List.d.ts.map +1 -1
  51. package/types/views/read/RecordSet-Read-RecordRead.d.ts.map +1 -1
  52. package/types/views/read/RecordSet-Read.d.ts +12 -3
  53. package/types/views/read/RecordSet-Read.d.ts.map +1 -1
  54. /package/example_applications/{list_view/index.html → mocks/list-view.html} +0 -0
@@ -1,4 +1,4 @@
1
- const libPictView = require('pict-view');
1
+ const libPictRecordSetRecordView = require('../RecordSet-RecordBaseView.js');
2
2
 
3
3
  const viewHeaderList = require('./RecordSet-List-HeaderList.js');
4
4
  const viewTitle = require('./RecordSet-List-Title.js');
@@ -13,7 +13,7 @@ const _DEFAULT_CONFIGURATION__List = (
13
13
  ViewIdentifier: 'PRSP-List',
14
14
 
15
15
  DefaultRenderable: 'PRSP_Renderable_List',
16
- DefaultDestinationAddress: '#PRSP_List_Container',
16
+ DefaultDestinationAddress: '#PRSP_Container',
17
17
  DefaultTemplateRecordAddress: false,
18
18
 
19
19
  // If this is set to true, when the App initializes this will.
@@ -61,7 +61,7 @@ const _DEFAULT_CONFIGURATION__List = (
61
61
  {
62
62
  RenderableHash: 'PRSP_Renderable_List',
63
63
  TemplateHash: 'PRSP-List-Template',
64
- DestinationAddress: '#PRSP_List_Container',
64
+ DestinationAddress: '#PRSP_Container',
65
65
  RenderMethod: 'replace'
66
66
  }
67
67
  ],
@@ -69,7 +69,7 @@ const _DEFAULT_CONFIGURATION__List = (
69
69
  Manifests: {}
70
70
  });
71
71
 
72
- class viewRecordSetList extends libPictView
72
+ class viewRecordSetList extends libPictRecordSetRecordView
73
73
  {
74
74
  constructor(pFable, pOptions, pServiceHash)
75
75
  {
@@ -87,6 +87,84 @@ class viewRecordSetList extends libPictView
87
87
  };
88
88
  }
89
89
 
90
+ handleRecordSetListRoute(pRoutePayload)
91
+ {
92
+ if (typeof(pRoutePayload) != 'object')
93
+ {
94
+ throw new Error(`Pict RecordSet List view route handler called with invalid route payload.`);
95
+ }
96
+
97
+ //_Pict.PictSectionRecordSet.recordSetProviderConfigurations['Book'], 'RSP-Provider-Book'
98
+ // FIXME: Not in love with this but good enough to start.
99
+ // FIXME: Typescript mumbo jumbo
100
+ // if (!('PictSectionRecordSet' in this.pict))
101
+ // {
102
+ // return false;
103
+ // }
104
+ const tmpProviderConfiguration = this.pict.PictSectionRecordSet.recordSetProviderConfigurations[pRoutePayload.data.RecordSet];
105
+ const tmpProviderHash = `RSP-Provider-${pRoutePayload.data.RecordSet}`;
106
+
107
+ const tmpFilterString = pRoutePayload.data.FilterString ? pRoutePayload.data.FilterString : '';
108
+
109
+ const tmpOffset = pRoutePayload.data.Offset ? pRoutePayload.data.Offset : 0;
110
+ const tmpPageSize = pRoutePayload.data.PageSize ? pRoutePayload.data.PageSize : 100;
111
+
112
+ return this.renderList(tmpProviderConfiguration, tmpProviderHash, tmpFilterString, tmpOffset, tmpPageSize);
113
+ }
114
+
115
+ addRoutes(pPictRouter)
116
+ {
117
+ pPictRouter.addRoute('/PSRS/:RecordSet/List/FilteredTo/:FilterString/:Offset/:PageSize', this.handleRecordSetListRoute.bind(this));
118
+ pPictRouter.addRoute('/PSRS/:RecordSet/List/:Offset/:PageSize', this.handleRecordSetListRoute.bind(this));
119
+ pPictRouter.addRoute('/PSRS/:RecordSet/List/:Offset', this.handleRecordSetListRoute.bind(this));
120
+ pPictRouter.addRoute('/PSRS/:RecordSet/List', this.handleRecordSetListRoute.bind(this));
121
+ return true;
122
+ }
123
+
124
+ onBeforeRenderList(pRecordListData)
125
+ {
126
+ // Put code here to preprocess columns into other data parts.
127
+ this.formatDisplayData(pRecordListData);
128
+
129
+ return pRecordListData;
130
+ }
131
+
132
+ formatDisplayData(pRecordListData)
133
+ {
134
+ pRecordListData.TableCells = [];
135
+ const tmpEntity = pRecordListData.RecordSetConfiguration.Entity;
136
+ this.excludedByDefaultCells = [
137
+ 'ID' + tmpEntity,
138
+ 'GUID' + tmpEntity,
139
+ 'CreateDate',
140
+ 'CreatingIDUser',
141
+ 'DeleteDate',
142
+ 'Deleted',
143
+ 'DeletingIDUser',
144
+ 'UpdateDate',
145
+ 'UpdatingIDUser',
146
+ ];
147
+
148
+ const tmpSchema = pRecordListData.RecordSchema;
149
+ const tmpProperties = tmpSchema?.properties;
150
+ // loop throught the schema and add the columns to the tableCells
151
+ for (const tmpColumn in tmpProperties)
152
+ {
153
+ if (tmpProperties.hasOwnProperty(tmpColumn))
154
+ {
155
+ // Check if the column is excluded by the default list of columns (or is not a GUID/ID)
156
+ if (this.excludedByDefaultCells.includes(tmpColumn) === false)
157
+ {
158
+ pRecordListData.TableCells.push({
159
+ 'Key': tmpColumn,
160
+ 'DisplayName': tmpProperties?.[tmpColumn].title || tmpColumn,
161
+ });
162
+ }
163
+ }
164
+ }
165
+ return pRecordListData;
166
+ }
167
+
90
168
  async renderList(pRecordSetConfiguration, pProviderHash, pFilterString, pOffset, pPageSize)
91
169
  {
92
170
  // Get the records
@@ -96,43 +174,111 @@ class viewRecordSetList extends libPictView
96
174
  return false;
97
175
  }
98
176
 
99
- let tmpResponse =
100
- {
101
- "Title": pRecordSetConfiguration.RecordSet,
177
+ let tmpRecordListData =
178
+ {
179
+ "Title": pRecordSetConfiguration.RecordSet,
180
+
181
+ "RecordSet": pRecordSetConfiguration.RecordSet,
182
+ "RecordSetConfiguration": pRecordSetConfiguration,
183
+
184
+ "RenderDestination": this.options.DefaultDestinationAddress,
185
+
186
+ "FilterString": pFilterString || false,
102
187
 
103
- "RecordSet": pRecordSetConfiguration.RecordSet,
104
- "RecordSetConfiguration": pRecordSetConfiguration,
188
+ "Records": { "Records": [] },
189
+ "TotalRecordCount": { "Count": -1 },
105
190
 
106
- "RenderDestination": this.options.DefaultDestinationAddress,
191
+ "Offset": pOffset || 0,
192
+ "PageSize": pPageSize || 100,
193
+ };
194
+
195
+ // TODO: There are still problems with the way these have nested data. Discuss how we might move that around
196
+ // Fetch the records
197
+ tmpRecordListData.Records = await this.pict.providers[pProviderHash].getRecords(tmpRecordListData);
198
+ // Get the total record count
199
+ tmpRecordListData.TotalRecordCount = await this.pict.providers[pProviderHash].getRecordSetCount(tmpRecordListData);
200
+ // Get the record schema
201
+ tmpRecordListData.RecordSchema = this.pict.providers[pProviderHash].recordSchema;
202
+
203
+ // TODO: This should be coming from the schema but that can come after we discuss how we deal with default routing
204
+ tmpRecordListData.GUIDAddress = `GUID${this.pict.providers[pProviderHash].options.Entity}`;
107
205
 
108
- "FilterString": pFilterString || '',
206
+ // Get the "page end record number" for the current page (e.g. for messaging like Record 700 to 800 of 75,000)
207
+ tmpRecordListData.PageEnd = parseInt(tmpRecordListData.Offset) + tmpRecordListData.Records.Records.length;
208
+
209
+ // Compute the number of pages total
210
+ tmpRecordListData.PageCount = Math.ceil(tmpRecordListData.TotalRecordCount.Count / tmpRecordListData.PageSize);
211
+
212
+ // Generate each page's links.
213
+ // TODO: This is fast and cool; any reason not to?
214
+ tmpRecordListData.PageLinks = [];
215
+ for (let i = 0; i < tmpRecordListData.PageCount; i++)
216
+ {
217
+ if (tmpRecordListData.FilterString)
218
+ {
219
+ tmpRecordListData.PageLinks.push(
220
+ {
221
+ Page: i+1,
222
+ URL:`#/PSRS/${tmpRecordListData.RecordSet}/List/FilteredTo/${tmpRecordListData.FilterString}/${i * tmpRecordListData.PageSize}/${tmpRecordListData.PageSize}`
223
+ });
224
+ }
225
+ else
226
+ {
227
+ tmpRecordListData.PageLinks.push(
228
+ {
229
+ Page: i+1,
230
+ URL:`#/PSRS/${tmpRecordListData.RecordSet}/List/${i * tmpRecordListData.PageSize}/${tmpRecordListData.PageSize}`
231
+ });
232
+ }
233
+ }
234
+ // Get "bookmarks" as references to the array of page links.
235
+ tmpRecordListData.PageLinkBookmarks = (
236
+ {
237
+ Current: Math.floor(tmpRecordListData.Offset / tmpRecordListData.PageSize)
238
+ });
109
239
 
110
- "Records": [],
111
- "TotalRecordCount": -1,
240
+ //FIXME: short-term workaround to not blow up the tempplate rendering with way too many links
241
+ const linkRangeStart = Math.max(0, tmpRecordListData.PageLinkBookmarks.Current - 10);
242
+ const linkRangeEnd = Math.min(tmpRecordListData.PageLinks.length - 1, tmpRecordListData.PageLinkBookmarks.Current + 10);
243
+ tmpRecordListData.PageLinksLimited = tmpRecordListData.PageLinks.slice(linkRangeStart, linkRangeEnd);
112
244
 
113
- "Offset": pOffset || 0,
114
- "PageSize": pPageSize || 100
115
- };
245
+ tmpRecordListData.PageLinkBookmarks.Previous = tmpRecordListData.PageLinkBookmarks.Current - 1;
246
+ tmpRecordListData.PageLinkBookmarks.Next = tmpRecordListData.PageLinkBookmarks.Current + 1;
247
+ if (tmpRecordListData.PageLinkBookmarks.Previous < 0)
248
+ {
249
+ tmpRecordListData.PageLinkBookmarks.Previous = false;
250
+ }
251
+ else
252
+ {
253
+ tmpRecordListData.PageLinkBookmarks.PreviousLink = tmpRecordListData.PageLinks[tmpRecordListData.PageLinkBookmarks.Previous];
254
+ }
255
+ if (tmpRecordListData.PageLinkBookmarks.Next >= tmpRecordListData.PageLinks.length)
256
+ {
257
+ tmpRecordListData.PageLinkBookmarks.Next = false;
258
+ }
259
+ else
260
+ {
261
+ tmpRecordListData.PageLinkBookmarks.NextLink = tmpRecordListData.PageLinks[tmpRecordListData.PageLinkBookmarks.Next];
262
+ }
116
263
 
117
- tmpResponse.Records = await this.pict.providers[pProviderHash].getRecords({Offset:tmpResponse.Offset, PageSize:tmpResponse.PageSize});
118
- tmpResponse.TotalRecordCount = await this.pict.providers[pProviderHash].getRecordSetCount({Offset:tmpResponse.Offset, PageSize:tmpResponse.PageSize});
264
+ tmpRecordListData = this.onBeforeRenderList(tmpRecordListData);
119
265
 
120
- this.renderAsync('PRSP_Renderable_List', tmpResponse.RenderDestination, tmpResponse,
266
+ this.renderAsync('PRSP_Renderable_List', tmpRecordListData.RenderDestination, tmpRecordListData,
121
267
  function (pError)
122
268
  {
123
269
  if (pError)
124
270
  {
125
- this.pict.log.error(`RecordSetList: Error rendering list ${pError}`, tmpResponse);
271
+ this.pict.log.error(`RecordSetList: Error rendering list ${pError}`, tmpRecordListData);
126
272
  return false;
127
273
  }
128
274
 
129
275
  if (this.pict.LogNoisiness > 0)
130
276
  {
131
- this.pict.log.info(`RecordSetList: Rendered list ${tmpResponse.RecordSet} with ${tmpResponse.Records.length} records.`, tmpResponse);
277
+ this.pict.log.info(`RecordSetList: Rendered list ${tmpRecordListData.RecordSet} with ${tmpRecordListData.Records.Records.length} records.`, tmpRecordListData);
132
278
  }
133
279
  else
134
280
  {
135
- this.pict.log.info(`RecordSetList: Rendered list ${tmpResponse.RecordSet} with ${tmpResponse.Records.length} records.`);
281
+ this.pict.log.info(`RecordSetList: Rendered list ${tmpRecordListData.RecordSet} with ${tmpRecordListData.Records.Records.length} records.`);
136
282
  }
137
283
  return true;
138
284
  }.bind(this));
@@ -1,60 +1,74 @@
1
1
  const libPictView = require('pict-view');
2
2
 
3
3
  const _DEFAULT_CONFIGURATION_Read_RecordRead = (
4
- {
5
- ViewIdentifier: 'PRSP-Read-RecordRead',
6
-
7
- DefaultRenderable: 'PRSP_Renderable_RecordRead',
8
- DefaultDestinationAddress: '#PRSP_RecordRead_Container',
9
- DefaultTemplateRecordAddress: false,
10
-
11
- // If this is set to true, when the App initializes this will.
12
- // While the App initializes, initialize will be called.
13
- AutoInitialize: false,
14
- AutoInitializeOrdinal: 0,
15
-
16
- // If this is set to true, when the App autorenders (on load) this will.
17
- // After the App initializes, render will be called.
18
- AutoRender: false,
19
- AutoRenderOrdinal: 0,
20
-
21
- AutoSolveWithApp: false,
22
- AutoSolveOrdinal: 0,
23
-
24
- CSS: false,
25
- CSSPriority: 500,
26
-
27
- Templates:
28
- [
29
- {
30
- Hash: 'PRSP-Read-RecordRead-Template',
31
- Template: /*html*/`
4
+ {
5
+ ViewIdentifier: 'PRSP-Read-RecordRead',
6
+
7
+ DefaultRenderable: 'PRSP_Renderable_RecordRead',
8
+ DefaultDestinationAddress: '#PRSP_RecordRead_Container',
9
+ DefaultTemplateRecordAddress: false,
10
+
11
+ // If this is set to true, when the App initializes this will.
12
+ // While the App initializes, initialize will be called.
13
+ AutoInitialize: false,
14
+ AutoInitializeOrdinal: 0,
15
+
16
+ // If this is set to true, when the App autorenders (on load) this will.
17
+ // After the App initializes, render will be called.
18
+ AutoRender: false,
19
+ AutoRenderOrdinal: 0,
20
+
21
+ AutoSolveWithApp: false,
22
+ AutoSolveOrdinal: 0,
23
+
24
+ CSS: false,
25
+ CSSPriority: 500,
26
+
27
+ Templates:
28
+ [
29
+ {
30
+ Hash: 'PRSP-Read-RecordRead-Template',
31
+ Template: /*html*/`
32
32
  <!-- DefaultPackage pict view template: [PRSP-Read-RecordRead-Template] -->
33
+ <div>
34
+ {~TSWP:PRSP-Read-RecordRead-Template-Row:Record.DisplayFields:Record.Record~}
35
+ </div>
33
36
  <!-- DefaultPackage end view template: [PRSP-Read-RecordRead-Template] -->
34
37
  `
35
- }
36
- ],
37
-
38
- Renderables:
39
- [
40
- {
41
- RenderableHash: 'PRSP_Renderable_RecordRead',
42
- TemplateHash: 'PRSP-Read-RecordRead-Template',
43
- DestinationAddress: '#PRSP_RecordRead_Container',
44
- RenderMethod: 'replace'
45
- }
46
- ],
47
-
48
- Manifests: {}
49
- });
38
+ },
39
+ {
40
+ Hash: 'PRSP-Read-RecordRead-Template-Row',
41
+ Template: /*html*/`
42
+ <!-- DefaultPackage pict view template: [PRSP-Read-RecordRead-Template] -->
43
+ <div>
44
+ <span style="font-style: italic;">{~D:Record.Data.DisplayName~}</span>
45
+ <span style="font-weight: bold;">{~DVBK:Record.Payload:Record.Data.Key~}</span>
46
+ </div>
47
+ <!-- DefaultPackage end view template: [PRSP-Read-RecordRead-Template] -->
48
+ `
49
+ }
50
+ ],
51
+
52
+ Renderables:
53
+ [
54
+ {
55
+ RenderableHash: 'PRSP_Renderable_RecordRead',
56
+ TemplateHash: 'PRSP-Read-RecordRead-Template',
57
+ DestinationAddress: '#PRSP_RecordRead_Container',
58
+ RenderMethod: 'replace'
59
+ }
60
+ ],
61
+
62
+ Manifests: {}
63
+ });
50
64
 
51
65
  class viewRecordSetReadRecordRead extends libPictView
52
66
  {
53
- constructor(pFable, pOptions, pServiceHash)
54
- {
55
- let tmpOptions = Object.assign({}, _DEFAULT_CONFIGURATION_Read_RecordRead, pOptions);
56
- super(pFable, tmpOptions, pServiceHash);
57
- }
67
+ constructor(pFable, pOptions, pServiceHash)
68
+ {
69
+ let tmpOptions = Object.assign({}, _DEFAULT_CONFIGURATION_Read_RecordRead, pOptions);
70
+ super(pFable, tmpOptions, pServiceHash);
71
+ }
58
72
  }
59
73
 
60
74
  module.exports = viewRecordSetReadRecordRead;
@@ -1,60 +1,202 @@
1
- const libPictView = require('pict-view');
1
+ const libPictRecordSetRecordView = require('../RecordSet-RecordBaseView.js');
2
+
3
+
4
+ const viewHeaderRead = require('./RecordSet-Read-HeaderRead.js');
5
+ const viewRecordRead = require('./RecordSet-Read-RecordRead.js');
6
+ const viewRecordReadExtra = require('./RecordSet-Read-RecordReadExtra.js');
7
+ const viewTabBarRead = require('./RecordSet-Read-TabBarRead.js');
2
8
 
3
9
  const _DEFAULT_CONFIGURATION__Read = (
4
- {
5
- ViewIdentifier: 'PRSP-Read',
6
-
7
- DefaultRenderable: 'PRSP_Renderable_Read',
8
- DefaultDestinationAddress: '#PRSP_Read_Container',
9
- DefaultTemplateRecordAddress: false,
10
-
11
- // If this is set to true, when the App initializes this will.
12
- // While the App initializes, initialize will be called.
13
- AutoInitialize: false,
14
- AutoInitializeOrdinal: 0,
15
-
16
- // If this is set to true, when the App autorenders (on load) this will.
17
- // After the App initializes, render will be called.
18
- AutoRender: false,
19
- AutoRenderOrdinal: 0,
20
-
21
- AutoSolveWithApp: false,
22
- AutoSolveOrdinal: 0,
23
-
24
- CSS: false,
25
- CSSPriority: 500,
26
-
27
- Templates:
28
- [
29
- {
30
- Hash: 'PRSP-Read-Template',
31
- Template: /*html*/`
10
+ {
11
+ ViewIdentifier: 'PRSP-Read',
12
+
13
+ DefaultRenderable: 'PRSP_Renderable_Read',
14
+ DefaultDestinationAddress: '#PRSP_Container',
15
+ DefaultTemplateRecordAddress: false,
16
+
17
+ // If this is set to true, when the App initializes this will.
18
+ // While the App initializes, initialize will be called.
19
+ AutoInitialize: false,
20
+ AutoInitializeOrdinal: 0,
21
+
22
+ // If this is set to true, when the App autorenders (on load) this will.
23
+ // After the App initializes, render will be called.
24
+ AutoRender: false,
25
+ AutoRenderOrdinal: 0,
26
+
27
+ AutoSolveWithApp: false,
28
+ AutoSolveOrdinal: 0,
29
+
30
+ CSS: false,
31
+ CSSPriority: 500,
32
+
33
+ Templates:
34
+ [
35
+ {
36
+ Hash: 'PRSP-Read-Template',
37
+ Template: /*html*/`
32
38
  <!-- DefaultPackage pict view template: [PRSP-Read-Template] -->
39
+ <h1>{~D:Record.RecordSet~} {~D:Record.GUIDAddress~} [{~D:Record.RecordConfiguration.GUIDRecord~}]</h1>
40
+ <!--
41
+ {~DJ:Record~}
42
+ -->
43
+ {~T:PRSP-Read-RecordRead-Template~}
33
44
  <!-- DefaultPackage end view template: [PRSP-Read-Template] -->
34
45
  `
35
- }
36
- ],
37
-
38
- Renderables:
39
- [
40
- {
41
- RenderableHash: 'PRSP_Renderable_Read',
42
- TemplateHash: 'PRSP-Read-Template',
43
- DestinationAddress: '#PRSP_Read_Container',
44
- RenderMethod: 'replace'
45
- }
46
- ],
47
-
48
- Manifests: {}
49
- });
50
-
51
- class viewRecordSetRead extends libPictView
46
+ },
47
+ {
48
+ Hash: 'PRSP-Read-Link-Name-Template',
49
+ Template: `View`
50
+ },
51
+ {
52
+ Hash: 'PRSP-Read-Link-URL-Template',
53
+ // TODO: Double payload pattern...
54
+ Template: `#/PSRS/{~D:Record.Payload.Payload.RecordSet~}/Read/{~DVBK:Record.Payload.Data:Record.Payload.Payload.GUIDAddress~}`
55
+ },
56
+ ],
57
+
58
+ Renderables:
59
+ [
60
+ {
61
+ RenderableHash: 'PRSP_Renderable_Read',
62
+ TemplateHash: 'PRSP-Read-Template',
63
+ DestinationAddress: '#PRSP_Container',
64
+ RenderMethod: 'replace'
65
+ }
66
+ ],
67
+
68
+ Manifests: {}
69
+ });
70
+
71
+ class viewRecordSetRead extends libPictRecordSetRecordView
52
72
  {
53
- constructor(pFable, pOptions, pServiceHash)
54
- {
55
- let tmpOptions = Object.assign({}, _DEFAULT_CONFIGURATION__Read, pOptions);
56
- super(pFable, tmpOptions, pServiceHash);
57
- }
73
+ constructor(pFable, pOptions, pServiceHash)
74
+ {
75
+ let tmpOptions = Object.assign({}, _DEFAULT_CONFIGURATION__Read, pOptions);
76
+ super(pFable, tmpOptions, pServiceHash);
77
+
78
+ this.childViews = {
79
+ viewHeaderRead: null,
80
+ viewTabBarRead: null,
81
+ viewRecordRead: null,
82
+ viewRecordReadExtra: null
83
+ };
84
+ }
85
+
86
+
87
+ handleRecordSetReadRoute(pRoutePayload)
88
+ {
89
+ if (typeof(pRoutePayload) != 'object')
90
+ {
91
+ throw new Error(`Pict RecordSet Read view route handler called with invalid route payload.`);
92
+ }
93
+
94
+ const tmpProviderConfiguration = this.pict.PictSectionRecordSet.recordSetProviderConfigurations[pRoutePayload.data.RecordSet];
95
+ const tmpProviderHash = `RSP-Provider-${pRoutePayload.data.RecordSet}`;
96
+
97
+ tmpProviderConfiguration.RoutePayload = pRoutePayload;
98
+ tmpProviderConfiguration.RecordSet = pRoutePayload.data.RecordSet;
99
+ tmpProviderConfiguration.GUIDRecord = pRoutePayload.data.GUIDRecord;
100
+
101
+ return this.renderRead(tmpProviderConfiguration, tmpProviderHash, pRoutePayload.data.GUIDRecord);
102
+ }
103
+
104
+ addRoutes(pPictRouter)
105
+ {
106
+ pPictRouter.addRoute('/PSRS/:RecordSet/Read/:GUIDRecord', this.handleRecordSetReadRoute.bind(this));
107
+ return true;
108
+ }
109
+
110
+ onBeforeRenderRead(pRecordReadData)
111
+ {
112
+ this.formatDisplayData(pRecordReadData);
113
+ return pRecordReadData;
114
+ }
115
+
116
+ formatDisplayData(pRecordListData)
117
+ {
118
+ pRecordListData.DisplayFields = [];
119
+ const tmpSchema = pRecordListData.RecordSchema;
120
+ const tmpProperties = tmpSchema?.properties;
121
+ // loop throught the schema and add the columns to the tableCells -- just show all for now.
122
+ for (const tmpColumn in tmpProperties)
123
+ {
124
+ pRecordListData.DisplayFields.push({
125
+ 'Key': tmpColumn,
126
+ 'DisplayName': tmpProperties?.[tmpColumn].title || tmpColumn,
127
+ });
128
+ }
129
+ return pRecordListData;
130
+ }
131
+
132
+ async renderRead(pRecordConfiguration, pProviderHash, pRecordGUID)
133
+ {
134
+ // Get the records
135
+ if (!(pProviderHash in this.pict.providers))
136
+ {
137
+ this.pict.log.error(`RecordSetRead: No provider found for ${pProviderHash} in ${pRecordConfiguration.RecordSet}. Read Render failed.`);
138
+ return false;
139
+ }
140
+
141
+ let tmpRecordReadData =
142
+ {
143
+ "RecordSet": pRecordConfiguration.RecordSet,
144
+
145
+ "RecordConfiguration": pRecordConfiguration,
146
+
147
+ "RenderDestination": this.options.DefaultDestinationAddress,
148
+
149
+ "Record": false,
150
+ };
151
+
152
+ // If the record configuration does not have a GUID, try to infer one from the RecordSet name
153
+ // TODO: This should be coming from the schema but that can come after we discuss how we deal with default routing
154
+ tmpRecordReadData.GUIDAddress = `GUID${this.pict.providers[pProviderHash].options.Entity}`;
155
+
156
+ tmpRecordReadData.Record = await this.pict.providers[pProviderHash].getRecordByGUID(pRecordGUID);
157
+ tmpRecordReadData.RecordSchema = this.pict.providers[pProviderHash].recordSchema;
158
+
159
+ tmpRecordReadData = this.onBeforeRenderRead(tmpRecordReadData);
160
+
161
+ this.renderAsync('PRSP_Renderable_Read', tmpRecordReadData.RenderDestination, tmpRecordReadData,
162
+ function (pError)
163
+ {
164
+ if (pError)
165
+ {
166
+ this.pict.log.error(`RecordSetRead: Error rendering read ${pError}`, tmpRecordReadData);
167
+ return false;
168
+ }
169
+
170
+ if (this.pict.LogNoisiness > 0)
171
+ {
172
+ this.pict.log.info(`RecordSetRead: Rendered read ${tmpRecordReadData.RecordSet} with ${tmpRecordReadData.RecordConfiguration.GUIDRecord} []`, tmpRecordReadData);
173
+ }
174
+ else
175
+ {
176
+ this.pict.log.info(`RecordSetRead: Rendered read ${tmpRecordReadData.RecordSet} with ${tmpRecordReadData.RecordConfiguration.GUIDRecord} []`);
177
+ }
178
+ return true;
179
+ }.bind(this));
180
+ }
181
+
182
+ onInitialize()
183
+ {
184
+ this.childViews.headerRead = this.pict.addView('PRSP-Read-HeaderRead', viewHeaderRead.default_configuration, viewHeaderRead);
185
+ this.childViews.recordRead = this.pict.addView('PRSP-Read-RecordRead', viewRecordRead.default_configuration, viewRecordRead);
186
+ this.childViews.recordReadExtra = this.pict.addView('PRSP-Read-RecordReadExtra', viewRecordReadExtra.default_configuration, viewRecordReadExtra);
187
+ this.childViews.tabBarRead = this.pict.addView('PRSP-Read-TabBarRead', viewTabBarRead.default_configuration, viewTabBarRead);
188
+
189
+ // // Initialize the subviews
190
+ this.childViews.headerRead.initialize();
191
+ this.childViews.recordRead.initialize();
192
+ this.childViews.recordReadExtra.initialize();
193
+ this.childViews.tabBarRead.initialize();
194
+
195
+ // Add the route templates for the read view
196
+ this.pict.PictSectionRecordSet.addRecordLinkTemplate('PRSP-Read-Link-Name-Template', 'PRSP-Read-Link-URL-Template', true);
197
+
198
+ return super.onInitialize();
199
+ }
58
200
  }
59
201
 
60
202
  module.exports = viewRecordSetRead;
@@ -74,6 +74,10 @@ suite
74
74
  Expect(_Application).to.be.an('object', 'Application should be an object.');
75
75
  Expect(_Application).to.be.an.instanceof(libPictSectionRecordSet.PictRecordSetApplication, 'Application should be an instance of PictRecordSetApplication.');
76
76
 
77
+ _Application.testDone = fDone;
78
+
79
+ _Application.initialize();
80
+
77
81
 
78
82
  // let _PictSectionRecordSet = _Pict.addView(tmpViewHash, tmpViewConfiguration, libPictSectionRecordSet);
79
83
 
@@ -87,7 +91,7 @@ suite
87
91
  // Expect(_PictSectionRecordSet._Package).to.be.an('object', 'Should have a _Package object.');
88
92
  // Expect(_PictSectionRecordSet._Package.name).to.equal('pict-section-recordset', '_Package.package.name should be set.');
89
93
 
90
- return fDone();
94
+ // return fDone();
91
95
  }
92
96
  );
93
97
  });
@@ -74,7 +74,7 @@ suite
74
74
  let _PictEnvironment = new libPict.EnvironmentObject(_Pict);
75
75
 
76
76
  let _Application = new DoNothingApplication(_Pict, {});
77
- _Pict.addProvider('BooksProvider', { Entity: 'Book', URLPrefix: 'http://www.datadebase.com:8086/1.0/' }, require('../source/providers/RecordSet-RecordProvider-MeadowEndpoints.js'));
77
+ _Pict.addProvider('BooksProvider', { Entity: 'Book', URLPrefix: 'http://localhost:8086/1.0/' }, require('../source/providers/RecordSet-RecordProvider-MeadowEndpoints.js'));
78
78
  await new Promise((resolve, reject) => _Application.initializeAsync((error) =>
79
79
  {
80
80
  if (error)
@@ -1,7 +1,11 @@
1
1
  declare const _exports: {
2
2
  new (pFable: any, pOptions: any, pServiceHash: any): import("./services/RecordsSet-MetaController.js");
3
- default_configuration: {};
3
+ default_configuration: {
4
+ DefaultMeadowURLPrefix: string;
5
+ };
4
6
  PictRecordSetApplication: typeof import("./application/Pict-Application-RecordSet.js");
7
+ RecordSetProviderBase: typeof import("./providers/RecordSet-RecordProvider-Base.js");
8
+ RecordSetProviderMeadowEndpoints: typeof import("./providers/RecordSet-RecordProvider-MeadowEndpoints.js");
5
9
  };
6
10
  export = _exports;
7
11
  //# sourceMappingURL=Pict-Section-RecordSet.d.ts.map