pict-section-form 1.0.125 → 1.0.128

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/debug/Harness.js CHANGED
@@ -3,5 +3,5 @@ const libParseCSV = require('../utility/csvparser/ParseCSV-Program.js');
3
3
  // This command takes the `TabularManifestCSV.csv` file and imports it into a JSON file
4
4
  //libParseCSV.run(['node', 'Harness.js', 'import']);
5
5
  // This command takes the `data/MathExampleForm.json` file and injects any sidecare files in the `input_data` folder into the JSON file
6
- //libParseCSV.run(['node', 'Harness.js', 'inject']);
7
- libParseCSV.run(['node', 'Harness.js', 'intersect']);
6
+ libParseCSV.run(['node', 'Harness.js', 'inject']);
7
+ //libParseCSV.run(['node', 'Harness.js', 'intersect']);
@@ -868,7 +868,7 @@
868
868
  "ExtraData": ""
869
869
  },
870
870
  {
871
- "Identifier": "C",
871
+ "Identifier": "C and 4\" Nails",
872
872
  "Width": "1",
873
873
  "Height": "1",
874
874
  "Depth": "1",
@@ -868,7 +868,7 @@
868
868
  "ExtraData": ""
869
869
  },
870
870
  {
871
- "Identifier": "C",
871
+ "Identifier": "C and 4\" Nails",
872
872
  "Width": "1",
873
873
  "Height": "1",
874
874
  "Depth": "1",
@@ -1,7 +1,7 @@
1
1
  Identifier,Width,Height,Depth,ExtraData
2
2
  A,1,1,1,
3
3
  B,1,1,1,
4
- C,1,1,1,
4
+ "C and 4"" Nails",1,1,1,
5
5
  D,1,1,1,
6
6
  E,1,1,1,
7
7
  F,1,1,1,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pict-section-form",
3
- "version": "1.0.125",
3
+ "version": "1.0.128",
4
4
  "description": "Pict dynamic form sections",
5
5
  "main": "source/Pict-Section-Form.js",
6
6
  "directories": {
@@ -283,10 +283,10 @@ class PictDynamicFormsSolverBehaviors extends libPictProvider
283
283
  * @param {string} pInputHash - The hash of the input to color.
284
284
  * @param {string} pColor - The HTML hex color to apply (e.g. #FF0000 for red).
285
285
  * @param {string} pApplyChange - If "0", the change will not be applied.
286
- * @param {string} [pClassTarget] - Optional. If provided, the color will be applied to the closest element with this class instead of the input itself.
286
+ * @param {string} [pCSSSelector] - Optional. If provided, the color will be applied to the closest element matching this selector instead of the input itself.
287
287
  * @returns {boolean} - Returns true if the color was applied successfully or if the change was skipped for pApplyChange equal to "0", false otherwise.
288
288
  */
289
- colorInputBackground(pSectionHash, pInputHash, pColor, pApplyChange, pClassTarget)
289
+ colorInputBackground(pSectionHash, pInputHash, pColor, pApplyChange, pCSSSelector)
290
290
  {
291
291
  if (pApplyChange == "0")
292
292
  {
@@ -321,13 +321,13 @@ class PictDynamicFormsSolverBehaviors extends libPictProvider
321
321
 
322
322
  // if we passed a class target, find the closest element with that class and apply the color to it
323
323
  // otherwise, just apply it to the input element itself
324
- if (pClassTarget)
324
+ if (pCSSSelector)
325
325
  {
326
326
  // find closest target by class name and if we find it, immediately break out of the loop
327
327
  for (let i = 0; i < tmpElementSet.length; i++)
328
328
  {
329
329
  const element = tmpElementSet[i];
330
- const closest = element.closest(`.${pClassTarget}`);
330
+ const closest = element.closest(`${pCSSSelector}`);
331
331
  if (closest)
332
332
  {
333
333
  tmpElement = closest;
@@ -624,7 +624,7 @@ class ManifestFactory extends libFableServiceProviderBase
624
624
  {
625
625
  // Clean up the equation a bit to remove any leading/trailing spaces and replace HTML quotes
626
626
  // that may have been added by the CSV or other source.
627
- const tmpCleanEquation = tmpRecord['Equation'].trim().replace(/&quot;/g, '"');
627
+ const tmpCleanEquation = tmpRecord['Equation'].trim();
628
628
  this.log.trace(`Adding solver to ${tmpRecord.Form} --> ${tmpGroup.Name} for ${tmpRecord['Input Hash']}: ${tmpRecord['Equation']}`);
629
629
  if ((tmpGroup.Layout == 'Tabular') || (tmpGroup.Layout == 'RecordSet'))
630
630
  {
@@ -7,6 +7,10 @@ const libPictViewDynamicForm = require('./Pict-View-DynamicForm.js');
7
7
  // TODO: Manage view lifecycle internally, including destruction of views if they are flagged to not be needed.
8
8
  // Why? This allows us to dynamically add and remove sections without having to reload the application.
9
9
 
10
+ const PENDING_ASYNC_OPERATION_TYPE = 'PendingAsyncOperation';
11
+ const TRANSACTION_COMPLETE_CALLBACK_TYPE = 'onTransactionComplete';
12
+ const READY_TO_FINALIZE_TYPE = 'ReadyToFinalize';
13
+
10
14
  /**
11
15
  * @typedef {(a: any, b: any) => number} SortFunction
12
16
  */
@@ -940,6 +944,146 @@ class PictFormMetacontroller extends libPictViewClass
940
944
  }
941
945
  }
942
946
 
947
+ /**
948
+ * @param {string} pTransactionGUID - The transaction GUID.
949
+ * @param {string} pAsyncOperationHash - The hash of the async operation.
950
+ */
951
+ registerEventTransactionAsyncOperation(pTransactionGUID, pAsyncOperationHash)
952
+ {
953
+ this.pict.TransactionTracking.pushToTransactionQueue(pTransactionGUID, pAsyncOperationHash, PENDING_ASYNC_OPERATION_TYPE);
954
+ }
955
+
956
+ /**
957
+ * @param {string} pTransactionGUID - The transaction GUID.
958
+ * @param {string} pAsyncOperationHash - The hash of the async operation.
959
+ *
960
+ * @return {boolean} - Returns true if the async operation was found and marked as complete, otherwise false.
961
+ */
962
+ eventTransactionAsyncOperationComplete(pTransactionGUID, pAsyncOperationHash)
963
+ {
964
+ const tmpQueue = this.pict.TransactionTracking.checkTransactionQueue(pTransactionGUID);
965
+ let tmpPendingAsyncOperationCount = 0;
966
+ let tmpMarkedOperationCount = 0;
967
+ let tmpFinalized = false;
968
+ for (let i = 0; i < tmpQueue.length; i++)
969
+ {
970
+ const tmpQueueItem = tmpQueue[i];
971
+ if (tmpQueueItem.Type === PENDING_ASYNC_OPERATION_TYPE)
972
+ {
973
+ if (tmpQueueItem.Data === pAsyncOperationHash)
974
+ {
975
+ tmpQueue.splice(i, 1);
976
+ ++tmpMarkedOperationCount;
977
+ --i;
978
+ }
979
+ else
980
+ {
981
+ ++tmpPendingAsyncOperationCount;
982
+ }
983
+ }
984
+ if (tmpQueueItem.Type === READY_TO_FINALIZE_TYPE)
985
+ {
986
+ tmpFinalized = true;
987
+ }
988
+ }
989
+ if (tmpPendingAsyncOperationCount === 0)
990
+ {
991
+ for (const tmpQueueItem of tmpQueue)
992
+ {
993
+ if (tmpQueueItem.Type === TRANSACTION_COMPLETE_CALLBACK_TYPE)
994
+ {
995
+ if (typeof tmpQueueItem.Data !== 'function')
996
+ {
997
+ this.log.error(`PICT View Metatemplate Helper eventTransactionAsyncOperationComplete transaction callback was not a function.`);
998
+ continue;
999
+ }
1000
+ try
1001
+ {
1002
+ tmpQueueItem.Data();
1003
+ }
1004
+ catch (pError)
1005
+ {
1006
+ this.log.error(`PICT View Metatemplate Helper eventTransactionAsyncOperationComplete transaction callback error: ${pError}`, { Stack: pError.stack });
1007
+ }
1008
+ }
1009
+ }
1010
+ }
1011
+ return tmpMarkedOperationCount > 0;
1012
+ }
1013
+
1014
+ /**
1015
+ * @param {string} pTransactionGUID - The transaction GUID.
1016
+ *
1017
+ * @return {boolean} - Returns true if the transaction was found and able to be finalized, otherwise false.
1018
+ */
1019
+ finalizeTransaction(pTransactionGUID)
1020
+ {
1021
+ this.pict.TransactionTracking.pushToTransactionQueue(pTransactionGUID, null, READY_TO_FINALIZE_TYPE);
1022
+
1023
+ const tmpQueue = this.pict.TransactionTracking.checkTransactionQueue(pTransactionGUID);
1024
+ let tmpPendingAsyncOperationCount = 0;
1025
+ for (const tmpQueueItem of tmpQueue)
1026
+ {
1027
+ if (tmpQueueItem.Type === PENDING_ASYNC_OPERATION_TYPE)
1028
+ {
1029
+ ++tmpPendingAsyncOperationCount;
1030
+ }
1031
+ }
1032
+ if (tmpPendingAsyncOperationCount > 0)
1033
+ {
1034
+ this.pict.log.info(`PICT View Metatemplate Helper finalizeTransaction ${pTransactionGUID} is waiting on ${tmpPendingAsyncOperationCount} pending async operations.`);
1035
+ return false;
1036
+ }
1037
+ for (const tmpQueueItem of tmpQueue)
1038
+ {
1039
+ if (tmpQueueItem.Type === TRANSACTION_COMPLETE_CALLBACK_TYPE)
1040
+ {
1041
+ if (typeof tmpQueueItem.Data !== 'function')
1042
+ {
1043
+ this.log.error(`PICT View Metatemplate Helper eventTransactionAsyncOperationComplete transaction callback was not a function.`);
1044
+ continue;
1045
+ }
1046
+ try
1047
+ {
1048
+ tmpQueueItem.Data();
1049
+ }
1050
+ catch (pError)
1051
+ {
1052
+ this.log.error(`PICT View Metatemplate Helper eventTransactionAsyncOperationComplete transaction callback error: ${pError}`, { Stack: pError.stack });
1053
+ }
1054
+ }
1055
+ }
1056
+ //TODO: figure out how to safely clean up old transactions
1057
+ //delete this.pict.TransactionTracking.transactions[pTransactionGUID];
1058
+ return true;
1059
+ }
1060
+
1061
+ /**
1062
+ * @param {string} pTransactionGUID - The transaction GUID.
1063
+ * @param {Function} fCallback - The callback to call when the transaction is complete.
1064
+ */
1065
+ registerOnTransactionCompleteCallback(pTransactionGUID, fCallback)
1066
+ {
1067
+ const tmpQueue = this.pict.TransactionTracking.checkTransactionQueue(pTransactionGUID);
1068
+ let tmpFinalized = false;
1069
+ for (const tmpQueueItem of tmpQueue)
1070
+ {
1071
+ if (tmpQueueItem.Type === READY_TO_FINALIZE_TYPE)
1072
+ {
1073
+ tmpFinalized = true;
1074
+ break;
1075
+ }
1076
+ }
1077
+ if (tmpFinalized)
1078
+ {
1079
+ fCallback();
1080
+ }
1081
+ else
1082
+ {
1083
+ this.pict.TransactionTracking.pushToTransactionQueue(pTransactionGUID, fCallback, TRANSACTION_COMPLETE_CALLBACK_TYPE);
1084
+ }
1085
+ }
1086
+
943
1087
  /**
944
1088
  * Returns whether the object is a Pict Metacontroller.
945
1089
  *
@@ -44,10 +44,10 @@ declare class PictDynamicFormsSolverBehaviors extends libPictProvider {
44
44
  * @param {string} pInputHash - The hash of the input to color.
45
45
  * @param {string} pColor - The HTML hex color to apply (e.g. #FF0000 for red).
46
46
  * @param {string} pApplyChange - If "0", the change will not be applied.
47
- * @param {string} [pClassTarget] - Optional. If provided, the color will be applied to the closest element with this class instead of the input itself.
47
+ * @param {string} [pCSSSelector] - Optional. If provided, the color will be applied to the closest element matching this selector instead of the input itself.
48
48
  * @returns {boolean} - Returns true if the color was applied successfully or if the change was skipped for pApplyChange equal to "0", false otherwise.
49
49
  */
50
- colorInputBackground(pSectionHash: string, pInputHash: string, pColor: string, pApplyChange: string, pClassTarget?: string): boolean;
50
+ colorInputBackground(pSectionHash: string, pInputHash: string, pColor: string, pApplyChange: string, pCSSSelector?: string): boolean;
51
51
  logValues(...args: any[]): any;
52
52
  }
53
53
  declare namespace PictDynamicFormsSolverBehaviors {
@@ -160,6 +160,29 @@ declare class PictFormMetacontroller extends libPictViewClass {
160
160
  * @param {string} [pTransactionGUID] - (optional) The transaction GUID to use for the event.
161
161
  */
162
162
  triggerGlobalInputEvent(pEvent: string, pTransactionGUID?: string): void;
163
+ /**
164
+ * @param {string} pTransactionGUID - The transaction GUID.
165
+ * @param {string} pAsyncOperationHash - The hash of the async operation.
166
+ */
167
+ registerEventTransactionAsyncOperation(pTransactionGUID: string, pAsyncOperationHash: string): void;
168
+ /**
169
+ * @param {string} pTransactionGUID - The transaction GUID.
170
+ * @param {string} pAsyncOperationHash - The hash of the async operation.
171
+ *
172
+ * @return {boolean} - Returns true if the async operation was found and marked as complete, otherwise false.
173
+ */
174
+ eventTransactionAsyncOperationComplete(pTransactionGUID: string, pAsyncOperationHash: string): boolean;
175
+ /**
176
+ * @param {string} pTransactionGUID - The transaction GUID.
177
+ *
178
+ * @return {boolean} - Returns true if the transaction was found and able to be finalized, otherwise false.
179
+ */
180
+ finalizeTransaction(pTransactionGUID: string): boolean;
181
+ /**
182
+ * @param {string} pTransactionGUID - The transaction GUID.
183
+ * @param {Function} fCallback - The callback to call when the transaction is complete.
184
+ */
185
+ registerOnTransactionCompleteCallback(pTransactionGUID: string, fCallback: Function): void;
163
186
  /**
164
187
  * Returns whether the object is a Pict Metacontroller.
165
188
  *
@@ -1 +1 @@
1
- {"version":3,"file":"Pict-View-Form-Metacontroller.d.ts","sourceRoot":"","sources":["../../../source/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;;;;;;OAOG;IACH,kFAJW,MAAM,GAEJ,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAoLtC;IA5JC,gCAA0D;IAC1D,yBAAiD;IA6JnD;;;;OAIG;IACH,gCAHW,MAAM,qBACN,MAAM,QA0BhB;IAED;;;;OAIG;IACH,4BAFa,OAAO,CAKnB;CACD;;;;;qCAGU,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;oBAh7BjB,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,KAAK,MAAM"}
1
+ {"version":3,"file":"Pict-View-Form-Metacontroller.d.ts","sourceRoot":"","sources":["../../../source/views/Pict-View-Form-Metacontroller.js"],"names":[],"mappings":";AAaA;;GAEG;AAEH;;;;;;GAMG;AACH;IAEC,2DAaC;IALA,yBAA2B;IAE3B,wBAAsF;IAEtF,cAAkC;IAQnC,wCAGC;IARD,kCAGC;IAOD;;;;OAIG;IACH,qBAFa,GAAG,CAaf;IAED;;;;OAIG;IACH,mBAFa,GAAG,CAaf;IAED,yCAYC;IAED;;;;;OAKG;IACH,kCAHW,aAAa,GACX,IAAI,CAsBhB;IAwBD;;;;OAIG;IACH,WAFa,GAAG,CAMf;IAED,gDAGC;IAED,+CAGC;IAED;;;;OAIG;IACH,2DAJW,MAAM,GAEL,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAW9B;IAED;;;OAGG;IACH,0BAHW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,sBACnB,MAAM,QAiChB;IAED;;;;;;;;;OASG;IACH,kCALW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,UACnB,MAAM,GAEL,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAsC9B;IAED;;;;OAIG;IACH,uCAJW,KAAK,CAAC,MAAM,CAAC,sBACb,MAAM,UACN,MAAM,QAahB;IAED;;;OAGG;IACH,6CAHW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,sBACnB,MAAM,SAehB;IAED;;;;;;;;OAQG;IACH,wDAHW,YAAY,SAoHtB;IAED;;;;;;;OAOG;IACH,4CAHW,MAAM,GACJ,IAAI,CAShB;IAED;;;;OAIG;IACH,6BAFa,IAAI,CAQhB;IAED;;;;;;;OAOG;IACH,+DAFW,YAAY,QAatB;IAED;;;;;OAKG;IACH,8EAFW,YAAY,QAmBtB;IAED;;;;;;OAMG;IACH,oEAHW,YAAY,GACV,IAAI,CAkDhB;IAED;;;;;;;OAOG;IACH,uEAJW,YAAY,GAEX,IAAI,CAsFf;IAED;;;;;OAKG;IACH,qCAHW,MAAM,GACJ,MAAM,GAAC,OAAO,CA2C1B;IAED,+CAeC;IAED;;;;;;;OAOG;IACH,kFAJW,MAAM,GAEJ,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAoLtC;IA5JC,gCAA0D;IAC1D,yBAAiD;IA6JnD;;;;OAIG;IACH,gCAHW,MAAM,qBACN,MAAM,QA0BhB;IAED;;;OAGG;IACH,yDAHW,MAAM,uBACN,MAAM,QAKhB;IAED;;;;;OAKG;IACH,yDALW,MAAM,uBACN,MAAM,GAEL,OAAO,CAoDlB;IAED;;;;OAIG;IACH,sCAJW,MAAM,GAEL,OAAO,CA0ClB;IAED;;;OAGG;IACH,wDAHW,MAAM,6BAuBhB;IAED;;;;OAIG;IACH,4BAFa,OAAO,CAKnB;CACD;;;;;qCAGU,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;oBA5jCjB,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,KAAK,MAAM"}
@@ -27,6 +27,7 @@ class ImportExtraDataCSVCommand extends libPictCommandLineUtility.ServiceCommand
27
27
  // Parse the CSV file
28
28
  const tmpRecords = [];
29
29
  const tmpCSVParser = this.fable.instantiateServiceProvider('CSVParser');
30
+ tmpCSVParser.EscapedQuoteString = '"';
30
31
  this.fable.log.info(`Parsing CSV file [${pFilePath}]...`);
31
32
 
32
33
  const tmpReadline = libReadline.createInterface(
@@ -59,6 +60,7 @@ class ImportExtraDataCSVCommand extends libPictCommandLineUtility.ServiceCommand
59
60
  // Parse the CSV file
60
61
  const tmpRecords = [];
61
62
  const tmpCSVParser = this.fable.instantiateServiceProvider('CSVParser');
63
+ tmpCSVParser.EscapedQuoteString = '"';
62
64
  this.fable.log.info(`Parsing Options CSV file [${pFilePath}]...`);
63
65
 
64
66
  const tmpReadline = libReadline.createInterface(
@@ -67,6 +67,7 @@ class ImportCSVCommand extends libPictCommandLineUtility.ServiceCommandLineComma
67
67
  // Parse the CSV file
68
68
  const tmpRecords = [];
69
69
  const tmpCSVParser = this.fable.instantiateServiceProvider('CSVParser');
70
+ tmpCSVParser.EscapedQuoteString = '"';
70
71
 
71
72
  this.fable.log.info(`Parsing CSV file [${tmpFileName}]...`);
72
73
 
@@ -82,6 +83,7 @@ class ImportCSVCommand extends libPictCommandLineUtility.ServiceCommandLineComma
82
83
  const tmpRecord = tmpCSVParser.parseCSVLine(pLine);
83
84
  if (tmpRecord)
84
85
  {
86
+ tmpRecord.Equation = tmpRecord.Equation.replace(/&quot;/g, '"');
85
87
  tmpRecords.push(tmpRecord);
86
88
  }
87
89
  });