view data fixes

This commit is contained in:
2026-01-23 15:30:23 +01:00
parent e22033be38
commit f8099f04bc
213 changed files with 3466 additions and 3003 deletions

View File

@@ -1,16 +1,9 @@
import type { LeagueConfigFormModel } from '@/lib/types/LeagueConfigFormModel';
import type { LeagueScoringPresetViewModel } from '@/lib/view-models/LeagueScoringPresetViewModel';
import type { CustomPointsConfig } from '@/lib/view-models/ScoringConfigurationViewModel';
/**
* LeagueScoringSectionViewModel
*
* View model for the league scoring section UI state and operations
*/
import { ViewModel } from "../contracts/view-models/ViewModel";
import { LeagueScoringPresetViewModel } from './LeagueScoringPresetViewModel';
import type { CustomPointsConfig } from "../view-data/ScoringConfigurationViewData";
import type { LeagueScoringSectionViewData } from "../view-data/LeagueScoringSectionViewData";
export class LeagueScoringSectionViewModel extends ViewModel {
readonly form: LeagueConfigFormModel;
readonly presets: LeagueScoringPresetViewModel[];
readonly readOnly: boolean;
readonly patternOnly: boolean;
@@ -18,28 +11,24 @@ export class LeagueScoringSectionViewModel extends ViewModel {
readonly disabled: boolean;
readonly currentPreset: LeagueScoringPresetViewModel | null;
readonly isCustom: boolean;
private readonly data: LeagueScoringSectionViewData;
constructor(
form: LeagueConfigFormModel,
presets: LeagueScoringPresetViewModel[],
options: {
readOnly?: boolean;
patternOnly?: boolean;
championshipsOnly?: boolean;
} = {}
) {
this.form = form;
this.presets = presets;
this.readOnly = options.readOnly || false;
this.patternOnly = options.patternOnly || false;
this.championshipsOnly = options.championshipsOnly || false;
constructor(data: LeagueScoringSectionViewData) {
super();
this.data = data;
this.presets = data.presets.map(p => new LeagueScoringPresetViewModel(p));
this.readOnly = data.options?.readOnly || false;
this.patternOnly = data.options?.patternOnly || false;
this.championshipsOnly = data.options?.championshipsOnly || false;
this.disabled = this.readOnly;
this.currentPreset = form.scoring.patternId
? presets.find(p => p.id === form.scoring.patternId) || null
this.currentPreset = data.form.scoring.patternId
? this.presets.find(p => p.id === data.form.scoring.patternId) || null
: null;
this.isCustom = form.scoring.customScoringEnabled || false;
this.isCustom = data.form.scoring.customScoringEnabled || false;
}
get form() { return this.data.form; }
/**
* Get default custom points configuration
*/
@@ -120,8 +109,6 @@ export class LeagueScoringSectionViewModel extends ViewModel {
* Get the active custom points configuration
*/
getActiveCustomPoints(): CustomPointsConfig {
// This would be stored separately in the form model
// For now, return defaults
return LeagueScoringSectionViewModel.getDefaultCustomPoints();
}
}
}