Introduces uniform column key concept for calendar events
Refactors column identification with a new buildColumnKey method to support flexible date and resource tracking Replaces separate dateKey and resourceId handling with a unified columnKey approach Improves column rendering and event management with more consistent key generation Simplifies cross-component event tracking and column lookups
This commit is contained in:
parent
7da88bb977
commit
0eb3bacb41
9 changed files with 99 additions and 71 deletions
|
|
@ -52,6 +52,48 @@ export class DateService {
|
|||
return this.formatDate(date);
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// COLUMN KEY
|
||||
// ============================================
|
||||
|
||||
/**
|
||||
* Build a uniform columnKey from grouping segments
|
||||
* Handles any combination of date, resource, team, etc.
|
||||
*
|
||||
* @example
|
||||
* buildColumnKey({ date: '2025-12-09' }) → "2025-12-09"
|
||||
* buildColumnKey({ date: '2025-12-09', resource: 'EMP001' }) → "2025-12-09:EMP001"
|
||||
*/
|
||||
buildColumnKey(segments: Record<string, string>): string {
|
||||
// Always put date first if present, then other segments alphabetically
|
||||
const date = segments.date;
|
||||
const others = Object.entries(segments)
|
||||
.filter(([k]) => k !== 'date')
|
||||
.sort(([a], [b]) => a.localeCompare(b))
|
||||
.map(([, v]) => v);
|
||||
|
||||
return date ? [date, ...others].join(':') : others.join(':');
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a columnKey back into segments
|
||||
* Assumes format: "date:resource:..." or just "date"
|
||||
*/
|
||||
parseColumnKey(columnKey: string): { date: string; resource?: string } {
|
||||
const parts = columnKey.split(':');
|
||||
return {
|
||||
date: parts[0],
|
||||
resource: parts[1]
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract dateKey from columnKey (first segment)
|
||||
*/
|
||||
getDateFromColumnKey(columnKey: string): string {
|
||||
return columnKey.split(':')[0];
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// TIME CALCULATIONS
|
||||
// ============================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue