pict-section-form
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -14,2 +14,3 @@ const libPictApplication = require('pict-application'); | ||
this.pict.addProvider('Postcard-DynamicSection-Provider', libProviderDynamicSection.default_configuration, libProviderDynamicSection); | ||
this.pict.addProvider('Postcard-Default-Theme-Provider', {}, require('./providers/PictProvider-BestPostcardTheme.js')); | ||
@@ -24,2 +25,16 @@ this.pict.addView('Postcard-Navigation', require('./views/PictView-Postcard-Navigation.json')); | ||
} | ||
changeToDefaultTheme() | ||
{ | ||
this.pict.views.PictFormMetacontroller.formTemplatePrefix = _Pict.providers.PictFormSectionDefaultTemplateProvider.formsTemplateSetPrefix | ||
this.pict.views.PictFormMetacontroller.regenerateAllFormSectionTemplates(); | ||
this.pict.views.PictFormMetacontroller.renderAllFormSections(); | ||
} | ||
changeToPostcardTheme() | ||
{ | ||
this.pict.views.PictFormMetacontroller.formTemplatePrefix = _Pict.providers['Postcard-Default-Theme-Provider'].formsTemplateSetPrefix; | ||
this.pict.views.PictFormMetacontroller.regenerateAllFormSectionTemplates(); | ||
this.pict.views.PictFormMetacontroller.renderAllFormSections(); | ||
} | ||
}; | ||
@@ -26,0 +41,0 @@ |
@@ -14,2 +14,12 @@ { | ||
"CSS": ".VeryImportantData { background-color: #ff00ff; }", | ||
"MetaTemplates": | ||
[ | ||
{ | ||
"HashPostfix": "-Template-Input-InputType-ParaGraphaString", | ||
"Template": "<p><span class=\"VeryImportantData\">{~D:Record.Name~}:</span>{~D:Record.Description~}<input type=\"text\" name=\"{~D:Record.Hash~}\" />\n" | ||
} | ||
], | ||
"Description": "The content and destination for the postcard you would like to send.", | ||
@@ -61,3 +71,3 @@ "Groups": [ | ||
"DataType":"String" | ||
,"PictForm": { "Section":"Postcard", "Group":"Content", "Row":2, "Width":12 } | ||
,"PictForm": { "Section":"Postcard", "Group":"Content", "Row":2, "Width":12, "InputType":"ParaGraphaString" } | ||
}, | ||
@@ -64,0 +74,0 @@ "PostcardContent.MessageBody": |
const libPictProvider = require('pict-provider'); | ||
const libPictFormSection = require('../../../source/Pict-Section-Form.js'); | ||
@@ -4,0 +3,0 @@ const _DEFAULT_PROVIDER_CONFIGURATION = |
@@ -12,3 +12,3 @@ { | ||
"Hash": "Postcard-Top-Navigation", | ||
"Template": "<div id=\"Navigation\"><a href=\"#\">Postcard</a> | <a href=\"#About\">About</a> | <a href=\"#Legal\">Legal</a></div>" | ||
"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>" | ||
} | ||
@@ -15,0 +15,0 @@ ], |
{ | ||
"name": "pict-section-form", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Pict dynamic form sections", | ||
@@ -5,0 +5,0 @@ "main": "source/Pict-Section-Form.js", |
@@ -68,2 +68,4 @@ const libPictViewClass = require('pict-view'); | ||
} | ||
// Make sure any form-specific CSS is injected properly. | ||
this.pict.CSSMap.injectCSS(); | ||
} | ||
@@ -70,0 +72,0 @@ |
@@ -22,3 +22,2 @@ const libPictViewClass = require('pict-view'); | ||
// Set the default destination address to be based on the section hash if it hasn't been overridden by the manifest section definition | ||
@@ -64,2 +63,22 @@ if (tmpOptions.DefaultDestinationAddress == '#Pict-Form-Container') | ||
} | ||
// Load any form-specific templates | ||
this.formsTemplateSetPrefix = `PFT-${this.Hash}-${this.UUID}`; | ||
if (this.options.hasOwnProperty('MetaTemplates') && Array.isArray(this.options.MetaTemplates)) | ||
{ | ||
for (let i = 0; i < this.options.MetaTemplates.length; i++) | ||
{ | ||
let tmpMetaTemplate = this.options.MetaTemplates[i]; | ||
if (tmpMetaTemplate.hasOwnProperty('HashPostfix') && tmpMetaTemplate.hasOwnProperty('Template')) | ||
{ | ||
let tmpTemplateHash = `${this.formsTemplateSetPrefix}${tmpMetaTemplate.HashPostfix}`; | ||
this.pict.TemplateProvider.addTemplate(tmpTemplateHash, tmpMetaTemplate.Template); | ||
} | ||
else | ||
{ | ||
this.log.warn(`MetaTemplate entry ${i} in PictSectionForm [${this.UUID}]::[${this.Hash}] does not have a Hash and Template property; custom template skipped.`); | ||
} | ||
} | ||
} | ||
this.initializeFormGroups(); | ||
@@ -160,12 +179,31 @@ } | ||
// Try to fid a template in the prefix group for the data type | ||
if (this.pict.TemplateProvider.getTemplate(`${tmpFormTemplatePrefix}${tmpTemplateInputScope}-InputType-${tmpGroup.Rows[j].Inputs[k].PictForm.InputType}`)) | ||
// Check for view-specific control/datatype templates | ||
if (this.pict.TemplateProvider.getTemplate(`${this.formsTemplateSetPrefix}${tmpTemplateInputScope}-InputType-${tmpGroup.Rows[j].Inputs[k].PictForm.InputType}`)) | ||
{ | ||
tmpTemplateInputScope += `-InputType-${tmpGroup.Rows[j].Inputs[k].PictForm.InputType}`; | ||
tmpTemplate += `\n{~T:${this.formsTemplateSetPrefix}${tmpTemplateInputScope}:Pict.views["${this.Hash}"].sectionDefinition.Groups[${i}].Rows[${j}].Inputs[${k}]~}`; | ||
} | ||
else if (this.pict.TemplateProvider.getTemplate(`${this.formsTemplateSetPrefix}${tmpTemplateInputScope}-DataType-${tmpGroup.Rows[j].Inputs[k].DataType}`)) | ||
{ | ||
tmpTemplateInputScope += `-DataType-${tmpGroup.Rows[j].Inputs[k].DataType}`; | ||
tmpTemplate += `\n{~T:${this.formsTemplateSetPrefix}${tmpTemplateInputScope}:Pict.views["${this.Hash}"].sectionDefinition.Groups[${i}].Rows[${j}].Inputs[${k}]~}`; | ||
} | ||
// Check for theme-specific control/datatype templates | ||
else if (this.pict.TemplateProvider.getTemplate(`${tmpFormTemplatePrefix}${tmpTemplateInputScope}-InputType-${tmpGroup.Rows[j].Inputs[k].PictForm.InputType}`)) | ||
{ | ||
tmpTemplateInputScope += `-InputType-${tmpGroup.Rows[j].Inputs[k].PictForm.InputType}`; | ||
tmpTemplate += `\n{~T:${tmpFormTemplatePrefix}${tmpTemplateInputScope}:Pict.views["${this.Hash}"].sectionDefinition.Groups[${i}].Rows[${j}].Inputs[${k}]~}`; | ||
} | ||
else if (this.pict.TemplateProvider.getTemplate(`${tmpFormTemplatePrefix}${tmpTemplateInputScope}-DataType-${tmpGroup.Rows[j].Inputs[k].DataType}`)) | ||
{ | ||
tmpTemplateInputScope += `-DataType-${tmpGroup.Rows[j].Inputs[k].DataType}`; | ||
tmpTemplate += `\n{~T:${tmpFormTemplatePrefix}${tmpTemplateInputScope}:Pict.views["${this.Hash}"].sectionDefinition.Groups[${i}].Rows[${j}].Inputs[${k}]~}`; | ||
} | ||
tmpTemplate += `\n{~T:${tmpFormTemplatePrefix}${tmpTemplateInputScope}:Pict.views["${this.Hash}"].sectionDefinition.Groups[${i}].Rows[${j}].Inputs[${k}]~}`; | ||
// Fall back on the default control/datatype template | ||
else | ||
{ | ||
tmpTemplate += `\n{~T:${tmpFormTemplatePrefix}${tmpTemplateInputScope}:Pict.views["${this.Hash}"].sectionDefinition.Groups[${i}].Rows[${j}].Inputs[${k}]~}`; | ||
} | ||
} | ||
@@ -172,0 +210,0 @@ tmpTemplate += `\n{~T:${tmpFormTemplatePrefix}-Template-Row-Postfix:Pict.views["${this.Hash}"].sectionDefinition.Groups[${i}]~}`; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
139507
24
938