Adds workweek settings and dynamic view configuration
Introduces settings service for managing tenant-specific calendar configurations Enables dynamic workweek presets with configurable work days Improves view switching with enhanced UI components Adds flexible calendar rendering based on tenant settings Extends DateService to support workweek date generation
This commit is contained in:
parent
58cedb9fad
commit
ad2df353b5
13 changed files with 751 additions and 38 deletions
|
|
@ -10,7 +10,7 @@ import { IStore } from './IStore';
|
|||
*/
|
||||
export class IndexedDBContext {
|
||||
private static readonly DB_NAME = 'CalendarV2DB';
|
||||
private static readonly DB_VERSION = 3;
|
||||
private static readonly DB_VERSION = 4;
|
||||
|
||||
private db: IDBDatabase | null = null;
|
||||
private initialized: boolean = false;
|
||||
|
|
|
|||
60
src/v2/storage/settings/SettingsService.ts
Normal file
60
src/v2/storage/settings/SettingsService.ts
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
import { EntityType, IEventBus } from '../../types/CalendarTypes';
|
||||
import { ITenantSettings, IWorkweekPreset } from '../../types/SettingsTypes';
|
||||
import { SettingsStore } from './SettingsStore';
|
||||
import { BaseEntityService } from '../BaseEntityService';
|
||||
import { IndexedDBContext } from '../IndexedDBContext';
|
||||
|
||||
/**
|
||||
* Default settings ID - single document per tenant
|
||||
*/
|
||||
const TENANT_SETTINGS_ID = 'tenant-settings';
|
||||
|
||||
/**
|
||||
* SettingsService - CRUD operations for tenant settings
|
||||
*
|
||||
* Settings are stored as a single document with sections.
|
||||
* This service provides convenience methods for accessing specific sections.
|
||||
*/
|
||||
export class SettingsService extends BaseEntityService<ITenantSettings> {
|
||||
readonly storeName = SettingsStore.STORE_NAME;
|
||||
readonly entityType: EntityType = 'Settings';
|
||||
|
||||
constructor(context: IndexedDBContext, eventBus: IEventBus) {
|
||||
super(context, eventBus);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tenant settings document
|
||||
* Returns null if not yet loaded from backend
|
||||
*/
|
||||
async getSettings(): Promise<ITenantSettings | null> {
|
||||
return this.get(TENANT_SETTINGS_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get workweek preset by ID
|
||||
*/
|
||||
async getWorkweekPreset(presetId: string): Promise<IWorkweekPreset | null> {
|
||||
const settings = await this.getSettings();
|
||||
if (!settings) return null;
|
||||
return settings.workweek.presets[presetId] || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default workweek preset
|
||||
*/
|
||||
async getDefaultWorkweekPreset(): Promise<IWorkweekPreset | null> {
|
||||
const settings = await this.getSettings();
|
||||
if (!settings) return null;
|
||||
return settings.workweek.presets[settings.workweek.defaultPreset] || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all available workweek presets
|
||||
*/
|
||||
async getWorkweekPresets(): Promise<IWorkweekPreset[]> {
|
||||
const settings = await this.getSettings();
|
||||
if (!settings) return [];
|
||||
return Object.values(settings.workweek.presets);
|
||||
}
|
||||
}
|
||||
16
src/v2/storage/settings/SettingsStore.ts
Normal file
16
src/v2/storage/settings/SettingsStore.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import { IStore } from '../IStore';
|
||||
|
||||
/**
|
||||
* SettingsStore - IndexedDB ObjectStore definition for tenant settings
|
||||
*
|
||||
* Single store for all settings sections. Settings are stored as one document
|
||||
* per tenant with id='tenant-settings'.
|
||||
*/
|
||||
export class SettingsStore implements IStore {
|
||||
static readonly STORE_NAME = 'settings';
|
||||
readonly storeName = SettingsStore.STORE_NAME;
|
||||
|
||||
create(db: IDBDatabase): void {
|
||||
db.createObjectStore(SettingsStore.STORE_NAME, { keyPath: 'id' });
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue