Add override for the event name in timetable

Add timetableName field to events that override which name is shown in
the timetable in order to allow using a custom condensed title in the
timetable for short events.
This commit is contained in:
Hornwitser 2025-09-12 19:23:34 +02:00
parent 732566a29c
commit 56791609f4
6 changed files with 38 additions and 3 deletions

View file

@ -21,10 +21,10 @@ function fixtureClientSchedule(multiSlot = false) {
const events = [
new ClientScheduleEvent(
1, now, false, "Up", false, "", false, "", "What's Up?", 0, new Set(multiSlot ? [1, 2] : [1]),
1, now, false, "Up", "", false, "", false, "", "What's Up?", 0, new Set(multiSlot ? [1, 2] : [1]),
),
new ClientScheduleEvent(
2, now, false, "Down", false, "", false, "", "", 0, new Set(multiSlot ? [] : [2]),
2, now, false, "Down", "", false, "", false, "", "", 0, new Set(multiSlot ? [] : [2]),
),
];
const eventSlots = idMap([

View file

@ -133,6 +133,7 @@ export class ClientScheduleLocation extends ClientEntity<ApiScheduleLocation> {
export class ClientScheduleEvent extends ClientEntity<ApiScheduleEvent> {
schedule!: ClientSchedule;
serverName: string;
serverTimetableName: string;
serverCrew: boolean;
serverHost: string;
serverCancelled: boolean;
@ -146,6 +147,7 @@ export class ClientScheduleEvent extends ClientEntity<ApiScheduleEvent> {
updatedAt: DateTime,
deleted: boolean,
public name: string,
public timetableName: string,
public crew: boolean,
public host: string,
public cancelled: boolean,
@ -156,6 +158,7 @@ export class ClientScheduleEvent extends ClientEntity<ApiScheduleEvent> {
) {
super(id, updatedAt, deleted);
this.serverName = name;
this.serverTimetableName = timetableName;
this.serverCrew = crew;
this.serverHost = host;
this.serverCancelled = cancelled;
@ -173,6 +176,7 @@ export class ClientScheduleEvent extends ClientEntity<ApiScheduleEvent> {
return (
super.isModified()
|| this.name !== this.serverName
|| this.timetableName !== this.serverTimetableName
|| this.crew !== this.serverCrew
|| this.host !== this.serverHost
|| this.cancelled !== this.serverCancelled
@ -191,6 +195,7 @@ export class ClientScheduleEvent extends ClientEntity<ApiScheduleEvent> {
this.updatedAt = this.serverUpdatedAt;;
this.deleted = this.serverDeleted;;
this.name = this.serverName;
this.timetableName = this.serverTimetableName;
this.crew = this.serverCrew;
this.host = this.serverHost;
this.cancelled = this.serverCancelled;
@ -210,6 +215,7 @@ export class ClientScheduleEvent extends ClientEntity<ApiScheduleEvent> {
schedule: ClientSchedule,
id: Id,
name: string,
timetableName: string,
crew: boolean,
host: string,
cancelled: boolean,
@ -224,6 +230,7 @@ export class ClientScheduleEvent extends ClientEntity<ApiScheduleEvent> {
DateTime.fromMillis(ClientEntity.newEntityMillis, opts),
false,
name,
timetableName,
crew,
host,
cancelled,
@ -245,6 +252,7 @@ export class ClientScheduleEvent extends ClientEntity<ApiScheduleEvent> {
DateTime.fromISO(api.updatedAt, opts),
api.deleted ?? false,
api.name,
api.timetableName ?? "",
api.crew ?? false,
api.host ?? "",
api.cancelled ?? false,
@ -263,6 +271,7 @@ export class ClientScheduleEvent extends ClientEntity<ApiScheduleEvent> {
this.serverUpdatedAt = DateTime.fromISO(api.updatedAt, opts);
this.serverDeleted = false;
this.serverName = api.name;
this.serverTimetableName = api.timetableName ?? "";
this.serverCrew = api.crew ?? false;
this.serverHost = api.host ?? "";
this.serverCancelled = api.cancelled ?? false;
@ -287,6 +296,7 @@ export class ClientScheduleEvent extends ClientEntity<ApiScheduleEvent> {
id: this.id,
updatedAt: toIso(this.updatedAt),
name: this.name,
timetableName: this.timetableName || undefined,
crew: this.crew || undefined,
host: this.host || undefined,
cancelled: this.cancelled || undefined,