tnx-shared 5.3.270 → 5.3.272
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 +91 -25
- 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 +2 -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 +36 -4
- package/fesm2015/tnx-shared.js +36 -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) {
|
|
@@ -16284,13 +16286,18 @@
|
|
|
16284
16286
|
}, 100);
|
|
16285
16287
|
return [2 /*return*/, false];
|
|
16286
16288
|
}
|
|
16287
|
-
|
|
16288
|
-
case 2:
|
|
16289
|
+
return [3 /*break*/, 3];
|
|
16290
|
+
case 2:
|
|
16291
|
+
this.removeAllError();
|
|
16292
|
+
_e.label = 3;
|
|
16293
|
+
case 3: return [2 /*return*/, true];
|
|
16289
16294
|
}
|
|
16290
16295
|
});
|
|
16291
16296
|
});
|
|
16292
16297
|
};
|
|
16293
|
-
CrudFormComponent.prototype.validateModel = function (currentNode) {
|
|
16298
|
+
CrudFormComponent.prototype.validateModel = function (currentNode, setValidateForm) {
|
|
16299
|
+
if (setValidateForm === void 0) { setValidateForm = true; }
|
|
16300
|
+
var _a;
|
|
16294
16301
|
return __awaiter(this, void 0, void 0, function () {
|
|
16295
16302
|
var _e, _f, childNode, e_28_1;
|
|
16296
16303
|
var e_28, _g;
|
|
@@ -16303,6 +16310,12 @@
|
|
|
16303
16310
|
case 1:
|
|
16304
16311
|
if (!!_f.done) return [3 /*break*/, 5];
|
|
16305
16312
|
childNode = _f.value;
|
|
16313
|
+
if (!setValidateForm && ((_a = this.setting.arrFieldMustValidate) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
16314
|
+
if (!this.setting.arrFieldMustValidate.includes(childNode.field)) {
|
|
16315
|
+
this.removeAllErrorByNodes(childNode);
|
|
16316
|
+
return [3 /*break*/, 4];
|
|
16317
|
+
}
|
|
16318
|
+
}
|
|
16306
16319
|
if (!childNode.control) {
|
|
16307
16320
|
if (childNode.childNodes == null) {
|
|
16308
16321
|
return [3 /*break*/, 4];
|
|
@@ -16729,6 +16742,59 @@
|
|
|
16729
16742
|
this._removeError(field);
|
|
16730
16743
|
}
|
|
16731
16744
|
};
|
|
16745
|
+
CrudFormComponent.prototype.removeAllError = function () {
|
|
16746
|
+
var e_30, _e;
|
|
16747
|
+
try {
|
|
16748
|
+
for (var _f = __values(this._rootNode.childNodes), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
16749
|
+
var childNode = _g.value;
|
|
16750
|
+
this.removeAllErrorByNodes(childNode);
|
|
16751
|
+
}
|
|
16752
|
+
}
|
|
16753
|
+
catch (e_30_1) { e_30 = { error: e_30_1 }; }
|
|
16754
|
+
finally {
|
|
16755
|
+
try {
|
|
16756
|
+
if (_g && !_g.done && (_e = _f.return)) _e.call(_f);
|
|
16757
|
+
}
|
|
16758
|
+
finally { if (e_30) throw e_30.error; }
|
|
16759
|
+
}
|
|
16760
|
+
};
|
|
16761
|
+
CrudFormComponent.prototype.removeAllErrorByNodes = function (currentNode) {
|
|
16762
|
+
var e_31, _e, e_32, _f;
|
|
16763
|
+
var _a, _b;
|
|
16764
|
+
currentNode.parentNode.model._errors[currentNode.field] = [];
|
|
16765
|
+
if (!((_a = currentNode.childNodes) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
16766
|
+
return;
|
|
16767
|
+
}
|
|
16768
|
+
try {
|
|
16769
|
+
for (var _g = __values(currentNode.childNodes), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
16770
|
+
var childNode = _h.value;
|
|
16771
|
+
if (!((_b = childNode.childNodes) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
16772
|
+
this.removeAllErrorByNodes(childNode);
|
|
16773
|
+
continue;
|
|
16774
|
+
}
|
|
16775
|
+
try {
|
|
16776
|
+
for (var _j = (e_32 = void 0, __values(childNode.childNodes)), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
16777
|
+
var node = _k.value;
|
|
16778
|
+
this.removeAllErrorByNodes(node);
|
|
16779
|
+
}
|
|
16780
|
+
}
|
|
16781
|
+
catch (e_32_1) { e_32 = { error: e_32_1 }; }
|
|
16782
|
+
finally {
|
|
16783
|
+
try {
|
|
16784
|
+
if (_k && !_k.done && (_f = _j.return)) _f.call(_j);
|
|
16785
|
+
}
|
|
16786
|
+
finally { if (e_32) throw e_32.error; }
|
|
16787
|
+
}
|
|
16788
|
+
}
|
|
16789
|
+
}
|
|
16790
|
+
catch (e_31_1) { e_31 = { error: e_31_1 }; }
|
|
16791
|
+
finally {
|
|
16792
|
+
try {
|
|
16793
|
+
if (_h && !_h.done && (_e = _g.return)) _e.call(_g);
|
|
16794
|
+
}
|
|
16795
|
+
finally { if (e_31) throw e_31.error; }
|
|
16796
|
+
}
|
|
16797
|
+
};
|
|
16732
16798
|
CrudFormComponent.prototype.cacheControlValue = function (control, value, parentPath) {
|
|
16733
16799
|
if (control && control.enableCaching) {
|
|
16734
16800
|
this.cachedValues[parentPath + '.' + control.field] = value;
|
|
@@ -16808,7 +16874,7 @@
|
|
|
16808
16874
|
* @param options
|
|
16809
16875
|
*/
|
|
16810
16876
|
CrudFormComponent.prototype.focusFirstControl = function () {
|
|
16811
|
-
var
|
|
16877
|
+
var e_33, _e;
|
|
16812
16878
|
var formElement = this.formElement.nativeElement;
|
|
16813
16879
|
var divs = formElement.querySelectorAll('div.crud-form-control');
|
|
16814
16880
|
if (divs) {
|
|
@@ -16843,12 +16909,12 @@
|
|
|
16843
16909
|
}
|
|
16844
16910
|
}
|
|
16845
16911
|
}
|
|
16846
|
-
catch (
|
|
16912
|
+
catch (e_33_1) { e_33 = { error: e_33_1 }; }
|
|
16847
16913
|
finally {
|
|
16848
16914
|
try {
|
|
16849
16915
|
if (divs_1_1 && !divs_1_1.done && (_e = divs_1.return)) _e.call(divs_1);
|
|
16850
16916
|
}
|
|
16851
|
-
finally { if (
|
|
16917
|
+
finally { if (e_33) throw e_33.error; }
|
|
16852
16918
|
}
|
|
16853
16919
|
}
|
|
16854
16920
|
};
|
|
@@ -17012,7 +17078,7 @@
|
|
|
17012
17078
|
if (fireEventFinish === void 0) { fireEventFinish = true; }
|
|
17013
17079
|
return __awaiter(this, void 0, void 0, function () {
|
|
17014
17080
|
var tableNode, index, parentPath, data, _e, _f, subControl, toAdd, newRowNode, _b_3, _c_3, _d_1;
|
|
17015
|
-
var
|
|
17081
|
+
var e_34, _g;
|
|
17016
17082
|
return __generator(this, function (_h) {
|
|
17017
17083
|
switch (_h.label) {
|
|
17018
17084
|
case 0:
|
|
@@ -17044,12 +17110,12 @@
|
|
|
17044
17110
|
this.initControlDefaultValue(data, subControl, parentPath);
|
|
17045
17111
|
}
|
|
17046
17112
|
}
|
|
17047
|
-
catch (
|
|
17113
|
+
catch (e_34_1) { e_34 = { error: e_34_1 }; }
|
|
17048
17114
|
finally {
|
|
17049
17115
|
try {
|
|
17050
17116
|
if (_f && !_f.done && (_g = _e.return)) _g.call(_e);
|
|
17051
17117
|
}
|
|
17052
|
-
finally { if (
|
|
17118
|
+
finally { if (e_34) throw e_34.error; }
|
|
17053
17119
|
}
|
|
17054
17120
|
toAdd = true;
|
|
17055
17121
|
if (control.onAdding) {
|
|
@@ -17135,7 +17201,7 @@
|
|
|
17135
17201
|
CrudFormComponent.prototype.handleSavedTableRow = function (data) {
|
|
17136
17202
|
return __awaiter(this, void 0, void 0, function () {
|
|
17137
17203
|
var control, tablePath, eventType, tableNode, index, parentPath, _e, _f, subControl, toAdd, newRowNode, _b_4, _c_4, _d_2;
|
|
17138
|
-
var
|
|
17204
|
+
var e_35, _g;
|
|
17139
17205
|
return __generator(this, function (_h) {
|
|
17140
17206
|
switch (_h.label) {
|
|
17141
17207
|
case 0:
|
|
@@ -17157,12 +17223,12 @@
|
|
|
17157
17223
|
this.initControlModel(data, subControl, parentPath);
|
|
17158
17224
|
}
|
|
17159
17225
|
}
|
|
17160
|
-
catch (
|
|
17226
|
+
catch (e_35_1) { e_35 = { error: e_35_1 }; }
|
|
17161
17227
|
finally {
|
|
17162
17228
|
try {
|
|
17163
17229
|
if (_f && !_f.done && (_g = _e.return)) _g.call(_e);
|
|
17164
17230
|
}
|
|
17165
|
-
finally { if (
|
|
17231
|
+
finally { if (e_35) throw e_35.error; }
|
|
17166
17232
|
}
|
|
17167
17233
|
toAdd = true;
|
|
17168
17234
|
if (control.onAdding) {
|
|
@@ -17597,7 +17663,7 @@
|
|
|
17597
17663
|
}
|
|
17598
17664
|
};
|
|
17599
17665
|
ControlTreeNode.prototype.initChildNodes = function (model, schemas, keysPlus) {
|
|
17600
|
-
var
|
|
17666
|
+
var e_36, _e, e_37, _f;
|
|
17601
17667
|
if (isLiteralObject(model)) {
|
|
17602
17668
|
var allKey = new Set(__spreadArray(__spreadArray([], __read(keysPlus)), __read(Object.keys(model))));
|
|
17603
17669
|
try {
|
|
@@ -17610,12 +17676,12 @@
|
|
|
17610
17676
|
}
|
|
17611
17677
|
}
|
|
17612
17678
|
}
|
|
17613
|
-
catch (
|
|
17679
|
+
catch (e_36_1) { e_36 = { error: e_36_1 }; }
|
|
17614
17680
|
finally {
|
|
17615
17681
|
try {
|
|
17616
17682
|
if (allKey_1_1 && !allKey_1_1.done && (_e = allKey_1.return)) _e.call(allKey_1);
|
|
17617
17683
|
}
|
|
17618
|
-
finally { if (
|
|
17684
|
+
finally { if (e_36) throw e_36.error; }
|
|
17619
17685
|
}
|
|
17620
17686
|
// Sau khi đã init xong node cho row thì fire event cho các control trong row
|
|
17621
17687
|
// 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 +17713,12 @@
|
|
|
17647
17713
|
i++;
|
|
17648
17714
|
}
|
|
17649
17715
|
}
|
|
17650
|
-
catch (
|
|
17716
|
+
catch (e_37_1) { e_37 = { error: e_37_1 }; }
|
|
17651
17717
|
finally {
|
|
17652
17718
|
try {
|
|
17653
17719
|
if (model_3_1 && !model_3_1.done && (_f = model_3.return)) _f.call(model_3);
|
|
17654
17720
|
}
|
|
17655
|
-
finally { if (
|
|
17721
|
+
finally { if (e_37) throw e_37.error; }
|
|
17656
17722
|
}
|
|
17657
17723
|
}
|
|
17658
17724
|
}
|
|
@@ -17798,7 +17864,7 @@
|
|
|
17798
17864
|
return this.findSchemaInTree(this.rootNode, schemaPath.toLowerCase());
|
|
17799
17865
|
};
|
|
17800
17866
|
ControlTreeNode.prototype.findInTree = function (node, modelPath) {
|
|
17801
|
-
var
|
|
17867
|
+
var e_38, _e;
|
|
17802
17868
|
if (node.modelPath != null && node.modelPath.toLowerCase() == modelPath.toLowerCase()) {
|
|
17803
17869
|
return node;
|
|
17804
17870
|
}
|
|
@@ -17813,18 +17879,18 @@
|
|
|
17813
17879
|
}
|
|
17814
17880
|
}
|
|
17815
17881
|
}
|
|
17816
|
-
catch (
|
|
17882
|
+
catch (e_38_1) { e_38 = { error: e_38_1 }; }
|
|
17817
17883
|
finally {
|
|
17818
17884
|
try {
|
|
17819
17885
|
if (_g && !_g.done && (_e = _f.return)) _e.call(_f);
|
|
17820
17886
|
}
|
|
17821
|
-
finally { if (
|
|
17887
|
+
finally { if (e_38) throw e_38.error; }
|
|
17822
17888
|
}
|
|
17823
17889
|
}
|
|
17824
17890
|
return null;
|
|
17825
17891
|
};
|
|
17826
17892
|
ControlTreeNode.prototype.findSchemaInTree = function (node, schemaPath) {
|
|
17827
|
-
var
|
|
17893
|
+
var e_39, _e;
|
|
17828
17894
|
if (node.schemaPath != null && node.schemaPath.toLowerCase() == schemaPath.toLowerCase()) {
|
|
17829
17895
|
return node;
|
|
17830
17896
|
}
|
|
@@ -17839,12 +17905,12 @@
|
|
|
17839
17905
|
}
|
|
17840
17906
|
}
|
|
17841
17907
|
}
|
|
17842
|
-
catch (
|
|
17908
|
+
catch (e_39_1) { e_39 = { error: e_39_1 }; }
|
|
17843
17909
|
finally {
|
|
17844
17910
|
try {
|
|
17845
17911
|
if (_g && !_g.done && (_e = _f.return)) _e.call(_f);
|
|
17846
17912
|
}
|
|
17847
|
-
finally { if (
|
|
17913
|
+
finally { if (e_39) throw e_39.error; }
|
|
17848
17914
|
}
|
|
17849
17915
|
}
|
|
17850
17916
|
return null;
|