diff --git a/frontend/src/app/modules/members/components/member-contacts/member-contacts.component.html b/frontend/src/app/modules/members/components/member-contacts/member-contacts.component.html index 700b1da4..a063faad 100644 --- a/frontend/src/app/modules/members/components/member-contacts/member-contacts.component.html +++ b/frontend/src/app/modules/members/components/member-contacts/member-contacts.component.html @@ -1,4 +1,4 @@ -

Kontakty

+

Kontakty rodiče

@for (contact of contacts; track $index) { @@ -54,22 +54,3 @@

Kontakty

Přidat kontakt - -

Adresa

- - - - - - - {{ getFullAddress(member) }} - Adresa není vyplněna - - - - - - - - - diff --git a/frontend/src/app/modules/members/components/member-contacts/member-contacts.component.scss b/frontend/src/app/modules/members/components/member-contacts/member-contacts.component.scss index 0df1851f..57d941e8 100644 --- a/frontend/src/app/modules/members/components/member-contacts/member-contacts.component.scss +++ b/frontend/src/app/modules/members/components/member-contacts/member-contacts.component.scss @@ -5,9 +5,3 @@ ion-list { padding: 0; } - -.address { - ion-label { - white-space: pre-wrap; - } -} diff --git a/frontend/src/app/modules/members/components/member-contacts/member-contacts.component.ts b/frontend/src/app/modules/members/components/member-contacts/member-contacts.component.ts index e91be92a..2a0e1ebe 100644 --- a/frontend/src/app/modules/members/components/member-contacts/member-contacts.component.ts +++ b/frontend/src/app/modules/members/components/member-contacts/member-contacts.component.ts @@ -37,6 +37,76 @@ export default class MemberContactsComponent implements OnChanges { } } + async editAddress() { + const data = await this.modalService.inputModal({ + header: "Upravit adresu", + inputs: { + addressStreet: { + type: "text", + placeholder: "Ulice", + value: this.member?.addressStreet, + }, + addressStreetNo: { + type: "text", + placeholder: "Číslo popisné", + value: this.member?.addressStreetNo, + }, + addressCity: { + type: "text", + placeholder: "Město", + value: this.member?.addressCity, + }, + addressPostalCode: { + type: "text", + placeholder: "PSČ", + value: this.member?.addressPostalCode, + }, + addressCountry: { + type: "text", + placeholder: "Země", + value: this.member?.addressCountry, + }, + }, + }); + + if (data) this.update.emit(data); + } + + getFullAddress(member: MemberResponseWithLinks) { + const addressLines = [ + `${member.addressStreet ?? ""}${member.addressStreetNo ? ` ${member.addressStreetNo}` : ""}`, + member.addressCity, + member.addressPostalCode, + ]; + + if (member.addressCountry) { + addressLines.push(member.addressCountry); + } + return addressLines.filter((line) => !!line).join("\n"); + } + + async editMobile() { + const data = await this.modalService.inputModal({ + header: "Upravit telefonní číslo", + inputs: { + mobile: { type: "tel", placeholder: "Telefonní číslo", value: this.member?.mobile }, + }, + }); + + if (data !== null) this.update.emit(data); + } + + async editEmail() { + const data = await this.modalService.inputModal({ + header: "Upravit email", + inputs: { + email: { type: "email", placeholder: "Email", value: this.member?.email }, + }, + }); + + if (data !== null) this.update.emit(data); + } + async openContactForm(contact: MemberContactResponseWithLinks | null) { const buttons: AlertButton[] = [ { @@ -126,57 +196,16 @@ export default class MemberContactsComponent implements OnChanges { } async deleteContact(contact: MemberContactResponseWithLinks) { + if (!this.member) return; + const confirmation = await this.modalService.deleteConfirmationModal( `Opravdu chcete smazat kontakt ${contact.title}?`, ); - console.log(confirmation); - } - - async openAddressForm() { - const data = await this.modalService.inputModal({ - header: "Upravit adresu", - inputs: { - addressStreet: { - type: "text", - placeholder: "Ulice", - value: this.member?.addressStreet, - }, - addressStreetNo: { - type: "text", - placeholder: "Číslo popisné", - value: this.member?.addressStreetNo, - }, - addressCity: { - type: "text", - placeholder: "Město", - value: this.member?.addressCity, - }, - addressPostalCode: { - type: "text", - placeholder: "PSČ", - value: this.member?.addressPostalCode, - }, - addressCountry: { - type: "text", - placeholder: "Země", - value: this.member?.addressCountry, - }, - }, - }); - if (data) this.update.emit(data); - } + await this.api.members.deleteContact(this.member.id, contact.id); - getFullAddress(member: MemberResponseWithLinks) { - const addressLines = [ - `${member.addressStreet ?? ""}${member.addressStreetNo ? ` ${member.addressStreetNo}` : ""}`, - member.addressCity, - member.addressPostalCode, - ]; + await this.loadContacts(this.member.id); - if (member.addressCountry) { - addressLines.push(member.addressCountry); - } - return addressLines.filter((line) => !!line).join("\n"); + await this.toastService.toast("Kontakt byl smazán", { color: "danger" }); } } diff --git a/frontend/src/app/modules/members/components/member-info/member-info.component.html b/frontend/src/app/modules/members/components/member-info/member-info.component.html index 0602a3d5..61307e92 100644 --- a/frontend/src/app/modules/members/components/member-info/member-info.component.html +++ b/frontend/src/app/modules/members/components/member-info/member-info.component.html @@ -1,4 +1,4 @@ -

Základní informace

+

Osobní informace

@@ -12,8 +12,37 @@

Základní informace

{{ member.birthday ? (member.birthday | date: "d. M. y") : "-" }} + + + {{ member.mobile || "-" }} + + + + + {{ member.email || "-" }} + +
+

Adresa

+ + + + + + + {{ getFullAddress(member) }} + Adresa není vyplněna + + + + + + + + + +

Členství ve skupině

diff --git a/frontend/src/app/modules/members/components/member-info/member-info.component.scss b/frontend/src/app/modules/members/components/member-info/member-info.component.scss index 91fb8bea..ff7d3cb0 100644 --- a/frontend/src/app/modules/members/components/member-info/member-info.component.scss +++ b/frontend/src/app/modules/members/components/member-info/member-info.component.scss @@ -4,3 +4,9 @@ ion-list { bo-item { --label-width: 120px; } + +.address { + ion-label { + white-space: pre-wrap; + } +} diff --git a/frontend/src/app/modules/members/components/member-info/member-info.component.ts b/frontend/src/app/modules/members/components/member-info/member-info.component.ts index 375a1223..ecb1bcc9 100644 --- a/frontend/src/app/modules/members/components/member-info/member-info.component.ts +++ b/frontend/src/app/modules/members/components/member-info/member-info.component.ts @@ -57,6 +57,76 @@ export class MemberInfoComponent implements OnInit { if (data !== null) this.update.emit(data); } + async editMobile() { + const data = await this.modalService.inputModal({ + header: "Upravit telefonní číslo", + inputs: { + mobile: { type: "tel", placeholder: "Telefonní číslo", value: this.member?.mobile }, + }, + }); + + if (data !== null) this.update.emit(data); + } + + async editEmail() { + const data = await this.modalService.inputModal({ + header: "Upravit email", + inputs: { + email: { type: "email", placeholder: "Email", value: this.member?.email }, + }, + }); + + if (data !== null) this.update.emit(data); + } + + async editAddress() { + const data = await this.modalService.inputModal({ + header: "Upravit adresu", + inputs: { + addressStreet: { + type: "text", + placeholder: "Ulice", + value: this.member?.addressStreet, + }, + addressStreetNo: { + type: "text", + placeholder: "Číslo popisné", + value: this.member?.addressStreetNo, + }, + addressCity: { + type: "text", + placeholder: "Město", + value: this.member?.addressCity, + }, + addressPostalCode: { + type: "text", + placeholder: "PSČ", + value: this.member?.addressPostalCode, + }, + addressCountry: { + type: "text", + placeholder: "Země", + value: this.member?.addressCountry, + }, + }, + }); + + if (data) this.update.emit(data); + } + + getFullAddress(member: MemberResponseWithLinks) { + const addressLines = [ + `${member.addressStreet ?? ""}${member.addressStreetNo ? ` ${member.addressStreetNo}` : ""}`, + member.addressCity, + member.addressPostalCode, + ]; + + if (member.addressCountry) { + addressLines.push(member.addressCountry); + } + return addressLines.filter((line) => !!line).join("\n"); + } + async editActivity() { const result = await this.modalService.selectModal({ header: "Změnit aktivitu", diff --git a/frontend/src/app/shared/components/icon-button/icon-button.component.html b/frontend/src/app/shared/components/icon-button/icon-button.component.html new file mode 100644 index 00000000..fe3ced43 --- /dev/null +++ b/frontend/src/app/shared/components/icon-button/icon-button.component.html @@ -0,0 +1,4 @@ + + + {{ label }} + diff --git a/frontend/src/app/shared/components/icon-button/icon-button.component.scss b/frontend/src/app/shared/components/icon-button/icon-button.component.scss new file mode 100644 index 00000000..157c45fb --- /dev/null +++ b/frontend/src/app/shared/components/icon-button/icon-button.component.scss @@ -0,0 +1,3 @@ +ion-button { + font-size: 10px; +} diff --git a/frontend/src/app/shared/components/icon-button/icon-button.component.ts b/frontend/src/app/shared/components/icon-button/icon-button.component.ts new file mode 100644 index 00000000..a7e2e21f --- /dev/null +++ b/frontend/src/app/shared/components/icon-button/icon-button.component.ts @@ -0,0 +1,23 @@ +import { Component, Input } from "@angular/core"; + +@Component({ + selector: "bo-icon-button", + templateUrl: "./icon-button.component.html", + styleUrl: "./icon-button.component.scss", +}) +export class IconButtonComponent { + @Input() label?: string; + @Input() icon?: string; + @Input() href?: string; + + constructor() {} + + onClick(event: Event) { + event.preventDefault(); + event.stopPropagation(); + + if (this.href) { + window.location.href = this.href; + } + } +} diff --git a/frontend/src/app/shared/shared.module.ts b/frontend/src/app/shared/shared.module.ts index 43ca48a3..2303b8f0 100644 --- a/frontend/src/app/shared/shared.module.ts +++ b/frontend/src/app/shared/shared.module.ts @@ -44,6 +44,7 @@ import { CopyButtonComponent } from "./components/copy-button/copy-button.compon import { DeleteButtonComponent } from "./components/delete-button/delete-button.component"; import { FilterModalComponent } from "./components/filter-modal/filter-modal.component"; import { GroupBadgeComponent } from "./components/group-badge/group-badge.component"; +import { IconButtonComponent } from "./components/icon-button/icon-button.component"; import { ItemComponent } from "./components/item/item.component"; import { ModalLayoutComponent } from "./components/modal-layout/modal-layout.component"; import { ModalTemplateComponent } from "./components/modal-template/modal-template.component"; @@ -102,6 +103,7 @@ register(); RolePipe, FilterModalComponent, ModalTemplateComponent, + IconButtonComponent, ], exports: [ FormsModule, @@ -153,6 +155,7 @@ register(); DeleteButtonComponent, RolePipe, ModalTemplateComponent, + IconButtonComponent, ], providers: [DatePipe], })