@senior-gestao-pessoas/hcm-advanced-filter-general 1.2.0 → 2.0.1

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.
Files changed (39) hide show
  1. package/bundles/senior-gestao-pessoas-hcm-advanced-filter-general.umd.js +122 -37
  2. package/bundles/senior-gestao-pessoas-hcm-advanced-filter-general.umd.js.map +1 -1
  3. package/bundles/senior-gestao-pessoas-hcm-advanced-filter-general.umd.min.js +1 -1
  4. package/bundles/senior-gestao-pessoas-hcm-advanced-filter-general.umd.min.js.map +1 -1
  5. package/core/enums/filter-type.d.ts +4 -0
  6. package/esm2015/core/enums/filter-type.js +6 -0
  7. package/esm2015/lib/filter-container/filter-container.component.js +153 -0
  8. package/esm2015/lib/filter-container/filter-container.module.js +42 -0
  9. package/esm2015/lib/filter-container/filter-container.service.js +52 -0
  10. package/esm2015/lib/filter-container/index.js +9 -0
  11. package/esm2015/public-api.js +2 -2
  12. package/esm2015/senior-gestao-pessoas-hcm-advanced-filter-general.js +3 -2
  13. package/esm5/core/enums/filter-type.js +6 -0
  14. package/esm5/lib/filter-container/filter-container.component.js +173 -0
  15. package/esm5/lib/filter-container/filter-container.module.js +45 -0
  16. package/esm5/lib/filter-container/filter-container.service.js +53 -0
  17. package/esm5/lib/filter-container/index.js +9 -0
  18. package/esm5/public-api.js +2 -2
  19. package/esm5/senior-gestao-pessoas-hcm-advanced-filter-general.js +3 -2
  20. package/fesm2015/senior-gestao-pessoas-hcm-advanced-filter-general.js +102 -24
  21. package/fesm2015/senior-gestao-pessoas-hcm-advanced-filter-general.js.map +1 -1
  22. package/fesm5/senior-gestao-pessoas-hcm-advanced-filter-general.js +119 -36
  23. package/fesm5/senior-gestao-pessoas-hcm-advanced-filter-general.js.map +1 -1
  24. package/lib/{process-filter/process-filter.component.d.ts → filter-container/filter-container.component.d.ts} +11 -3
  25. package/lib/filter-container/filter-container.module.d.ts +2 -0
  26. package/lib/filter-container/filter-container.service.d.ts +22 -0
  27. package/lib/filter-container/index.d.ts +8 -0
  28. package/package.json +2 -47
  29. package/public-api.d.ts +1 -1
  30. package/senior-gestao-pessoas-hcm-advanced-filter-general.d.ts +2 -1
  31. package/senior-gestao-pessoas-hcm-advanced-filter-general.metadata.json +1 -1
  32. package/esm2015/lib/process-filter/index.js +0 -9
  33. package/esm2015/lib/process-filter/process-filter.component.js +0 -119
  34. package/esm2015/lib/process-filter/process-filter.module.js +0 -40
  35. package/esm5/lib/process-filter/index.js +0 -9
  36. package/esm5/lib/process-filter/process-filter.component.js +0 -135
  37. package/esm5/lib/process-filter/process-filter.module.js +0 -43
  38. package/lib/process-filter/index.d.ts +0 -8
  39. package/lib/process-filter/process-filter.module.d.ts +0 -2
@@ -1927,8 +1927,8 @@
1927
1927
  ProcessFilterType["ADVANCED_FILTER"] = "ADVANCED_FILTER";
1928
1928
  })(exports.ProcessFilterType || (exports.ProcessFilterType = {}));
1929
1929
 
1930
- var ProcessFilterComponent = /** @class */ (function () {
1931
- function ProcessFilterComponent(translate, filtersStorageService) {
1930
+ var FilterContainerComponent = /** @class */ (function () {
1931
+ function FilterContainerComponent(translate, filtersStorageService) {
1932
1932
  this.translate = translate;
1933
1933
  this.filtersStorageService = filtersStorageService;
1934
1934
  this.advancedFilterIsPresentInCache = false;
@@ -1942,12 +1942,32 @@
1942
1942
  value: exports.ProcessFilterType.ADVANCED_FILTER
1943
1943
  }
1944
1944
  ];
1945
+ this.searchTokensSubject = new rxjs.Subject();
1946
+ this.tokens = [];
1947
+ this.KEY_STORAGE = "AdvancedFilterComponent";
1945
1948
  this.filterTypeChanged = new core.EventEmitter();
1946
1949
  }
1947
- ProcessFilterComponent.prototype.ngOnInit = function () {
1950
+ Object.defineProperty(FilterContainerComponent.prototype, "searchTokens", {
1951
+ set: function (tokens) {
1952
+ if (tokens) {
1953
+ this.tokens = tokens;
1954
+ this.searchTokensSubject.next(tokens);
1955
+ }
1956
+ },
1957
+ enumerable: true,
1958
+ configurable: true
1959
+ });
1960
+ FilterContainerComponent.prototype.ngOnInit = function () {
1961
+ var _this = this;
1962
+ this.searchTokensSubject.subscribe(function (tokens) {
1963
+ if (tokens.length > 0) {
1964
+ _this.setSelectedFilter(tokens);
1965
+ _this.toggleFilterControls();
1966
+ }
1967
+ });
1948
1968
  this.storeFilter();
1949
1969
  };
1950
- Object.defineProperty(ProcessFilterComponent.prototype, "selectedFilterType", {
1970
+ Object.defineProperty(FilterContainerComponent.prototype, "selectedFilterType", {
1951
1971
  get: function () {
1952
1972
  var _a;
1953
1973
  if (!((_a = this.selectButton) === null || _a === void 0 ? void 0 : _a.value)) {
@@ -1958,10 +1978,10 @@
1958
1978
  enumerable: true,
1959
1979
  configurable: true
1960
1980
  });
1961
- ProcessFilterComponent.prototype.onSwitchSelectButton = function () {
1981
+ FilterContainerComponent.prototype.onSwitchSelectButton = function () {
1962
1982
  this.toggleFilterControls();
1963
1983
  };
1964
- ProcessFilterComponent.prototype.onEventAdvancedFilter = function ($event) {
1984
+ FilterContainerComponent.prototype.onEventAdvancedFilter = function ($event) {
1965
1985
  var _this = this;
1966
1986
  var _a, _b, _c;
1967
1987
  this.advancedFilterData = {
@@ -1972,22 +1992,24 @@
1972
1992
  var advancedFilterControls = this.filterControls.ADVANCED_FILTER;
1973
1993
  advancedFilterControls.forEach(function (control) { return _this.formGroup.get(control).setValue(data); });
1974
1994
  };
1975
- ProcessFilterComponent.prototype.setSelectedFilter = function () {
1976
- var _this = this;
1977
- var _a;
1978
- if (!((_a = this.selectButton) === null || _a === void 0 ? void 0 : _a.value)) {
1979
- this.selectedFilter = this.advancedFilterIsPresentInCache ? this.filterOptions[1] : this.filterOptions[0];
1995
+ FilterContainerComponent.prototype.setSelectedFilter = function (tokens) {
1996
+ var _a, _b;
1997
+ var basicFilterControls = ((_a = this.filterControls) === null || _a === void 0 ? void 0 : _a.BASIC_FILTER) || [];
1998
+ var basicTokenEnabled = (tokens === null || tokens === void 0 ? void 0 : tokens.some(function (token) { return basicFilterControls.includes(token === null || token === void 0 ? void 0 : token.id); })) || false;
1999
+ if (!((_b = this.selectButton) === null || _b === void 0 ? void 0 : _b.value)) {
2000
+ var filterType = this.determineFilterType(basicTokenEnabled);
2001
+ this.selectedFilter = this.getFilterOption(filterType);
1980
2002
  }
1981
2003
  else {
1982
- this.selectedFilter = this.filterOptions.find(function (option) { return option.value === _this.selectButton.value.value; });
2004
+ this.selectedFilter = this.getFilterOption(this.selectButton.value.value);
1983
2005
  }
1984
2006
  };
1985
- ProcessFilterComponent.prototype.storeFilter = function () {
2007
+ FilterContainerComponent.prototype.storeFilter = function () {
1986
2008
  return __awaiter(this, void 0, void 0, function () {
1987
2009
  var advancedFilter;
1988
2010
  return __generator(this, function (_a) {
1989
2011
  switch (_a.label) {
1990
- case 0: return [4 /*yield*/, this.filtersStorageService.getFilters("AdvancedFilterComponent")];
2012
+ case 0: return [4 /*yield*/, this.filtersStorageService.getFilters(this.KEY_STORAGE)];
1991
2013
  case 1:
1992
2014
  advancedFilter = _a.sent();
1993
2015
  if (Object.keys(advancedFilter).length > 0) {
@@ -2000,7 +2022,7 @@
2000
2022
  });
2001
2023
  });
2002
2024
  };
2003
- ProcessFilterComponent.prototype.toggleFilterControls = function () {
2025
+ FilterContainerComponent.prototype.toggleFilterControls = function () {
2004
2026
  var basicFilterControls = this.filterControls.BASIC_FILTER;
2005
2027
  var advancedFilterControls = this.filterControls.ADVANCED_FILTER;
2006
2028
  if (this.selectedFilterType === exports.ProcessFilterType.ADVANCED_FILTER) {
@@ -2013,7 +2035,7 @@
2013
2035
  }
2014
2036
  this.filterTypeChanged.emit(this.selectedFilterType);
2015
2037
  };
2016
- ProcessFilterComponent.prototype.toggleControls = function (controls, enable, validators) {
2038
+ FilterContainerComponent.prototype.toggleControls = function (controls, enable, validators) {
2017
2039
  var _this = this;
2018
2040
  controls.forEach(function (controlName) {
2019
2041
  var control = _this.formGroup.get(controlName);
@@ -2029,36 +2051,96 @@
2029
2051
  control.updateValueAndValidity();
2030
2052
  });
2031
2053
  };
2032
- ProcessFilterComponent.ctorParameters = function () { return [
2054
+ FilterContainerComponent.prototype.getFilterOption = function (filterType) {
2055
+ return this.filterOptions.find(function (option) { return option.value === filterType; }) || this.filterOptions[0];
2056
+ };
2057
+ FilterContainerComponent.prototype.determineFilterType = function (basicTokenEnabled) {
2058
+ if (!basicTokenEnabled && this.advancedFilterIsPresentInCache) {
2059
+ return exports.ProcessFilterType.ADVANCED_FILTER;
2060
+ }
2061
+ return exports.ProcessFilterType.BASIC_FILTER;
2062
+ };
2063
+ FilterContainerComponent.ctorParameters = function () { return [
2033
2064
  { type: core$1.TranslateService },
2034
2065
  { type: FiltersStorageService }
2035
2066
  ]; };
2036
2067
  __decorate([
2037
2068
  core.ViewChild("selectButton")
2038
- ], ProcessFilterComponent.prototype, "selectButton", void 0);
2069
+ ], FilterContainerComponent.prototype, "selectButton", void 0);
2039
2070
  __decorate([
2040
2071
  core.Output()
2041
- ], ProcessFilterComponent.prototype, "filterTypeChanged", void 0);
2072
+ ], FilterContainerComponent.prototype, "filterTypeChanged", void 0);
2042
2073
  __decorate([
2043
2074
  core.Input()
2044
- ], ProcessFilterComponent.prototype, "formGroup", void 0);
2075
+ ], FilterContainerComponent.prototype, "filterType", void 0);
2045
2076
  __decorate([
2046
2077
  core.Input()
2047
- ], ProcessFilterComponent.prototype, "filterControls", void 0);
2048
- ProcessFilterComponent = __decorate([
2078
+ ], FilterContainerComponent.prototype, "formGroup", void 0);
2079
+ __decorate([
2080
+ core.Input()
2081
+ ], FilterContainerComponent.prototype, "filterControls", void 0);
2082
+ __decorate([
2083
+ core.Input()
2084
+ ], FilterContainerComponent.prototype, "searchTokens", null);
2085
+ FilterContainerComponent = __decorate([
2049
2086
  core.Component({
2050
- selector: "fnd-process-filter",
2051
- template: "<div class=\"ui-fluid\">\n <div class=\"ui-g\">\n <div class=\"ui-g-3 ui-sm-12 select-button-container\">\n <div class=\"select-button-child\">\n <p-selectButton #selectButton id=\"select-button\" [options]=\"filterOptions\" optionLabel=\"label\"\n [(ngModel)]=\"selectedFilter\" optionValue=\"value\" (onOptionClick)=\"onSwitchSelectButton()\">\n </p-selectButton>\n </div>\n </div>\n <div class=\"ui-g-12 ui-md-12 required\" [ngSwitch]=\"selectedFilterType\">\n <div *ngSwitchCase=\"'BASIC_FILTER'\">\n <ng-content></ng-content>\n </div>\n <div *ngSwitchCase=\"'ADVANCED_FILTER'\">\n <div class=\"ui-g-12 ui-md-6 required\">\n <fnd-advanced-filter (advancedFilterEvent)=\"onEventAdvancedFilter($event)\"></fnd-advanced-filter>\n </div>\n </div>\n </div>\n </div>\n</div>\n",
2052
- styles: ["::ng-deep .ui-selectbutton.ui-buttonset .ui-button.ui-state-active{background:#428bca!important;color:#fff!important}@media (min-width:640px) and (max-width:1130px){.select-button-container{width:50%}}"]
2087
+ selector: "fnd-filter-container",
2088
+ template: "<div class=\"ui-fluid\">\n <div class=\"ui-g\">\n <div class=\"ui-g-3 ui-sm-12 select-button-container\" [ngClass]=\"{'list-container': filterType === 'LIST'}\">\n <div class=\"select-button-child\">\n <p-selectButton #selectButton id=\"select-button\" [options]=\"filterOptions\" optionLabel=\"label\"\n [(ngModel)]=\"selectedFilter\" optionValue=\"value\" (onOptionClick)=\"onSwitchSelectButton()\">\n </p-selectButton>\n </div>\n </div>\n <div class=\"ui-g-12 ui-md-12 required\" [ngSwitch]=\"selectedFilterType\">\n <div *ngSwitchCase=\"'BASIC_FILTER'\">\n <ng-content></ng-content>\n </div>\n <div *ngSwitchCase=\"'ADVANCED_FILTER'\">\n <div class=\"ui-g-12 ui-md-6 required\">\n <fnd-advanced-filter (advancedFilterEvent)=\"onEventAdvancedFilter($event)\"></fnd-advanced-filter>\n </div>\n </div>\n </div>\n </div>\n</div>\n",
2089
+ styles: ["::ng-deep .ui-selectbutton.ui-buttonset .ui-button.ui-state-active{background:#428bca!important;color:#fff!important}@media (min-width:640px) and (max-width:1130px){.select-button-container{width:50%}}.list-container{margin-top:.5%}"]
2053
2090
  })
2054
- ], ProcessFilterComponent);
2055
- return ProcessFilterComponent;
2091
+ ], FilterContainerComponent);
2092
+ return FilterContainerComponent;
2056
2093
  }());
2057
2094
 
2058
- var ProcessFilterModule = /** @class */ (function () {
2059
- function ProcessFilterModule() {
2095
+ var FilterContainerService = /** @class */ (function () {
2096
+ function FilterContainerService(http, messageService, translate, advancedFilterService) {
2097
+ this.http = http;
2098
+ this.messageService = messageService;
2099
+ this.translate = translate;
2100
+ this.advancedFilterService = advancedFilterService;
2101
+ this.clearAdvancedFilterSubject = new rxjs.Subject();
2102
+ }
2103
+ FilterContainerService.prototype.buildAdvancedFilter = function (advancedFilter, filterQuery) {
2104
+ var tokens = [];
2105
+ var tokenName = "advancedFilter";
2106
+ tokens.push({
2107
+ id: tokenName,
2108
+ label: this.translate.instant("hcm_contract.employment_contract.advanced_filter_advanced_filter_label") + ": " + advancedFilter.name
2109
+ });
2110
+ var advancedFilterQuery = tokenName + " eq '" + advancedFilter.id + "'";
2111
+ var updatedFilterQuery = filterQuery ? filterQuery + " and " + advancedFilterQuery : advancedFilterQuery;
2112
+ return {
2113
+ tokens: tokens,
2114
+ updatedFilterQuery: updatedFilterQuery
2115
+ };
2116
+ };
2117
+ FilterContainerService.prototype.setStorageAdvancedFilterIntoForm = function (form, advancedFilter, basicFilterControls) {
2118
+ if (!(Object.keys(advancedFilter).length === 0)) {
2119
+ form.get("advancedFilter").setValue(advancedFilter);
2120
+ basicFilterControls.forEach(function (control) {
2121
+ form.get(control).setValue(undefined);
2122
+ });
2123
+ }
2124
+ };
2125
+ FilterContainerService.prototype.clearAdvancedFilter = function () {
2126
+ this.advancedFilterService.setClearAdvancedFilter(true);
2127
+ };
2128
+ FilterContainerService.ctorParameters = function () { return [
2129
+ { type: http.HttpClient },
2130
+ { type: api.MessageService },
2131
+ { type: core$1.TranslateService },
2132
+ { type: AdvancedFilterService }
2133
+ ]; };
2134
+ FilterContainerService = __decorate([
2135
+ core.Injectable()
2136
+ ], FilterContainerService);
2137
+ return FilterContainerService;
2138
+ }());
2139
+
2140
+ var FilterContainerModule = /** @class */ (function () {
2141
+ function FilterContainerModule() {
2060
2142
  }
2061
- ProcessFilterModule = __decorate([
2143
+ FilterContainerModule = __decorate([
2062
2144
  core.NgModule({
2063
2145
  imports: [
2064
2146
  angularComponents.LocaleModule.forChild(),
@@ -2076,27 +2158,30 @@
2076
2158
  })
2077
2159
  ],
2078
2160
  providers: [
2079
- FiltersStorageService
2161
+ FiltersStorageService,
2162
+ FilterContainerService
2080
2163
  ],
2081
- declarations: [ProcessFilterComponent],
2082
- exports: [ProcessFilterComponent]
2164
+ declarations: [FilterContainerComponent],
2165
+ exports: [FilterContainerComponent]
2083
2166
  })
2084
- ], ProcessFilterModule);
2085
- return ProcessFilterModule;
2167
+ ], FilterContainerModule);
2168
+ return FilterContainerModule;
2086
2169
  }());
2087
2170
 
2088
2171
  exports.AdvancedFilterDtoConverter = AdvancedFilterDtoConverter;
2089
2172
  exports.AdvancedFilterFieldsModule = AdvancedFilterFieldsModule;
2090
2173
  exports.AdvancedFilterModule = AdvancedFilterModule;
2091
2174
  exports.AdvancedFilterService = AdvancedFilterService;
2092
- exports.ProcessFilterComponent = ProcessFilterComponent;
2093
- exports.ProcessFilterModule = ProcessFilterModule;
2175
+ exports.FilterContainerModule = FilterContainerModule;
2176
+ exports.FilterContainerService = FilterContainerService;
2094
2177
  exports.ɵa = AdvancedFilterFieldsComponent;
2095
2178
  exports.ɵb = AdvancedFilterComponent;
2096
2179
  exports.ɵc = EntityService;
2097
2180
  exports.ɵd = FiltersStorageService;
2098
2181
  exports.ɵe = StorageService;
2099
2182
  exports.ɵf = AdvancedFilterModule;
2183
+ exports.ɵg = AdvancedFilterService;
2184
+ exports.ɵh = FilterContainerComponent;
2100
2185
 
2101
2186
  Object.defineProperty(exports, '__esModule', { value: true });
2102
2187