diff --git a/backend/exence/src/main/java/com/exence/finance/modules/category/entity/Category.java b/backend/exence/src/main/java/com/exence/finance/modules/category/entity/Category.java index 9d9ca16..6596b11 100644 --- a/backend/exence/src/main/java/com/exence/finance/modules/category/entity/Category.java +++ b/backend/exence/src/main/java/com/exence/finance/modules/category/entity/Category.java @@ -38,11 +38,11 @@ @NoArgsConstructor @AllArgsConstructor @EqualsAndHashCode( - callSuper = false, - exclude = {"user", "transactions"}) + callSuper = false, + exclude = {"user", "transactions"}) @ToString( - callSuper = true, - exclude = {"user", "transactions"}) + callSuper = true, + exclude = {"user", "transactions"}) @Table(name = "category") @Filter(name = "userFilter", condition = "user_id = :userId") public class Category extends BaseAuditableEntity { diff --git a/frontend/Exence/src/app/private/dashboard/dashboard.component.ts b/frontend/Exence/src/app/private/dashboard/dashboard.component.ts index cd11227..e2602bf 100644 --- a/frontend/Exence/src/app/private/dashboard/dashboard.component.ts +++ b/frontend/Exence/src/app/private/dashboard/dashboard.component.ts @@ -1,6 +1,5 @@ import { CommonModule } from '@angular/common'; import { Component, computed, inject, OnInit } from '@angular/core'; -import { RouterModule } from '@angular/router'; import { TransactionType } from '../../data-model/modules/transaction/TransactionType'; import { CategoriesComponent, DateInterval } from '../../private/dashboard/categories/categories.component'; import { SummaryContainerComponent } from '../../private/dashboard/summary-container/summary-container.component'; @@ -24,7 +23,6 @@ import { TransactionStore } from '../transactions-and-categories/transaction.sto styleUrl: './dashboard.component.scss', imports: [ CommonModule, - RouterModule, CardSliderDirective, SummaryContainerComponent, DataTableComponent, diff --git a/frontend/Exence/src/app/private/dashboard/summary-container/summary-container.component.html b/frontend/Exence/src/app/private/dashboard/summary-container/summary-container.component.html index c90b1cb..a9a8493 100644 --- a/frontend/Exence/src/app/private/dashboard/summary-container/summary-container.component.html +++ b/frontend/Exence/src/app/private/dashboard/summary-container/summary-container.component.html @@ -1,5 +1,4 @@ - - +
@if (svgIcon()) { diff --git a/frontend/Exence/src/app/private/dashboard/summary-container/summary-container.component.scss b/frontend/Exence/src/app/private/dashboard/summary-container/summary-container.component.scss index b0d6207..384a621 100644 --- a/frontend/Exence/src/app/private/dashboard/summary-container/summary-container.component.scss +++ b/frontend/Exence/src/app/private/dashboard/summary-container/summary-container.component.scss @@ -13,9 +13,11 @@ mat-card.mat-mdc-card { box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.2); transition: background 0.3s ease-in-out; - // &:hover { - // background-color: lighten(var(--mat-card-elevated-container-color), 5%); - // } + cursor: pointer; + + &:hover { + background-color: lighten(var(--mat-card-elevated-container-color), 5%); + } } .icon-container { diff --git a/frontend/Exence/src/app/private/dashboard/summary-container/summary-container.component.ts b/frontend/Exence/src/app/private/dashboard/summary-container/summary-container.component.ts index 8f779f1..52d4b42 100644 --- a/frontend/Exence/src/app/private/dashboard/summary-container/summary-container.component.ts +++ b/frontend/Exence/src/app/private/dashboard/summary-container/summary-container.component.ts @@ -16,7 +16,7 @@ import { SvgIcons } from '../../../shared/svg-icons/svg-icons'; imports: [MatCardModule, MatIconModule, CurrencyPipe, MatButtonModule, RouterModule, AbsoluteValuePipe], }) export class SummaryContainerComponent { - private readonly navigation = inject(NavigationService); + private readonly navigationService = inject(NavigationService); private readonly router = inject(Router); svgIcon = input(); @@ -27,27 +27,12 @@ export class SummaryContainerComponent { transactionTypes = TransactionType; - // TODO navigate with filter on click navigate(): void { const queryParams: Record = {}; - // switch (this.data().type) { - // case SummaryType.INCOME: - // queryParams['amountFilter'] = 'gt'; - // queryParams['amountValue'] = '0'; - // break; - // case SummaryType.EXPENSE: - // queryParams['amountFilter'] = 'lt'; - // queryParams['amountValue'] = '0'; - // break; - // case SummaryType.OTHER: - // if (this.filterCondition()) { - // Object.entries(this.filterCondition()!).forEach(([key, value]) => { - // queryParams[key] = value; - // }); - // } - // break; - // } - this.router.navigate([this.navigation.private().transactions()], { + if (this.type()) { + queryParams['type'] = this.type()!; + } + this.router.navigate([this.navigationService.private().transactions()], { queryParams, }); } diff --git a/frontend/Exence/src/app/private/transactions-and-categories/transactions-and-categories.component.ts b/frontend/Exence/src/app/private/transactions-and-categories/transactions-and-categories.component.ts index 36f90b9..0f396f7 100644 --- a/frontend/Exence/src/app/private/transactions-and-categories/transactions-and-categories.component.ts +++ b/frontend/Exence/src/app/private/transactions-and-categories/transactions-and-categories.component.ts @@ -25,6 +25,8 @@ import { CategoryStore } from './category.store'; import { CreateCategoryDialogComponent } from './create-category-dialog/create-category-dialog.component'; import { CreateTransactionDialogComponent } from './create-transaction-dialog/create-transaction-dialog.component'; import { TransactionStore } from './transaction.store'; +import { ActivatedRoute } from '@angular/router'; +import { mapToTransactionFilter } from '../../shared/util/utils'; @Component({ selector: 'ex-transactions-and-categories', @@ -55,6 +57,7 @@ export class TransactionsAndCategoriesComponent extends BaseComponent implements private readonly dialog = inject(DialogService); private readonly categoryStore = inject(CategoryStore); private readonly fb = inject(NonNullableFormBuilder); + private readonly route = inject(ActivatedRoute); readonly display = inject(DisplaySizeService); readonly transactionStore = inject(TransactionStore); @@ -107,6 +110,8 @@ export class TransactionsAndCategoriesComponent extends BaseComponent implements this.transactionStore.updateFilters(newFilters as TransactionFilter); }), ); + + this.applyQueryParamsToFilters(); } async openCreateTransactionDialog(): Promise { @@ -120,4 +125,10 @@ export class TransactionsAndCategoriesComponent extends BaseComponent implements onScroll(type?: TransactionType, recurring?: boolean): void { this.transactionStore.loadNextPage(type, recurring); } + + private applyQueryParamsToFilters(): void { + const queryParams = this.route.snapshot.queryParamMap; + const filters = mapToTransactionFilter(queryParams); + this.transactionFilterForm.patchValue(filters); + } } diff --git a/frontend/Exence/src/app/shared/util/utils.ts b/frontend/Exence/src/app/shared/util/utils.ts index 74841f6..ac5a713 100644 --- a/frontend/Exence/src/app/shared/util/utils.ts +++ b/frontend/Exence/src/app/shared/util/utils.ts @@ -1,10 +1,26 @@ import { Signal } from '@angular/core'; import { toSignal } from '@angular/core/rxjs-interop'; import { AbstractControl } from '@angular/forms'; +import { ParamMap } from '@angular/router'; import { map } from 'rxjs'; +import { TransactionFilter } from '../../data-model/modules/transaction/TransactionFilter'; +import { TransactionType } from '../../data-model/modules/transaction/TransactionType'; export function toRawValueSignal(control: AbstractControl): Signal { return toSignal(control.valueChanges.pipe(map(() => control.getRawValue() as T)), { initialValue: control.getRawValue() as T, }); } + +export function mapToTransactionFilter(queryParam: ParamMap): TransactionFilter { + const filter: TransactionFilter = {} as TransactionFilter; + if (queryParam.get('keyword')) filter.keyword = queryParam.get('keyword')!; + if (queryParam.get('dateFrom')) filter.dateFrom = queryParam.get('dateFrom')!; + if (queryParam.get('dateTo')) filter.dateTo = queryParam.get('dateTo')!; + if (queryParam.get('categoryId')) filter.categoryId = +queryParam.get('categoryId')!; + if (queryParam.get('type')) filter.type = queryParam.get('type')! as TransactionType; + if (queryParam.get('amountFrom')) filter.amountFrom = parseFloat(queryParam.get('amountFrom')!); + if (queryParam.get('amountTo')) filter.amountTo = parseFloat(queryParam.get('amountTo')!); + if (queryParam.get('recurring')) filter.recurring = queryParam.get('recurring') === 'true'; + return filter; +}