@senior-gestao-pessoas/hcm-advanced-filter-general 4.1.2 → 4.2.0

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 (22) hide show
  1. package/bundles/senior-gestao-pessoas-hcm-advanced-filter-general.umd.js +86 -25
  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/esm2015/lib/advanced-filter/advanced-filter.component.js +36 -20
  6. package/esm2015/lib/advanced-filter-fields/advanced-filter-fields.component.js +9 -5
  7. package/esm2015/lib/filter-container/filter-container.component.js +6 -1
  8. package/esm2015/shared/storage/storage.service.js +7 -1
  9. package/esm5/lib/advanced-filter/advanced-filter.component.js +63 -22
  10. package/esm5/lib/advanced-filter-fields/advanced-filter-fields.component.js +9 -5
  11. package/esm5/lib/filter-container/filter-container.component.js +6 -1
  12. package/esm5/shared/storage/storage.service.js +12 -1
  13. package/fesm2015/senior-gestao-pessoas-hcm-advanced-filter-general.js +54 -23
  14. package/fesm2015/senior-gestao-pessoas-hcm-advanced-filter-general.js.map +1 -1
  15. package/fesm5/senior-gestao-pessoas-hcm-advanced-filter-general.js +86 -25
  16. package/fesm5/senior-gestao-pessoas-hcm-advanced-filter-general.js.map +1 -1
  17. package/lib/advanced-filter/advanced-filter.component.d.ts +3 -2
  18. package/lib/advanced-filter-fields/advanced-filter-fields.component.d.ts +1 -0
  19. package/lib/filter-container/filter-container.component.d.ts +1 -0
  20. package/package.json +1 -1
  21. package/senior-gestao-pessoas-hcm-advanced-filter-general.metadata.json +1 -1
  22. package/shared/storage/storage.service.d.ts +2 -0
@@ -727,10 +727,8 @@
727
727
  return currentEntity !== nextEntity;
728
728
  };
729
729
  AdvancedFilterFieldsComponent.prototype.getConditionType = function (index) {
730
- var _a, _b, _c;
731
- if (((_a = this.fieldListAdvancedFilter[index]) === null || _a === void 0 ? void 0 : _a.entityName) !== FilterFieldType.SALARY_TYPE
732
- && ((_b = this.fieldListAdvancedFilter[index]) === null || _b === void 0 ? void 0 : _b.entityName) !== FilterFieldType.TIME_SHIFT_TYPE
733
- && ((_c = this.fieldListAdvancedFilter[index]) === null || _c === void 0 ? void 0 : _c.entityName) !== FilterFieldType.COST_CENTER) {
730
+ var _a;
731
+ if (this.lookupsWithOneFilterType((_a = this.fieldListAdvancedFilter[index]) === null || _a === void 0 ? void 0 : _a.entityName)) {
734
732
  return this.conditionType;
735
733
  }
736
734
  else {
@@ -740,6 +738,12 @@
740
738
  }];
741
739
  }
742
740
  };
741
+ AdvancedFilterFieldsComponent.prototype.lookupsWithOneFilterType = function (entityName) {
742
+ return entityName !== FilterFieldType.SALARY_TYPE
743
+ && entityName !== FilterFieldType.TIME_SHIFT_TYPE
744
+ && entityName !== FilterFieldType.COST_CENTER
745
+ && entityName !== FilterFieldType.EMPLOYMENT_RELATIONSHIP;
746
+ };
743
747
  AdvancedFilterFieldsComponent.prototype.changeDefaultFieldInformation = function (field, name, index, entityName) {
744
748
  field.gridClass = ["ui-g-12"];
745
749
  field.label = "";
@@ -952,7 +956,18 @@
952
956
  var StorageService = /** @class */ (function () {
953
957
  function StorageService() {
954
958
  this.GET_USER_ID = seniorPlatformData.user.getUserData().then(function (user) { return user.id; });
959
+ this.GET_USERNAME = seniorPlatformData.user.getUserData().then(function (user) { return (user === null || user === void 0 ? void 0 : user.username) + "@" + (user === null || user === void 0 ? void 0 : user.tenantDomain); });
955
960
  }
961
+ StorageService.prototype.getUser = function () {
962
+ return __awaiter(this, void 0, void 0, function () {
963
+ return __generator(this, function (_a) {
964
+ switch (_a.label) {
965
+ case 0: return [4 /*yield*/, this.GET_USERNAME];
966
+ case 1: return [2 /*return*/, _a.sent()];
967
+ }
968
+ });
969
+ });
970
+ };
956
971
  StorageService.prototype.store = function (key, value) {
957
972
  return __awaiter(this, void 0, void 0, function () {
958
973
  var _a, _b;
@@ -1585,18 +1600,30 @@
1585
1600
  });
1586
1601
  };
1587
1602
  AdvancedFilterComponent.prototype.onAdvancedFilterSearchRequest = function (event) {
1588
- var _this = this;
1589
- var first = event.first, rows = event.rows, multiSortMeta = event.multiSortMeta, filterData = event.filterData;
1590
- var page = first / rows;
1591
- var sort = multiSortMeta;
1592
- var filterQuery = createSearchRequestFilter(filterData, this.getAdvancedFilterFields());
1593
- this.advancedFilterService
1594
- .list({ page: page, sort: sort, filterQuery: filterQuery })
1595
- .pipe(operators.takeUntil(this.ngUnsubscribe))
1596
- .pipe(operators.map(function (list) { return _this.mapToComponent(list); }))
1597
- .subscribe(function (list) {
1598
- _this.advancedFilterSearchGridData = list.contents;
1599
- _this.advancedFilterSearchTotalRecords = list.totalElements;
1603
+ return __awaiter(this, void 0, void 0, function () {
1604
+ var first, rows, multiSortMeta, filterData, page, sort, filterQuery;
1605
+ var _this = this;
1606
+ return __generator(this, function (_a) {
1607
+ switch (_a.label) {
1608
+ case 0:
1609
+ first = event.first, rows = event.rows, multiSortMeta = event.multiSortMeta, filterData = event.filterData;
1610
+ page = first / rows;
1611
+ sort = multiSortMeta;
1612
+ filterQuery = createSearchRequestFilter(filterData, this.getAdvancedFilterFields());
1613
+ return [4 /*yield*/, this.buildFilterByUsername(filterQuery)];
1614
+ case 1:
1615
+ filterQuery = _a.sent();
1616
+ this.advancedFilterService
1617
+ .list({ page: page, sort: sort, filterQuery: filterQuery })
1618
+ .pipe(operators.takeUntil(this.ngUnsubscribe))
1619
+ .pipe(operators.map(function (list) { return _this.mapToComponent(list); }))
1620
+ .subscribe(function (list) {
1621
+ _this.advancedFilterSearchGridData = list.contents;
1622
+ _this.advancedFilterSearchTotalRecords = list.totalElements;
1623
+ });
1624
+ return [2 /*return*/];
1625
+ }
1626
+ });
1600
1627
  });
1601
1628
  };
1602
1629
  AdvancedFilterComponent.prototype.mapToComponent = function (list) {
@@ -1645,15 +1672,27 @@
1645
1672
  }, function () { return _this.loading = false; });
1646
1673
  };
1647
1674
  AdvancedFilterComponent.prototype.onAdvancedFilterLookupRequest = function (value) {
1648
- var _this = this;
1649
- var sort = this.advancedFilterLookupDisplayFields.map(function (field) { return ({ field: field, order: 1 }); });
1650
- var filterQuery = createLookupRequestFilter(value, this.getAdvancedFilterFields());
1651
- this.advancedFilterService
1652
- .list({ sort: sort, filterQuery: filterQuery })
1653
- .pipe(operators.takeUntil(this.ngUnsubscribe))
1654
- .pipe(operators.map(function (list) { return _this.mapToComponent(list); }))
1655
- .subscribe(function (list) {
1656
- _this.advancedFilterLookupSuggestions = list.contents;
1675
+ return __awaiter(this, void 0, void 0, function () {
1676
+ var sort, filterQuery;
1677
+ var _this = this;
1678
+ return __generator(this, function (_a) {
1679
+ switch (_a.label) {
1680
+ case 0:
1681
+ sort = this.advancedFilterLookupDisplayFields.map(function (field) { return ({ field: field, order: 1 }); });
1682
+ filterQuery = createLookupRequestFilter(value, this.getAdvancedFilterFields());
1683
+ return [4 /*yield*/, this.buildFilterByUsername(filterQuery)];
1684
+ case 1:
1685
+ filterQuery = _a.sent();
1686
+ this.advancedFilterService
1687
+ .list({ sort: sort, filterQuery: filterQuery })
1688
+ .pipe(operators.takeUntil(this.ngUnsubscribe))
1689
+ .pipe(operators.map(function (list) { return _this.mapToComponent(list); }))
1690
+ .subscribe(function (list) {
1691
+ _this.advancedFilterLookupSuggestions = list.contents;
1692
+ });
1693
+ return [2 /*return*/];
1694
+ }
1695
+ });
1657
1696
  });
1658
1697
  };
1659
1698
  AdvancedFilterComponent.prototype.getAdvancedFilterFields = function () {
@@ -1665,6 +1704,23 @@
1665
1704
  }),
1666
1705
  ];
1667
1706
  };
1707
+ AdvancedFilterComponent.prototype.buildFilterByUsername = function (filterQuery) {
1708
+ return __awaiter(this, void 0, void 0, function () {
1709
+ var user, filterString;
1710
+ return __generator(this, function (_a) {
1711
+ switch (_a.label) {
1712
+ case 0: return [4 /*yield*/, this.filtersStorageService.getUser()];
1713
+ case 1:
1714
+ user = _a.sent();
1715
+ if (user) {
1716
+ filterString = "username eq '" + user + "'";
1717
+ filterQuery = filterQuery ? filterQuery + " and (" + filterString + ")" : filterString;
1718
+ }
1719
+ return [2 /*return*/, filterQuery];
1720
+ }
1721
+ });
1722
+ });
1723
+ };
1668
1724
  AdvancedFilterComponent.prototype.validateFieldsSaveAndApply = function () {
1669
1725
  var arrFormGroup = this.formGroup.get("advancedFilterFields");
1670
1726
  var rowInvalid = false;
@@ -2378,6 +2434,7 @@
2378
2434
  this.tokens = [];
2379
2435
  this.KEY_STORAGE = "AdvancedFilterComponent";
2380
2436
  this.filterTypeChanged = new core.EventEmitter();
2437
+ this.advancedFilterEvent = new core.EventEmitter();
2381
2438
  this.loadFilterFieldsOnInit = true;
2382
2439
  this.filterOptions = [
2383
2440
  {
@@ -2439,6 +2496,7 @@
2439
2496
  var advancedFilterControls = this.filterControls.ADVANCED_FILTER;
2440
2497
  advancedFilterControls.forEach(function (control) { return _this.formGroup.get(control).setValue(data); });
2441
2498
  FormUtils.updateAndValidateControlValues(this.formGroup, false);
2499
+ this.advancedFilterEvent.emit($event);
2442
2500
  };
2443
2501
  FilterContainerComponent.prototype.setSelectedFilter = function (tokens) {
2444
2502
  var _a, _b;
@@ -2597,6 +2655,9 @@
2597
2655
  __decorate([
2598
2656
  core.Output()
2599
2657
  ], FilterContainerComponent.prototype, "filterTypeChanged", void 0);
2658
+ __decorate([
2659
+ core.Output()
2660
+ ], FilterContainerComponent.prototype, "advancedFilterEvent", void 0);
2600
2661
  __decorate([
2601
2662
  core.Input()
2602
2663
  ], FilterContainerComponent.prototype, "filterType", void 0);