diff --git a/frontend/src/admin/daytheme/AdminDaythemeController.js b/frontend/src/admin/daytheme/AdminDaythemeController.js deleted file mode 100755 index 8f372d1a..00000000 --- a/frontend/src/admin/daytheme/AdminDaythemeController.js +++ /dev/null @@ -1,30 +0,0 @@ -var module = angular.module("billett.admin") - -module.controller( - "AdminDaythemeController", - ( - Page, - $stateParams, - $http, - $scope, - AdminDaytheme, - AdminEvent, - $location, - ) => { - Page.setTitle("Temadag") - - var loader = Page.setLoading() - AdminDaytheme.get( - { id: $stateParams["id"] }, - (ret) => { - loader() - - $scope.daytheme = ret - }, - () => { - loader() - Page.set404() - }, - ) - }, -) diff --git a/frontend/src/admin/daytheme/AdminDaythemeEditNewController.js b/frontend/src/admin/daytheme/AdminDaythemeEditNewController.js deleted file mode 100755 index 9fd649e9..00000000 --- a/frontend/src/admin/daytheme/AdminDaythemeEditNewController.js +++ /dev/null @@ -1,82 +0,0 @@ -var module = angular.module("billett.admin") - -module.controller( - "AdminDaythemeEditNewController", - ( - Page, - AdminDaytheme, - $stateParams, - $rootScope, - $scope, - $location, - $window, - $timeout, - ) => { - var is_new = ($scope.is_new = !("id" in $stateParams)) - - var loader = Page.setLoading() - - if (is_new) { - Page.setTitle("Ny temadag") - $scope.eventgroup_id = $stateParams["eventgroup_id"] - loader() - } else { - Page.setTitle("Rediger temadag") - //loader(); - - AdminDaytheme.get( - { id: $stateParams["id"] }, - (ret) => { - loader() - - $scope.daytheme = ret - }, - () => { - loader() - Page.set404() - }, - ) - } - - $scope.storeDaytheme = () => { - if (!$scope.daytheme.title || !$scope.daytheme.date) return - - $scope.daytheme.date = moment($scope.daytheme.date, "YYYY-MM-DD").unix() - - if (is_new) { - $scope.daytheme.eventgroup_id = $scope.eventgroup_id - - var eg = new AdminDaytheme($scope.daytheme) - - eg.$save( - (res) => { - $location.path("/a/eventgroup/" + res.eventgroup_id) - }, - (err) => { - alert(err.data) - }, - ) - } else { - $scope.daytheme.$update( - (res) => { - // go to previous page or redirect to daytheme admin page - var timer = $timeout(() => { - $location.path("/a/eventgroup/" + res.eventgroup_id) - }, 100) - var ev = $rootScope.$on( - "$routeChangeStart", - (event, next, current) => { - ev() - $timeout.cancel(timer) - }, - ) - $window.history.back() - }, - (err) => { - alert(err.data) - }, - ) - } - } - }, -) diff --git a/frontend/src/admin/daytheme/AdminDaythemeService.js b/frontend/src/admin/daytheme/AdminDaythemeService.js deleted file mode 100755 index 2902b4e9..00000000 --- a/frontend/src/admin/daytheme/AdminDaythemeService.js +++ /dev/null @@ -1,18 +0,0 @@ -import { api } from "../../api" - -var module = angular.module("billett.admin") - -module.factory("AdminDaytheme", ($http, $resource) => { - var r = $resource( - api("daytheme/:id"), - { - id: "@id", - admin: 1, - }, - { - update: { method: "PUT" }, - }, - ) - - return r -}) diff --git a/frontend/src/admin/daytheme/admin-daytheme-create.component.html b/frontend/src/admin/daytheme/admin-daytheme-create.component.html new file mode 100644 index 00000000..16429c86 --- /dev/null +++ b/frontend/src/admin/daytheme/admin-daytheme-create.component.html @@ -0,0 +1,40 @@ + + +@if (eventgroup) { + + +
+

Grunnleggende informasjon

+
+ +
+ +
+
+ +
+
+ +
+
+ + Avbryt +
+
+
+} diff --git a/frontend/src/admin/daytheme/admin-daytheme-create.component.ts b/frontend/src/admin/daytheme/admin-daytheme-create.component.ts new file mode 100755 index 00000000..bd99994c --- /dev/null +++ b/frontend/src/admin/daytheme/admin-daytheme-create.component.ts @@ -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}`) + }) + } +} diff --git a/frontend/src/admin/daytheme/admin-daytheme.service.ts b/frontend/src/admin/daytheme/admin-daytheme.service.ts new file mode 100755 index 00000000..7fa42991 --- /dev/null +++ b/frontend/src/admin/daytheme/admin-daytheme.service.ts @@ -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(api("daytheme"), data, { + params: { admin: "1" }, + }) + } +} diff --git a/frontend/src/admin/daytheme/daytheme.scss b/frontend/src/admin/daytheme/daytheme.scss deleted file mode 100755 index 916e100c..00000000 --- a/frontend/src/admin/daytheme/daytheme.scss +++ /dev/null @@ -1,105 +0,0 @@ -@import "../../common/vars"; - -.admin-eventgroup { - table > tbody::before { - line-height: 20px; - content: "-"; - visibility: hidden; - display: block; - } - table tbody th { - font-weight: normal; - color: #444; - background: transparent !important; - border-top: none; - border-bottom-width: 2px; - } - table tbody > tr:nth-child(2) td { - border-top-width: 2px !important; - } - table { - > tbody > tr:nth-child(even) { - > td, - > th { - background-color: $table-bg-accent; - } - } - } - table th:nth-child(5), - table td:nth-child(5), - table th:nth-child(6), - table td:nth-child(6), - table th:nth-child(7), - table td:nth-child(7) { - text-align: right; - } - table th:nth-child(8), - table td:nth-child(8), - table th:nth-child(9), - table td:nth-child(9) { - text-align: center; - } - table td:nth-child(8), - table td:nth-child(9) { - background-color: hsl(120, 100%, 90%) !important; - } - /*table td:nth-child(8) { - - }*/ - table tr.event-not-published { - td { - opacity: 0.5; - } - td:nth-child(8), - td:nth-child(9) { - opacity: 1; - } - td:nth-child(8) { - background-color: hsl(0, 100%, 90%) !important; - } - } - table tr.event-no-selling { - td:nth-child(9) { - background-color: hsl(0, 100%, 90%) !important; - } - } - - .eventgroup-event-action { - cursor: pointer; - } - - .event-not-selling { - opacity: 0.3; - } -} - -.admin-soldTicketsStats { - .event-time { - display: block; - color: $gray; - font-size: 90%; - } - - table { - font-size: 85%; - } - - table td, - table th { - white-space: nowrap; - } - - td:not(:first-child), - th:not(:first-child) { - text-align: right; - } - - th, - td { - &:first-child { - max-width: 150px; - text-overflow: ellipsis; - overflow: hidden; - } - } -} diff --git a/frontend/src/admin/daytheme/edit.html b/frontend/src/admin/daytheme/edit.html deleted file mode 100644 index d5cf37f0..00000000 --- a/frontend/src/admin/daytheme/edit.html +++ /dev/null @@ -1,58 +0,0 @@ -
- - - - -
-

-
- -
-

Grunnleggende informasjon

-
- -
- -
-
- -
-
- -
-
- - Avbryt -
-
-
-
- - Avbryt -
-
-
-
diff --git a/frontend/src/admin/daytheme/index.html b/frontend/src/admin/daytheme/index.html deleted file mode 100644 index 33cf0059..00000000 --- a/frontend/src/admin/daytheme/index.html +++ /dev/null @@ -1,183 +0,0 @@ -
- - - - - - -
- -

- Arrangementliste - - Nytt arrangement - -

- -
-

Ingen arrangementer eksisterer.

-
- -
-
- - - -
- - - - - - - - - - - - - - - - @for ((day, events) in days; track (day, events) in days) { - - - - - @for (event of events; track event) { - - - - - - - - - - - - } - - } -
VarighetKategoriStedTittelSalgTilg.OmsattPubBillett-
info
- {{ - events[0].time_start - 21600 | formatdate: "dddd D. MMMM YYYY" - }} -
- {{ event.time_start | formatdate: "HH:mm" }} - - - {{ event.time_end | formatdate: "HH:mm" }} - - {{ event.category }}{{ event.location }} - - {{::event.ticket_count.totals.valid}} - - - {{ event.max_sales == 0 ? "" : event.ticket_count.totals.free }} - - {{event.max_sales == 0 && event.ticket_count.totals.valid == 0 ? '' - : - (event.ticket_count.totals.sum_price+event.ticket_count.totals.sum_fee|price)}} - - - - -
-
-
diff --git a/frontend/src/admin/daytheme/new.html b/frontend/src/admin/daytheme/new.html deleted file mode 100644 index fbafb507..00000000 --- a/frontend/src/admin/daytheme/new.html +++ /dev/null @@ -1,4 +0,0 @@ - - -tilbake -

TODO

diff --git a/frontend/src/admin/daytheme/routes.ts b/frontend/src/admin/daytheme/routes.ts index ac6749f1..1028f450 100755 --- a/frontend/src/admin/daytheme/routes.ts +++ b/frontend/src/admin/daytheme/routes.ts @@ -1,27 +1,11 @@ import { Routes } from "@angular/router" import { requireAdmin } from "../../auth/require-admin" -import { TodoComponent } from "../todo.component" +import { AdminDaythemeCreateComponent } from "./admin-daytheme-create.component" export const routes: Routes = [ { - path: "a/eventgroup/:eventgroup_id/new_daytheme", - // edit.html - // component: AdminDaythemeEditNewComponent, - component: TodoComponent, - canActivate: [requireAdmin], - }, - { - path: "a/daytheme/:id/edit", - // edit.html - // component: AdminDaythemeEditNewComponent, - component: TodoComponent, - canActivate: [requireAdmin], - }, - { - path: "a/daytheme/:id", - // index.html - // component: AdminDaythemeComponent, - component: TodoComponent, + path: "a/eventgroup/:eventgroupId/new_daytheme", + component: AdminDaythemeCreateComponent, canActivate: [requireAdmin], }, ] diff --git a/frontend/src/admin/eventgroup/admin-eventgroup.service.ts b/frontend/src/admin/eventgroup/admin-eventgroup.service.ts index a062f79d..2daeeb5b 100755 --- a/frontend/src/admin/eventgroup/admin-eventgroup.service.ts +++ b/frontend/src/admin/eventgroup/admin-eventgroup.service.ts @@ -4,6 +4,7 @@ import { api } from "../../api" export interface AdminEventgroupData { id: number + title: string [k: string]: any } diff --git a/frontend/src/styles.scss b/frontend/src/styles.scss index 67f8fa6d..6c168927 100644 --- a/frontend/src/styles.scss +++ b/frontend/src/styles.scss @@ -2,7 +2,6 @@ @import "./common/template"; @import "./common/events"; -@import "./admin/daytheme/daytheme.scss"; @import "./admin/event/event.scss"; @import "./admin/eventgroup/eventgroup.scss"; @import "./admin/order/new.scss";