@glowgreen/gg-questionnaire-v2 0.0.109 → 0.0.111
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.
- package/bundles/glowgreen-gg-questionnaire-v2.umd.js +41 -31
- package/bundles/glowgreen-gg-questionnaire-v2.umd.js.map +1 -1
- package/bundles/glowgreen-gg-questionnaire-v2.umd.min.js +1 -1
- package/bundles/glowgreen-gg-questionnaire-v2.umd.min.js.map +1 -1
- package/esm2015/lib/services/form-constructor.service.js +31 -8
- package/esm2015/lib/services/questionnaire.service.js +13 -26
- package/fesm2015/glowgreen-gg-questionnaire-v2.js +42 -32
- package/fesm2015/glowgreen-gg-questionnaire-v2.js.map +1 -1
- package/package.json +1 -1
|
@@ -738,16 +738,16 @@
|
|
|
738
738
|
if (noChange && !skipFilter) {
|
|
739
739
|
return null;
|
|
740
740
|
}
|
|
741
|
-
var questionnaireForms = this.generateFormsForSections(sections, currentQuestionnaireForm);
|
|
741
|
+
var questionnaireForms = this.generateFormsForSections(sections, currentQuestionnaireForm, additionalData);
|
|
742
742
|
return { sections: sections, forms: questionnaireForms };
|
|
743
743
|
};
|
|
744
|
-
FormConstructorService.prototype.generateFormsForSections = function (sections, currentQuestionnaireForm) {
|
|
744
|
+
FormConstructorService.prototype.generateFormsForSections = function (sections, currentQuestionnaireForm, additionalData) {
|
|
745
745
|
var e_1, _a;
|
|
746
746
|
var questionnaireForms = this.fb.group({});
|
|
747
747
|
try {
|
|
748
748
|
for (var sections_1 = __values(sections), sections_1_1 = sections_1.next(); !sections_1_1.done; sections_1_1 = sections_1.next()) {
|
|
749
749
|
var section = sections_1_1.value;
|
|
750
|
-
var sectionForms = this.generateFormsForSection(section, currentQuestionnaireForm);
|
|
750
|
+
var sectionForms = this.generateFormsForSection(section, currentQuestionnaireForm, additionalData);
|
|
751
751
|
questionnaireForms.addControl(section.name, sectionForms);
|
|
752
752
|
}
|
|
753
753
|
}
|
|
@@ -767,7 +767,7 @@
|
|
|
767
767
|
* @returns A filtered form group.
|
|
768
768
|
* @author Will Poulson
|
|
769
769
|
*/
|
|
770
|
-
FormConstructorService.prototype.generateFormsForSection = function (section, currentQuestionnaireForm) {
|
|
770
|
+
FormConstructorService.prototype.generateFormsForSection = function (section, currentQuestionnaireForm, additionalData) {
|
|
771
771
|
var e_2, _a;
|
|
772
772
|
var sectionForms = this.fb.group({});
|
|
773
773
|
try {
|
|
@@ -776,7 +776,7 @@
|
|
|
776
776
|
if (question.type === exports.QuestionType.Info) {
|
|
777
777
|
continue;
|
|
778
778
|
}
|
|
779
|
-
var questionControl = this.generateControlForQuestion(question, section, currentQuestionnaireForm);
|
|
779
|
+
var questionControl = this.generateControlForQuestion(question, section, currentQuestionnaireForm, additionalData);
|
|
780
780
|
sectionForms.addControl(question.name, questionControl);
|
|
781
781
|
}
|
|
782
782
|
}
|
|
@@ -795,10 +795,33 @@
|
|
|
795
795
|
* @returns An abstract control.
|
|
796
796
|
* @author Will Poulson
|
|
797
797
|
*/
|
|
798
|
-
FormConstructorService.prototype.generateControlForQuestion = function (question, section, currentQuestionnaireForm) {
|
|
798
|
+
FormConstructorService.prototype.generateControlForQuestion = function (question, section, currentQuestionnaireForm, additionalData) {
|
|
799
799
|
var e_3, _a;
|
|
800
800
|
var convertedValidators = this.convertValidators(question.validators);
|
|
801
801
|
var defaultValue = question.defaultValue ? question.defaultValue : null;
|
|
802
|
+
if (defaultValue !== null) {
|
|
803
|
+
defaultValue = this.filterService.getValueForString(defaultValue, currentQuestionnaireForm, additionalData);
|
|
804
|
+
}
|
|
805
|
+
var titleRegEx = /(\{\{([^\}]+)\}\})/gi;
|
|
806
|
+
var titlePlaceholdersFound = null;
|
|
807
|
+
while ((titlePlaceholdersFound = titleRegEx.exec(question.title)) !== null) {
|
|
808
|
+
var titleReplacementValue = this.filterService.getValueForString(titlePlaceholdersFound[2], currentQuestionnaireForm, additionalData);
|
|
809
|
+
var titleReplaceRe = new RegExp('\{\{' + titlePlaceholdersFound[2] + '\}\}', 'g');
|
|
810
|
+
titleReplacementValue = titleReplacementValue.replace(/\w\S*/g, function (txt) {
|
|
811
|
+
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
|
|
812
|
+
});
|
|
813
|
+
question.title = question.title.replace(titleReplaceRe, titleReplacementValue);
|
|
814
|
+
}
|
|
815
|
+
var subTitleRegEx = /(\{\{([^\}]+)\}\})/gi;
|
|
816
|
+
var subTitlePlaceholdersFound = null;
|
|
817
|
+
while ((subTitlePlaceholdersFound = subTitleRegEx.exec(question.subtitle)) !== null) {
|
|
818
|
+
var subTitleReplacementValue = this.filterService.getValueForString(subTitlePlaceholdersFound[2], currentQuestionnaireForm, additionalData);
|
|
819
|
+
var subTitleReplaceRe = new RegExp('\{\{' + subTitlePlaceholdersFound[2] + '\}\}', 'g');
|
|
820
|
+
subTitleReplacementValue = subTitleReplacementValue.replace(/\w\S*/g, function (txt) {
|
|
821
|
+
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
|
|
822
|
+
});
|
|
823
|
+
question.subtitle = question.subtitle.replace(subTitleReplaceRe, subTitleReplacementValue);
|
|
824
|
+
}
|
|
802
825
|
switch (question.type) {
|
|
803
826
|
case exports.QuestionType.Repeater:
|
|
804
827
|
var newArray = this.fb.array([], convertedValidators);
|
|
@@ -1333,34 +1356,21 @@
|
|
|
1333
1356
|
if (!data) {
|
|
1334
1357
|
return null;
|
|
1335
1358
|
}
|
|
1336
|
-
var regexp = /(\{\{([^\}]+)\}\})/gi;
|
|
1337
|
-
var placeholdersFound = null;
|
|
1338
|
-
while ((placeholdersFound = regexp.exec(data.title)) !== null) {
|
|
1339
|
-
var replacementValue = this.filterService.getValueForString(placeholdersFound[2], this.currentQuestionnaireForm, this.additionalData);
|
|
1340
|
-
var replace_re = new RegExp('\{\{' + placeholdersFound[2] + '\}\}', 'g');
|
|
1341
|
-
replacementValue = replacementValue.replace(/\w\S*/g, function (txt) {
|
|
1342
|
-
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
|
|
1343
|
-
});
|
|
1344
|
-
data.title = data.title.replace(replace_re, replacementValue);
|
|
1345
|
-
}
|
|
1346
|
-
var regexp2 = /(\{\{([^\}]+)\}\})/gi;
|
|
1347
|
-
var subTitlePlaceholdersFound = null;
|
|
1348
|
-
while ((subTitlePlaceholdersFound = regexp2.exec(data.subtitle)) !== null) {
|
|
1349
|
-
var replacementValue2 = this.filterService.getValueForString(subTitlePlaceholdersFound[2], this.currentQuestionnaireForm, this.additionalData);
|
|
1350
|
-
var replace_re2 = new RegExp('\{\{' + subTitlePlaceholdersFound[2] + '\}\}', 'g');
|
|
1351
|
-
replacementValue2 = replacementValue2.replace(/\w\S*/g, function (txt) {
|
|
1352
|
-
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
|
|
1353
|
-
});
|
|
1354
|
-
data.subtitle = data.subtitle.replace(replace_re2, replacementValue2);
|
|
1355
|
-
}
|
|
1356
1359
|
var formControl = this.currentSection.formGroup.get(data.name);
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1360
|
+
/*
|
|
1361
|
+
if (data.defaultValue !== null && data.defaultValue !== '') {
|
|
1362
|
+
const oriDefaultValue = data.defaultValue;
|
|
1363
|
+
data.defaultValue = this.filterService.getValueForString(
|
|
1364
|
+
data.defaultValue,
|
|
1365
|
+
this.currentQuestionnaireForm,
|
|
1366
|
+
this.additionalData);
|
|
1367
|
+
|
|
1368
|
+
if (oriDefaultValue !== data.defaultValue) {
|
|
1361
1369
|
formControl.patchValue(data.defaultValue);
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1362
1372
|
}
|
|
1363
|
-
|
|
1373
|
+
*/
|
|
1364
1374
|
return {
|
|
1365
1375
|
data: data,
|
|
1366
1376
|
formControl: formControl
|