tnx-shared 5.3.270 → 5.3.271
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/tnx-shared.umd.js +70 -23
- package/bundles/tnx-shared.umd.js.map +1 -1
- package/bundles/tnx-shared.umd.min.js +1 -1
- package/bundles/tnx-shared.umd.min.js.map +1 -1
- package/classes/form-schema.d.ts +1 -0
- package/classes/form-schema.d.ts.map +1 -1
- package/components/crud/crud-form/crud-form.component.d.ts +1 -0
- package/components/crud/crud-form/crud-form.component.d.ts.map +1 -1
- package/esm2015/classes/form-schema.js +2 -1
- package/esm2015/components/crud/crud-form/crud-form.component.js +28 -4
- package/fesm2015/tnx-shared.js +28 -3
- package/fesm2015/tnx-shared.js.map +1 -1
- package/package.json +2 -2
- package/tnx-shared.metadata.json +1 -1
|
@@ -1307,6 +1307,7 @@
|
|
|
1307
1307
|
this.hiddenKySoSimCaNhan = false;
|
|
1308
1308
|
this.hiddenKySoUsbCaNhan = false;
|
|
1309
1309
|
this.hiddenKySoDonVi = false;
|
|
1310
|
+
this.arrFieldMustValidate = [];
|
|
1310
1311
|
this.getCustomDataTrinhKy = function (rowData) { return ({}); };
|
|
1311
1312
|
for (var key in init) {
|
|
1312
1313
|
this[key] = init[key];
|
|
@@ -16268,14 +16269,15 @@
|
|
|
16268
16269
|
};
|
|
16269
16270
|
CrudFormComponent.prototype.validateForm = function (setValidateForm) {
|
|
16270
16271
|
if (setValidateForm === void 0) { setValidateForm = true; }
|
|
16272
|
+
var _a;
|
|
16271
16273
|
return __awaiter(this, void 0, void 0, function () {
|
|
16272
16274
|
var _this = this;
|
|
16273
16275
|
return __generator(this, function (_e) {
|
|
16274
16276
|
switch (_e.label) {
|
|
16275
16277
|
case 0:
|
|
16276
|
-
if (!setValidateForm) return [3 /*break*/, 2];
|
|
16278
|
+
if (!(setValidateForm || ((_a = this.setting.arrFieldMustValidate) === null || _a === void 0 ? void 0 : _a.length))) return [3 /*break*/, 2];
|
|
16277
16279
|
this._inValidForm = false;
|
|
16278
|
-
return [4 /*yield*/, this.validateModel(this._rootNode)];
|
|
16280
|
+
return [4 /*yield*/, this.validateModel(this._rootNode, setValidateForm)];
|
|
16279
16281
|
case 1:
|
|
16280
16282
|
_e.sent();
|
|
16281
16283
|
if (this._inValidForm) {
|
|
@@ -16290,7 +16292,9 @@
|
|
|
16290
16292
|
});
|
|
16291
16293
|
});
|
|
16292
16294
|
};
|
|
16293
|
-
CrudFormComponent.prototype.validateModel = function (currentNode) {
|
|
16295
|
+
CrudFormComponent.prototype.validateModel = function (currentNode, setValidateForm) {
|
|
16296
|
+
if (setValidateForm === void 0) { setValidateForm = true; }
|
|
16297
|
+
var _a;
|
|
16294
16298
|
return __awaiter(this, void 0, void 0, function () {
|
|
16295
16299
|
var _e, _f, childNode, e_28_1;
|
|
16296
16300
|
var e_28, _g;
|
|
@@ -16303,6 +16307,12 @@
|
|
|
16303
16307
|
case 1:
|
|
16304
16308
|
if (!!_f.done) return [3 /*break*/, 5];
|
|
16305
16309
|
childNode = _f.value;
|
|
16310
|
+
if (!setValidateForm && ((_a = this.setting.arrFieldMustValidate) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
16311
|
+
if (!this.setting.arrFieldMustValidate.includes(childNode.field)) {
|
|
16312
|
+
this.removeAllErrorByNodes(childNode);
|
|
16313
|
+
return [3 /*break*/, 4];
|
|
16314
|
+
}
|
|
16315
|
+
}
|
|
16306
16316
|
if (!childNode.control) {
|
|
16307
16317
|
if (childNode.childNodes == null) {
|
|
16308
16318
|
return [3 /*break*/, 4];
|
|
@@ -16729,6 +16739,43 @@
|
|
|
16729
16739
|
this._removeError(field);
|
|
16730
16740
|
}
|
|
16731
16741
|
};
|
|
16742
|
+
CrudFormComponent.prototype.removeAllErrorByNodes = function (currentNode) {
|
|
16743
|
+
var e_30, _e, e_31, _f;
|
|
16744
|
+
var _a, _b;
|
|
16745
|
+
currentNode.parentNode.model._errors[currentNode.field] = [];
|
|
16746
|
+
if (!((_a = currentNode.childNodes) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
16747
|
+
return;
|
|
16748
|
+
}
|
|
16749
|
+
try {
|
|
16750
|
+
for (var _g = __values(currentNode.childNodes), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
16751
|
+
var childNode = _h.value;
|
|
16752
|
+
if (!((_b = childNode.childNodes) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
16753
|
+
this.removeAllErrorByNodes(childNode);
|
|
16754
|
+
continue;
|
|
16755
|
+
}
|
|
16756
|
+
try {
|
|
16757
|
+
for (var _j = (e_31 = void 0, __values(childNode.childNodes)), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
16758
|
+
var node = _k.value;
|
|
16759
|
+
this.removeAllErrorByNodes(node);
|
|
16760
|
+
}
|
|
16761
|
+
}
|
|
16762
|
+
catch (e_31_1) { e_31 = { error: e_31_1 }; }
|
|
16763
|
+
finally {
|
|
16764
|
+
try {
|
|
16765
|
+
if (_k && !_k.done && (_f = _j.return)) _f.call(_j);
|
|
16766
|
+
}
|
|
16767
|
+
finally { if (e_31) throw e_31.error; }
|
|
16768
|
+
}
|
|
16769
|
+
}
|
|
16770
|
+
}
|
|
16771
|
+
catch (e_30_1) { e_30 = { error: e_30_1 }; }
|
|
16772
|
+
finally {
|
|
16773
|
+
try {
|
|
16774
|
+
if (_h && !_h.done && (_e = _g.return)) _e.call(_g);
|
|
16775
|
+
}
|
|
16776
|
+
finally { if (e_30) throw e_30.error; }
|
|
16777
|
+
}
|
|
16778
|
+
};
|
|
16732
16779
|
CrudFormComponent.prototype.cacheControlValue = function (control, value, parentPath) {
|
|
16733
16780
|
if (control && control.enableCaching) {
|
|
16734
16781
|
this.cachedValues[parentPath + '.' + control.field] = value;
|
|
@@ -16808,7 +16855,7 @@
|
|
|
16808
16855
|
* @param options
|
|
16809
16856
|
*/
|
|
16810
16857
|
CrudFormComponent.prototype.focusFirstControl = function () {
|
|
16811
|
-
var
|
|
16858
|
+
var e_32, _e;
|
|
16812
16859
|
var formElement = this.formElement.nativeElement;
|
|
16813
16860
|
var divs = formElement.querySelectorAll('div.crud-form-control');
|
|
16814
16861
|
if (divs) {
|
|
@@ -16843,12 +16890,12 @@
|
|
|
16843
16890
|
}
|
|
16844
16891
|
}
|
|
16845
16892
|
}
|
|
16846
|
-
catch (
|
|
16893
|
+
catch (e_32_1) { e_32 = { error: e_32_1 }; }
|
|
16847
16894
|
finally {
|
|
16848
16895
|
try {
|
|
16849
16896
|
if (divs_1_1 && !divs_1_1.done && (_e = divs_1.return)) _e.call(divs_1);
|
|
16850
16897
|
}
|
|
16851
|
-
finally { if (
|
|
16898
|
+
finally { if (e_32) throw e_32.error; }
|
|
16852
16899
|
}
|
|
16853
16900
|
}
|
|
16854
16901
|
};
|
|
@@ -17012,7 +17059,7 @@
|
|
|
17012
17059
|
if (fireEventFinish === void 0) { fireEventFinish = true; }
|
|
17013
17060
|
return __awaiter(this, void 0, void 0, function () {
|
|
17014
17061
|
var tableNode, index, parentPath, data, _e, _f, subControl, toAdd, newRowNode, _b_3, _c_3, _d_1;
|
|
17015
|
-
var
|
|
17062
|
+
var e_33, _g;
|
|
17016
17063
|
return __generator(this, function (_h) {
|
|
17017
17064
|
switch (_h.label) {
|
|
17018
17065
|
case 0:
|
|
@@ -17044,12 +17091,12 @@
|
|
|
17044
17091
|
this.initControlDefaultValue(data, subControl, parentPath);
|
|
17045
17092
|
}
|
|
17046
17093
|
}
|
|
17047
|
-
catch (
|
|
17094
|
+
catch (e_33_1) { e_33 = { error: e_33_1 }; }
|
|
17048
17095
|
finally {
|
|
17049
17096
|
try {
|
|
17050
17097
|
if (_f && !_f.done && (_g = _e.return)) _g.call(_e);
|
|
17051
17098
|
}
|
|
17052
|
-
finally { if (
|
|
17099
|
+
finally { if (e_33) throw e_33.error; }
|
|
17053
17100
|
}
|
|
17054
17101
|
toAdd = true;
|
|
17055
17102
|
if (control.onAdding) {
|
|
@@ -17135,7 +17182,7 @@
|
|
|
17135
17182
|
CrudFormComponent.prototype.handleSavedTableRow = function (data) {
|
|
17136
17183
|
return __awaiter(this, void 0, void 0, function () {
|
|
17137
17184
|
var control, tablePath, eventType, tableNode, index, parentPath, _e, _f, subControl, toAdd, newRowNode, _b_4, _c_4, _d_2;
|
|
17138
|
-
var
|
|
17185
|
+
var e_34, _g;
|
|
17139
17186
|
return __generator(this, function (_h) {
|
|
17140
17187
|
switch (_h.label) {
|
|
17141
17188
|
case 0:
|
|
@@ -17157,12 +17204,12 @@
|
|
|
17157
17204
|
this.initControlModel(data, subControl, parentPath);
|
|
17158
17205
|
}
|
|
17159
17206
|
}
|
|
17160
|
-
catch (
|
|
17207
|
+
catch (e_34_1) { e_34 = { error: e_34_1 }; }
|
|
17161
17208
|
finally {
|
|
17162
17209
|
try {
|
|
17163
17210
|
if (_f && !_f.done && (_g = _e.return)) _g.call(_e);
|
|
17164
17211
|
}
|
|
17165
|
-
finally { if (
|
|
17212
|
+
finally { if (e_34) throw e_34.error; }
|
|
17166
17213
|
}
|
|
17167
17214
|
toAdd = true;
|
|
17168
17215
|
if (control.onAdding) {
|
|
@@ -17597,7 +17644,7 @@
|
|
|
17597
17644
|
}
|
|
17598
17645
|
};
|
|
17599
17646
|
ControlTreeNode.prototype.initChildNodes = function (model, schemas, keysPlus) {
|
|
17600
|
-
var
|
|
17647
|
+
var e_35, _e, e_36, _f;
|
|
17601
17648
|
if (isLiteralObject(model)) {
|
|
17602
17649
|
var allKey = new Set(__spreadArray(__spreadArray([], __read(keysPlus)), __read(Object.keys(model))));
|
|
17603
17650
|
try {
|
|
@@ -17610,12 +17657,12 @@
|
|
|
17610
17657
|
}
|
|
17611
17658
|
}
|
|
17612
17659
|
}
|
|
17613
|
-
catch (
|
|
17660
|
+
catch (e_35_1) { e_35 = { error: e_35_1 }; }
|
|
17614
17661
|
finally {
|
|
17615
17662
|
try {
|
|
17616
17663
|
if (allKey_1_1 && !allKey_1_1.done && (_e = allKey_1.return)) _e.call(allKey_1);
|
|
17617
17664
|
}
|
|
17618
|
-
finally { if (
|
|
17665
|
+
finally { if (e_35) throw e_35.error; }
|
|
17619
17666
|
}
|
|
17620
17667
|
// Sau khi đã init xong node cho row thì fire event cho các control trong row
|
|
17621
17668
|
// Thường dùng với mục đích cần disabled, hidden các control của row khi có nhu cầu
|
|
@@ -17647,12 +17694,12 @@
|
|
|
17647
17694
|
i++;
|
|
17648
17695
|
}
|
|
17649
17696
|
}
|
|
17650
|
-
catch (
|
|
17697
|
+
catch (e_36_1) { e_36 = { error: e_36_1 }; }
|
|
17651
17698
|
finally {
|
|
17652
17699
|
try {
|
|
17653
17700
|
if (model_3_1 && !model_3_1.done && (_f = model_3.return)) _f.call(model_3);
|
|
17654
17701
|
}
|
|
17655
|
-
finally { if (
|
|
17702
|
+
finally { if (e_36) throw e_36.error; }
|
|
17656
17703
|
}
|
|
17657
17704
|
}
|
|
17658
17705
|
}
|
|
@@ -17798,7 +17845,7 @@
|
|
|
17798
17845
|
return this.findSchemaInTree(this.rootNode, schemaPath.toLowerCase());
|
|
17799
17846
|
};
|
|
17800
17847
|
ControlTreeNode.prototype.findInTree = function (node, modelPath) {
|
|
17801
|
-
var
|
|
17848
|
+
var e_37, _e;
|
|
17802
17849
|
if (node.modelPath != null && node.modelPath.toLowerCase() == modelPath.toLowerCase()) {
|
|
17803
17850
|
return node;
|
|
17804
17851
|
}
|
|
@@ -17813,18 +17860,18 @@
|
|
|
17813
17860
|
}
|
|
17814
17861
|
}
|
|
17815
17862
|
}
|
|
17816
|
-
catch (
|
|
17863
|
+
catch (e_37_1) { e_37 = { error: e_37_1 }; }
|
|
17817
17864
|
finally {
|
|
17818
17865
|
try {
|
|
17819
17866
|
if (_g && !_g.done && (_e = _f.return)) _e.call(_f);
|
|
17820
17867
|
}
|
|
17821
|
-
finally { if (
|
|
17868
|
+
finally { if (e_37) throw e_37.error; }
|
|
17822
17869
|
}
|
|
17823
17870
|
}
|
|
17824
17871
|
return null;
|
|
17825
17872
|
};
|
|
17826
17873
|
ControlTreeNode.prototype.findSchemaInTree = function (node, schemaPath) {
|
|
17827
|
-
var
|
|
17874
|
+
var e_38, _e;
|
|
17828
17875
|
if (node.schemaPath != null && node.schemaPath.toLowerCase() == schemaPath.toLowerCase()) {
|
|
17829
17876
|
return node;
|
|
17830
17877
|
}
|
|
@@ -17839,12 +17886,12 @@
|
|
|
17839
17886
|
}
|
|
17840
17887
|
}
|
|
17841
17888
|
}
|
|
17842
|
-
catch (
|
|
17889
|
+
catch (e_38_1) { e_38 = { error: e_38_1 }; }
|
|
17843
17890
|
finally {
|
|
17844
17891
|
try {
|
|
17845
17892
|
if (_g && !_g.done && (_e = _f.return)) _e.call(_f);
|
|
17846
17893
|
}
|
|
17847
|
-
finally { if (
|
|
17894
|
+
finally { if (e_38) throw e_38.error; }
|
|
17848
17895
|
}
|
|
17849
17896
|
}
|
|
17850
17897
|
return null;
|