pict-section-form 1.0.114 → 1.0.116

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.
@@ -20,8 +20,11 @@
20
20
  "ITDRO = Height * Width",
21
21
  "ITPRO = Height * Width",
22
22
  "LoggedValues = logvalues(\"ITPRO\", ITPRO)",
23
- "VisibleMarshalingGroup = SetGroupVisibility(\"Area\", \"Help\", if(Height,\"GT\", 99, \"\", 1))",
24
- "VisibleMarshalingSection = SetSectionVisibility(\"Marshaling\", if(ITPRO,\"LT\", 10000, \"\", 1))"
23
+ "SetGroupVisibility(\"Area\", \"Help\", if(Height,\"GT\", 99, 0, 1))",
24
+ "SetSectionVisibility(\"Marshaling\", if(ITPRO,\"LT\", 10000, 0, 1))",
25
+ "ColorSectionBackground(\"Marshaling\",\"#FF00FF\", 1)",
26
+ "ColorGroupBackground(\"Area\", \"Help\", ContentBackgroundColor, 1)"
27
+
25
28
  ],
26
29
  "MetaTemplates":
27
30
  [
@@ -99,6 +102,15 @@
99
102
  "Default": "<p>To calculate the area of a rectangle, you multiply its length by its width. The length is one side of the rectangle, and the width is the adjacent side at a right angle. Since a rectangle has opposite sides that are equal and all angles are right angles, this simple multiplication gives the total space inside the rectangle, expressed in square units.</p>"
100
103
  ,"PictForm": { "InputType": "HTML", "Section":"Area", "Group":"Help" }
101
104
  },
105
+ "ContentBackgroundColor":
106
+ {
107
+ "Name":"Content Background Color",
108
+ "Hash":"ContentBackgroundColor",
109
+ "DataType":"String",
110
+ "Default": "#FFFFEE"
111
+ ,"PictForm": { "InputType": "Color", "Section":"Area", "Group":"Help", "Row":2 }
112
+ },
113
+
102
114
 
103
115
 
104
116
  "DTPN":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pict-section-form",
3
- "version": "1.0.114",
3
+ "version": "1.0.116",
4
4
  "description": "Pict dynamic form sections",
5
5
  "main": "source/Pict-Section-Form.js",
6
6
  "directories": {
@@ -31,8 +31,8 @@
31
31
  "browser-env": "^3.3.0",
32
32
  "eslint": "^9.36.0",
33
33
  "jquery": "^3.7.1",
34
- "pict": "^1.0.302",
35
- "pict-application": "^1.0.27",
34
+ "pict": "^1.0.304",
35
+ "pict-application": "^1.0.29",
36
36
  "pict-service-commandlineutility": "^1.0.15",
37
37
  "quackage": "^1.0.42",
38
38
  "tui-grid": "^4.21.22",
@@ -73,8 +73,16 @@ class PictDynamicFormsSolverBehaviors extends libPictProvider
73
73
  {
74
74
  // Wire up the solver functions.
75
75
  this.addSolverFunction(pExpressionParser, 'logValues', 'fable.providers.DynamicFormSolverBehaviors.logValues', 'Logs a set of values to the console and returns the last one.');
76
+
76
77
  this.addSolverFunction(pExpressionParser, 'setSectionVisibility', 'fable.providers.DynamicFormSolverBehaviors.setSectionVisibility', 'Sets a sections visiblity to true or fales based on the second parameter.');
77
78
  this.addSolverFunction(pExpressionParser, 'setGroupVisibility', 'fable.providers.DynamicFormSolverBehaviors.setGroupVisibility', 'Sets a group visiblity to true or fales based on the third parameter.');
79
+
80
+ this.addSolverFunction(pExpressionParser, 'generateHTMLHexColor', 'fable.providers.DynamicFormSolverBehaviors.generateHTMLHexColor', 'Generates a HTML hex color from three integer parameters (red, green, blue).');
81
+
82
+ this.addSolverFunction(pExpressionParser, 'colorSectionBackground', 'fable.providers.DynamicFormSolverBehaviors.colorSectionBackground', 'Colors a section background with a HTML hex color (e.g. #FF0000 for red).');
83
+ this.addSolverFunction(pExpressionParser, 'colorGroupBackground', 'fable.providers.DynamicFormSolverBehaviors.colorGroupBackground', 'Colors a group background with a HTML hex color (e.g. #FF0000 for red).');
84
+ this.addSolverFunction(pExpressionParser, 'colorInputBackground', 'fable.providers.DynamicFormSolverBehaviors.colorInputBackground', 'Colors an input background with a HTML hex color (e.g. #FF0000 for red).');
85
+
78
86
  return false;
79
87
  }
80
88
 
@@ -85,7 +93,7 @@ class PictDynamicFormsSolverBehaviors extends libPictProvider
85
93
 
86
94
  setSectionVisibility(pSectionHash, pVisible)
87
95
  {
88
- if (pVisible)
96
+ if (pVisible != "0")
89
97
  {
90
98
  return this.showSection(pSectionHash);
91
99
  }
@@ -189,6 +197,123 @@ class PictDynamicFormsSolverBehaviors extends libPictProvider
189
197
  return true;
190
198
  }
191
199
 
200
+ generateHTMLHexColor(pRed, pGreen, pBlue)
201
+ {
202
+ let tmpRed = (parseInt(pRed) || 0);
203
+ let tmpGreen = (parseInt(pGreen) || 0);
204
+ let tmpBlue = (parseInt(pBlue) || 0);
205
+
206
+ if (tmpRed < 0) { tmpRed = 0; }
207
+ if (tmpRed > 255) { tmpRed = 255; }
208
+ if (tmpGreen < 0) { tmpGreen = 0; }
209
+ if (tmpGreen > 255) { tmpGreen = 255; }
210
+ if (tmpBlue < 0) { tmpBlue = 0; }
211
+ if (tmpBlue > 255) { tmpBlue = 255; }
212
+
213
+ let tmpRedHex = tmpRed.toString(16).toUpperCase();
214
+ if (tmpRedHex.length < 2) { tmpRedHex = `0${tmpRedHex}`; }
215
+ let tmpGreenHex = tmpGreen.toString(16).toUpperCase();
216
+ if (tmpGreenHex.length < 2) { tmpGreenHex = `0${tmpGreenHex}`; }
217
+ let tmpBlueHex = tmpBlue.toString(16).toUpperCase();
218
+ if (tmpBlueHex.length < 2) { tmpBlueHex = `0${tmpBlueHex}`; }
219
+
220
+ return `#${tmpRedHex}${tmpGreenHex}${tmpBlueHex}`;
221
+ }
222
+
223
+ colorSectionBackground(pSectionHash, pColor, pApplyChange)
224
+ {
225
+ if (pApplyChange == "0")
226
+ {
227
+ return true;
228
+ }
229
+
230
+ let tmpSectionView = this.pict.views.PictFormMetacontroller.getSectionViewFromHash(pSectionHash)
231
+ if (!tmpSectionView)
232
+ {
233
+ this.log.warn(`PictDynamicFormsInformary: colorSection could not find section with hash [${pSectionHash}].`);
234
+ return false;
235
+ }
236
+
237
+ let tmpElementSet = this.pict.ContentAssignment.getElement(this.getSectionSelector(tmpSectionView.formID));
238
+
239
+ if (tmpElementSet.length < 1)
240
+ {
241
+ this.log.warn(`PictDynamicFormsInformary: colorSection could not find section element with hash [${pSectionHash}] selector [${this.getSectionSelector(tmpSectionView.formID)}].`);
242
+ return false;
243
+ }
244
+
245
+ let tmpElement = tmpElementSet[0];
246
+
247
+ tmpElement.style.backgroundColor = pColor;
248
+
249
+ return true;
250
+ }
251
+
252
+ colorGroupBackground(pSectionHash, pGroupHash, pColor, pApplyChange)
253
+ {
254
+ if (pApplyChange == "0")
255
+ {
256
+ return true;
257
+ }
258
+
259
+ let tmpGroupView = this.pict.views.PictFormMetacontroller.getSectionViewFromHash(pSectionHash)
260
+ if (!tmpGroupView)
261
+ {
262
+ this.log.warn(`PictDynamicFormsInformary: colorGroup could not find group with section hash [${pSectionHash}] group [${pGroupHash}].`);
263
+ return false;
264
+ }
265
+
266
+ let tmpElementSet = this.pict.ContentAssignment.getElement(this.getGroupSelector(tmpGroupView.formID, pGroupHash));
267
+
268
+ if (tmpElementSet.length < 1)
269
+ {
270
+ this.log.warn(`PictDynamicFormsInformary: colorGroup could not find group element with section hash [${pSectionHash}] group [${pGroupHash}] selector [${this.getGroupSelector(tmpGroupView.formID, pGroupHash)}].`);
271
+ return false;
272
+ }
273
+
274
+ let tmpElement = tmpElementSet[0];
275
+ tmpElement.style.backgroundColor = pColor;
276
+
277
+ return true;
278
+ }
279
+
280
+ colorInputBackground(pSectionHash, pInputHash, pColor, pApplyChange)
281
+ {
282
+ if (pApplyChange == "0")
283
+ {
284
+ return true;
285
+ }
286
+
287
+ let tmpInputView = this.pict.views.PictFormMetacontroller.getInputViewFromHash(pSectionHash)
288
+
289
+ if (!tmpInputView)
290
+ {
291
+ this.log.warn(`PictDynamicFormsInformary: colorInput could not find input with section hash [${pSectionHash}] input [${pInputHash}].`);
292
+ return false;
293
+ }
294
+
295
+ let tmpInput = tmpInputView.getInputFromHash(pInputHash);
296
+
297
+ if (!tmpInput)
298
+ {
299
+ this.log.warn(`PictDynamicFormsInformary: colorInput could not find input with section hash [${pSectionHash}] input [${pInputHash}].`);
300
+ return false;
301
+ }
302
+
303
+ let tmpElementSet = this.pict.ContentAssignment.getElement(`#INPUT-${tmpInput.formID}`);
304
+
305
+ if (tmpElementSet.length < 1)
306
+ {
307
+ this.log.warn(`PictDynamicFormsInformary: colorInput could not find input element with section hash [${pSectionHash}] input [${pInputHash}] selector [#INPUT-${tmpInput.formID}].`);
308
+ return false;
309
+ }
310
+
311
+ let tmpElement = tmpElementSet[0];
312
+ tmpElement.style.backgroundColor = pColor;
313
+
314
+ return true;
315
+ }
316
+
192
317
  logValues()
193
318
  {
194
319
  let tmpLastValue = null;
@@ -218,6 +218,20 @@ Glug glug glug Oo... -->
218
218
  <!-- DataType DateTime {~D:Record.Hash~} {~D:Record.DataType~} -->
219
219
  <input type="hidden" {~D:Record.Macro.InputFullProperties~} value="">
220
220
  <span>{~D:Record.Name~}:</span> <input id="DATETIME-INPUT-FOR-{~D:Record.Macro.RawHTMLID~}" onchange="{~D:Record.Macro.DataRequestFunction~}" type="datetime-local" value="" />
221
+ `
222
+ },
223
+ {
224
+ "HashPostfix": "-Template-Input-InputType-Color",
225
+ "Template": /*HTML*/`
226
+ <!-- InputType Color {~D:Record.Hash~} {~D:Record.DataType~} -->
227
+ <span>{~D:Record.Name~}:</span> <input type="color" {~D:Record.Macro.InputFullProperties~} {~D:Record.Macro.InputChangeHandler~} />
228
+ `
229
+ },
230
+ {
231
+ "HashPostfix": "-Template-Input-InputType-DisplayOnly",
232
+ "Template": /*HTML*/`
233
+ <!-- InputType DisplayOnly {~D:Record.Hash~} {~D:Record.DataType~} -->
234
+ <span>{~D:Record.Name~}:</span> <span {~D:Record.Macro.InputFullProperties~}></span>
221
235
  `
222
236
  },
223
237
  {
@@ -375,6 +389,28 @@ Glug glug glug Oo... -->
375
389
  <span>{~D:Record.PictForm.ExtraDescription~}</span>
376
390
  <input id="DATETIME-INPUT-FOR-{~D:Record.Macro.RawHTMLID~}" onchange="{~D:Record.Macro.DataRequestFunction~}" type="datetime-local" value="" />
377
391
  </div>
392
+ `
393
+ },
394
+ {
395
+ "HashPostfix": "-VerticalTemplate-Input-InputType-Color",
396
+ "Template": /*HTML*/`
397
+ <!-- InputType Color {~D:Record.Hash~} {~D:Record.DataType~} -->
398
+ <div class="pict-form-vertical-input">
399
+ <span>{~D:Record.Name~}:</span>
400
+ <span>{~D:Record.PictForm.ExtraDescription~}</span>
401
+ <input type="color" {~D:Record.Macro.InputFullProperties~} {~D:Record.Macro.InputChangeHandler~} />
402
+ </div>
403
+ `
404
+ },
405
+ {
406
+ "HashPostfix": "-VerticalTemplate-Input-InputType-DisplayOnly",
407
+ "Template": /*HTML*/`
408
+ <!-- InputType DisplayOnly {~D:Record.Hash~} {~D:Record.DataType~} -->
409
+ <div class="pict-form-vertical-input">
410
+ <span>{~D:Record.Name~}:</span>
411
+ <span>{~D:Record.PictForm.ExtraDescription~}</span>
412
+ <span {~D:Record.Macro.InputFullProperties~}></span>
413
+ </div>
378
414
  `
379
415
  },
380
416
  {
@@ -896,6 +932,30 @@ Glug glug glug Oo... -->
896
932
  `
897
933
  },
898
934
 
935
+ {
936
+ "HashPostfix": "-TabularTemplate-Begin-Input-InputType-Color",
937
+ "Template": /*HTML*/`
938
+ <!-- InputType Color {~D:Record.Hash~} {~D:Record.DataType~} -->
939
+ <span>{~D:Record.Name~}:</span> <input type="color" {~D:Record.Macro.InputFullProperties~} {~D:Record.Macro.InputChangeHandler~} {~D:Record.Macro.InformaryTabular~}`
940
+ },
941
+ {
942
+ "HashPostfix": "-TabularTemplate-End-Input-InputType-Color",
943
+ "Template": /*HTML*/` />
944
+ `
945
+ },
946
+
947
+ {
948
+ "HashPostfix": "-TabularTemplate-Begin-Input-InputType-DisplayOnly",
949
+ "Template": /*HTML*/`
950
+ <!-- InputType DisplayOnly {~D:Record.Hash~} {~D:Record.DataType~} -->
951
+ <span>{~D:Record.Name~}:</span> <span {~D:Record.Macro.InputFullProperties~} {~D:Record.Macro.InformaryTabular~}`
952
+ },
953
+ {
954
+ "HashPostfix": "-TabularTemplate-End-Input-InputType-DisplayOnly",
955
+ "Template": /*HTML*/` ></span>
956
+ `
957
+ },
958
+
899
959
  {
900
960
  "HashPostfix": "-TabularTemplate-Begin-Input-InputType-ReadOnly",
901
961
  "Template": /*HTML*/`