Fix sorting

This commit is contained in:
aditya.chandel
2024-12-25 16:25:37 -07:00
parent 8d7eb8c460
commit b4f9829682
5 changed files with 162 additions and 53 deletions
@@ -0,0 +1,25 @@
import { Injectable } from '@angular/core';
import { SortOption } from '../model/sort-option.model';
@Injectable({
providedIn: 'root',
})
export class SortService {
private selectedSorts: { [key: string]: SortOption | null } = {};
generateKey(entityType: string, entityId: number): string {
if (entityType && entityId) {
return `${entityType.toLowerCase()}-${entityId}`;
}
return '';
}
getSortOption(key: string): SortOption | null {
return this.selectedSorts[key] || null;
}
setSortOption(key: string, sortOption: SortOption): void {
this.selectedSorts[key] = sortOption;
}
}