From 0d15d1573125dcf4cc886d8c895468b56215bc48 Mon Sep 17 00:00:00 2001 From: Henrik Steen Date: Wed, 17 Jul 2024 09:30:40 +0200 Subject: [PATCH] Improve modal naming and types --- .../src/admin/event/admin-event.component.ts | 2 +- frontend/src/admin/index/index.component.ts | 2 +- .../order/admin-order-create.component.ts | 4 +- ...=> admin-order-email-modal.component.html} | 0 ...s => admin-order-email-modal.component.ts} | 20 +++++---- .../admin/order/admin-order-item.component.ts | 32 +++++++------- .../src/admin/order/admin-order.service.ts | 21 +++++----- ...admin-payment-create-modal.component.html} | 0 ...> admin-payment-create-modal.component.ts} | 15 ++++--- .../admin/payment/admin-payment.service.ts | 17 ++++---- ...-paymentgroup-create-modal.component.html} | 0 ...in-paymentgroup-create-modal.component.ts} | 15 ++++--- .../admin-paymentgroup-item.component.html | 2 +- .../admin-paymentgroup-item.component.ts | 25 +++++------ .../admin-paymentgroup-list.component.ts | 6 ++- ...-paymentgroup-select-modal.component.html} | 0 ...in-paymentgroup-select-modal.component.ts} | 14 ++++--- .../admin-paymentgroup-selectbox.component.ts | 6 ++- .../admin-paymentgroup.service.ts | 42 +++++++++---------- ...paymentsource-create-modal.component.html} | 0 ...n-paymentsource-create-modal.component.ts} | 14 ++++--- ...admin-printer-select-modal.component.html} | 0 ...> admin-printer-select-modal.component.ts} | 20 +++++---- ...> admin-printer-text-modal.component.html} | 0 ... => admin-printer-text-modal.component.ts} | 16 ++++--- .../admin/printer/admin-printer.service.ts | 24 ++++++----- ... admin-ticket-revoke-modal.component.html} | 0 ...=> admin-ticket-revoke-modal.component.ts} | 20 +++++---- .../src/admin/ticket/admin-ticket.service.ts | 23 +++++----- ...etgroup-add-to-order-modal.component.html} | 0 ...etgroup-add-to-order-modal.component.scss} | 0 ...cketgroup-add-to-order-modal.component.ts} | 22 ++++++---- .../ticketgroup/admin-ticketgroup.service.ts | 18 ++++---- 33 files changed, 214 insertions(+), 166 deletions(-) rename frontend/src/admin/order/{admin-order-email.component.html => admin-order-email-modal.component.html} (100%) rename frontend/src/admin/order/{admin-order-email.component.ts => admin-order-email-modal.component.ts} (69%) rename frontend/src/admin/payment/{admin-payment-create.component.html => admin-payment-create-modal.component.html} (100%) rename frontend/src/admin/payment/{admin-payment-create.component.ts => admin-payment-create-modal.component.ts} (76%) rename frontend/src/admin/paymentgroup/{admin-paymentgroup-create.component.html => admin-paymentgroup-create-modal.component.html} (100%) rename frontend/src/admin/paymentgroup/{admin-paymentgroup-create.component.ts => admin-paymentgroup-create-modal.component.ts} (70%) rename frontend/src/admin/paymentgroup/{admin-paymentgroup-select.component.html => admin-paymentgroup-select-modal.component.html} (100%) rename frontend/src/admin/paymentgroup/{admin-paymentgroup-select.component.ts => admin-paymentgroup-select-modal.component.ts} (63%) rename frontend/src/admin/paymentgroup/{admin-paymentsource-create.component.html => admin-paymentsource-create-modal.component.html} (100%) rename frontend/src/admin/paymentgroup/{admin-paymentsource-create.component.ts => admin-paymentsource-create-modal.component.ts} (91%) rename frontend/src/admin/printer/{admin-printer-select.component.html => admin-printer-select-modal.component.html} (100%) rename frontend/src/admin/printer/{admin-printer-select.component.ts => admin-printer-select-modal.component.ts} (66%) rename frontend/src/admin/printer/{admin-printer-text.component.html => admin-printer-text-modal.component.html} (100%) rename frontend/src/admin/printer/{admin-printer-text.component.ts => admin-printer-text-modal.component.ts} (76%) rename frontend/src/admin/ticket/{admin-ticket-revoke.component.html => admin-ticket-revoke-modal.component.html} (100%) rename frontend/src/admin/ticket/{admin-ticket-revoke.component.ts => admin-ticket-revoke-modal.component.ts} (77%) rename frontend/src/admin/ticketgroup/{admin-ticketgroup-add-to-order.component.html => admin-ticketgroup-add-to-order-modal.component.html} (100%) rename frontend/src/admin/ticketgroup/{admin-ticketgroup-add-to-order.component.scss => admin-ticketgroup-add-to-order-modal.component.scss} (100%) rename frontend/src/admin/ticketgroup/{admin-ticketgroup-add-to-order.component.ts => admin-ticketgroup-add-to-order-modal.component.ts} (84%) diff --git a/frontend/src/admin/event/admin-event.component.ts b/frontend/src/admin/event/admin-event.component.ts index 39152348..d4d9bcbb 100755 --- a/frontend/src/admin/event/admin-event.component.ts +++ b/frontend/src/admin/event/admin-event.component.ts @@ -110,7 +110,7 @@ export class AdminEventComponent implements OnInit { } previewTicketPrint(ticketgroup: ApiTicketgroupAdmin) { - this.adminPrinterService.printSelectModal({ + this.adminPrinterService.openPrinterSelectModal({ handler: (printer) => this.adminPrinterService.printPreviewTicket(printer, ticketgroup).pipe( tap(() => { diff --git a/frontend/src/admin/index/index.component.ts b/frontend/src/admin/index/index.component.ts index 8dec48c2..790aa32f 100755 --- a/frontend/src/admin/index/index.component.ts +++ b/frontend/src/admin/index/index.component.ts @@ -18,7 +18,7 @@ export class AdminIndexComponent implements OnInit { private adminPrinterService = inject(AdminPrinterService) printText() { - this.adminPrinterService.printTextModal() + this.adminPrinterService.openPrintTextModal() } ngOnInit(): void { diff --git a/frontend/src/admin/order/admin-order-create.component.ts b/frontend/src/admin/order/admin-order-create.component.ts index 07761be3..8e967c23 100755 --- a/frontend/src/admin/order/admin-order-create.component.ts +++ b/frontend/src/admin/order/admin-order-create.component.ts @@ -305,11 +305,11 @@ export class AdminOrderCreateComponent implements OnInit { addTickets() { this.adminTicketgroupService - .addTicketsModal({ + .openAddTicketsModal({ eventgroupId: this.eventgroup!.id, getOrderId: () => this.getOrCreateOrder().then((order) => order.id!), }) - .subscribe((tickets) => { + .closed.subscribe((tickets) => { if (!tickets) return this.getOrCreateOrder(true).then( () => { diff --git a/frontend/src/admin/order/admin-order-email.component.html b/frontend/src/admin/order/admin-order-email-modal.component.html similarity index 100% rename from frontend/src/admin/order/admin-order-email.component.html rename to frontend/src/admin/order/admin-order-email-modal.component.html diff --git a/frontend/src/admin/order/admin-order-email.component.ts b/frontend/src/admin/order/admin-order-email-modal.component.ts similarity index 69% rename from frontend/src/admin/order/admin-order-email.component.ts rename to frontend/src/admin/order/admin-order-email-modal.component.ts index 39737b98..24e3bf4a 100755 --- a/frontend/src/admin/order/admin-order-email.component.ts +++ b/frontend/src/admin/order/admin-order-email-modal.component.ts @@ -4,25 +4,29 @@ import { FormsModule } from "@angular/forms" import { ApiEventgroupAdmin, ApiOrderAdmin } from "../../apitypes" import { AdminOrderService } from "./admin-order.service" -export interface AdminOrderEmailComponentInput { +export interface AdminOrderEmailModalInput { order: ApiOrderAdmin & { eventgroup: ApiEventgroupAdmin } } +export interface AdminOrderEmailModalResult { + completed: true +} + @Component({ - selector: "billett-admin-order-email", + selector: "billett-admin-order-email-modal", standalone: true, imports: [FormsModule], - templateUrl: "./admin-order-email.component.html", + templateUrl: "./admin-order-email-modal.component.html", }) -export class AdminOrderEmailComponent { +export class AdminOrderEmailModal { constructor( @Inject(DIALOG_DATA) - public data: AdminOrderEmailComponentInput, + public data: AdminOrderEmailModalInput, ) {} - private dialogRef = inject(DialogRef) + private dialogRef = inject(DialogRef) private adminOrderService = inject(AdminOrderService) sending = false @@ -41,7 +45,9 @@ export class AdminOrderEmailComponent { .subscribe({ next: () => { this.sending = false - this.dialogRef.close(true) + this.dialogRef.close({ + completed: true, + }) }, error: (err) => { this.sending = false diff --git a/frontend/src/admin/order/admin-order-item.component.ts b/frontend/src/admin/order/admin-order-item.component.ts index 461644a8..c32072bb 100755 --- a/frontend/src/admin/order/admin-order-item.component.ts +++ b/frontend/src/admin/order/admin-order-item.component.ts @@ -18,7 +18,7 @@ import { import { AdminPaymentService } from "../payment/admin-payment.service" import { AdminPaymentgroupService } from "../paymentgroup/admin-paymentgroup.service" import { AdminPrinterService } from "../printer/admin-printer.service" -import { AdminTicketRevokeComponentInput } from "../ticket/admin-ticket-revoke.component" +import { AdminTicketRevokeModalInput } from "../ticket/admin-ticket-revoke-modal.component" import { AdminTicketService } from "../ticket/admin-ticket.service" import { AdminTicketgroupService } from "../ticketgroup/admin-ticketgroup.service" import { AdminOrderGetData, AdminOrderService } from "./admin-order.service" @@ -160,12 +160,12 @@ export class AdminOrderItemComponent implements OnInit { completeOrder() { this.adminPaymentgroupService - .selectModal({ + .openSelectModal({ eventgroupId: this.order!.eventgroup.id, actionText: "Marker som betalt", amount: this.totalReserved, }) - .subscribe((paymentgroup) => { + .closed.subscribe((paymentgroup) => { if (!paymentgroup) return this.adminOrderService @@ -201,23 +201,23 @@ export class AdminOrderItemComponent implements OnInit { addTickets() { this.adminTicketgroupService - .addTicketsModal({ + .openAddTicketsModal({ eventgroupId: this.order!.eventgroup.id, getOrderId: async () => this.order!.id, }) - .subscribe((tickets) => { + .closed.subscribe((tickets) => { if (!tickets) return this.refreshOrder() }) } - revokeTicket(ticket: AdminTicketRevokeComponentInput["ticket"]) { + revokeTicket(ticket: AdminTicketRevokeModalInput["ticket"]) { this.adminTicketService - .revokeModal({ + .openRevokeModal({ order: this.order!, ticket, }) - .subscribe((result) => { + .closed.subscribe((result) => { if (!result) return this.refreshOrder() }) @@ -229,12 +229,12 @@ export class AdminOrderItemComponent implements OnInit { }, ) { this.adminPaymentgroupService - .selectModal({ + .openSelectModal({ eventgroupId: this.order!.eventgroup.id, actionText: "Inntekstfør", amount: ticket.ticketgroup.price + ticket.ticketgroup.fee, }) - .subscribe((paymentgroup) => { + .closed.subscribe((paymentgroup) => { if (!paymentgroup) return this.adminTicketService @@ -258,27 +258,27 @@ export class AdminOrderItemComponent implements OnInit { newPayment() { this.adminPaymentService - .createModal({ + .openCreateModal({ order: this.order!, }) - .subscribe(() => { + .closed.subscribe(() => { this.refreshOrder() }) } sendEmail() { this.adminOrderService - .emailModal({ + .openEmailModal({ order: this.order!, }) - .subscribe((sent) => { + .closed.subscribe((sent) => { if (!sent) return this.pageService.toast("E-post ble sendt", { class: "success" }) }) } printTickets() { - this.adminPrinterService.printSelectModal({ + this.adminPrinterService.openPrinterSelectModal({ handler: (printer) => this.adminPrinterService.printTickets(printer, this.validTickets).pipe( tap(() => { @@ -297,7 +297,7 @@ export class AdminOrderItemComponent implements OnInit { } printTicket(ticket: ApiTicketAdmin) { - this.adminPrinterService.printSelectModal({ + this.adminPrinterService.openPrinterSelectModal({ handler: (printer) => { console.log("print!") return this.adminPrinterService.printTicket(printer, ticket).pipe( diff --git a/frontend/src/admin/order/admin-order.service.ts b/frontend/src/admin/order/admin-order.service.ts index 94962a97..50cf6277 100755 --- a/frontend/src/admin/order/admin-order.service.ts +++ b/frontend/src/admin/order/admin-order.service.ts @@ -13,9 +13,10 @@ import { Paginated, } from "../../apitypes" import { - AdminOrderEmailComponent, - AdminOrderEmailComponentInput, -} from "./admin-order-email.component" + AdminOrderEmailModal, + AdminOrderEmailModalInput, + AdminOrderEmailModalResult, +} from "./admin-order-email-modal.component" export type AdminOrderData = Paginated< ApiOrderAdmin & { @@ -152,12 +153,12 @@ export class AdminOrderService { ) } - emailModal(data: AdminOrderEmailComponentInput) { - return this.dialog.open( - AdminOrderEmailComponent, - { - data, - }, - ).closed + openEmailModal(data: AdminOrderEmailModalInput) { + return this.dialog.open< + AdminOrderEmailModalResult, + AdminOrderEmailModalInput + >(AdminOrderEmailModal, { + data, + }) } } diff --git a/frontend/src/admin/payment/admin-payment-create.component.html b/frontend/src/admin/payment/admin-payment-create-modal.component.html similarity index 100% rename from frontend/src/admin/payment/admin-payment-create.component.html rename to frontend/src/admin/payment/admin-payment-create-modal.component.html diff --git a/frontend/src/admin/payment/admin-payment-create.component.ts b/frontend/src/admin/payment/admin-payment-create-modal.component.ts similarity index 76% rename from frontend/src/admin/payment/admin-payment-create.component.ts rename to frontend/src/admin/payment/admin-payment-create-modal.component.ts index 5c81f3ab..26a59cc4 100755 --- a/frontend/src/admin/payment/admin-payment-create.component.ts +++ b/frontend/src/admin/payment/admin-payment-create-modal.component.ts @@ -4,30 +4,33 @@ import { FormsModule } from "@angular/forms" import { ApiEventgroupAdmin, ApiOrderAdmin, + ApiPaymentAdmin, ApiPaymentgroupAdmin, } from "../../apitypes" import { AdminPaymentgroupSelectboxComponent } from "../paymentgroup/admin-paymentgroup-selectbox.component" import { AdminPaymentService } from "./admin-payment.service" -export interface AdminPaymentCreateComponentInput { +export interface AdminPaymentCreateModalInput { order: ApiOrderAdmin & { eventgroup: ApiEventgroupAdmin } } +export type AdminPaymentCreateModalResult = ApiPaymentAdmin + @Component({ - selector: "billett-admin-payment-create", + selector: "billett-admin-payment-create-modal", standalone: true, imports: [FormsModule, AdminPaymentgroupSelectboxComponent], - templateUrl: "./admin-payment-create.component.html", + templateUrl: "./admin-payment-create-modal.component.html", }) -export class AdminPaymentCreateComponent implements OnInit { +export class AdminPaymentCreateModal implements OnInit { constructor( @Inject(DIALOG_DATA) - public data: AdminPaymentCreateComponentInput, + public data: AdminPaymentCreateModalInput, ) {} - private dialogRef = inject(DialogRef) + private dialogRef = inject(DialogRef) private adminPaymentService = inject(AdminPaymentService) sending = false diff --git a/frontend/src/admin/payment/admin-payment.service.ts b/frontend/src/admin/payment/admin-payment.service.ts index c666c58d..ec8ae00b 100755 --- a/frontend/src/admin/payment/admin-payment.service.ts +++ b/frontend/src/admin/payment/admin-payment.service.ts @@ -8,9 +8,10 @@ import { ApiPaymentgroupAdmin, } from "../../apitypes" import { - AdminPaymentCreateComponent, - AdminPaymentCreateComponentInput, -} from "./admin-payment-create.component" + AdminPaymentCreateModal, + AdminPaymentCreateModalInput, + AdminPaymentCreateModalResult, +} from "./admin-payment-create-modal.component" @Injectable({ providedIn: "root", @@ -31,12 +32,12 @@ export class AdminPaymentService { }) } - createModal(data: AdminPaymentCreateComponentInput) { + openCreateModal(data: AdminPaymentCreateModalInput) { return this.dialog.open< - ApiPaymentgroupAdmin, - AdminPaymentCreateComponentInput - >(AdminPaymentCreateComponent, { + AdminPaymentCreateModalResult, + AdminPaymentCreateModalInput + >(AdminPaymentCreateModal, { data, - }).closed + }) } } diff --git a/frontend/src/admin/paymentgroup/admin-paymentgroup-create.component.html b/frontend/src/admin/paymentgroup/admin-paymentgroup-create-modal.component.html similarity index 100% rename from frontend/src/admin/paymentgroup/admin-paymentgroup-create.component.html rename to frontend/src/admin/paymentgroup/admin-paymentgroup-create-modal.component.html diff --git a/frontend/src/admin/paymentgroup/admin-paymentgroup-create.component.ts b/frontend/src/admin/paymentgroup/admin-paymentgroup-create-modal.component.ts similarity index 70% rename from frontend/src/admin/paymentgroup/admin-paymentgroup-create.component.ts rename to frontend/src/admin/paymentgroup/admin-paymentgroup-create-modal.component.ts index 1e0d24d4..9096b910 100755 --- a/frontend/src/admin/paymentgroup/admin-paymentgroup-create.component.ts +++ b/frontend/src/admin/paymentgroup/admin-paymentgroup-create-modal.component.ts @@ -1,26 +1,29 @@ import { DIALOG_DATA, DialogRef } from "@angular/cdk/dialog" import { Component, inject, Inject } from "@angular/core" import { FormsModule } from "@angular/forms" +import { ApiPaymentgroupAdmin } from "../../apitypes" import { PagePropertyComponent } from "../../common/page-property.component" import { AdminPaymentgroupService } from "./admin-paymentgroup.service" -export interface AdminPaymentgroupCreateComponentInput { +export interface AdminPaymentgroupCreateModalInput { eventgroupId: number } +export type AdminPaymentgroupCreateModalResult = ApiPaymentgroupAdmin + @Component({ - selector: "billett-admin-paymentgroup-create", + selector: "billett-admin-paymentgroup-create-modal", standalone: true, imports: [PagePropertyComponent, FormsModule], - templateUrl: "./admin-paymentgroup-create.component.html", + templateUrl: "./admin-paymentgroup-create-modal.component.html", }) -export class AdminPaymentgroupCreateComponent { +export class AdminPaymentgroupCreateModal { constructor( @Inject(DIALOG_DATA) - public data: AdminPaymentgroupCreateComponentInput, + public data: AdminPaymentgroupCreateModalInput, ) {} - private dialogRef = inject(DialogRef) + private dialogRef = inject(DialogRef) private adminPaymentgroupService = inject(AdminPaymentgroupService) sending = false diff --git a/frontend/src/admin/paymentgroup/admin-paymentgroup-item.component.html b/frontend/src/admin/paymentgroup/admin-paymentgroup-item.component.html index 9abc4e19..76378b32 100644 --- a/frontend/src/admin/paymentgroup/admin-paymentgroup-item.component.html +++ b/frontend/src/admin/paymentgroup/admin-paymentgroup-item.component.html @@ -239,7 +239,7 @@

Opptelling/kontroll @if (!paymentgroup.time_end) { - Registrer opptelling } diff --git a/frontend/src/admin/paymentgroup/admin-paymentgroup-item.component.ts b/frontend/src/admin/paymentgroup/admin-paymentgroup-item.component.ts index 18288502..0b7bf2ee 100755 --- a/frontend/src/admin/paymentgroup/admin-paymentgroup-item.component.ts +++ b/frontend/src/admin/paymentgroup/admin-paymentgroup-item.component.ts @@ -19,9 +19,10 @@ import { AdminPaymentgroupService, } from "./admin-paymentgroup.service" import { - AdminPaymentsourceCreateComponent, - AdminPaymentsourceCreateComponentInput, -} from "./admin-paymentsource-create.component" + AdminPaymentsourceCreateModal, + AdminPaymentsourceCreateModalInput, + AdminPaymentsourceCreateModalResult, +} from "./admin-paymentsource-create-modal.component" import { AdminPaymentsourceService } from "./admin-paymentsource.service" @Component({ @@ -338,17 +339,17 @@ export class AdminPaymentgroupItemComponent implements OnInit { } } - newPaymentsource() { + openCreatePaymentsourceModal() { this.dialog - .open( - AdminPaymentsourceCreateComponent, - { - data: { - eventgroup: this.paymentgroup!.eventgroup, - paymentgroup: this.paymentgroup!, - }, + .open< + AdminPaymentsourceCreateModalResult, + AdminPaymentsourceCreateModalInput + >(AdminPaymentsourceCreateModal, { + data: { + eventgroup: this.paymentgroup!.eventgroup, + paymentgroup: this.paymentgroup!, }, - ) + }) .closed.subscribe((paymentsource) => { if (paymentsource) { this.refresh() diff --git a/frontend/src/admin/paymentgroup/admin-paymentgroup-list.component.ts b/frontend/src/admin/paymentgroup/admin-paymentgroup-list.component.ts index 9726d589..2ba4cdff 100755 --- a/frontend/src/admin/paymentgroup/admin-paymentgroup-list.component.ts +++ b/frontend/src/admin/paymentgroup/admin-paymentgroup-list.component.ts @@ -64,8 +64,10 @@ export class AdminPaymentgroupListComponent implements OnInit { createNew() { this.adminPaymentgroupService - .createModal(this.eventgroup!.id) - .subscribe((paymentgroup) => { + .openCreateModal({ + eventgroupId: this.eventgroup!.id, + }) + .closed.subscribe((paymentgroup) => { if (paymentgroup) { this.#loadPaymentGroups(this.eventgroup!.id) } diff --git a/frontend/src/admin/paymentgroup/admin-paymentgroup-select.component.html b/frontend/src/admin/paymentgroup/admin-paymentgroup-select-modal.component.html similarity index 100% rename from frontend/src/admin/paymentgroup/admin-paymentgroup-select.component.html rename to frontend/src/admin/paymentgroup/admin-paymentgroup-select-modal.component.html diff --git a/frontend/src/admin/paymentgroup/admin-paymentgroup-select.component.ts b/frontend/src/admin/paymentgroup/admin-paymentgroup-select-modal.component.ts similarity index 63% rename from frontend/src/admin/paymentgroup/admin-paymentgroup-select.component.ts rename to frontend/src/admin/paymentgroup/admin-paymentgroup-select-modal.component.ts index d5dd1890..eac710ba 100755 --- a/frontend/src/admin/paymentgroup/admin-paymentgroup-select.component.ts +++ b/frontend/src/admin/paymentgroup/admin-paymentgroup-select-modal.component.ts @@ -5,25 +5,27 @@ import { ApiPaymentgroupAdmin } from "../../apitypes" import { PricePipe } from "../../common/price.pipe" import { AdminPaymentgroupSelectboxComponent } from "./admin-paymentgroup-selectbox.component" -export interface AdminPaymentgroupSelectComponentInput { +export interface AdminPaymentgroupSelectModalInput { eventgroupId: number actionText: string amount: number } +export type AdminPaymentgroupSelectModalResult = ApiPaymentgroupAdmin + @Component({ - selector: "billett-admin-paymentgroup-select", + selector: "billett-admin-paymentgroup-select-modal", standalone: true, imports: [AdminPaymentgroupSelectboxComponent, PricePipe, FormsModule], - templateUrl: "./admin-paymentgroup-select.component.html", + templateUrl: "./admin-paymentgroup-select-modal.component.html", }) -export class AdminPaymentgroupSelectComponent { +export class AdminPaymentgroupSelectModal { constructor( @Inject(DIALOG_DATA) - public data: AdminPaymentgroupSelectComponentInput, + public data: AdminPaymentgroupSelectModalInput, ) {} - private dialogRef = inject(DialogRef) + private dialogRef = inject(DialogRef) paymentgroup?: ApiPaymentgroupAdmin diff --git a/frontend/src/admin/paymentgroup/admin-paymentgroup-selectbox.component.ts b/frontend/src/admin/paymentgroup/admin-paymentgroup-selectbox.component.ts index 699d9024..3eba7468 100755 --- a/frontend/src/admin/paymentgroup/admin-paymentgroup-selectbox.component.ts +++ b/frontend/src/admin/paymentgroup/admin-paymentgroup-selectbox.component.ts @@ -54,8 +54,10 @@ export class AdminPaymentgroupSelectboxComponent implements OnInit { createNew() { this.adminPaymentgroupService - .createModal(this.eventgroupId) - .subscribe((paymentgroup) => { + .openCreateModal({ + eventgroupId: this.eventgroupId, + }) + .closed.subscribe((paymentgroup) => { if (paymentgroup) { this.paymentgroup = paymentgroup this.paymentgroupChange.emit(paymentgroup) diff --git a/frontend/src/admin/paymentgroup/admin-paymentgroup.service.ts b/frontend/src/admin/paymentgroup/admin-paymentgroup.service.ts index 97f20d94..3fc74f4b 100644 --- a/frontend/src/admin/paymentgroup/admin-paymentgroup.service.ts +++ b/frontend/src/admin/paymentgroup/admin-paymentgroup.service.ts @@ -13,13 +13,15 @@ import { ApiTicketgroupAdmin, } from "../../apitypes" import { - AdminPaymentgroupCreateComponent, - AdminPaymentgroupCreateComponentInput, -} from "./admin-paymentgroup-create.component" + AdminPaymentgroupCreateModal, + AdminPaymentgroupCreateModalInput, + AdminPaymentgroupCreateModalResult, +} from "./admin-paymentgroup-create-modal.component" import { - AdminPaymentgroupSelectComponent, - AdminPaymentgroupSelectComponentInput, -} from "./admin-paymentgroup-select.component" + AdminPaymentgroupSelectModal, + AdminPaymentgroupSelectModalInput, + AdminPaymentgroupSelectModalResult, +} from "./admin-paymentgroup-select-modal.component" export type AdminPaymentgroupData = ApiPaymentgroupAdmin & { eventgroup: ApiEventgroupAdmin @@ -130,27 +132,21 @@ export class AdminPaymentgroupService { return groups.find((it) => it.id === Number(lastId)) ?? undefined } - createModal(eventgroupId: number) { + openCreateModal(data: AdminPaymentgroupCreateModalInput) { return this.dialog.open< - ApiPaymentgroupAdmin, - AdminPaymentgroupCreateComponentInput - >(AdminPaymentgroupCreateComponent, { - data: { - eventgroupId, - }, - }).closed + AdminPaymentgroupCreateModalResult, + AdminPaymentgroupCreateModalInput + >(AdminPaymentgroupCreateModal, { + data, + }) } - selectModal(data: { - eventgroupId: number - actionText: string - amount: number - }) { + openSelectModal(data: AdminPaymentgroupSelectModalInput) { return this.dialog.open< - ApiPaymentgroupAdmin, - AdminPaymentgroupSelectComponentInput - >(AdminPaymentgroupSelectComponent, { + AdminPaymentgroupSelectModalResult, + AdminPaymentgroupSelectModalInput + >(AdminPaymentgroupSelectModal, { data, - }).closed + }) } } diff --git a/frontend/src/admin/paymentgroup/admin-paymentsource-create.component.html b/frontend/src/admin/paymentgroup/admin-paymentsource-create-modal.component.html similarity index 100% rename from frontend/src/admin/paymentgroup/admin-paymentsource-create.component.html rename to frontend/src/admin/paymentgroup/admin-paymentsource-create-modal.component.html diff --git a/frontend/src/admin/paymentgroup/admin-paymentsource-create.component.ts b/frontend/src/admin/paymentgroup/admin-paymentsource-create-modal.component.ts similarity index 91% rename from frontend/src/admin/paymentgroup/admin-paymentsource-create.component.ts rename to frontend/src/admin/paymentgroup/admin-paymentsource-create-modal.component.ts index 8ec82565..7fc0589b 100755 --- a/frontend/src/admin/paymentgroup/admin-paymentsource-create.component.ts +++ b/frontend/src/admin/paymentgroup/admin-paymentsource-create-modal.component.ts @@ -12,13 +12,15 @@ import { PageService } from "../../common/page.service" import { PricePipe } from "../../common/price.pipe" import { AdminPaymentsourceService } from "./admin-paymentsource.service" -export interface AdminPaymentsourceCreateComponentInput { +export interface AdminPaymentsourceCreateModalInput { paymentgroup: ApiPaymentgroupAdmin eventgroup: ApiEventgroupAdmin } +export type AdminPaymentsourceCreateModalResult = ApiPaymentsourceAdmin + @Component({ - selector: "billett-admin-paymentsource-create", + selector: "billett-admin-paymentsource-create-modal", standalone: true, imports: [ PagePropertyComponent, @@ -26,19 +28,19 @@ export interface AdminPaymentsourceCreateComponentInput { FormsModule, NgxTypeAheadComponent, ], - templateUrl: "./admin-paymentsource-create.component.html", + templateUrl: "./admin-paymentsource-create-modal.component.html", }) -export class AdminPaymentsourceCreateComponent { +export class AdminPaymentsourceCreateModal { constructor( @Inject(DIALOG_DATA) - private data: AdminPaymentsourceCreateComponentInput, + private data: AdminPaymentsourceCreateModalInput, ) { this.loadMathjs() } private adminPaymentsourceService = inject(AdminPaymentsourceService) private pageService = inject(PageService) - private dialogRef = inject(DialogRef) + private dialogRef = inject(DialogRef) evaluate?: (value: string) => number diff --git a/frontend/src/admin/printer/admin-printer-select.component.html b/frontend/src/admin/printer/admin-printer-select-modal.component.html similarity index 100% rename from frontend/src/admin/printer/admin-printer-select.component.html rename to frontend/src/admin/printer/admin-printer-select-modal.component.html diff --git a/frontend/src/admin/printer/admin-printer-select.component.ts b/frontend/src/admin/printer/admin-printer-select-modal.component.ts similarity index 66% rename from frontend/src/admin/printer/admin-printer-select.component.ts rename to frontend/src/admin/printer/admin-printer-select-modal.component.ts index 18421005..239e989c 100755 --- a/frontend/src/admin/printer/admin-printer-select.component.ts +++ b/frontend/src/admin/printer/admin-printer-select-modal.component.ts @@ -5,23 +5,27 @@ import { Observable } from "rxjs" import { ApiPrinterAdmin } from "../../apitypes" import { AdminPrinterSelectboxComponent } from "./admin-printer-selectbox.component" -export interface AdminPrinterSelectComponentInput { +export interface AdminPrinterSelectInput { handler: (printer: ApiPrinterAdmin) => Observable } +export interface AdminPrinterSelectResult { + completed: true +} + @Component({ - selector: "billett-admin-printer-select", + selector: "billett-admin-printer-select-modal", standalone: true, imports: [AdminPrinterSelectboxComponent, FormsModule], - templateUrl: "./admin-printer-select.component.html", + templateUrl: "./admin-printer-select-modal.component.html", }) -export class AdminPrinterSelectComponent { +export class AdminPrinterSelectModal { constructor( @Inject(DIALOG_DATA) - public data: AdminPrinterSelectComponentInput, + public data: AdminPrinterSelectInput, ) {} - private dialogRef = inject(DialogRef) + private dialogRef = inject(DialogRef) sending = false printer?: ApiPrinterAdmin @@ -31,7 +35,9 @@ export class AdminPrinterSelectComponent { this.data.handler(this.printer!).subscribe({ next: () => { this.sending = false - this.dialogRef.close(true) + this.dialogRef.close({ + completed: true, + }) }, error: () => { this.sending = false diff --git a/frontend/src/admin/printer/admin-printer-text.component.html b/frontend/src/admin/printer/admin-printer-text-modal.component.html similarity index 100% rename from frontend/src/admin/printer/admin-printer-text.component.html rename to frontend/src/admin/printer/admin-printer-text-modal.component.html diff --git a/frontend/src/admin/printer/admin-printer-text.component.ts b/frontend/src/admin/printer/admin-printer-text-modal.component.ts similarity index 76% rename from frontend/src/admin/printer/admin-printer-text.component.ts rename to frontend/src/admin/printer/admin-printer-text-modal.component.ts index 417cd6fa..a33caa8d 100755 --- a/frontend/src/admin/printer/admin-printer-text.component.ts +++ b/frontend/src/admin/printer/admin-printer-text-modal.component.ts @@ -6,14 +6,18 @@ import { PageService } from "../../common/page.service" import { AdminPrinterSelectboxComponent } from "./admin-printer-selectbox.component" import { AdminPrinterService } from "./admin-printer.service" +export interface AdminPrinterTextModalResult { + completed: true +} + @Component({ - selector: "billett-admin-printer-text", + selector: "billett-admin-printer-text-modal", standalone: true, imports: [AdminPrinterSelectboxComponent, FormsModule], - templateUrl: "./admin-printer-text.component.html", + templateUrl: "./admin-printer-text-modal.component.html", }) -export class AdminPrinterTextComponent { - private dialogRef = inject(DialogRef) +export class AdminPrinterTextModal { + private dialogRef = inject(DialogRef) private adminPrinterService = inject(AdminPrinterService) private pageService = inject(PageService) @@ -29,7 +33,9 @@ export class AdminPrinterTextComponent { next: () => { this.sending = false this.pageService.toast("Utskrift lagt i kø", { class: "success" }) - this.dialogRef.close(true) + this.dialogRef.close({ + completed: true, + }) }, error: () => { this.sending = false diff --git a/frontend/src/admin/printer/admin-printer.service.ts b/frontend/src/admin/printer/admin-printer.service.ts index 2d7388b7..8e55eae0 100755 --- a/frontend/src/admin/printer/admin-printer.service.ts +++ b/frontend/src/admin/printer/admin-printer.service.ts @@ -8,10 +8,14 @@ import { ApiTicketgroupAdmin, } from "../../apitypes" import { - AdminPrinterSelectComponent, - AdminPrinterSelectComponentInput, -} from "./admin-printer-select.component" -import { AdminPrinterTextComponent } from "./admin-printer-text.component" + AdminPrinterSelectInput, + AdminPrinterSelectModal, + AdminPrinterSelectResult, +} from "./admin-printer-select-modal.component" +import { + AdminPrinterTextModal, + AdminPrinterTextModalResult, +} from "./admin-printer-text-modal.component" @Injectable({ providedIn: "root", @@ -24,17 +28,17 @@ export class AdminPrinterService { return this.http.get(api("printer")) } - printSelectModal(data: AdminPrinterSelectComponentInput) { - return this.dialog.open( - AdminPrinterSelectComponent, + openPrinterSelectModal(data: AdminPrinterSelectInput) { + return this.dialog.open( + AdminPrinterSelectModal, { data, }, - ).closed + ) } - printTextModal() { - return this.dialog.open(AdminPrinterTextComponent).closed + openPrintTextModal() { + return this.dialog.open(AdminPrinterTextModal) } printTickets(printer: ApiPrinterAdmin, tickets: ApiTicketAdmin[]) { diff --git a/frontend/src/admin/ticket/admin-ticket-revoke.component.html b/frontend/src/admin/ticket/admin-ticket-revoke-modal.component.html similarity index 100% rename from frontend/src/admin/ticket/admin-ticket-revoke.component.html rename to frontend/src/admin/ticket/admin-ticket-revoke-modal.component.html diff --git a/frontend/src/admin/ticket/admin-ticket-revoke.component.ts b/frontend/src/admin/ticket/admin-ticket-revoke-modal.component.ts similarity index 77% rename from frontend/src/admin/ticket/admin-ticket-revoke.component.ts rename to frontend/src/admin/ticket/admin-ticket-revoke-modal.component.ts index 154bdead..f9a7c7e9 100755 --- a/frontend/src/admin/ticket/admin-ticket-revoke.component.ts +++ b/frontend/src/admin/ticket/admin-ticket-revoke-modal.component.ts @@ -15,7 +15,7 @@ import { PricePipe } from "../../common/price.pipe" import { AdminPaymentgroupSelectboxComponent } from "../paymentgroup/admin-paymentgroup-selectbox.component" import { AdminTicketService } from "./admin-ticket.service" -export interface AdminTicketRevokeComponentInput { +export interface AdminTicketRevokeModalInput { order: ApiOrderAdmin & { eventgroup: ApiEventgroupAdmin } @@ -25,8 +25,12 @@ export interface AdminTicketRevokeComponentInput { } } +export interface AdminTicketRevokeModalResult { + completed: true +} + @Component({ - selector: "billett-admin-ticket-revoke", + selector: "billett-admin-ticket-revoke-modal", standalone: true, imports: [ FormsModule, @@ -35,15 +39,15 @@ export interface AdminTicketRevokeComponentInput { PricePipe, AdminPaymentgroupSelectboxComponent, ], - templateUrl: "./admin-ticket-revoke.component.html", + templateUrl: "./admin-ticket-revoke-modal.component.html", }) -export class AdminTicketRevokeComponent { +export class AdminTicketRevokeModal { constructor( @Inject(DIALOG_DATA) - public data: AdminTicketRevokeComponentInput, + public data: AdminTicketRevokeModalInput, ) {} - private dialogRef = inject(DialogRef) + private dialogRef = inject(DialogRef) private adminTicketService = inject(AdminTicketService) sending = false @@ -57,7 +61,9 @@ export class AdminTicketRevokeComponent { .subscribe({ next: () => { this.sending = false - this.dialogRef.close(true) + this.dialogRef.close({ + completed: true, + }) }, error: (err) => { this.sending = false diff --git a/frontend/src/admin/ticket/admin-ticket.service.ts b/frontend/src/admin/ticket/admin-ticket.service.ts index 78b5a2ee..d15b2108 100644 --- a/frontend/src/admin/ticket/admin-ticket.service.ts +++ b/frontend/src/admin/ticket/admin-ticket.service.ts @@ -2,11 +2,12 @@ import { Dialog } from "@angular/cdk/dialog" import { HttpClient } from "@angular/common/http" import { inject, Injectable } from "@angular/core" import { api } from "../../api" -import { ApiPaymentgroupAdmin, ApiTicketAdmin } from "../../apitypes" +import { ApiPaymentgroupAdmin } from "../../apitypes" import { - AdminTicketRevokeComponent, - AdminTicketRevokeComponentInput, -} from "./admin-ticket-revoke.component" + AdminTicketRevokeModal, + AdminTicketRevokeModalInput, + AdminTicketRevokeModalResult, +} from "./admin-ticket-revoke-modal.component" @Injectable({ providedIn: "root", @@ -45,12 +46,12 @@ export class AdminTicketService { ) } - revokeModal(data: AdminTicketRevokeComponentInput) { - return this.dialog.open( - AdminTicketRevokeComponent, - { - data, - }, - ).closed + openRevokeModal(data: AdminTicketRevokeModalInput) { + return this.dialog.open< + AdminTicketRevokeModalResult, + AdminTicketRevokeModalInput + >(AdminTicketRevokeModal, { + data, + }) } } diff --git a/frontend/src/admin/ticketgroup/admin-ticketgroup-add-to-order.component.html b/frontend/src/admin/ticketgroup/admin-ticketgroup-add-to-order-modal.component.html similarity index 100% rename from frontend/src/admin/ticketgroup/admin-ticketgroup-add-to-order.component.html rename to frontend/src/admin/ticketgroup/admin-ticketgroup-add-to-order-modal.component.html diff --git a/frontend/src/admin/ticketgroup/admin-ticketgroup-add-to-order.component.scss b/frontend/src/admin/ticketgroup/admin-ticketgroup-add-to-order-modal.component.scss similarity index 100% rename from frontend/src/admin/ticketgroup/admin-ticketgroup-add-to-order.component.scss rename to frontend/src/admin/ticketgroup/admin-ticketgroup-add-to-order-modal.component.scss diff --git a/frontend/src/admin/ticketgroup/admin-ticketgroup-add-to-order.component.ts b/frontend/src/admin/ticketgroup/admin-ticketgroup-add-to-order-modal.component.ts similarity index 84% rename from frontend/src/admin/ticketgroup/admin-ticketgroup-add-to-order.component.ts rename to frontend/src/admin/ticketgroup/admin-ticketgroup-add-to-order-modal.component.ts index d579713e..517fb25a 100755 --- a/frontend/src/admin/ticketgroup/admin-ticketgroup-add-to-order.component.ts +++ b/frontend/src/admin/ticketgroup/admin-ticketgroup-add-to-order-modal.component.ts @@ -3,7 +3,11 @@ import { NgClass } from "@angular/common" import { Component, inject, Inject, OnInit } from "@angular/core" import { FormsModule } from "@angular/forms" import { RouterLink } from "@angular/router" -import { ApiEventAdmin, ApiTicketgroupAdmin } from "../../apitypes" +import { + ApiEventAdmin, + ApiTicketAdmin, + ApiTicketgroupAdmin, +} from "../../apitypes" import { FormatdatePipe } from "../../common/formatdate.pipe" import { PagePropertyComponent } from "../../common/page-property.component" import { PricePipe } from "../../common/price.pipe" @@ -13,13 +17,15 @@ import { } from "../eventgroup/admin-eventgroup.service" import { AdminOrderService } from "../order/admin-order.service" -export interface AdminTicketgroupAddToOrderComponentInput { +export interface AdminTicketgroupAddToOrderModalInput { eventgroupId: number getOrderId: () => Promise } +export type AdminTicketgroupAddToOrderModalResult = ApiTicketAdmin[] + @Component({ - selector: "billett-admin-ticketgroup-add-to-order", + selector: "billett-admin-ticketgroup-add-to-order-modal", standalone: true, imports: [ PagePropertyComponent, @@ -29,16 +35,16 @@ export interface AdminTicketgroupAddToOrderComponentInput { RouterLink, FormatdatePipe, ], - templateUrl: "./admin-ticketgroup-add-to-order.component.html", - styleUrl: "./admin-ticketgroup-add-to-order.component.scss", + templateUrl: "./admin-ticketgroup-add-to-order-modal.component.html", + styleUrl: "./admin-ticketgroup-add-to-order-modal.component.scss", }) -export class AdminTicketgroupAddToOrderComponent implements OnInit { +export class AdminTicketgroupAddToOrderModal implements OnInit { constructor( @Inject(DIALOG_DATA) - public data: AdminTicketgroupAddToOrderComponentInput, + public data: AdminTicketgroupAddToOrderModalInput, ) {} - private dialogRef = inject(DialogRef) + private dialogRef = inject(DialogRef) private adminEventgroupService = inject(AdminEventgroupService) private adminOrderService = inject(AdminOrderService) diff --git a/frontend/src/admin/ticketgroup/admin-ticketgroup.service.ts b/frontend/src/admin/ticketgroup/admin-ticketgroup.service.ts index d6b42fb3..c4e9503d 100755 --- a/frontend/src/admin/ticketgroup/admin-ticketgroup.service.ts +++ b/frontend/src/admin/ticketgroup/admin-ticketgroup.service.ts @@ -5,13 +5,13 @@ import { api } from "../../api" import { ApiEventAdmin, ApiEventgroupAdmin, - ApiTicketAdmin, ApiTicketgroupAdmin, } from "../../apitypes" import { - AdminTicketgroupAddToOrderComponent, - AdminTicketgroupAddToOrderComponentInput, -} from "./admin-ticketgroup-add-to-order.component" + AdminTicketgroupAddToOrderModal, + AdminTicketgroupAddToOrderModalInput, + AdminTicketgroupAddToOrderModalResult, +} from "./admin-ticketgroup-add-to-order-modal.component" export type AdminTicketgroupData = ApiTicketgroupAdmin & { event: ApiEventAdmin & { @@ -59,12 +59,12 @@ export class AdminTicketgroupService { }) } - addTicketsModal(data: AdminTicketgroupAddToOrderComponentInput) { + openAddTicketsModal(data: AdminTicketgroupAddToOrderModalInput) { return this.dialog.open< - ApiTicketAdmin[], - AdminTicketgroupAddToOrderComponentInput - >(AdminTicketgroupAddToOrderComponent, { + AdminTicketgroupAddToOrderModalResult, + AdminTicketgroupAddToOrderModalInput + >(AdminTicketgroupAddToOrderModal, { data, - }).closed + }) } }