@senior-gestao-pessoas/payroll-core 9.8.0 → 9.9.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.
@@ -2659,62 +2659,96 @@ let InputRestAutoCompleteComponent = class InputRestAutoCompleteComponent {
2659
2659
  ngOnInit() { }
2660
2660
  filterQuery(event) {
2661
2661
  const query = event.query;
2662
- if (!(isNaN(query) && query.toString().length < this.minCharactersToSearch)) {
2662
+ if (!(Number.isNaN(query) && query.toString().length < this.minCharactersToSearch)) {
2663
2663
  try {
2664
- if (this.isTimetrackingSituation) {
2665
- return this.service
2666
- .query('autocompleteTimetrackingSituation', {
2667
- valueSearch: query,
2668
- referenceDate: this.referenceDate,
2669
- })
2670
- .subscribe(payload => this.formaterResponce(payload.result));
2671
- }
2672
- else if (this.isDismissalReason) {
2673
- const params = { valueSearch: query };
2674
- if (this.referenceDate) {
2675
- params['referenceDate'] = this.referenceDate;
2676
- }
2677
- return this.service
2678
- .query('autocompleteDismissalReason', params, ServiceType.GENERAL_REGISTER)
2679
- .subscribe(payload => this.formaterResponce(payload.result));
2680
- }
2681
- else if (this.usingType && this.usingType.length) {
2682
- return this.service
2683
- .query('autocompleteOtherCompanyFilterUsingType', {
2684
- searchText: query,
2685
- usingType: this.usingType,
2686
- })
2687
- .subscribe(payload => this.formaterResponce(payload.result));
2688
- }
2689
- else if (this.isDepartmentFromCompany) {
2690
- return this.service
2691
- .query('autocompleteDepartmentQuery', {
2692
- searchText: query,
2693
- companyId: this.companyId,
2694
- referenceDate: this.referenceDate,
2695
- })
2696
- .subscribe(payload => this.formaterResponce(payload.result));
2697
- }
2698
- else if (this.isSituationDefinition) {
2699
- const params = { searchText: query };
2700
- return this.service
2701
- .query('autocompleteSituationDefinitionQuery', params, ServiceType.ORGANIZATION_REGISTER)
2702
- .subscribe(payload => this.formaterResponce(payload.result));
2703
- }
2704
- else if (this.isWagetype) {
2705
- const params = { searchText: query, companyId: this.companyId };
2706
- return this.service
2707
- .query('autocompleteWagetypeQuery', params, ServiceType.ENTRY)
2708
- .subscribe(payload => this.formaterResponce(payload.result));
2709
- }
2710
- this.service
2711
- .query('autocomplete', this.getParamsRest(query), this.serviceType).subscribe(payload => this.formaterResponce(payload.result));
2664
+ const queryConfig = this.getQueryConfiguration(query);
2665
+ return this.service
2666
+ .query(queryConfig.endpoint, queryConfig.params, queryConfig.serviceType)
2667
+ .subscribe(payload => this.formaterResponce(payload.result));
2712
2668
  }
2713
2669
  catch (e) {
2714
2670
  console.log(e);
2715
2671
  }
2716
2672
  }
2717
2673
  }
2674
+ getQueryConfiguration(query) {
2675
+ const queryStrategies = [
2676
+ {
2677
+ condition: () => this.isTimetrackingSituation,
2678
+ endpoint: 'autocompleteTimetrackingSituation',
2679
+ params: () => ({
2680
+ valueSearch: query,
2681
+ referenceDate: this.referenceDate,
2682
+ }),
2683
+ serviceType: this.serviceType,
2684
+ },
2685
+ {
2686
+ condition: () => this.isDismissalReason,
2687
+ endpoint: 'autocompleteDismissalReason',
2688
+ params: () => {
2689
+ const params = { valueSearch: query };
2690
+ if (this.referenceDate) {
2691
+ params['referenceDate'] = this.referenceDate;
2692
+ }
2693
+ return params;
2694
+ },
2695
+ serviceType: ServiceType.GENERAL_REGISTER,
2696
+ },
2697
+ {
2698
+ condition: () => this.usingType && this.usingType.length,
2699
+ endpoint: 'autocompleteOtherCompanyFilterUsingType',
2700
+ params: () => ({
2701
+ searchText: query,
2702
+ usingType: this.usingType,
2703
+ }),
2704
+ serviceType: this.serviceType,
2705
+ },
2706
+ {
2707
+ condition: () => this.isDepartmentFromCompany,
2708
+ endpoint: 'autocompleteDepartmentQuery',
2709
+ params: () => ({
2710
+ searchText: query,
2711
+ companyId: this.companyId,
2712
+ referenceDate: this.referenceDate,
2713
+ }),
2714
+ serviceType: this.serviceType,
2715
+ },
2716
+ {
2717
+ condition: () => this.isSituationDefinition,
2718
+ endpoint: 'autocompleteSituationDefinitionQuery',
2719
+ params: () => ({ searchText: query }),
2720
+ serviceType: ServiceType.ORGANIZATION_REGISTER,
2721
+ },
2722
+ {
2723
+ condition: () => this.isWagetype,
2724
+ endpoint: 'autocompleteWagetypeQuery',
2725
+ params: () => ({
2726
+ searchText: query,
2727
+ companyId: this.companyId,
2728
+ }),
2729
+ serviceType: ServiceType.ENTRY,
2730
+ },
2731
+ {
2732
+ condition: () => this.isTransportationVoucherScaleGroup,
2733
+ endpoint: 'autocompleteTransportationVoucherScaleGroupQuery',
2734
+ params: () => ({ searchText: query }),
2735
+ serviceType: ServiceType.GENERAL_REGISTER,
2736
+ },
2737
+ ];
2738
+ const strategy = queryStrategies.find(s => s.condition());
2739
+ if (strategy) {
2740
+ return {
2741
+ endpoint: strategy.endpoint,
2742
+ params: strategy.params(),
2743
+ serviceType: strategy.serviceType,
2744
+ };
2745
+ }
2746
+ return {
2747
+ endpoint: 'autocomplete',
2748
+ params: this.getParamsRest(query),
2749
+ serviceType: this.serviceType,
2750
+ };
2751
+ }
2718
2752
  formaterResponce(result) {
2719
2753
  this.suggestions = [];
2720
2754
  const valsResult = [];
@@ -2927,6 +2961,9 @@ __decorate([
2927
2961
  __decorate([
2928
2962
  Input()
2929
2963
  ], InputRestAutoCompleteComponent.prototype, "multiple", void 0);
2964
+ __decorate([
2965
+ Input()
2966
+ ], InputRestAutoCompleteComponent.prototype, "isTransportationVoucherScaleGroup", void 0);
2930
2967
  __decorate([
2931
2968
  Input()
2932
2969
  ], InputRestAutoCompleteComponent.prototype, "serviceType", void 0);