pict-section-form 1.0.165 → 1.0.166

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.
@@ -2,6 +2,62 @@ const libPictSectionForm = require('../../source/Pict-Section-Form.js');
2
2
 
3
3
  const libCustomDataProvider = require('./Complex-Tabular-CustomDataProvider.js');
4
4
 
5
+ const SelectInputProvider = require('../../source/providers/inputs/Pict-Provider-Input-Select.js');
6
+
7
+ class CustomSelectInputProvider extends SelectInputProvider
8
+ {
9
+ /**
10
+ * Handles events for the Pict-Provider-InputExtension.
11
+ *
12
+ * @param {Object} pView - The view object.
13
+ * @param {Object} pInput - The input object.
14
+ * @param {any} pValue - The value from AppData.
15
+ * @param {string} pHTMLSelector - The HTML selector.
16
+ * @param {string} pEvent - The event hash that is expected to be triggered.
17
+ * @param {string} pTransactionGUID - The transaction GUID, if any.
18
+ * @returns {boolean} - Returns true.
19
+ */
20
+ onEvent(pView, pInput, pValue, pHTMLSelector, pEvent, pTransactionGUID)
21
+ {
22
+ const tmpResult = super.onEvent(pView, pInput, pValue, pHTMLSelector, pEvent, pTransactionGUID);
23
+ if (typeof pEvent !== "string")
24
+ {
25
+ return tmpResult;
26
+ }
27
+ const tmpEventParts = pEvent.split(':');
28
+ const tmpEventHash = tmpEventParts[0];
29
+ if (tmpEventHash !== 'GetPickList')
30
+ {
31
+ return tmpResult;
32
+ }
33
+ const tmpListHash = tmpEventParts[1];
34
+ if (tmpListHash !== pInput.PictForm.SelectOptionsPickList)
35
+ {
36
+ return tmpResult;
37
+ }
38
+ const tmpListDataAddress = tmpEventParts[2];
39
+ const tmpEventOptions = JSON.parse(tmpEventParts.slice(3).join(':'));
40
+ this.pict.log.info(`CustomSelectInputProvider received event: ${pEvent} for list ${tmpListHash} with options:`, { tmpEventHash, tmpListHash, tmpListDataAddress, tmpEventOptions });
41
+ const tmpListData = this.pict.manifest.getValueByHash(this.pict, tmpListDataAddress);
42
+ if (!Array.isArray(tmpListData))
43
+ {
44
+ this.pict.log.error(`CustomSelectInputProvider expected array data at address ${tmpListDataAddress} but found:`, { tmpListData });
45
+ return tmpResult;
46
+ }
47
+ if (tmpListData.length > 0)
48
+ {
49
+ return tmpResult;
50
+ }
51
+ for (let i = 0; i < 10; ++i)
52
+ {
53
+ const tmpRandomNumber = Math.floor(Math.random() * 1000);
54
+ tmpListData.push({ id: `random-${tmpRandomNumber}`, text: `${tmpRandomNumber}` });
55
+ }
56
+
57
+ return tmpResult;
58
+ }
59
+ }
60
+
5
61
  class ComplexTabularApplication extends libPictSectionForm.PictFormApplication
6
62
  {
7
63
  constructor(pFable, pOptions, pServiceHash)
@@ -16,6 +72,12 @@ class ComplexTabularApplication extends libPictSectionForm.PictFormApplication
16
72
  this.pict.AppData.UI.StatisticsTabState = "FruitStatistics";
17
73
  this.pict.addProvider('CustomDataProvider', libCustomDataProvider.default_configuration, libCustomDataProvider);
18
74
  }
75
+
76
+ onInitialize()
77
+ {
78
+ this.pict.addProvider('Pict-Input-Select', CustomSelectInputProvider.default_configuration, CustomSelectInputProvider);
79
+ return super.onInitialize();
80
+ }
19
81
  }
20
82
 
21
83
  module.exports = ComplexTabularApplication;
@@ -67,7 +129,11 @@ module.exports.default_configuration.pict_configuration = {
67
129
  IDTemplate: "{~D:Record.IDBook~}",
68
130
  Sorted: true,
69
131
  UpdateFrequency: "Always",
70
- }
132
+ },
133
+ {
134
+ Hash: "RandomNumbers",
135
+ Dynamic: true,
136
+ },
71
137
  ],
72
138
 
73
139
  Sections: [
@@ -200,6 +266,12 @@ module.exports.default_configuration.pict_configuration = {
200
266
  ],
201
267
 
202
268
  Descriptors: {
269
+ RandomNumber: {
270
+ Name: "Pick a Random Number",
271
+ Hash: "PickRandomNumber",
272
+ DataType: "String",
273
+ PictForm: { Section: "Recipe", Group: "Recipe", Row: 1, InputType: "Option", SelectOptionsPickList: "RandomNumbers" },
274
+ },
203
275
  RecipeName: {
204
276
  Name: "Recipe Name",
205
277
  Hash: "RecipeName",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pict-section-form",
3
- "version": "1.0.165",
3
+ "version": "1.0.166",
4
4
  "description": "Pict dynamic form sections",
5
5
  "main": "source/Pict-Section-Form.js",
6
6
  "directories": {
@@ -45,7 +45,7 @@
45
45
  "chart.js": "^4.5.1",
46
46
  "fable-serviceproviderbase": "^3.0.15",
47
47
  "marked": "^15.0.12",
48
- "pict-provider": "^1.0.6",
48
+ "pict-provider": "^1.0.7",
49
49
  "pict-section-tuigrid": "^1.0.27",
50
50
  "pict-template": "^1.0.13",
51
51
  "pict-view": "^1.0.64"
@@ -30,7 +30,7 @@ class PictMetalist extends libPictProvider
30
30
 
31
31
  /** @type {any} */
32
32
  this.options;
33
- /** @type {import('pict')} */
33
+ /** @type {import('pict') & { log: any, instantiateServiceProviderWithoutRegistration: (hash: String) => any, instantiateServiceProviderIfNotExists: (hash: string) => any, TransactionTracking: import('pict/types/source/services/Fable-Service-TransactionTracking') }} */
34
34
  this.pict;
35
35
  /** @type {import('pict')} */
36
36
  this.fable;
@@ -44,15 +44,31 @@ class PictMetalist extends libPictProvider
44
44
  this.computedLists = {};
45
45
  this.listDefinitions = {};
46
46
  }
47
+ /** @typedef {{ id: string, text: string }} PickListItem */
47
48
 
48
49
  /**
49
50
  * Retrieves a list based on the provided view hash and list hash.
50
51
  *
51
52
  * @param {string} pListHash - The list hash.
52
- * @returns {Array} - The retrieved list.
53
+ * @param {Object} [pOptions={}] - (optional) Additional options for retrieving the list. (ex. search term)
54
+ *
55
+ * @returns {Array<PickListItem>} - The retrieved list.
53
56
  */
54
- getList(pListHash)
57
+ getList(pListHash, pOptions = {})
55
58
  {
59
+ if (this.listDefinitions[pListHash].Dynamic)
60
+ {
61
+ const tmpList = [];
62
+ const tmpTransactionGUID = this.pict.getUUID();
63
+ const tmpHash = tmpTransactionGUID.substring(0, 8);
64
+ const tmpAddress = `AppData._MetaLists.${tmpHash}`;
65
+ this.pict.manifest.setValueByHash(this.pict, tmpAddress, tmpList);
66
+ this.pict.TransactionTracking.registerTransaction(tmpTransactionGUID);
67
+ this.pict.views.PictFormMetacontroller.triggerGlobalInputEvent(`GetPickList:${pListHash}:${tmpAddress}:${JSON.stringify(pOptions)}`, tmpTransactionGUID);
68
+ this.pict.views.PictFormMetacontroller.finalizeTransaction(tmpTransactionGUID);
69
+ delete this.pict.AppData._MetaLists[tmpHash];
70
+ return tmpList;
71
+ }
56
72
  if (pListHash in this.computedLists)
57
73
  {
58
74
  return this.computedLists[pListHash];
@@ -5,19 +5,30 @@ export = PictMetalist;
5
5
  declare class PictMetalist extends libPictProvider {
6
6
  /** @type {any} */
7
7
  options: any;
8
- /** @type {import('pict')} */
9
- pict: import("pict");
8
+ /** @type {import('pict') & { log: any, instantiateServiceProviderWithoutRegistration: (hash: String) => any, instantiateServiceProviderIfNotExists: (hash: string) => any, TransactionTracking: import('pict/types/source/services/Fable-Service-TransactionTracking') }} */
9
+ pict: import("pict") & {
10
+ log: any;
11
+ instantiateServiceProviderWithoutRegistration: (hash: string) => any;
12
+ instantiateServiceProviderIfNotExists: (hash: string) => any;
13
+ TransactionTracking: import("pict/types/source/services/Fable-Service-TransactionTracking");
14
+ };
10
15
  /** @type {import('pict')} */
11
16
  fable: import("pict");
12
17
  computedLists: {};
13
18
  listDefinitions: {};
19
+ /** @typedef {{ id: string, text: string }} PickListItem */
14
20
  /**
15
21
  * Retrieves a list based on the provided view hash and list hash.
16
22
  *
17
23
  * @param {string} pListHash - The list hash.
18
- * @returns {Array} - The retrieved list.
24
+ * @param {Object} [pOptions={}] - (optional) Additional options for retrieving the list. (ex. search term)
25
+ *
26
+ * @returns {Array<PickListItem>} - The retrieved list.
19
27
  */
20
- getList(pListHash: string): any[];
28
+ getList(pListHash: string, pOptions?: any): Array<{
29
+ id: string;
30
+ text: string;
31
+ }>;
21
32
  /**
22
33
  * Checks if a list exists in the Pict Provider MetaLists.
23
34
  *
@@ -1 +1 @@
1
- {"version":3,"file":"Pict-Provider-MetaLists.d.ts","sourceRoot":"","sources":["../../../source/providers/Pict-Provider-MetaLists.js"],"names":[],"mappings":";AAaA;;GAEG;AACH;IAcE,kBAAkB;IAClB,SADW,GAAG,CACF;IACZ,6BAA6B;IAC7B,MADW,OAAO,MAAM,CAAC,CAChB;IACT,6BAA6B;IAC7B,OADW,OAAO,MAAM,CAAC,CACf;IAQV,kBAAuB;IACvB,oBAAyB;IAG1B;;;;;OAKG;IACH,mBAHW,MAAM,SAUhB;IAED;;;;;OAKG;IACH,mBAHW,MAAM,GACJ,OAAO,CAKnB;IAED;;;OAGG;IACH,iDAsBC;IAED;;;;OAIG;IACH,6BAFW,MAAM,QAQhB;IAED;;;;OAIG;IACH,qCAwGC;CACD;;;;;AA9ND,kCAAkC;AAClC,6CADW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAS3B"}
1
+ {"version":3,"file":"Pict-Provider-MetaLists.d.ts","sourceRoot":"","sources":["../../../source/providers/Pict-Provider-MetaLists.js"],"names":[],"mappings":";AAaA;;GAEG;AACH;IAcE,kBAAkB;IAClB,SADW,GAAG,CACF;IACZ,6QAA6Q;IAC7Q,MADW,OAAO,MAAM,CAAC,GAAG;QAAE,GAAG,EAAE,GAAG,CAAC;QAAC,6CAA6C,EAAE,CAAC,IAAI,QAAQ,KAAK,GAAG,CAAC;QAAC,qCAAqC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,GAAG,CAAC;QAAC,mBAAmB,EAAE,OAAO,8DAA8D,CAAC,CAAA;KAAE,CAChQ;IACT,6BAA6B;IAC7B,OADW,OAAO,MAAM,CAAC,CACf;IAQV,kBAAuB;IACvB,oBAAyB;IAE1B,2DAA2D;IAE3D;;;;;;;OAOG;IACH,mBALW,MAAM,mBAGJ,KAAK;YARE,MAAM;cAAQ,MAAM;MAQR,CAsB/B;IAED;;;;;OAKG;IACH,mBAHW,MAAM,GACJ,OAAO,CAKnB;IAED;;;OAGG;IACH,iDAsBC;IAED;;;;OAIG;IACH,6BAFW,MAAM,QAQhB;IAED;;;;OAIG;IACH,qCAwGC;CACD;;;;;AA9OD,kCAAkC;AAClC,6CADW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAS3B"}
@@ -9,7 +9,7 @@ declare class PictMetatemplateGenerator extends libPictProvider {
9
9
  /** @type {libPictViewDynamicForm} */
10
10
  dynamicInputView: libPictViewDynamicForm;
11
11
  baseTemplatePrefix: string;
12
- onInitializeAsync(fCallback: any): any;
12
+ onInitializeAsync(fCallback: any): void;
13
13
  createOnDemandMetatemplateView(): void;
14
14
  /**
15
15
  * Retrieves the metatemplate template reference in raw format.
@@ -1 +1 @@
1
- {"version":3,"file":"Pict-Provider-MetatemplateGenerator.d.ts","sourceRoot":"","sources":["../../../source/providers/Pict-Provider-MetatemplateGenerator.js"],"names":[],"mappings":";AAkDA;;;GAGG;AACH;IAcE,6BAA6B;IAC7B,MADW,OAAO,MAAM,CAAC,CAChB;IAIT,qCAAqC;IACrC,kBADW,sBAAsB,CACZ;IAErB,2BAAwC;IAGzC,uCAIC;IAED,uCAYC;IAED;;;;;;;OAOG;IACH,kEAJW,MAAM,2BACN,MAAM,GACJ,MAAM,CAmBlB;IAED;;;;;;;OAOG;IACH,+DAJW,MAAM,oBACN,MAAM,GACJ,MAAM,CAKlB;IAED;;;;;;;;OAQG;IACH,6DALW,MAAM,cACN,MAAM,oBACN,MAAM,GACJ,MAAM,CA4BlB;IAED;;;;;;;;;;OAUG;IACH,oEAPW,MAAM,cACN,MAAM,oBACN,MAAM,eACN,MAAM,aACN,MAAM,GACJ,MAAM,CAqDlB;IAED;;;;;;;;OAQG;IACH,qEALW,MAAM,cACN,MAAM,oBACN,MAAM,GACJ,MAAM,CA4BlB;IAED;;;;;;OAMG;IACH,qDA2BC;IAED;;;;;;OAMG;IACH,wCA8BC;CACD;;;;;;AA3VD,kCAAkC;AAClC,6CADW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAS3B"}
1
+ {"version":3,"file":"Pict-Provider-MetatemplateGenerator.d.ts","sourceRoot":"","sources":["../../../source/providers/Pict-Provider-MetatemplateGenerator.js"],"names":[],"mappings":";AAkDA;;;GAGG;AACH;IAcE,6BAA6B;IAC7B,MADW,OAAO,MAAM,CAAC,CAChB;IAIT,qCAAqC;IACrC,kBADW,sBAAsB,CACZ;IAErB,2BAAwC;IAGzC,wCAIC;IAED,uCAYC;IAED;;;;;;;OAOG;IACH,kEAJW,MAAM,2BACN,MAAM,GACJ,MAAM,CAmBlB;IAED;;;;;;;OAOG;IACH,+DAJW,MAAM,oBACN,MAAM,GACJ,MAAM,CAKlB;IAED;;;;;;;;OAQG;IACH,6DALW,MAAM,cACN,MAAM,oBACN,MAAM,GACJ,MAAM,CA4BlB;IAED;;;;;;;;;;OAUG;IACH,oEAPW,MAAM,cACN,MAAM,oBACN,MAAM,eACN,MAAM,aACN,MAAM,GACJ,MAAM,CAqDlB;IAED;;;;;;;;OAQG;IACH,qEALW,MAAM,cACN,MAAM,oBACN,MAAM,GACJ,MAAM,CA4BlB;IAED;;;;;;OAMG;IACH,qDA2BC;IAED;;;;;;OAMG;IACH,wCA8BC;CACD;;;;;;AA3VD,kCAAkC;AAClC,6CADW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAS3B"}