pict-section-form 1.0.2 → 1.0.3

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,7 +2,7 @@
2
2
  "Name": "A Simple Postcard Application",
3
3
  "Hash": "Postcard",
4
4
 
5
- "MainViewportViewIdentifier": "Postcard-Navigation",
5
+ "MainViewportViewIdentifier": "PostcardNavigation",
6
6
 
7
7
  "pict_configuration":
8
8
  {
@@ -4,6 +4,8 @@ const libPictSectionForm = require('../../source/Pict-Section-Form.js');
4
4
 
5
5
  const libProviderDynamicSection = require('./providers/PictProvider-Dynamic-Sections.js');
6
6
 
7
+ const libMainApplicationView = require('./views/PictView-Postcard-MainApplication.js')
8
+
7
9
  class PostcardApplication extends libPictApplication
8
10
  {
9
11
  constructor(pFable, pOptions, pServiceHash)
@@ -13,13 +15,17 @@ class PostcardApplication extends libPictApplication
13
15
  this.pict.addProvider('Postcard-DynamicSection-Provider', libProviderDynamicSection.default_configuration, libProviderDynamicSection);
14
16
  this.pict.addProvider('Postcard-Default-Theme-Provider', {}, require('./providers/PictProvider-BestPostcardTheme.js'));
15
17
 
16
- this.pict.addView('Postcard-Navigation', require('./views/PictView-Postcard-Navigation.json'));
18
+ this.pict.addView('PostcardNavigation', require('./views/PictView-Postcard-Navigation.json'));
19
+ this.pict.addView('PostcardAbout', require('./views/PictView-Postcard-Content-About.json'));
20
+ this.pict.addView('PostcardLegal', require('./views/PictView-Postcard-Content-Legal.json'));
17
21
 
18
22
  // Add the pict form service
19
23
  this.pict.addServiceType('PictSectionForm', libPictSectionForm);
20
24
 
21
25
  // Add the pict form metacontroller service, which provides programmaatic view construction from manifests and render/marshal methods.
22
26
  this.pict.addView('PictFormMetacontroller', {}, libPictSectionForm.PictFormMetacontroller);
27
+
28
+ this.pict.addView('PostcardMainApplication', libMainApplicationView.default_configuration, libMainApplicationView);
23
29
  }
24
30
 
25
31
  changeToDefaultTheme()
@@ -27,6 +33,7 @@ class PostcardApplication extends libPictApplication
27
33
  this.pict.views.PictFormMetacontroller.formTemplatePrefix = _Pict.providers.PictFormSectionDefaultTemplateProvider.formsTemplateSetPrefix
28
34
  this.pict.views.PictFormMetacontroller.regenerateAllFormSectionTemplates();
29
35
  this.pict.views.PictFormMetacontroller.renderAllFormSections();
36
+ this.marshalDataFromAppDataToView();
30
37
  }
31
38
 
32
39
  changeToPostcardTheme()
@@ -34,6 +41,22 @@ class PostcardApplication extends libPictApplication
34
41
  this.pict.views.PictFormMetacontroller.formTemplatePrefix = _Pict.providers['Postcard-Default-Theme-Provider'].formsTemplateSetPrefix;
35
42
  this.pict.views.PictFormMetacontroller.regenerateAllFormSectionTemplates();
36
43
  this.pict.views.PictFormMetacontroller.renderAllFormSections();
44
+ this.marshalDataFromAppDataToView();
45
+ }
46
+
47
+ onAfterInitialize()
48
+ {
49
+ this.pict.views.PostcardMainApplication.render();
50
+ }
51
+
52
+ marshalDataFromViewToAppData()
53
+ {
54
+ this.pict.views.PictFormMetacontroller.marshalFromView();
55
+ }
56
+
57
+ marshalDataFromAppDataToView()
58
+ {
59
+ this.pict.views.PictFormMetacontroller.marshalToView();
37
60
  }
38
61
  };
39
62
 
@@ -8,6 +8,7 @@
8
8
 
9
9
  <title>Das Postkärd</title>
10
10
 
11
+ <link href="postcard.css" rel="stylesheet">
11
12
  <!-- PICT Dynamic View CSS Container -->
12
13
  <style id="PICT-CSS"></style>
13
14
 
@@ -28,8 +29,7 @@
28
29
  <!-- where the Navigation view puts its content -->
29
30
  <div id="Postcard-Navigation-Container"></div>
30
31
 
31
- <!-- where the Form Metacontroller view puts its content -->
32
- <div id="Pict-Form-Container"></div>
32
+ <div id="Postcard-Content-Container"></div>
33
33
 
34
34
  <!-- Load the Postcard PICT Application -->
35
35
  <script src="dist/postcard_application.min.js" type="text/javascript"></script>
@@ -0,0 +1,14 @@
1
+ body {
2
+ font-size: 16px;
3
+ padding: 2em;
4
+ }
5
+
6
+ select,
7
+ input,
8
+ button,
9
+ a {
10
+ padding: 0.5rem;
11
+ margin: 0.25rem;
12
+ border: 1px solid red;
13
+ font: 1rem "Helvetica", sans-serif;
14
+ }
@@ -10,7 +10,8 @@ const _Theme = (
10
10
  "HashPostfix": "-Template-Input-DataType-String",
11
11
  "Template": /*HTML*/`
12
12
  <!-- DataType Number {~D:Record.Hash~} {~D:Record.DataType~} -->
13
- <span>{~D:Record.Name~}: AND COLOR ME DIFFERENT </span> <input type="text" id="{~D:Context[0].UUID~}-FormInput-{~D:Record.Hash~}" name="{~D:Record.Name~}" value="">
13
+ <span style="font-weight: bold; background-color: #efffef;">{~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="">
14
+ <!-- <p>{~D:Record.Description~}</p> -->
14
15
  `
15
16
  },
16
17
  // -Form-Template-Input-DataType-Number
@@ -18,7 +19,8 @@ const _Theme = (
18
19
  "HashPostfix": "-Template-Input-DataType-Number",
19
20
  "Template": /*HTML*/`
20
21
  <!-- DataType Number {~D:Record.Hash~} {~D:Record.DataType~} -->
21
- <span>{~D:Record.Name~} COLOR ME DIFFERENT:</span> <input type="Number" id="{~D:Context[0].UUID~}-FormInput-{~D:Record.Hash~}" name="{~D:Record.Name~}" value="">
22
+ <span style="background-color: #efefef;">{~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="">
23
+ <!-- <p>{~D:Record.Description~}</p> -->
22
24
  `
23
25
  }
24
26
  ]}); // End of _Theme
@@ -17,7 +17,7 @@
17
17
  [
18
18
  {
19
19
  "HashPostfix": "-Template-Input-InputType-ParaGraphaString",
20
- "Template": "<p><span class=\"VeryImportantData\">{~D:Record.Name~}:</span>{~D:Record.Description~}<input type=\"text\" name=\"{~D:Record.Hash~}\" />\n"
20
+ "Template": "<p><span class=\"VeryImportantData\">{~D:Record.Name~}:</span>{~D:Record.Description~}<input type=\"text\" name=\"{~D:Record.Hash~}\" data-i-form=\"{~D:Context[0].formID~}\" data-i-datum=\"{~D:Record.PictForm.InformaryDataAddress~}\" />\n"
21
21
  }
22
22
  ],
23
23
 
@@ -0,0 +1,21 @@
1
+ {
2
+ "ViewIdentifier": "Postcard-About-View",
3
+
4
+ "DefaultRenderable": "Postcard-About",
5
+ "DefaultDestinationAddress": "#Postcard-Content-Container",
6
+
7
+ "RenderOnLoad": false,
8
+
9
+ "Templates": [
10
+ {
11
+ "Hash": "Postcard-About-Content",
12
+ "Template": "<h1>Welcome to PostKard, where every moment becomes a cherished memory to share.</h1> <p>In a world filled with digital communication, we believe in the enduring power of a tangible connection. PostKard is not just an app; it's a portal to capture the essence of life's most beautiful moments and send them off into the world with a personal touch.</p> <p>Our journey began with a simple idea: to bridge the gap between the digital and physical worlds, allowing people to share their experiences in a way that transcends screens and keyboards. With PostKard, you can turn your photos into stunning postcards, complete with personalized messages, and send them to your loved ones near and far.</p> <p>What sets us apart is our commitment to quality and convenience. Our intuitive app makes it easy to create custom postcards in minutes, whether you're commemorating a special occasion or simply sharing a slice of your everyday life. From birthdays to holidays, travels to everyday moments, PostKard helps you celebrate life's moments, big and small.</p> <p>But PostKard is more than just a platform; it's a community of storytellers, adventurers, and dreamers. We believe in the power of connection, and we're proud to facilitate meaningful interactions that transcend borders and bring people closer together.</p> <p>Join us on our mission to spread joy, one postcard at a time. Whether you're sending a smile across the miles or sharing a piece of your world with someone special, PostKard is here to help you make every moment count.</p>"
13
+ }
14
+ ],
15
+ "Renderables": [
16
+ {
17
+ "RenderableHash": "Postcard-About",
18
+ "TemplateHash": "Postcard-About-Content"
19
+ }
20
+ ]
21
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "ViewIdentifier": "Postcard-Legal-View",
3
+
4
+ "DefaultRenderable": "Postcard-Legal",
5
+ "DefaultDestinationAddress": "#Postcard-Content-Container",
6
+
7
+ "RenderOnLoad": false,
8
+
9
+ "Templates": [
10
+ {
11
+ "Hash": "Postcard-Legal-Content",
12
+ "Template": "<h1>Legal Disclaimer:</h1> <p>By using our postcard sending site, you agree to abide by the following terms and conditions:</p> <p><b>Intellectual Property Rights</b>: All content, including but not limited to text, images, graphics, logos, and software, provided on our site is the property of our company or its licensors and is protected by copyright, trademark, and other intellectual property laws. You may not reproduce, distribute, modify, or otherwise use any content without the prior written consent of the respective owners.</p> <p><b>User Content</b>: By uploading or submitting any content (such as text, images, or personal information) to our site, you grant us a worldwide, royalty-free, non-exclusive license to use, reproduce, modify, adapt, publish, translate, and distribute such content for the purpose of providing our services. You represent and warrant that you have the necessary rights to grant us this license.</p> <p><b>Privacy Policy</b>: We are committed to protecting your privacy. Our Privacy Policy outlines how we collect, use, and disclose your personal information. By using our site, you consent to the collection, use, and disclosure of your information as described in our Privacy Policy.</p> <p><b>Limitation of Liability</b>: We make every effort to ensure the accuracy and reliability of the information provided on our site. However, we cannot guarantee that our site will be error-free, uninterrupted, or free of viruses or other harmful components. In no event shall we be liable for any direct, indirect, incidental, special, or consequential damages arising out of or in any way connected with your use of our site.</p> <p><b>Governing Law</b>: These terms and conditions shall be governed by and construed in accordance with the laws of the world, without regard to its conflict of law provisions. Any disputes arising out of or relating to these terms and conditions shall be subject to the exclusive jurisdiction of the courts of the world.</p> <p>By using our postcard sending site, you acknowledge that you have read, understood, and agree to be bound by these terms and conditions. If you do not agree to these terms and conditions, please refrain from using our site.</p>"
13
+ }
14
+ ],
15
+ "Renderables": [
16
+ {
17
+ "RenderableHash": "Postcard-Legal",
18
+ "TemplateHash": "Postcard-Legal-Content"
19
+ }
20
+ ]
21
+ }
@@ -0,0 +1,55 @@
1
+ const libPictView = require('pict-view');
2
+
3
+ const _ViewConfiguration = (
4
+ {
5
+ ViewIdentifier: "Postcard-MainApplication",
6
+
7
+ DefaultRenderable: "Postcard-Main-Application",
8
+ DefaultDestinationAddress: "#Postcard-Content-Container",
9
+
10
+ RenderOnLoad: true,
11
+
12
+ CSS: ".PostcardControls { margin-top: 2em; background-color: #fff5f5; }",
13
+
14
+ Templates: [
15
+ {
16
+ Hash: "Postcard-Main-Application-Template",
17
+ Template: /*html*/`
18
+ <h1>Send a Fabulous Postkard!</h1>
19
+
20
+ <!-- where the Form Metacontroller view puts its content -->
21
+ <div id="Pict-Form-Container"></div>
22
+
23
+ <div class="PostcardControls">
24
+ <a href="#" onclick="_Pict.PictApplication.marshalDataFromViewToAppData()">[ Store Data ]</a> | <a href="#" onclick="_Pict.PictApplication.marshalDataFromAppDataToView()">[ Read Data ]</a>
25
+ ||
26
+ <a href="#" onclick="_Pict.PictApplication.changeToPostcardTheme()">[ Postkard Theme ]</a> | <a href="#" onclick="_Pict.PictApplication.changeToDefaultTheme()">[ Default Theme ]</a>
27
+ </div>
28
+ `
29
+ }
30
+ ],
31
+ Renderables: [
32
+ {
33
+ RenderableHash: "Postcard-Main-Application",
34
+ TemplateHash: "Postcard-Main-Application-Template"
35
+ }]
36
+ });
37
+
38
+ class PostcardMainApplicationView extends libPictView
39
+ {
40
+ constructor(pFable, pOptions, pServiceHash)
41
+ {
42
+ super(pFable, pOptions, pServiceHash);
43
+ }
44
+
45
+ onAfterRender()
46
+ {
47
+ this.pict.views.PictFormMetacontroller.render();
48
+ this.pict.views.PictFormMetacontroller.renderAllFormSections();
49
+ this.pict.PictApplication.marshalDataFromAppDataToView();
50
+ }
51
+ }
52
+
53
+ module.exports = PostcardMainApplicationView;
54
+
55
+ module.exports.default_configuration = _ViewConfiguration;
@@ -6,10 +6,12 @@
6
6
 
7
7
  "RenderOnLoad": true,
8
8
 
9
+ "CSS": ".PostcardNavigation { background-color: #fff5f5; }",
10
+
9
11
  "Templates": [
10
12
  {
11
13
  "Hash": "Postcard-Top-Navigation",
12
- "Template": "<div id=\"Navigation\"><a href=\"#\">Postcard</a> | <a href=\"#About\">About</a> | <a href=\"#Legal\">Legal </a> || <a href=\"#\" onclick=\"_Pict.PictApplication.changeToPostcardTheme()\">[ Postkard Theme ]</a> | <a href=\"#\" onclick=\"_Pict.PictApplication.changeToDefaultTheme()\">[ Default Theme ]</a></div>"
14
+ "Template": "<div class=\"PostcardNavigation\"><a href=\"#\" onclick=\"_Pict.views.PostcardMainApplication.render()\">Postcard</a> | <a href=\"#About\" onclick=\"_Pict.views.PostcardAbout.render()\">About</a> | <a href=\"#Legal\" onclick=\"_Pict.views.PostcardLegal.render()\">Legal </a></div>"
13
15
  }
14
16
  ],
15
17
  "Renderables": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pict-section-form",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Pict dynamic form sections",
5
5
  "main": "source/Pict-Section-Form.js",
6
6
  "directories": {
@@ -30,6 +30,7 @@
30
30
  "quackage": "^1.0.29"
31
31
  },
32
32
  "dependencies": {
33
+ "informary": "^2.0.21",
33
34
  "pict-provider": "^1.0.2",
34
35
  "pict-view": "^1.0.43"
35
36
  },
@@ -22,6 +22,32 @@ class PictFormMetacontroller extends libPictViewClass
22
22
  this.formTemplatePrefix = 'Pict-Forms-Basic';
23
23
  }
24
24
 
25
+ onMarshalFromView()
26
+ {
27
+ let tmpViewList = Object.keys(this.fable.views);
28
+
29
+ for (let i = 0; i < tmpViewList.length; i++)
30
+ {
31
+ if (this.fable.views[tmpViewList[i]].isPictSectionForm)
32
+ {
33
+ this.fable.views[tmpViewList[i]].marshalFromView();
34
+ }
35
+ }
36
+ }
37
+
38
+ onMarshalToView()
39
+ {
40
+ let tmpViewList = Object.keys(this.fable.views);
41
+
42
+ for (let i = 0; i < tmpViewList.length; i++)
43
+ {
44
+ if (this.fable.views[tmpViewList[i]].isPictSectionForm)
45
+ {
46
+ this.fable.views[tmpViewList[i]].marshalToView();
47
+ }
48
+ }
49
+ }
50
+
25
51
  onAfterInitializeAsync(fCallback)
26
52
  {
27
53
  // This is safe -- if there is no settings.DefaultFormManifest configuration, it just doesn't do anything
@@ -119,8 +119,8 @@ Glug glug glug
119
119
  {
120
120
  "HashPostfix": "-Template-Input",
121
121
  "Template": /*HTML*/`
122
- <!-- Input {~D:Record.Hash~} {~D:Record.DataType~} -->
123
- <span>{~D:Record.Name~}:</span> <input type="hidden" id="{~D:Context[0].UUID~}-FormInput-{~D:Record.Hash~}" name="{~D:Record.Name~}" value="">
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="">
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~}" value="">
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="">
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~}" value="">
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="">
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~}"></textarea>
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>
148
148
  `
149
149
  }
150
150
  ]
@@ -1,5 +1,7 @@
1
1
  const libPictViewClass = require('pict-view');
2
2
 
3
+ const libInformary = require('informary');
4
+
3
5
  const libFormsTemplateProvider = require('./Pict-Section-Form-Provider-Templates.js');
4
6
 
5
7
  class PictSectionForm extends libPictViewClass
@@ -79,9 +81,52 @@ class PictSectionForm extends libPictViewClass
79
81
  }
80
82
  }
81
83
  }
84
+
85
+ this.formID = `Pict-Form-${this.Hash}-${this.UUID}`;
86
+
87
+ this.informary = new libInformary({ Form:this.formID })
88
+
82
89
  this.initializeFormGroups();
83
90
  }
84
91
 
92
+ onMarshalToView()
93
+ {
94
+ try
95
+ {
96
+ this.informary.marshalDataToForm(this.AppData,
97
+ function(pError)
98
+ {
99
+ if (pError)
100
+ {
101
+ this.log.error(`Error marshaling data from view: ${pError}`);
102
+ }
103
+ });
104
+ }
105
+ catch (pError)
106
+ {
107
+ this.log.error(`Gross error marshaling data from view: ${pError}`);
108
+ }
109
+ }
110
+
111
+ onMarshalFromView()
112
+ {
113
+ try
114
+ {
115
+ this.informary.marshalFormToData(this.AppData,
116
+ function(pError)
117
+ {
118
+ if (pError)
119
+ {
120
+ this.log.error(`Error marshaling data to view: ${pError}`);
121
+ }
122
+ });
123
+ }
124
+ catch (pError)
125
+ {
126
+ this.log.error(`Gross error marshaling data to view: ${pError}`);
127
+ }
128
+ }
129
+
85
130
  initializeFormGroups()
86
131
  {
87
132
  // Enumerate the manifest and make sure a group exists for each group in the section definition
@@ -103,6 +148,8 @@ class PictSectionForm extends libPictViewClass
103
148
  tmpDescriptor.PictForm.Section == this.sectionDefinition.Hash
104
149
  )
105
150
  {
151
+ tmpDescriptor.PictForm.InformaryDataAddress = tmpDescriptorKeys[i];
152
+
106
153
  let tmpGroupHash = (typeof(tmpDescriptor.PictForm.Group) == 'string') ? tmpDescriptor.PictForm.Group : 'Default';
107
154
 
108
155
  let tmpGroup = this.sectionDefinition.Groups.find((pGroup) => { return pGroup.Hash == tmpGroupHash; });