This commit is contained in:
2023-07-23 20:27:23 +03:00
parent d0cdaa85b6
commit 96eca795ab
62 changed files with 2934 additions and 847 deletions
@@ -30,11 +30,12 @@
<tr *ngFor="let account of accountInCategory(category)">
<td>{{account.name}}</td>
<td>{{account.currencyId}}</td>
<td>{{account.type}}</td>
<td>
<button class="btn-space " (click)="edit(account)" mat-raised-button color="primary">
<button class="btn-space" (click)="edit(account)" mat-raised-button color="primary">
Edit
</button>
<button class="btn-space " (click)="remove(account)" mat-raised-button color="primary">
<button class="btn-space" *ngIf="account.allowDelete" (click)="remove(account)" mat-raised-button color="primary">
Delete
</button>
</td>
@@ -48,11 +49,12 @@
<tr *ngFor="let account of accountInCategory()">
<td>{{account.name}}</td>
<td>{{account.currencyId}}</td>
<td>{{account.type}}</td>
<td>
<button class="btn-space " (click)="edit(account)" mat-raised-button color="primary">
<button class="btn-space" (click)="edit(account)" mat-raised-button color="primary">
Edit
</button>
<button class="btn-space " (click)="remove(account)" mat-raised-button color="primary">
<button class="btn-space" *ngIf="account.allowDelete" (click)="remove(account)" mat-raised-button color="primary">
Delete
</button>
</td>
@@ -67,10 +69,10 @@
<td>{{account.name}}</td>
<td>{{account.currencyId}}</td>
<td>
<button class="btn-space " (click)="edit(account)" mat-raised-button color="primary">
<button class="btn-space" (click)="edit(account)" mat-raised-button color="primary">
Edit
</button>
<button class="btn-space " (click)="remove(account)" mat-raised-button color="primary">
<button class="btn-space" *ngIf="account.allowDelete" (click)="remove(account)" mat-raised-button color="primary">
Delete
</button>
</td>
@@ -81,15 +81,15 @@ export class SettingsAccountComponent {
});
}
public remove(category: AccountModel) {
/*Swal.fire({
title: 'Remove account category ' + category.name,
public remove(account: AccountModel) {
Swal.fire({
title: 'Remove account ' + account.name,
showCancelButton: true,
confirmButtonText: 'Add',
confirmButtonText: 'Delete',
showLoaderOnConfirm: true,
preConfirm: (name) => {
return new Promise((resolve, reject) => {
this.httpClient.delete(ApiRoutes.SettingsAccountCategory.replace(':id', category.id!))
this.httpClient.delete(ApiRoutes.SettingsAccount.replace(':id', account.id!))
.subscribe(data => {
resolve(data);
}, error => {
@@ -103,7 +103,7 @@ export class SettingsAccountComponent {
},
allowOutsideClick: () => !Swal.isLoading(),
}).then((result) => {
this.load();
});*/
this.loadAccounts();
});
}
}
@@ -4,6 +4,22 @@
</h2>
<div mat-dialog-content>
<form [formGroup]="editForm!" (ngSubmit)="onSubmitClick()">
<div class="row">
<div class="col-md-12">
<div class="text-inside">
<mat-form-field class="example-full-width">
<mat-label>Type</mat-label>
<mat-select formControlName="type">
<mat-option *ngFor="let type of types | keyvalue" [value]="type.key">
{{type.key}} ({{type.value}})
</mat-option>
</mat-select>
</mat-form-field>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="text-inside">
@@ -19,6 +19,7 @@ import { CurrencyModel } from '../../../model/currency.model';
import { AccountCategoryService } from '../../../services/account.category.service';
import { AccountCategoryModel } from '../../../model/account.category.model';
import { AuthService } from '../../../core/service/auth.service';
import { AccountService } from '../../../services/account.service';
@Component({
templateUrl: './add.account.component.html',
@@ -30,6 +31,7 @@ export class SettingsAccountAddComponent {
public currencies?: CurrencyModel[];
public categories?: AccountCategoryModel[];
public username: string;
public types = new Map<string, string>();
constructor(
private fb: UntypedFormBuilder,
@@ -38,9 +40,11 @@ export class SettingsAccountAddComponent {
private currencyService: CurrencyService,
private accountCategoryService: AccountCategoryService,
private authService: AuthService,
private accountService: AccountService,
@Inject(MAT_DIALOG_DATA) public account: AccountModel
) {
this.username = authService.currentUserValue.userName;
this.types = this.accountService.getTypes();
}
ngOnInit(): void {
@@ -60,6 +64,9 @@ export class SettingsAccountAddComponent {
'',
[Validators.required],
],
type: [
this.account.type
]
});
this.currencyService
@@ -4,6 +4,22 @@
</h2>
<div mat-dialog-content>
<form [formGroup]="editForm!" (ngSubmit)="onSubmitClick()">
<div class="row">
<div class="col-md-12">
<div class="text-inside">
<mat-form-field class="example-full-width">
<mat-label>Type</mat-label>
<mat-select formControlName="type">
<mat-option *ngFor="let type of types | keyvalue" [value]="type.key">
{{type.key}} ({{type.value}})
</mat-option>
</mat-select>
</mat-form-field>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="text-inside">
@@ -26,7 +42,9 @@
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<label>Categories</label>
<div class="col-md-12">
@@ -42,20 +60,21 @@
</div>
</div>
<div class="col-md-12">
<table class="table">
<table class="table" style="table-layout: fixed;">
<tbody>
<tr *ngFor="let category of account.categories">
<td>{{category.name}}</td>
<td>
<button class="btn-space" (click)="removeCategory(category)" mat-raised-button color="primary">
Delete
</button>
</td>
</tr>
<tr *ngFor="let category of account.categories">
<td style="width: 100%;">{{category.name}}</td>
<td style="width: 100px;">
<button class="btn-space" (click)="removeCategory(category)" mat-raised-button color="primary">
Delete
</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="col-md-6">
<label>Users</label>
<div class="col-md-12">
@@ -70,20 +89,24 @@
</mat-form-field>
</div>
</div>
<table class="table">
<tbody>
<div class="col-md-12">
<table class="table" style="table-layout: fixed;">
<tbody>
<tr *ngFor="let accessRight of account.accessRights">
<td>{{accessRight.user.email}}</td>
<td>
<td style="width: 100%;">{{accessRight.user.email}}</td>
<td style="width: 100px;">
<button class="btn-space" [disabled]="account.accessRights!.length <= 1" click="removeAccessRight(accessRight)" mat-raised-button color="primary">
Delete
</button>
</td>
</tr>
</tbody>
</table>
</tbody>
</table>
</div>
</div>
</div>
<mat-dialog-actions class="mat-dialog-actions">
<div class="mat-dialog-left">
<div class="alert alert-danger mat-dialog-error" *ngIf="errorMessage">
@@ -19,6 +19,7 @@ import { CurrencyModel } from '../../../model/currency.model';
import { AccountCategoryService } from '../../../services/account.category.service';
import { AccountCategoryModel } from '../../../model/account.category.model';
import { AccountAccessRightModel } from '../../../model/account.accessRight.model';
import { AccountService } from '../../../services/account.service';
@Component({
templateUrl: './edit.account.component.html',
@@ -29,6 +30,7 @@ export class SettingsAccountEditComponent {
public errorMessage?: string;
public currencies?: CurrencyModel[];
public categories?: AccountCategoryModel[];
public types = new Map<string, string>();
constructor(
private fb: UntypedFormBuilder,
@@ -36,8 +38,10 @@ export class SettingsAccountEditComponent {
private dialogRef: MatDialogRef<SettingsAccountEditComponent>,
private currencyService: CurrencyService,
private accountCategoryService: AccountCategoryService,
private accountService: AccountService,
@Inject(MAT_DIALOG_DATA) public account: AccountModel
) {
this.types = this.accountService.getTypes();
}
ngOnInit(): void {
@@ -56,6 +60,9 @@ export class SettingsAccountEditComponent {
categoryId: [
'',
],
type: [
this.account.type,
],
});
this.currencyService