-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A lot of this was unused/not fully implemented.
- Loading branch information
Showing
13 changed files
with
143 additions
and
500 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
82 changes: 0 additions & 82 deletions
82
frontend/src/admin/daytheme/AdminDaythemeEditNewController.js
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
frontend/src/admin/daytheme/admin-daytheme-create.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<page-states [state]="pageState"></page-states> | ||
|
||
@if (eventgroup) { | ||
<div class="page-header"> | ||
<h1>Ny temadag for {{ eventgroup.title }}</h1> | ||
</div> | ||
|
||
<form (ngSubmit)="storeDaytheme()" class="form-horizontal" autocomplete="off"> | ||
<h3>Grunnleggende informasjon</h3> | ||
<div class="form-group"> | ||
<label for="title" class="col-sm-3 control-label">Tittel</label> | ||
<div class="col-sm-9 col-md-6"> | ||
<input | ||
type="text" | ||
name="title" | ||
class="form-control" | ||
[(ngModel)]="form.title" | ||
required | ||
autofocus | ||
/> | ||
</div> | ||
<div class="col-sm-4 col-md-3"> | ||
<input | ||
type="datetime" | ||
name="date" | ||
class="form-control" | ||
[(ngModel)]="form.date" | ||
placeholder="YYYY-MM-DD" | ||
/> | ||
</div> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<div class="col-sm-9 col-md-6 col-sm-offset-3"> | ||
<input type="submit" value="Opprett" class="btn btn-primary" /> | ||
<a routerLink="/a/eventgroup/{{ eventgroupId }}">Avbryt</a> | ||
</div> | ||
</div> | ||
</form> | ||
} |
77 changes: 77 additions & 0 deletions
77
frontend/src/admin/daytheme/admin-daytheme-create.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { Component, Input, OnInit } from "@angular/core" | ||
import { FormsModule } from "@angular/forms" | ||
import { Router, RouterLink } from "@angular/router" | ||
import moment from "moment" | ||
import { catchError, of } from "rxjs" | ||
import { PageStatesComponent } from "../../common/page-states.component" | ||
import { PageService } from "../../common/page.service" | ||
import { | ||
handleResourceLoadingStates, | ||
ResourceLoadingState, | ||
} from "../../common/resource-loading" | ||
import { | ||
AdminEventgroupData, | ||
AdminEventgroupService, | ||
} from "../eventgroup/admin-eventgroup.service" | ||
import { AdminDaythemeService } from "./admin-daytheme.service" | ||
|
||
@Component({ | ||
selector: "admin-daytheme", | ||
standalone: true, | ||
imports: [PageStatesComponent, RouterLink, FormsModule], | ||
templateUrl: "./admin-daytheme-create.component.html", | ||
}) | ||
export class AdminDaythemeCreateComponent implements OnInit { | ||
@Input() | ||
eventgroupId!: string | ||
|
||
pageState = new ResourceLoadingState() | ||
eventgroup?: AdminEventgroupData | ||
form = { | ||
title: "", | ||
date: "", | ||
} | ||
|
||
constructor( | ||
private adminDaythemeService: AdminDaythemeService, | ||
private adminEventgroupService: AdminEventgroupService, | ||
private pageService: PageService, | ||
private router: Router, | ||
) {} | ||
|
||
ngOnInit(): void { | ||
this.pageService.set("title", "Ny temadag") | ||
this.adminEventgroupService | ||
.get(this.eventgroupId) | ||
.pipe(handleResourceLoadingStates(this.pageState)) | ||
.subscribe((data) => { | ||
this.eventgroup = data | ||
}) | ||
} | ||
|
||
storeDaytheme() { | ||
if (!this.form || !this.form.title || !this.form.date) return | ||
|
||
const date = moment(this.form.date, "YYYY-MM-DD").unix() | ||
if (!date) { | ||
alert("Ugyldig dato") | ||
return | ||
} | ||
|
||
this.adminDaythemeService | ||
.create({ | ||
eventgroup_id: this.eventgroup!.id, | ||
date, | ||
title: this.form.title, | ||
}) | ||
.pipe( | ||
catchError((err) => { | ||
alert(err) | ||
return of() | ||
}), | ||
) | ||
.subscribe(() => { | ||
this.router.navigateByUrl(`/a/eventgroup/${this.eventgroupId}`) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { HttpClient } from "@angular/common/http" | ||
import { Injectable } from "@angular/core" | ||
import { api } from "../../api" | ||
|
||
export interface AdminDaythemeCreateData { | ||
eventgroup_id: number | ||
title?: string | ||
date?: number | ||
} | ||
|
||
@Injectable({ | ||
providedIn: "root", | ||
}) | ||
export class AdminDaythemeService { | ||
constructor(private http: HttpClient) {} | ||
|
||
create(data: AdminDaythemeCreateData) { | ||
return this.http.post<AdminDaythemeCreateData>(api("daytheme"), data, { | ||
params: { admin: "1" }, | ||
}) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.