Skip to content

Commit

Permalink
fix roles
Browse files Browse the repository at this point in the history
  • Loading branch information
dysTOS committed Dec 9, 2023
1 parent 0d4d61b commit e8b7e8e
Show file tree
Hide file tree
Showing 26 changed files with 918 additions and 649 deletions.
1,230 changes: 790 additions & 440 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
"jspdf-autotable": "^3.5.23",
"moment": "^2.29.1",
"normalize.css": "^8.0.1",
"primeflex": "^3.2.1",
"primeflex": "3.3",
"primeicons": "^6.0.1",
"primeng": "^16.7.2",
"primeng": "^17.0.0",
"prismjs": "^1.27.0",
"rxjs": "^7.4.0",
"subsink": "^1.0.2",
Expand Down Expand Up @@ -68,4 +68,4 @@
"tslint": "~6.1.0",
"typescript": "5.2"
}
}
}
7 changes: 1 addition & 6 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import { EinstellungenWrapperComponent } from "./components/einstellungen/einste
import { MitgliedPersonalEditComponent } from "./components/einstellungen/mitglied-personal-edit/mitglied-personal-edit.component";
import { RollenEditComponent } from "./components/einstellungen/rollen-edit/rollen-edit.component";
import { LokaleEinstellungenComponent } from "./components/einstellungen/lokale-einstellungen/lokale-einstellungen.component";
import { BugReportComponent } from "./components/einstellungen/bug-report/bug-report.component";
import { StatistikOverviewComponent } from "./components/statistik/statistik-overview/statistik-overview.component";
import { NotenEditorComponent } from "./components/archiv/noten/noten-editor/noten-editor.component";
import { InstrumenteOverviewComponent } from "./components/archiv/instrumente/instrumente-overview/instrumente-overview.component";
Expand Down Expand Up @@ -225,6 +224,7 @@ import { KassabuchungEditComponent } from "./components/finanzen/kassabuchung-ed
path: "details/:buchId/:id",
component: KassabuchungEditComponent,
canActivate: [RouteGuard],
canDeactivate: [EditDeactivateGuard],
},
],
},
Expand Down Expand Up @@ -256,11 +256,6 @@ import { KassabuchungEditComponent } from "./components/finanzen/kassabuchung-ed
component: GlobaleEinstellungenComponent,
canActivate: [RouteGuard],
},
{
path: "bugreport",
component: BugReportComponent,
canActivate: [RouteGuard],
},
{
path: "changelog",
component: MkjChangeLogsComponent,
Expand Down
12 changes: 6 additions & 6 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ import { AusrueckungenAktuellComponent } from "./components/ausrueckungen/ausrue
import { AusrueckungenWrapperComponent } from "./components/ausrueckungen/ausrueckungen-wrapper.component";
import { KalenderaboComponent } from "./components/ausrueckungen/kalenderabo/kalenderabo.component";
import { TerminCardComponent } from "./components/ausrueckungen/termin-card/termin-card.component";
import { BugReportComponent } from "./components/einstellungen/bug-report/bug-report.component";
import { EinstellungenWrapperComponent } from "./components/einstellungen/einstellungen-wrapper.component";
import { LokaleEinstellungenComponent } from "./components/einstellungen/lokale-einstellungen/lokale-einstellungen.component";
import { MitgliedPersonalEditComponent } from "./components/einstellungen/mitglied-personal-edit/mitglied-personal-edit.component";
Expand Down Expand Up @@ -189,10 +188,11 @@ import { MkjFormWrapperComponent } from "./utilities/form-components/mkj-form-wr
import { KassabuchungEditComponent } from "./components/finanzen/kassabuchung-edit/kassabuchung-edit.component";
import { AnschriftFormComponent } from "./utilities/form-input-components/anschrift-form/anschrift-form.component";
import { MkjFormErrorPipe } from "./utilities/form-components/mkj-form-wrapper/mkj-form-error.pipe";
import { MkjNumberInputComponent } from './utilities/form-input-components/mkj-number-input/mkj-number-input.component';
import { MkjDropdownComponent } from './utilities/form-input-components/mkj-dropdown/mkj-dropdown.component';
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 { MkjNumberInputComponent } from "./utilities/form-input-components/mkj-number-input/mkj-number-input.component";
import { MkjDropdownComponent } from "./utilities/form-input-components/mkj-dropdown/mkj-dropdown.component";
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";

// FullCalendarModule.registerPlugins([
// dayGridPlugin,
Expand Down Expand Up @@ -294,6 +294,7 @@ registerLocaleData(localeDe);
],
declarations: [
AppComponent,
PermissionSelectedPipe,
AppMainComponent,
AppTopbarComponent,
AppFooterComponent,
Expand Down Expand Up @@ -348,7 +349,6 @@ registerLocaleData(localeDe);
GruppeDetailsComponent,
MkjGruppeFormComponent,
FullNamePipe,
BugReportComponent,
MkjColorPickerComponent,
NotenmappeDetailsComponent,
MkjNotenmappeFormComponent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ export class AusrueckungenAktuellComponent implements OnInit, AfterViewInit {
}

exportCsv() {
this.ausrueckungenTable.exportCSV({ filteredValues: true });
this.ausrueckungenTable.exportCSV();
}

public exportPdf() {
Expand Down

This file was deleted.

Empty file.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Pipe, PipeTransform } from "@angular/core";
import { Permission } from "../../../models/User";

@Pipe({
name: "permissionIncluded",
})
export class PermissionSelectedPipe implements PipeTransform {
transform(value: Permission, permissions: Permission[]) {
return permissions?.some((p) => p.id === value.id);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,68 +16,34 @@
<b>{{ role.name | mkjTextTransform }}</b>
</td>
</tr></ng-template
><ng-template pTemplate="rowexpansion" let-role
><div class="ml-6">
<p-listbox
*ngIf="rolePermissions"
[options]="permissions"
[(ngModel)]="rolePermissions"
[multiple]="true"
[checkbox]="true"
[filter]="false"
filterPlaceHolder="Berechtigung filtern..."
[showToggleAll]="false"
optionLabel="name"
dataKey="id"
>
<ng-template pTemplate="header">
<div
class="col-12 flex justify-content-between align-items-center p-0"
>
<span
>{{ role.name | mkjTextTransform }} -
Berechtigungen</span
>
<div>
<p-button
label="Update"
[icon]="
isSaving
? 'pi pi-spin pi-spinner'
: 'pi pi-save'
"
class="m-2"
[disabled]="isSaving"
(click)="saveRolePermissions()"
></p-button>
<p-button
icon="pi pi-trash"
styleClass="p-button-danger p-button-outlined p-button-sm ml-2"
label="Rolle löschen"
[disabled]="isSaving"
(click)="deleteRole(role)"
></p-button>
</div></div
></ng-template>
<ng-template let-permission pTemplate="item">
<div>
<div>
{{ permission.name | mkjTextTransform }}
</div>
</div>
</ng-template>
</p-listbox>
><ng-template pTemplate="rowexpansion" let-role>
<mkj-content-loader [loading]="!rolePermissions">
<div class="col-12 m-4 flex justify-content-between">
<h4>Berechtigungen</h4>
<button
pButton
pRipple
label="Speichern"
class="p-button-text"
(click)="saveRolePermissions()"
></button>
</div>
<div
*ngIf="!rolePermissions"
class="flex justify-content-center align-items-center"
style="height: 250px"
*ngFor="let permission of permissions"
class="col-12 flex justify-content-between permission-row"
(click)="togglePermission(permission)"
>
<i
class="pi pi-spin pi-spinner"
style="font-size: 2rem"
*ngIf="
permission | permissionIncluded : rolePermissions
"
class="pi pi-check"
></i>
</div></div></ng-template
></p-table>
<span>{{ permission.name | mkjTextTransform }}</span>
</div>
</mkj-content-loader>
</ng-template></p-table
>
</div>

<p-dialog
Expand All @@ -98,26 +64,17 @@
required
/>

<p-listbox
[options]="permissions"
[(ngModel)]="rolePermissions"
[multiple]="true"
[checkbox]="true"
[filter]="false"
[showToggleAll]="false"
optionLabel="name"
dataKey="id"
required
<div
*ngFor="let permission of permissions"
class="col-12 flex justify-content-between permission-row"
(click)="togglePermission(permission)"
>
<ng-template pTemplate="header"> Berechtigungen </ng-template>
<ng-template let-permission pTemplate="item">
<div>
<div>
{{ permission.name | mkjTextTransform }}
</div>
</div>
</ng-template>
</p-listbox>
<i
*ngIf="permission | permissionIncluded : rolePermissions"
class="pi pi-check"
></i>
<span>{{ permission.name | mkjTextTransform }}</span>
</div>
</ng-template>

<ng-template pTemplate="footer">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.permission-row {
cursor: pointer;

&:hover {
opacity: 0.8;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export class RollenEditComponent implements OnInit {
{
label: "Neue Rolle",
click: () => {
this.rolePermissions = [];
this.addDialogVisible = true;
},
icon: "pi pi-plus",
Expand Down Expand Up @@ -147,4 +148,15 @@ export class RollenEditComponent implements OnInit {
},
});
}

public togglePermission(permission: Permission): void {
if (this.rolePermissions.some((p) => p.id === permission.id)) {
this.rolePermissions = this.rolePermissions.filter(
(p) => p.id !== permission.id
);
} else {
this.rolePermissions.push(permission);
this.rolePermissions = [...this.rolePermissions];
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Component, OnInit } from "@angular/core";
import { ActivatedRoute, Router } from "@angular/router";
import { BehaviorSubject } from "rxjs";
import { Kassabuch, KassabuchungTyp } from "src/app/models/Kassabuch";
import { PermissionMap } from "src/app/models/User";
import { KassabuchApiService } from "src/app/services/api/kassabuch-api.service";
import { MkjToolbarService } from "src/app/utilities/mkj-toolbar/mkj-toolbar.service";

Expand Down Expand Up @@ -38,6 +39,7 @@ export class KassabuchDetailsComponent implements OnInit {
],
{ relativeTo: this.route }
),
permissions: [PermissionMap.KASSABUCH_SAVE],
},
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,26 @@
formControlName="bezahltDatum"
></mkj-date-input>
</div>
<div class="p-field col-12 lg:col-3 md:col-6">
<div class="p-field col-12">
<mkj-text-area-input
label="Anmerkungen"
formControlName="anmerkungen"
></mkj-text-area-input>
</div>
</div>
<p-divider></p-divider>
<div class="p-field col-12">
<p-divider align="left" type="solid">
<div class="inline-flex align-items-center">
<i class="pi pi-user mr-2"></i>
<b class="mr-2">Kontrahent</b>
<p *ngIf="formGroup.controls.anschrift_id.value">
(aus System)
</p>
<p *ngIf="!formGroup.controls.anschrift_id.value">
(Neuanlage)
</p>
</div>
</p-divider>
</div>
<mkj-anschrift-form formControlName="anschrift"></mkj-anschrift-form>
</mkj-form-wrapper>
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
import { ActivatedRoute, Router } from "@angular/router";
import { UtilFunctions } from "src/app/helpers/util-functions";
import { Kassabuchung, KassabuchungTyp } from "src/app/models/Kassabuch";
import { PermissionMap } from "src/app/models/User";
import { KassabuchungenApiService } from "src/app/services/api/kassabuchungen-api.service";
import { InfoService } from "src/app/services/info.service";
import { AbstractFormComponent } from "src/app/utilities/form-components/_abstract-form-component.class";
Expand Down Expand Up @@ -39,6 +40,7 @@ export class KassabuchungEditComponent extends AbstractFormComponent<Kassabuchun
click: () => {
this.delete();
},
permissions: [PermissionMap.KASSABUCHUNG_DELETE],
},
];
this._subSink.add(
Expand Down
Loading

0 comments on commit e8b7e8e

Please sign in to comment.