Skip to content

Commit

Permalink
Replace presence type with remote column
Browse files Browse the repository at this point in the history
  • Loading branch information
joonashak committed Dec 31, 2024
1 parent 67daa8d commit 6b4f343
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { MigrationInterface, QueryRunner, TableColumn } from "typeorm";

export class ReplacePresenceTypeWithRemoteColumn1735633836694 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
const table = await queryRunner.getTable("presence");

await queryRunner.dropColumn(table, "type");

await queryRunner.addColumn(
table,
new TableColumn({ name: "remote", type: "boolean", isNullable: false, default: false }),
);
}

public async down(): Promise<void> {}
}
5 changes: 3 additions & 2 deletions app/src/entities/presence/presence.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Column, Entity, JoinColumn, ManyToOne, PrimaryColumn, Repository } from
import { Office } from "../office/office.model";
import { User } from "../user/user.model";

// TODO: Remove.
export enum PresenceType {
OFFICE = "office",
REMOTE = "remote",
Expand All @@ -20,8 +21,8 @@ export class Presence {
@PrimaryColumn({ type: "date" })
date: string;

@Column({ type: "enum", enum: PresenceType, nullable: true })
type: PresenceType | null;
@Column({ name: "remote", type: "boolean", nullable: false, default: false })
remote: boolean;

@ManyToOne(() => Office, { nullable: true, eager: true })
@JoinColumn({ name: "office_id" })
Expand Down
4 changes: 2 additions & 2 deletions app/src/gui/home-tab/views/registration/day-list-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ export class DayListItem {
text: "Toimistolla",
actionId: Action.SET_OFFICE_PRESENCE,
value: dateString,
}).primary(currentPresence?.type === "office"),
}).primary(currentPresence?.remote === false),
Button({
text: "Etänä",
actionId: Action.SET_REMOTE_PRESENCE,
value: dateString,
}).primary(currentPresence?.type === "remote"),
}).primary(currentPresence?.remote === true),
this.getOfficeBlocks(props),
OverflowMenu({ actionId: Action.DAY_LIST_ITEM_OVERFLOW }).options(
Option({
Expand Down

0 comments on commit 6b4f343

Please sign in to comment.