pict-section-form 1.0.19 → 1.0.20

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.
@@ -312,6 +312,12 @@ module.exports.default_configuration.pict_configuration = {
312
312
  DataType: "String",
313
313
  PictForm: { Section: "FruitGrid", Group: "FruitGrid" },
314
314
  },
315
+ lastWatered: {
316
+ Name: "Last Watered",
317
+ Hash: "LastWatered",
318
+ DataType: "DateTime",
319
+ PictForm: { Section: "FruitGrid", Group: "FruitGrid", "InputType":"DateTime", "Providers": ["Pict-Input-DateTime"]},
320
+ },
315
321
  "nutritions.calories": {
316
322
  Name: "Calories",
317
323
  Hash: "Calories",
@@ -2,7 +2,6 @@
2
2
  "FruitData": {
3
3
  "DataURL": "https://www.fruityvice.com/",
4
4
  "DataLicense": "Public Domain",
5
-
6
5
  "FruityVice": [
7
6
  {
8
7
  "name": "Persimmon",
@@ -38,6 +37,7 @@
38
37
  "family": "Musaceae",
39
38
  "order": "Zingiberales",
40
39
  "genus": "Musa",
40
+ "lastWatered": "2022-05-19T04:52",
41
41
  "nutritions": {
42
42
  "calories": 96,
43
43
  "fat": 0.2,
@@ -691,5 +691,10 @@
691
691
  }
692
692
  }
693
693
  ]
694
+ },
695
+ "MetaFruit": {
696
+ "Information": {
697
+ "LastPrepared": "2020-01-25T08:33"
698
+ }
694
699
  }
695
- }
700
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pict-section-form",
3
- "version": "1.0.19",
3
+ "version": "1.0.20",
4
4
  "description": "Pict dynamic form sections",
5
5
  "main": "source/Pict-Section-Form.js",
6
6
  "directories": {
@@ -395,7 +395,7 @@ Glug glug glug Oo... -->
395
395
  {
396
396
  "HashPostfix": "-TabularTemplate-End-Input-DataType-DateTime",
397
397
  "Template": /*HTML*/` value="">
398
- <input id="DATETIME-TABULAR-INPUT-{~D:Record.Macro.RawHTMLID~}-{~D:Context[2].Key~}" onchange="{~D:Record.Macro.DataRequestFunction~}" type="datetime-local" value="" />
398
+ <input id="DATETIME-TABULAR-INPUT-{~D:Record.Macro.RawHTMLID~}-{~D:Context[2].Key~}" onchange="_Pict.views['{~D:Context[0].Hash~}'].inputDataRequestTabular('{~D:Context[2].Group~}', '{~D:Record.PictForm.InputIndex~}', '{~D:Context[2].Key~}')" type="datetime-local" value="" />
399
399
  `
400
400
  },
401
401
  /*
@@ -7,87 +7,51 @@ class CustomInputHandler extends libPictSectionInputExtension
7
7
  super(pFable, pOptions, pServiceHash);
8
8
  }
9
9
 
10
- getSelectInputHTMLID(pInputHTMLID)
10
+ getDateTimeInputHTMLID(pInputHTMLID)
11
11
  {
12
12
  return `#DATETIME-INPUT-FOR-${pInputHTMLID}`;
13
13
  }
14
14
 
15
- getTabularSelectInputID(pInputHTMLID, pRowIndex)
15
+ getTabularDateTimeHiddenInputHTMLID(pInputHTMLID, pRowIndex)
16
16
  {
17
17
  return `#DATETIME-TABULAR-DATA-${pInputHTMLID}-${pRowIndex}`;
18
18
  }
19
19
 
20
- getTabularSelectDateTimeID(pInputHTMLID, pRowIndex)
20
+ getTabularDateTimeInputHTMLID(pInputHTMLID, pRowIndex)
21
21
  {
22
- return `#DATETIME-TABULAR-DROPDOWN-${pInputHTMLID}-${pRowIndex}`;
22
+ return `#DATETIME-TABULAR-INPUT-${pInputHTMLID}-${pRowIndex}`;
23
23
  }
24
24
 
25
25
 
26
26
  onDataMarshalToForm(pView, pGroup, pRow, pInput, pValue, pHTMLSelector)
27
27
  {
28
- let tmpDateTimeElement = this.pict.ContentAssignment.getElement(this.getSelectInputHTMLID(pInput.Macro.RawHTMLID));
29
- if (tmpDateTimeElement && tmpDateTimeElement.length > 0)
30
- {
31
- tmpDateTimeElement = tmpDateTimeElement[0];
32
- }
33
- else
34
- {
35
- return false;
36
- }
37
-
28
+ this.pict.ContentAssignment.assignContent(this.getDateTimeInputHTMLID(pInput.Macro.RawHTMLID), pValue);
38
29
  return super.onDataMarshalToForm(pView, pGroup, pRow, pInput, pValue, pHTMLSelector);
39
30
  }
40
31
 
41
32
  onDataMarshalToFormTabular(pView, pGroup, pInput, pValue, pHTMLSelector, pRowIndex)
42
33
  {
43
- let tmpDateTimeElement = this.pict.ContentAssignment.getElement(this.getTabularSelectDateTimeID(pInput.Macro.RawHTMLID, pRowIndex));
44
- if (tmpDateTimeElement && tmpDateTimeElement.length > 0)
45
- {
46
- tmpDateTimeElement = tmpDateTimeElement[0];
47
- }
48
- else
49
- {
50
- return super.onInputInitializeTabular(pView, pGroup, pInput, pHTMLSelector);
51
- }
52
-
53
-
54
- let tmpValueSelected = false;
55
-
56
- for (let i = 0; i < tmpDateTimeElement.options.length; i++)
57
- {
58
- if (tmpDateTimeElement.options[i].value === pValue)
59
- {
60
- tmpDateTimeElement.selectedIndex = i;
61
- tmpValueSelected = true;
62
- break;
63
- }
64
- }
65
-
66
- if (!tmpValueSelected)
67
- {
68
- tmpDateTimeElement.selectedIndex = -1;
69
- this.pict.log.error(`The value [${pValue}] was not found in the select options for input [${pInput.Macro.RawHTMLID}] but was set in the hidden HTML input.`);
70
- }
71
-
34
+ this.pict.ContentAssignment.assignContent(this.getTabularDateTimeInputHTMLID(pInput.Macro.RawHTMLID, pRowIndex), pValue);
72
35
  return super.onDataMarshalToFormTabular(pView, pGroup, pInput, pValue, pHTMLSelector, pRowIndex);
73
36
  }
74
37
 
75
38
  onDataRequest(pView, pInput, pValue, pHTMLSelector)
76
39
  {
77
- let tmpDateTimeElement = this.pict.ContentAssignment.getElement(this.getSelectInputHTMLID(pInput.Macro.RawHTMLID));
78
- if (tmpDateTimeElement && tmpDateTimeElement.length > 0)
79
- {
80
- tmpDateTimeElement = tmpDateTimeElement[0];
81
- }
82
- else
83
- {
84
- return false;
85
- }
40
+ // TODO: Should this be opinionated about time zone? If so, this is the start of it.
41
+ // let tmpDateTimeElement = this.pict.ContentAssignment.getElement(this.getDateTimeInputHTMLID(pInput.Macro.RawHTMLID));
42
+ // if (tmpDateTimeElement && tmpDateTimeElement.length > 0)
43
+ // {
44
+ // tmpDateTimeElement = tmpDateTimeElement[0];
45
+ // }
46
+ // else
47
+ // {
48
+ // return false;
49
+ // }
50
+ //let tmpDateValue = this.fable.Dates.dayJS(tmpDateTimeElement.value);
86
51
 
87
52
  try
88
53
  {
89
- let tmpDateValue = this.fable.Dates.dayJS(tmpDateTimeElement.value);
90
- let tmpInputSelectValue = this.pict.ContentAssignment.readContent(this.getSelectInputHTMLID(pInput.Macro.RawHTMLID));
54
+ let tmpInputSelectValue = this.pict.ContentAssignment.readContent(this.getDateTimeInputHTMLID(pInput.Macro.RawHTMLID));
91
55
  this.pict.ContentAssignment.assignContent(pHTMLSelector, tmpInputSelectValue);
92
56
  pView.dataChanged(pInput.Hash);
93
57
  }
@@ -101,9 +65,18 @@ class CustomInputHandler extends libPictSectionInputExtension
101
65
 
102
66
  onDataRequestTabular(pView, pInput, pValue, pHTMLSelector, pRowIndex)
103
67
  {
104
- let tmpInputSelectValue = this.pict.ContentAssignment.readContent(this.getTabularSelectDateTimeID(pInput.Macro.RawHTMLID, pRowIndex));
105
- this.pict.ContentAssignment.assignContent(this.getTabularSelectInputID(pInput.Macro.RawHTMLID, pRowIndex), tmpInputSelectValue);
106
- pView.dataChangedTabular(pInput.PictForm.GroupIndex, pInput.PictForm.InputIndex, pRowIndex);
68
+ // TODO: If we decide to be opinionated about time zone, use the above here as well
69
+ try
70
+ {
71
+ let tmpInputSelectValue = this.pict.ContentAssignment.readContent(this.getTabularDateTimeInputHTMLID(pInput.Macro.RawHTMLID, pRowIndex));
72
+ this.pict.ContentAssignment.assignContent(this.getTabularDateTimeHiddenInputHTMLID(pInput.Macro.RawHTMLID, pRowIndex), tmpInputSelectValue);
73
+ pView.dataChangedTabular(pInput.PictForm.GroupIndex, pInput.PictForm.InputIndex, pRowIndex);
74
+ }
75
+ catch
76
+ {
77
+ this.pict.log.error(`The value [${tmpDateTimeElement.value}] is not a valid date; skipping parsing for [#${pInput.Macro.RawHTMLID}].`);
78
+ }
79
+
107
80
  return super.onDataRequestTabular(pView, pInput, pValue, pHTMLSelector, pRowIndex);
108
81
  }
109
82
 
@@ -170,7 +170,12 @@ class PictViewDynamicForm extends libPictViewClass
170
170
  dataChangedTabular(pGroupIndex, pInputIndex, pRowIndex)
171
171
  {
172
172
  let tmpInput = this.getTabularRecordInput(pGroupIndex, pInputIndex);
173
- if (pGroupIndex && pInputIndex && pRowIndex && tmpInput)
173
+ if (
174
+ (typeof(pGroupIndex) != 'undefined')
175
+ && (typeof(pInputIndex) != 'undefined')
176
+ && (typeof(pRowIndex) != 'undefined')
177
+ && (typeof(tmpInput) == 'object')
178
+ )
174
179
  {
175
180
  // The informary stuff doesn't know the resolution of the hash to address, so do it here.
176
181
  let tmpHashAddress = tmpInput.Address;