pict-section-form 1.0.3 → 1.0.4

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.
@@ -46,6 +46,10 @@ class PostcardApplication extends libPictApplication
46
46
 
47
47
  onAfterInitialize()
48
48
  {
49
+ // Set a custom address for all the views to marshal to.
50
+ // This can also be set on specific views (same property)
51
+ this.pict.views.PictFormMetacontroller.viewMarshalDestination = 'AppData.PostKard';
52
+
49
53
  this.pict.views.PostcardMainApplication.render();
50
54
  }
51
55
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pict-section-form",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Pict dynamic form sections",
5
5
  "main": "source/Pict-Section-Form.js",
6
6
  "directories": {
@@ -25,14 +25,14 @@
25
25
  "license": "MIT",
26
26
  "devDependencies": {
27
27
  "browser-env": "^3.3.0",
28
- "pict": "^1.0.177",
28
+ "pict": "^1.0.178",
29
29
  "pict-application": "^1.0.15",
30
30
  "quackage": "^1.0.29"
31
31
  },
32
32
  "dependencies": {
33
33
  "informary": "^2.0.21",
34
34
  "pict-provider": "^1.0.2",
35
- "pict-view": "^1.0.43"
35
+ "pict-view": "^1.0.45"
36
36
  },
37
37
  "mocha": {
38
38
  "diff": true,
@@ -19,6 +19,8 @@ class PictFormMetacontroller extends libPictViewClass
19
19
  tmpDefaultTemplateProvider.initialize();
20
20
  }
21
21
 
22
+ this.viewMarshalDestination = 'AppData';
23
+
22
24
  this.formTemplatePrefix = 'Pict-Forms-Basic';
23
25
  }
24
26
 
@@ -120,7 +120,7 @@ Glug glug glug
120
120
  "HashPostfix": "-Template-Input",
121
121
  "Template": /*HTML*/`
122
122
  <!-- Input {~"D:Record.Hash~} {~D:Record.DataType~} -->
123
- <span style="background-color:#fffdfd;">{~D:Record.Name~}:</span> <input type="text" id="{~D:Context[0].UUID~}-FormInput-{~D:Record.Hash~}" name="{~D:Record.Name~}" data-i-form="{~D:Context[0].formID~}" data-i-datum="{~D:Record.PictForm.InformaryDataAddress~}" value="">
123
+ <span style="background-color:#fffdfd;">{~D:Record.Name~}:</span> <input type="text" {~D:Record.PictForm.HTMLInputFullProperties~} value="">
124
124
  `
125
125
  },
126
126
  // -Form-Template-Input-DataType-String
@@ -128,7 +128,7 @@ Glug glug glug
128
128
  "HashPostfix": "-Template-Input-DataType-String",
129
129
  "Template": /*HTML*/`
130
130
  <!-- DataType Number {~D:Record.Hash~} {~D:Record.DataType~} -->
131
- <span>{~D:Record.Name~}:</span> <input type="text" id="{~D:Context[0].UUID~}-FormInput-{~D:Record.Hash~}" name="{~D:Record.Name~}" data-i-form="{~D:Context[0].formID~}" data-i-datum="{~D:Record.PictForm.InformaryDataAddress~}" value="">
131
+ <span>{~D:Record.Name~}:</span> <input type="text" {~D:Record.PictForm.HTMLInputFullProperties~} value="">
132
132
  `
133
133
  },
134
134
  // -Form-Template-Input-DataType-Number
@@ -136,7 +136,7 @@ Glug glug glug
136
136
  "HashPostfix": "-Template-Input-DataType-Number",
137
137
  "Template": /*HTML*/`
138
138
  <!-- DataType Number {~D:Record.Hash~} {~D:Record.DataType~} -->
139
- <span>{~D:Record.Name~}:</span> <input type="Number" id="{~D:Context[0].UUID~}-FormInput-{~D:Record.Hash~}" name="{~D:Record.Name~}" data-i-form="{~D:Context[0].formID~}" data-i-datum="{~D:Record.PictForm.InformaryDataAddress~}" value="">
139
+ <span>{~D:Record.Name~}:</span> <input type="Number" {~D:Record.PictForm.HTMLInputFullProperties~} value="">
140
140
  `
141
141
  },
142
142
  // -Form-Template-Input-InputType-TextArea
@@ -144,7 +144,7 @@ Glug glug glug
144
144
  "HashPostfix": "-Template-Input-InputType-TextArea",
145
145
  "Template": /*HTML*/`
146
146
  <!-- InputType TextArea {~D:Record.Hash~} {~D:Record.DataType~} -->
147
- <span>{~D:Record.Name~}:</span> <textarea id="{~D:Context[0].UUID~}-FormInput-{~D:Record.Hash~}" name="{~D:Record.Name~}" data-i-form="{~D:Context[0].formID~}" data-i-datum="{~D:Record.PictForm.InformaryDataAddress~}"></textarea>
147
+ <span>{~D:Record.Name~}:</span> <textarea {~D:Record.PictForm.HTMLInputFullProperties~}></textarea>
148
148
  `
149
149
  }
150
150
  ]
@@ -86,6 +86,8 @@ class PictSectionForm extends libPictViewClass
86
86
 
87
87
  this.informary = new libInformary({ Form:this.formID })
88
88
 
89
+ this.viewMarshalDestination = false;
90
+
89
91
  this.initializeFormGroups();
90
92
  }
91
93
 
@@ -93,7 +95,23 @@ class PictSectionForm extends libPictViewClass
93
95
  {
94
96
  try
95
97
  {
96
- this.informary.marshalDataToForm(this.AppData,
98
+ let tmpMarshalDestinationObject = false;
99
+ if (this.viewMarshalDestination)
100
+ {
101
+ tmpMarshalDestinationObject = this.sectionManifest.getValueAtAddress(this, this.viewMarshalDestination);
102
+ }
103
+ else if (this.pict.views.PictFormMetacontroller && this.pict.views.PictFormMetacontroller.viewMarshalDestination)
104
+ {
105
+ tmpMarshalDestinationObject = this.sectionManifest.getValueAtAddress(this, this.pict.views.PictFormMetacontroller.viewMarshalDestination);
106
+ }
107
+
108
+ if (typeof(tmpMarshalDestinationObject) != 'object')
109
+ {
110
+ this.log.error(`Marshal destination object is not an object; if you initialize the view yourself you must set the viewMarshalDestination property to a valid address within the view.`);
111
+ return;
112
+ }
113
+
114
+ this.informary.marshalDataToForm(tmpMarshalDestinationObject,
97
115
  function(pError)
98
116
  {
99
117
  if (pError)
@@ -112,7 +130,33 @@ class PictSectionForm extends libPictViewClass
112
130
  {
113
131
  try
114
132
  {
115
- this.informary.marshalFormToData(this.AppData,
133
+ let tmpMarshalDestinationObject = false;
134
+ if (this.viewMarshalDestination)
135
+ {
136
+ tmpMarshalDestinationObject = this.sectionManifest.getValueAtAddress(this, this.viewMarshalDestination);
137
+ }
138
+ else if (this.pict.views.PictFormMetacontroller && this.pict.views.PictFormMetacontroller.viewMarshalDestination)
139
+ {
140
+ tmpMarshalDestinationObject = this.sectionManifest.getValueAtAddress(this, this.pict.views.PictFormMetacontroller.viewMarshalDestination);
141
+
142
+ if (!tmpMarshalDestinationObject)
143
+ {
144
+ // Try to create an empty object.
145
+ if (this.sectionManifest.setValueAtAddress(this, this.pict.views.PictFormMetacontroller.viewMarshalDestination, {}))
146
+ {
147
+ // And try to load it once more!
148
+ tmpMarshalDestinationObject = this.sectionManifest.getValueAtAddress(this, this.pict.views.PictFormMetacontroller.viewMarshalDestination);
149
+ }
150
+ }
151
+ }
152
+
153
+ if (typeof(tmpMarshalDestinationObject) != 'object')
154
+ {
155
+ this.log.error(`Marshal destination object is not an object; if you initialize the view yourself you must set the viewMarshalDestination property to a valid address within the view.`);
156
+ return;
157
+ }
158
+
159
+ this.informary.marshalFormToData(tmpMarshalDestinationObject,
116
160
  function(pError)
117
161
  {
118
162
  if (pError)
@@ -221,6 +265,13 @@ class PictSectionForm extends libPictViewClass
221
265
  {
222
266
  let tmpTemplateInputScope = '-Template-Input';
223
267
 
268
+ tmpGroup.Rows[j].Inputs[k].PictForm.HTMLInformaryProperties = ` data-i-form="${this.formID}" data-i-datum="${tmpGroup.Rows[j].Inputs[k].PictForm.InformaryDataAddress}" `;
269
+ tmpGroup.Rows[j].Inputs[k].PictForm.HTMLInputName = ` name="${tmpGroup.Rows[j].Inputs[k].Name}" `;
270
+ tmpGroup.Rows[j].Inputs[k].PictForm.HTMLInputID = ` id="${this.UUID}-FormInput-${tmpGroup.Rows[j].Inputs[k].Hash}" `;
271
+
272
+ tmpGroup.Rows[j].Inputs[k].PictForm.HTMLInputFullProperties = `${tmpGroup.Rows[j].Inputs[k].PictForm.HTMLInputID}${tmpGroup.Rows[j].Inputs[k].PictForm.HTMLInputName}${tmpGroup.Rows[j].Inputs[k].PictForm.HTMLInformaryProperties}`;
273
+
274
+
224
275
  // Check for view-specific control/datatype templates
225
276
  if (this.pict.TemplateProvider.getTemplate(`${this.formsTemplateSetPrefix}${tmpTemplateInputScope}-InputType-${tmpGroup.Rows[j].Inputs[k].PictForm.InputType}`))
226
277
  {