Skip to content

Commit

Permalink
create anschriften-components
Browse files Browse the repository at this point in the history
  • Loading branch information
dysTOS committed Dec 12, 2023
1 parent da15a82 commit 5ddc863
Show file tree
Hide file tree
Showing 13 changed files with 163 additions and 16 deletions.
13 changes: 13 additions & 0 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ import { FinanzenWrapperComponent } from "./components/finanzen/finanzen-wrapper
import { KassabuchDetailsComponent } from "./components/finanzen/kassabuch-details/kassabuch-details.component";
import { KassabuchEditComponent } from "./components/finanzen/kassabuch-edit/kassabuch-edit.component";
import { KassabuchungEditComponent } from "./components/finanzen/kassabuchung-edit/kassabuchung-edit.component";
import { AnschriftenOverviewComponent as AnschriftOverviewComponent } from "./components/anschriften/anschriften-overview/anschriften-overview.component";
import { AnschriftEditComponent as AnschriftEditComponent } from "./components/anschriften/anschriften-edit/anschriften-edit.component";

@NgModule({
imports: [
Expand Down Expand Up @@ -226,6 +228,17 @@ import { KassabuchungEditComponent } from "./components/finanzen/kassabuchung-ed
canActivate: [RouteGuard],
canDeactivate: [EditDeactivateGuard],
},
{
path: "adressen",
component: AnschriftOverviewComponent,
canActivate: [RouteGuard],
},
{
path: "adressen/:id",
component: AnschriftEditComponent,
canActivate: [RouteGuard],
canDeactivate: [EditDeactivateGuard],
},
],
},
{
Expand Down
4 changes: 4 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ import { MkjDropdownComponent } from "./utilities/form-input-components/mkj-drop
import { MkjTextAreaInputComponent } from "./utilities/form-input-components/mkj-text-area-input/mkj-text-area-input.component";
import { MkjTagComponent } from "./utilities/mkj-tag/mkj-tag.component";
import { PermissionSelectedPipe } from "./components/einstellungen/rollen-edit/permission-included.pipe";
import { AnschriftenOverviewComponent as AnschriftOverviewComponent } from "./components/anschriften/anschriften-overview/anschriften-overview.component";
import { AnschriftEditComponent } from "./components/anschriften/anschriften-edit/anschriften-edit.component";

// FullCalendarModule.registerPlugins([
// dayGridPlugin,
Expand Down Expand Up @@ -293,6 +295,8 @@ registerLocaleData(localeDe);
declarations: [
AppComponent,
PermissionSelectedPipe,
AnschriftOverviewComponent,
AnschriftEditComponent,
AppMainComponent,
AppTopbarComponent,
AppFooterComponent,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<mkj-form-wrapper [formGroup]="formGroup" [component]="this">
<mkj-anschrift-form [formControl]="formGroup"></mkj-anschrift-form>
</mkj-form-wrapper>
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { Component } from "@angular/core";
import { FormControl, FormGroup } from "@angular/forms";
import { ActivatedRoute, Router } from "@angular/router";
import { Anschrift } from "src/app/models/Anschrift";
import { PermissionMap } from "src/app/models/User";
import { AnschriftenApiService } from "src/app/services/api/anschriften-api.service";
import { InfoService } from "src/app/services/info.service";
import { AbstractFormComponent } from "src/app/utilities/form-components/_abstract-form-component.class";
import { MkjToolbarService } from "src/app/utilities/mkj-toolbar/mkj-toolbar.service";

@Component({
selector: "app-anschriften-edit",
templateUrl: "./anschriften-edit.component.html",
styleUrl: "./anschriften-edit.component.scss",
})
export class AnschriftEditComponent extends AbstractFormComponent<Anschrift> {
protected navigateBackOnSave = true;

constructor(
toolbarService: MkjToolbarService,
apiService: AnschriftenApiService,
infoService: InfoService,
route: ActivatedRoute,
router: Router
) {
super(toolbarService, apiService, infoService, route, router);
}

protected initToolbar(): void {
this.toolbarService.backButton = true;

if (this.getId() !== "new") {
this.toolbarService.header = "Adresse bearbeiten";
this.toolbarService.buttons = [
{
label: "Adresse Löschen",
icon: "pi pi-trash",
click: () => this.delete(),
permissions: [PermissionMap.ANSCHRIFTEN_DELETE],
},
];
} else {
this.toolbarService.header = "Neue Adresse";
}
}
protected initFormGroup(): FormGroup<any> {
return new FormControl(null) as unknown as FormGroup<any>;
}
protected getId(): string {
return this.route.snapshot.params.id;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<mkj-content-loader [loading]="!adressen">
<div
*ngFor="let add of adressen"
class="col-12 flex justify-content-between border-1"
>
<span>{{ add.vorname }} {{ add.zuname }}{{ add.firma }}</span>
<button
pButton
icon="pi pi-pencil"
class="p-button-text p-button-small"
[routerLink]="add.id"
></button>
</div>
</mkj-content-loader>
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Component } from "@angular/core";
import { ActivatedRoute, Router } from "@angular/router";
import { Anschrift } from "src/app/models/Anschrift";
import { PermissionMap } from "src/app/models/User";
import { AnschriftenApiService } from "src/app/services/api/anschriften-api.service";
import { MkjToolbarService } from "src/app/utilities/mkj-toolbar/mkj-toolbar.service";

@Component({
selector: "app-anschriften-overview",
templateUrl: "./anschriften-overview.component.html",
styleUrl: "./anschriften-overview.component.scss",
})
export class AnschriftenOverviewComponent {
public adressen: Anschrift[];

constructor(
private apiService: AnschriftenApiService,
private toolbarService: MkjToolbarService,
private router: Router,
private route: ActivatedRoute
) {
apiService.getList().subscribe((list) => {
this.adressen = list.values;
});
toolbarService.header = "Adressen";
toolbarService.buttons = [
{
icon: "pi pi-plus",
routerLink: "/new",
click: () =>
this.router.navigate(["new"], {
relativeTo: this.route,
}),
permissions: [PermissionMap.ANSCHRIFTEN_SAVE],
},
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,8 @@
</div>
</p-divider>
</div>
<mkj-anschrift-form formControlName="anschrift"></mkj-anschrift-form>
<mkj-anschrift-form
mode="suggest"
formControlName="anschrift"
></mkj-anschrift-form>
</mkj-form-wrapper>
6 changes: 6 additions & 0 deletions src/app/services/menu.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ export class MenuService implements OnDestroy {
permission: PermissionMap.KASSABUCH_READ,
visible: false,
},
{
label: "Adressen",
icon: "pi pi-fw pi-users",
routerLink: "finanzen/adressen",
permission: PermissionMap.ANSCHRIFTEN_READ,
},
],
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
</div>
<div class="p-field col-12">
<p-messages
*ngIf="formControl?.errors"
*ngIf="formControl?.errors && mode !== 'edit'"
[value]="formControl.errors | mkjFormError"
[closeable]="false"
[enableService]="false"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Injector, ViewChild } from "@angular/core";
import { Component, Injector, Input, ViewChild } from "@angular/core";
import {
AbstractControl,
FormBuilder,
Expand All @@ -12,6 +12,7 @@ import {
debounceTime,
distinctUntilChanged,
merge,
takeWhile,
tap,
} from "rxjs";
import { Anschrift } from "src/app/models/Anschrift";
Expand All @@ -34,6 +35,9 @@ export class AnschriftFormComponent
extends AbstractControlAccessor<Anschrift>
implements Validator
{
@Input()
public mode: "edit" | "suggest" = "edit";

@ViewChild("op")
private overlayPanel: OverlayPanel;
@ViewChild("opTarget")
Expand Down Expand Up @@ -63,10 +67,12 @@ export class AnschriftFormComponent
}
}),
this.internalFormGroup.valueChanges.subscribe((value) => {
value.id = null;
this.internalFormGroup.controls.id.patchValue(null, {
emitEvent: false,
});
if (this.mode === "suggest") {
value.id = null;
this.internalFormGroup.controls.id.patchValue(null, {
emitEvent: false,
});
}
this.touch();
this.change(value);
}),
Expand All @@ -76,6 +82,7 @@ export class AnschriftFormComponent
this.internalFormGroup.controls.firma.valueChanges
)
.pipe(
takeWhile(() => this.mode === "suggest"),
tap((_) => {
this.suggestions = [];
this.overlayPanel?.hide();
Expand Down
25 changes: 16 additions & 9 deletions src/configurations/changeLogVersion.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const MkjAppVersion = "0.8.3 - ALPHA";
export const MkjAppVersion = "0.9.1 - BETA";

export interface MkjAppChangeLog {
date: string;
Expand All @@ -7,14 +7,21 @@ export interface MkjAppChangeLog {
}

export const MkjAppChangeLog: MkjAppChangeLog[] = [
// {
// date: "x",
// version: "0.9.1 - BETA",
// changes: {
// Environments: "Die App kann nun automatisiert für verschiedene Umgebungen/Vereine/Bands ausgeliefert werden.",
// Einstellungen: "Globale Einstellungen ermöglichen dem Administrator die Konfiguration des ganzen Environments.",
// }
// },
{
date: "01.01.2024",
version: "0.9.1 - BETA",
changes: {
Environments:
"Die App kann nun automatisiert für verschiedene Umgebungen/Vereine/Bands ausgeliefert werden.",
Einstellungen:
"Globale Einstellungen ermöglichen dem Administrator die Konfiguration der App (Benennung der Menüpunkte, Dropdown-Optionen).",
Kassabücher:
"Es können nun Kassabücher erstellt/verwaltet und Gruppen zugeordnet werden.",
Adressen:
"Es können nun beliebig viele Adressen angelegt werden. Dieser Adressen werden u.a. für die Kassabuchungen verwendet.",
UI: "Verbesserungen der Benutzeroberfläche.",
},
},
{
date: "24. Juni 2023",
version: "0.8.3 - ALPHA",
Expand Down

0 comments on commit 5ddc863

Please sign in to comment.