Skip to content

Commit

Permalink
Ability for admins to edit a level's gameVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
jvyden committed Jan 2, 2024
1 parent 55dfcb4 commit 7f0d6c9
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/app/api/types/level-edit-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ export interface LevelEditRequest {
title: string | undefined;
description: string | undefined;
iconHash: string | undefined;
gameVersion: GameVersion | undefined;
gameVersion: string | undefined;
}
6 changes: 6 additions & 0 deletions src/app/pages/edit-level/edit-level.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
<p>(id: <code>{{level?.levelId ?? 0}}</code>)</p>
<divider></divider>

<div *ngIf="ownUser?.role == UserRoles.Admin">
<page-header class="text-2xl">Admin Settings</page-header>
<form-dropdown name="Game Version" [options]="gameVersions" [(value)]="gameVersion"></form-dropdown>
</div>
<divider></divider>

<div class="flex max-lg:flex-col gap-x-10 gap-y-2.5">
<div class="flex flex-col gap-y-2.5">
<page-header class="text-2xl">Metadata</page-header>
Expand Down
29 changes: 28 additions & 1 deletion src/app/pages/edit-level/edit-level.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {ApiClient} from "../../api/api-client.service";
import {faCancel, faCertificate, faFloppyDisk, faPencil, faTrash} from "@fortawesome/free-solid-svg-icons";
import {LevelEditRequest} from "../../api/types/level-edit-request";
import {UserRoles} from "../../api/types/user-roles";
import {DropdownOption} from "../../components/form-dropdown/form-dropdown.component";

@Component({
selector: 'edit-level',
Expand All @@ -20,6 +21,30 @@ export class EditLevelComponent implements OnInit {

title: string = "";
description: string = "";
gameVersion: string = "0";

gameVersions: DropdownOption[] = [
{
Name: "LittleBigPlanet 1",
Value: "0",
},
{
Name: "LittleBigPlanet 2",
Value: "1",
},
{
Name: "LittleBigPlanet 3",
Value: "2",
},
{
Name: "LittleBigPlanet Vita",
Value: "3",
},
{
Name: "LittleBigPlanet PSP",
Value: "4",
},
];

constructor(private authService: AuthService, private apiClient: ApiClient, private router: Router, private route: ActivatedRoute) {
}
Expand All @@ -44,6 +69,7 @@ export class EditLevelComponent implements OnInit {

this.title = data.title;
this.description = data.description;
this.gameVersion = data.gameVersion.toString();
});
});

Expand All @@ -60,7 +86,7 @@ export class EditLevelComponent implements OnInit {
title: this.title,
description: this.description,
iconHash: undefined,
gameVersion: undefined,
gameVersion: this.gameVersion,
}

this.apiClient.EditLevel(payload, this.level.levelId, this.ownUser?.role == UserRoles.Admin);
Expand All @@ -80,4 +106,5 @@ export class EditLevelComponent implements OnInit {
protected readonly faFloppyDisk = faFloppyDisk;
protected readonly faTrash = faTrash;
protected readonly faCancel = faCancel;
protected readonly UserRoles = UserRoles;
}

0 comments on commit 7f0d6c9

Please sign in to comment.