@esfaenza/forms-and-validations 12.2.11 → 12.2.12
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/esfaenza-forms-and-validations.umd.js +26 -23
- package/bundles/esfaenza-forms-and-validations.umd.js.map +1 -1
- package/esm2015/lib/forms/base-form-control.js +27 -24
- package/fesm2015/esfaenza-forms-and-validations.js +26 -23
- package/fesm2015/esfaenza-forms-and-validations.js.map +1 -1
- package/package.json +1 -1
|
@@ -1871,32 +1871,35 @@
|
|
|
1871
1871
|
if (this.Source.length == 0 && !this.FirstBind)
|
|
1872
1872
|
this.BoundSource = [];
|
|
1873
1873
|
this.FirstBind = false;
|
|
1874
|
+
// Cache locale per evitare di rifare dei regex.match ogni santa volta
|
|
1874
1875
|
if (this.Source.length > 0) {
|
|
1875
1876
|
this.BoundSource = [];
|
|
1876
|
-
|
|
1877
|
-
var
|
|
1878
|
-
var
|
|
1877
|
+
// Blocco per tirare fuori le condizioni scritte tipo --> :prop?(Roba con {prop})
|
|
1878
|
+
var iffedMatches = this.Display.match(/:([a-z]+)\?\(([^\(\)]+)\)/g);
|
|
1879
|
+
var bindCheckingGroups = [];
|
|
1880
|
+
if (iffedMatches) {
|
|
1881
|
+
iffedMatches.forEach(function (m) {
|
|
1882
|
+
// Stessa regex di sopra ma il tag "i" serve per tirare fuori i singoli capturing group e per qualche motivo
|
|
1883
|
+
// new RegExp(baseRegex, "g") non funziona quindi non ho potuto razionalizzarlo
|
|
1884
|
+
var groups = m.match(/:([a-z]+)\?\(([^\(\)]+)\)/i);
|
|
1885
|
+
bindCheckingGroups.push({ global: m, prop: groups[1], whenexists: groups[2] });
|
|
1886
|
+
});
|
|
1887
|
+
}
|
|
1888
|
+
// Blocco per tirare fuori le proprietà scritte tipo --> {prop}
|
|
1889
|
+
var bindProperties = [];
|
|
1890
|
+
var matches = this.Display.match(/{[a-z]+}/gi);
|
|
1891
|
+
if (matches)
|
|
1892
|
+
matches.forEach(function (m) { bindProperties.push({ global: m, prop: m.substring(1, m.length - 1) }); });
|
|
1893
|
+
// Blocco per generare la descrizione finale di un elemento
|
|
1879
1894
|
this.Source.forEach(function (s) {
|
|
1880
|
-
|
|
1881
|
-
var
|
|
1882
|
-
//
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
// altrimenti elimino il blocco completamente
|
|
1889
|
-
tmpDescription = tmpDescription.replace(m[0], s[groups[1]] ? groups[2] : "");
|
|
1890
|
-
}
|
|
1891
|
-
}
|
|
1892
|
-
var matches = tmpDescription.match(bindings_1);
|
|
1893
|
-
if (matches) {
|
|
1894
|
-
for (var i = 0; i < matches.length; i++) {
|
|
1895
|
-
var m = matches[i];
|
|
1896
|
-
tmpDescription = tmpDescription.replace(m, s[m.substring(1, m.length - 1)]);
|
|
1897
|
-
}
|
|
1898
|
-
}
|
|
1899
|
-
_this.BoundSource.push({ id: s[_this.IdField], description: tmpDescription });
|
|
1895
|
+
// Parto sempre dalla variabile di Display, poi sostituisco pezzo per pezzo
|
|
1896
|
+
var desc = _this.Display;
|
|
1897
|
+
// Taglio o mantengo le condizioni in base alla proprietà su cui fare check
|
|
1898
|
+
// Dopodiché scrivo tutte le proprietà
|
|
1899
|
+
bindCheckingGroups.forEach(function (t) { desc = desc.replace(t.global, (s[t.prop] != null && s[t.prop] != undefined) ? t.whenexists : ""); });
|
|
1900
|
+
bindProperties.forEach(function (t) { desc = desc.replace(t.global, s[t.prop]); });
|
|
1901
|
+
// Aggiungo alla BoundSource in formato standard KeyValue
|
|
1902
|
+
_this.BoundSource.push({ id: s[_this.IdField], description: desc });
|
|
1900
1903
|
});
|
|
1901
1904
|
}
|
|
1902
1905
|
};
|