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.
@@ -845,6 +845,7 @@ class CrudFormSetting {
845
845
  this.hiddenKySoSimCaNhan = false;
846
846
  this.hiddenKySoUsbCaNhan = false;
847
847
  this.hiddenKySoDonVi = false;
848
+ this.arrFieldMustValidate = [];
848
849
  this.getCustomDataTrinhKy = (rowData) => ({});
849
850
  for (const key in init) {
850
851
  this[key] = init[key];
@@ -13657,10 +13658,11 @@ class CrudFormComponent extends ComponentBase {
13657
13658
  return 'string';
13658
13659
  }
13659
13660
  validateForm(setValidateForm = true) {
13661
+ var _a;
13660
13662
  return __awaiter(this, void 0, void 0, function* () {
13661
- if (setValidateForm) {
13663
+ if (setValidateForm || ((_a = this.setting.arrFieldMustValidate) === null || _a === void 0 ? void 0 : _a.length)) {
13662
13664
  this._inValidForm = false;
13663
- yield this.validateModel(this._rootNode);
13665
+ yield this.validateModel(this._rootNode, setValidateForm);
13664
13666
  if (this._inValidForm) {
13665
13667
  setTimeout(() => {
13666
13668
  this.focusToFirstErrorControl();
@@ -13668,12 +13670,22 @@ class CrudFormComponent extends ComponentBase {
13668
13670
  return false;
13669
13671
  }
13670
13672
  }
13673
+ else {
13674
+ this.removeAllError();
13675
+ }
13671
13676
  return true;
13672
13677
  });
13673
13678
  }
13674
- validateModel(currentNode) {
13679
+ validateModel(currentNode, setValidateForm = true) {
13680
+ var _a;
13675
13681
  return __awaiter(this, void 0, void 0, function* () {
13676
13682
  for (const childNode of currentNode.childNodes) {
13683
+ if (!setValidateForm && ((_a = this.setting.arrFieldMustValidate) === null || _a === void 0 ? void 0 : _a.length)) {
13684
+ if (!this.setting.arrFieldMustValidate.includes(childNode.field)) {
13685
+ this.removeAllErrorByNodes(childNode);
13686
+ continue;
13687
+ }
13688
+ }
13677
13689
  if (!childNode.control) {
13678
13690
  if (childNode.childNodes == null) {
13679
13691
  continue;
@@ -13990,6 +14002,27 @@ class CrudFormComponent extends ComponentBase {
13990
14002
  this._removeError(field);
13991
14003
  }
13992
14004
  }
14005
+ removeAllError() {
14006
+ for (const childNode of this._rootNode.childNodes) {
14007
+ this.removeAllErrorByNodes(childNode);
14008
+ }
14009
+ }
14010
+ removeAllErrorByNodes(currentNode) {
14011
+ var _a, _b;
14012
+ currentNode.parentNode.model._errors[currentNode.field] = [];
14013
+ if (!((_a = currentNode.childNodes) === null || _a === void 0 ? void 0 : _a.length)) {
14014
+ return;
14015
+ }
14016
+ for (const childNode of currentNode.childNodes) {
14017
+ if (!((_b = childNode.childNodes) === null || _b === void 0 ? void 0 : _b.length)) {
14018
+ this.removeAllErrorByNodes(childNode);
14019
+ continue;
14020
+ }
14021
+ for (const node of childNode.childNodes) {
14022
+ this.removeAllErrorByNodes(node);
14023
+ }
14024
+ }
14025
+ }
13993
14026
  cacheControlValue(control, value, parentPath) {
13994
14027
  if (control && control.enableCaching) {
13995
14028
  this.cachedValues[parentPath + '.' + control.field] = value;