@senior-gestao-pessoas/hcm-advanced-filter-general 2.0.2 → 2.0.3

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.
@@ -2028,7 +2028,7 @@
2028
2028
  case 0: return [4 /*yield*/, this.filtersStorageService.getFilters(this.KEY_STORAGE)];
2029
2029
  case 1:
2030
2030
  advancedFilter = _a.sent();
2031
- if (Object.keys(advancedFilter).length > 0) {
2031
+ if (this.isAdvancedFilterPresent(advancedFilter)) {
2032
2032
  this.advancedFilterIsPresentInCache = true;
2033
2033
  }
2034
2034
  this.setSelectedFilter();
@@ -2039,17 +2039,30 @@
2039
2039
  });
2040
2040
  };
2041
2041
  FilterContainerComponent.prototype.toggleFilterControls = function () {
2042
- var basicFilterControls = this.filterControls.BASIC_FILTER;
2043
- var advancedFilterControls = this.filterControls.ADVANCED_FILTER;
2044
- if (this.selectedFilterType === exports.ProcessFilterType.ADVANCED_FILTER) {
2045
- this.toggleControls(basicFilterControls, false);
2046
- this.toggleControls(advancedFilterControls, true, [forms.Validators.required]);
2047
- }
2048
- else {
2049
- this.toggleControls(basicFilterControls, true);
2050
- this.toggleControls(advancedFilterControls, false);
2051
- }
2052
- this.filterTypeChanged.emit(this.selectedFilterType);
2042
+ return __awaiter(this, void 0, void 0, function () {
2043
+ var basicFilterControls, advancedFilterControls;
2044
+ return __generator(this, function (_a) {
2045
+ switch (_a.label) {
2046
+ case 0:
2047
+ basicFilterControls = this.filterControls.BASIC_FILTER;
2048
+ advancedFilterControls = this.filterControls.ADVANCED_FILTER;
2049
+ if (!(this.selectedFilterType === exports.ProcessFilterType.ADVANCED_FILTER)) return [3 /*break*/, 2];
2050
+ return [4 /*yield*/, this.clearAdvancedFilterControls(advancedFilterControls)];
2051
+ case 1:
2052
+ _a.sent();
2053
+ this.toggleControls(basicFilterControls, false);
2054
+ this.toggleControls(advancedFilterControls, true, [forms.Validators.required]);
2055
+ return [3 /*break*/, 3];
2056
+ case 2:
2057
+ this.toggleControls(basicFilterControls, true);
2058
+ this.toggleControls(advancedFilterControls, false);
2059
+ _a.label = 3;
2060
+ case 3:
2061
+ this.filterTypeChanged.emit(this.selectedFilterType);
2062
+ return [2 /*return*/];
2063
+ }
2064
+ });
2065
+ });
2053
2066
  };
2054
2067
  FilterContainerComponent.prototype.toggleControls = function (controls, enable, validators) {
2055
2068
  var _this = this;
@@ -2085,6 +2098,26 @@
2085
2098
  }
2086
2099
  return exports.ProcessFilterType.BASIC_FILTER;
2087
2100
  };
2101
+ FilterContainerComponent.prototype.clearAdvancedFilterControls = function (advancedFilterControls) {
2102
+ return __awaiter(this, void 0, void 0, function () {
2103
+ var advancedFilter;
2104
+ var _this = this;
2105
+ return __generator(this, function (_a) {
2106
+ switch (_a.label) {
2107
+ case 0: return [4 /*yield*/, this.filtersStorageService.getFilters(this.KEY_STORAGE)];
2108
+ case 1:
2109
+ advancedFilter = _a.sent();
2110
+ if (!this.isAdvancedFilterPresent(advancedFilter)) {
2111
+ advancedFilterControls.forEach(function (control) { return _this.formGroup.get(control).setValue(undefined); });
2112
+ }
2113
+ return [2 /*return*/];
2114
+ }
2115
+ });
2116
+ });
2117
+ };
2118
+ FilterContainerComponent.prototype.isAdvancedFilterPresent = function (advancedFilter) {
2119
+ return Object.keys(advancedFilter).length > 0;
2120
+ };
2088
2121
  FilterContainerComponent.ctorParameters = function () { return [
2089
2122
  { type: core$1.TranslateService },
2090
2123
  { type: FiltersStorageService }