Fixed smart filters encode/decode issues from last release.

This commit is contained in:
Joseph Milazzo 2023-10-28 15:57:10 -05:00
parent f7c1e37694
commit 34282f3222
3 changed files with 34 additions and 34 deletions

View file

@ -72,7 +72,7 @@ public static class SmartFilterHelper
private static string EncodeSortOptions(SortOptions sortOptions)
{
return Uri.EscapeDataString($"sortField={(int) sortOptions.SortField}&isAscending={sortOptions.IsAscending}");
return Uri.EscapeDataString($"sortField={(int) sortOptions.SortField},isAscending={sortOptions.IsAscending}");
}
private static string EncodeFilterStatementDtos(ICollection<FilterStatementDto> statements)

View file

@ -121,37 +121,37 @@ export class MetadataFilterComponent implements OnInit {
this.loadFromPresetsAndSetup();
}
loadSavedFilter(event: Select2UpdateEvent<any>) {
// Load the filter from the backend and update the screen
if (event.value === undefined || typeof(event.value) === 'string') return;
const smartFilter = event.value as SmartFilter;
this.filterV2 = this.filterUtilitiesService.decodeSeriesFilter(smartFilter.filter);
this.cdRef.markForCheck();
console.log('update event: ', event);
}
createFilterValue(event: Select2AutoCreateEvent<any>) {
// Create a new name and filter
if (!this.filterV2) return;
this.filterV2.name = event.value;
this.filterService.saveFilter(this.filterV2).subscribe(() => {
const item = {
value: {
filter: this.filterUtilitiesService.encodeSeriesFilter(this.filterV2!),
name: event.value,
} as SmartFilter,
label: event.value
};
this.smartFilters.push(item);
this.sortGroup.get('name')?.setValue(item);
this.cdRef.markForCheck();
this.toastr.success(translate('toasts.smart-filter-updated'));
this.apply();
});
console.log('create event: ', event);
}
// loadSavedFilter(event: Select2UpdateEvent<any>) {
// // Load the filter from the backend and update the screen
// if (event.value === undefined || typeof(event.value) === 'string') return;
// const smartFilter = event.value as SmartFilter;
// this.filterV2 = this.filterUtilitiesService.decodeSeriesFilter(smartFilter.filter);
// this.cdRef.markForCheck();
// console.log('update event: ', event);
// }
//
// createFilterValue(event: Select2AutoCreateEvent<any>) {
// // Create a new name and filter
// if (!this.filterV2) return;
// this.filterV2.name = event.value;
// this.filterService.saveFilter(this.filterV2).subscribe(() => {
//
// const item = {
// value: {
// filter: this.filterUtilitiesService.encodeSeriesFilter(this.filterV2!),
// name: event.value,
// } as SmartFilter,
// label: event.value
// };
// this.smartFilters.push(item);
// this.sortGroup.get('name')?.setValue(item);
// this.cdRef.markForCheck();
// this.toastr.success(translate('toasts.smart-filter-updated'));
// this.apply();
// });
//
// console.log('create event: ', event);
// }
close() {

View file

@ -209,9 +209,9 @@ export class FilterUtilitiesService {
}
decodeFilterStatements(encodedStatements: string): FilterStatement[] {
const statementStrings = decodeURIComponent(encodedStatements).split(',');
const statementStrings = decodeURIComponent(encodedStatements).split(',').map(s => decodeURIComponent(s));
return statementStrings.map(statementString => {
const parts = statementString.split('&');
const parts = statementString.split(',');
if (parts === null || parts.length < 3) return null;
const comparisonStartToken = parts.find(part => part.startsWith('comparison='));