@provoly/dashboard 1.4.31 → 1.4.33

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.
@@ -5054,30 +5054,33 @@ class SearchService {
5054
5054
  getItemsFilter(id, cumulative) {
5055
5055
  let params = cumulative ?? new HttpParams({ encoder: new FilterParamEncoder() });
5056
5056
  if (this.filters[id]) {
5057
- this.filters[id]
5058
- .filter((filter) => filter.value !== null && filter.value !== undefined)
5059
- .forEach((filter) => {
5060
- let valuesToAddToParams = filter.value;
5061
- // INSIDE and OUTSIDE operators uses 2 values but not sent in an array, values are separated by a coma
5062
- // wich must not be encoded (as if values were in an array)
5063
- const isMultiValued = ['INSIDE', 'OUTSIDE'].find((val) => val === filter.operator) !== undefined;
5064
- if (isMultiValued) {
5065
- valuesToAddToParams = filter.value.split(',');
5066
- }
5067
- // date filter value must be send in ISO-8601 format
5068
- if (filter.type === 'date') {
5069
- valuesToAddToParams = isMultiValued
5070
- ? valuesToAddToParams.map((value) => DateUtils.parseToIsoString(value))
5071
- : DateUtils.parseToIsoString(valuesToAddToParams);
5072
- }
5073
- const value = Array.isArray(valuesToAddToParams)
5074
- ? valuesToAddToParams.map((v) => encodeURIComponent(v.toString().split(',').join('\\,'))).join(',')
5075
- : encodeURIComponent(valuesToAddToParams.toString().replace(/,/g, '\\,'));
5076
- params = params.append('filter', `${filter.attribute},${filter.operator},${value}`);
5077
- });
5057
+ const filtersToAppendToParams = this.filters[id].filter((filter) => filter.value !== null && filter.value !== undefined);
5058
+ params = this.appendItemFilter(filtersToAppendToParams, params);
5078
5059
  }
5079
5060
  return params;
5080
5061
  }
5062
+ appendItemFilter(filters, params) {
5063
+ filters.forEach((filter) => {
5064
+ let valuesToAddToParams = filter.value;
5065
+ // INSIDE and OUTSIDE operators uses 2 values but not sent in an array, values are separated by a coma
5066
+ // wich must not be encoded (as if values were in an array)
5067
+ const isMultiValued = ['INSIDE', 'OUTSIDE'].find((val) => val === filter.operator) !== undefined;
5068
+ if (isMultiValued) {
5069
+ valuesToAddToParams = filter.value.split(',');
5070
+ }
5071
+ // date filter value must be send in ISO-8601 format
5072
+ if (filter.type === 'date') {
5073
+ valuesToAddToParams = isMultiValued
5074
+ ? valuesToAddToParams.map((value) => DateUtils.parseToIsoString(value))
5075
+ : DateUtils.parseToIsoString(valuesToAddToParams);
5076
+ }
5077
+ const value = Array.isArray(valuesToAddToParams)
5078
+ ? valuesToAddToParams.map((v) => encodeURIComponent(v.toString().split(',').join('\\,'))).join(',')
5079
+ : encodeURIComponent(valuesToAddToParams.toString().replace(/,/g, '\\,'));
5080
+ params = params.append('filter', `${filter.attribute},${filter.operator},${value}`);
5081
+ });
5082
+ return params;
5083
+ }
5081
5084
  getOrder(quickOrder) {
5082
5085
  let params = new HttpParams({ encoder: new FilterParamEncoder() });
5083
5086
  if (quickOrder) {
@@ -5128,12 +5131,16 @@ class SearchService {
5128
5131
  this.transformations.forEach((func) => (transformed = func(id, transformed)));
5129
5132
  return transformed;
5130
5133
  }
5131
- autocomplete(attributes, search = '', limit) {
5134
+ autocomplete(attributes, search = '', filters = [], limit) {
5135
+ const params = this.appendItemFilter(filters, new HttpParams({ encoder: new FilterParamEncoder() }));
5132
5136
  return this.store.select(ConfigSelectors.dataUrl).pipe(switchMap((url) => this.httpClient.post(encodeURI(`${url}/data-sources/values`), {
5133
- attributes: (attributes ?? []).map((attr) => ({ datasource: attr.datasource, attribute: attr.id })),
5137
+ attributes: (attributes ?? []).map((attr) => ({
5138
+ datasource: attr.datasource,
5139
+ attribute: attr.id
5140
+ })),
5134
5141
  value: search,
5135
5142
  limit
5136
- })));
5143
+ }, { params })));
5137
5144
  }
5138
5145
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.7", ngImport: i0, type: SearchService, deps: [{ token: i1$1.HttpClient }, { token: i1.Store }], target: i0.ɵɵFactoryTarget.Injectable }); }
5139
5146
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.7", ngImport: i0, type: SearchService, providedIn: 'root' }); }
@@ -5486,7 +5493,7 @@ class SearchEffects {
5486
5493
  next: action.next
5487
5494
  }))));
5488
5495
  this.getPossibleFilterValues$ = createEffect(() => this.actions$.pipe(ofType(SearchActions.getPossibleFilterValues), withLatestFrom(this.store.select(SearchSelectors.filterValues), this.store.select(DashboardSelectors.rank)), filter(([action, filterValues, rank]) => (action.force || !filterValues[action.filterId] || filterValues[action.filterId].length === 0) && rank === 0), mergeMap(([action]) => this.searchService
5489
- .autocomplete(action.attributes, '', action.limit)
5496
+ .autocomplete(action.attributes, '', action.valuesFilters, action.limit)
5490
5497
  .pipe(map((values) => SearchActions.setPossibleFilterValues({ filterId: action.filterId, values }))))));
5491
5498
  }
5492
5499
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.7", ngImport: i0, type: SearchEffects, deps: [{ token: i1$2.Actions }, { token: SearchService }, { token: i1.Store }, { token: WidgetFactoryService }], target: i0.ɵɵFactoryTarget.Injectable }); }