diff --git a/projects/admin/src/app/circulation/checkin/checkin-action/checkin-action.component.html b/projects/admin/src/app/circulation/checkin/checkin-action/checkin-action.component.html index 409f78995..547bbe8a9 100644 --- a/projects/admin/src/app/circulation/checkin/checkin-action/checkin-action.component.html +++ b/projects/admin/src/app/circulation/checkin/checkin-action/checkin-action.component.html @@ -20,10 +20,18 @@
- - + +
diff --git a/projects/admin/src/app/circulation/circulation.module.ts b/projects/admin/src/app/circulation/circulation.module.ts index 6052f46e7..833bf3791 100644 --- a/projects/admin/src/app/circulation/circulation.module.ts +++ b/projects/admin/src/app/circulation/circulation.module.ts @@ -22,8 +22,11 @@ import { RecordModule } from '@rero/ng-core'; import { SharedModule } from '@rero/shared'; import { ButtonModule } from 'primeng/button'; import { DynamicDialogModule } from 'primeng/dynamicdialog'; +import { InputSwitchModule } from 'primeng/inputswitch'; import { MenuModule } from 'primeng/menu'; +import { MessagesModule } from 'primeng/messages'; import { RippleModule } from 'primeng/ripple'; +import { SplitButtonModule } from 'primeng/splitbutton'; import { TabMenuModule } from 'primeng/tabmenu'; import { TagModule } from 'primeng/tag'; import { JournalVolumePipe } from 'projects/public-search/src/app/pipe/journal-volume.pipe'; @@ -38,7 +41,6 @@ import { RequestedItemsListComponent } from './main-request/requested-items-list import { CancelRequestButtonComponent } from './patron/cancel-request-button.component'; import { CardComponent } from './patron/card/card.component'; import { ChangePasswordFormComponent } from './patron/change-password-form/change-password-form.component'; -import { HistoryLogLibraryComponent } from './patron/history/history-log-library/history-log-library.component'; import { HistoryLogComponent } from './patron/history/history-log/history-log.component'; import { HistoryComponent } from './patron/history/history.component'; import { IllRequestItemComponent } from './patron/ill-request/ill-request-item/ill-request-item.component'; @@ -97,7 +99,6 @@ import { GetLoanCipoPipe } from './pipe/get-loan-cipo.pipe'; FixedDateFormComponent, OverdueTransactionComponent, HistoryLogComponent, - HistoryLogLibraryComponent, GetLoanCipoPipe, CheckinActionComponent, PatronFeeComponent, @@ -120,7 +121,10 @@ import { GetLoanCipoPipe } from './pipe/get-loan-cipo.pipe'; TagModule, ButtonModule, TabMenuModule, - RippleModule + RippleModule, + MessagesModule, + InputSwitchModule, + SplitButtonModule ], providers: [ CurrencyPipe diff --git a/projects/admin/src/app/circulation/circulation.scss b/projects/admin/src/app/circulation/circulation.scss index f5d1c379d..2e8057c8b 100644 --- a/projects/admin/src/app/circulation/circulation.scss +++ b/projects/admin/src/app/circulation/circulation.scss @@ -1,6 +1,6 @@ /* * RERO ILS UI - * Copyright (C) 2023 RERO + * Copyright (C) 2023-2024 RERO * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -18,12 +18,6 @@ @import 'bootstrap/scss/functions'; @import 'bootstrap/scss/variables'; - .btn-hover { - color: $black; - background-color: $warning; - // could be better to use ``@extend .btn:hover`` but it doesn't work for hover property - } - .item { margin-bottom: map-get($spacers, 1) !important; padding: map-get($spacers, 1) !important; diff --git a/projects/admin/src/app/circulation/main-request/main-request.component.html b/projects/admin/src/app/circulation/main-request/main-request.component.html index d44b75119..b75250f6d 100644 --- a/projects/admin/src/app/circulation/main-request/main-request.component.html +++ b/projects/admin/src/app/circulation/main-request/main-request.component.html @@ -14,33 +14,27 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . --> -
-
+
+
+ />
-
+
-
- - +
+ +
-
- - +
+ +
@if (refreshInterval > 0) { + /> } - + />
-
+
+ />
diff --git a/projects/admin/src/app/circulation/main-request/main-request.component.ts b/projects/admin/src/app/circulation/main-request/main-request.component.ts index 55f3b090d..433da8321 100644 --- a/projects/admin/src/app/circulation/main-request/main-request.component.ts +++ b/projects/admin/src/app/circulation/main-request/main-request.component.ts @@ -198,14 +198,6 @@ export class MainRequestComponent implements OnInit, OnDestroy { } } - /** - * Function used when detail collapsed is clicked - * @param state: the toggle switch state - */ - toggleDetailCollapsed(state: boolean): void { - this.isDetailCollapsed = state; - } - /** * Function used when auto-refresh is toggled * @param state: the toggle switch state diff --git a/projects/admin/src/app/circulation/main-request/requested-item/requested-item.component.html b/projects/admin/src/app/circulation/main-request/requested-item/requested-item.component.html index e4427c26c..aa02b786f 100644 --- a/projects/admin/src/app/circulation/main-request/requested-item/requested-item.component.html +++ b/projects/admin/src/app/circulation/main-request/requested-item/requested-item.component.html @@ -14,28 +14,22 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . --> - @if (document) { -
- +
@if (item.loan.state === LoanState.PENDING) { - + }
diff --git a/projects/admin/src/app/circulation/main-request/requested-items-list/requested-items-list.component.html b/projects/admin/src/app/circulation/main-request/requested-items-list/requested-items-list.component.html index 1064d854d..5eaee360f 100644 --- a/projects/admin/src/app/circulation/main-request/requested-items-list/requested-items-list.component.html +++ b/projects/admin/src/app/circulation/main-request/requested-items-list/requested-items-list.component.html @@ -15,7 +15,7 @@ along with this program. If not, see . --> -
+
Item
Document
Call number
diff --git a/projects/admin/src/app/circulation/patron/cancel-request-button.component.ts b/projects/admin/src/app/circulation/patron/cancel-request-button.component.ts index 531a307ac..b96444143 100644 --- a/projects/admin/src/app/circulation/patron/cancel-request-button.component.ts +++ b/projects/admin/src/app/circulation/patron/cancel-request-button.component.ts @@ -25,19 +25,20 @@ import { MessageService } from 'primeng/api'; selector: 'admin-cancel-request-button', template: ` @if (canCancelRequest()) { - + } @else { - + } ` }) diff --git a/projects/admin/src/app/circulation/patron/card/card.component.html b/projects/admin/src/app/circulation/patron/card/card.component.html index e2eda6f62..fa880abf0 100644 --- a/projects/admin/src/app/circulation/patron/card/card.component.html +++ b/projects/admin/src/app/circulation/patron/card/card.component.html @@ -16,14 +16,14 @@ --> @if (patron?.patron) {
-
-
-
- -
-
-
-
+
+
+
+
+ +
+
+ - @if (clearPatronButton) { -
- -
- } -
-
-
-
- @if (patron.birth_date) { - {{ patron.birth_date | dateTranslate:'mediumDate' }} - ({{ patronAge }} {{ 'years old' | translate }}) - @if (isBirthday) { -   - +
+
+
+ @if (patron.birth_date) { + {{ patron.birth_date | dateTranslate:'mediumDate' }} + ({{ patronAge }} {{ 'years old' | translate }}) + @if (isBirthday) { +   + + } + } +
+
{{ patron.city }}
+
+
+ @if (patron.patron.type.pid | getRecord: 'patron_types': 'string':'name' | async; as patronTypeName) { +
{{ patronTypeName }}
} - } +
{{ barcode }}
+
-
{{ patron.city }}
-
-
- @if (patron.patron.type.pid | getRecord: 'patron_types': 'string':'name' | async; as patronTypeName) { -
{{ patronTypeName }}
- } -
{{ barcode }}
+
+ +
@if (patron.notes) { - + + +
    + @for (note of patron.notes; track note) { +
  • + {{ note.type | translate | ucfirst }} +

    +
  • + } +
+
+
}
- - @if (displayCirculationMessages) { -
    - @if (patron.circulation_information) { - @for (message of patron.circulation_informations.messages; track message) { -
  • +
    + + @if (displayCirculationMessages) { + @if (patron.circulation_information) { + @for (message of patron.circulation_informations.messages; track message) { + + } + } + @for (message of circulationMessages; track message) { + } - } - @for (message of circulationMessages; track message) { -
  • - } -
- } + } +
} diff --git a/projects/admin/src/app/circulation/patron/card/card.component.scss b/projects/admin/src/app/circulation/patron/card/card.component.scss index ee2357705..a3ed182c0 100644 --- a/projects/admin/src/app/circulation/patron/card/card.component.scss +++ b/projects/admin/src/app/circulation/patron/card/card.component.scss @@ -1,6 +1,6 @@ /* * RERO ILS UI - * Copyright (C) 2019 RERO + * Copyright (C) 2019-2024 RERO * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -14,18 +14,11 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ - -.user-icon { - line-height: 90px; - i { - vertical-align: bottom; - } -} - .blink { animation: blink-animation 1s steps(5, start) infinite; -webkit-animation: blink-animation 1s steps(5, start) infinite; } + @keyframes blink-animation { to { visibility: hidden; diff --git a/projects/admin/src/app/circulation/patron/card/card.component.ts b/projects/admin/src/app/circulation/patron/card/card.component.ts index f1bd94e0d..a0ee6920d 100644 --- a/projects/admin/src/app/circulation/patron/card/card.component.ts +++ b/projects/admin/src/app/circulation/patron/card/card.component.ts @@ -15,9 +15,9 @@ * along with this program. If not, see . */ import { Component, EventEmitter, inject, Input, Output } from '@angular/core'; -import { getBootstrapLevel } from '../../../utils/utils'; -import { CirculationService } from '../../services/circulation.service'; import { DateTime } from 'luxon'; +import { getSeverity } from '../../../utils/utils'; +import { CirculationService } from '../../services/circulation.service'; @Component({ selector: 'admin-circulation-patron-detailed', @@ -84,12 +84,12 @@ export class CardComponent { } /** - * Get bootstrap color by level + * Get message severity * @param level - string * @return string */ - getBootstrapColor(level: string): string { - return getBootstrapLevel(level); + getMessageSeverity(level: string): string { + return getSeverity(level); } } diff --git a/projects/admin/src/app/circulation/patron/history/history-log-library/history-log-library.component.html b/projects/admin/src/app/circulation/patron/history/history-log-library/history-log-library.component.html deleted file mode 100644 index 2c1df37b8..000000000 --- a/projects/admin/src/app/circulation/patron/history/history-log-library/history-log-library.component.html +++ /dev/null @@ -1,22 +0,0 @@ - - -@if (location.library) { - {{ location.library.name }} -} @else { - {{ location.name }} -} diff --git a/projects/admin/src/app/circulation/patron/history/history-log-library/history-log-library.component.spec.ts b/projects/admin/src/app/circulation/patron/history/history-log-library/history-log-library.component.spec.ts deleted file mode 100644 index 38b563f42..000000000 --- a/projects/admin/src/app/circulation/patron/history/history-log-library/history-log-library.component.spec.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* - * RERO ILS UI - * Copyright (C) 2021 RERO - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, version 3 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { HistoryLogLibraryComponent } from './history-log-library.component'; - -describe('HistoryLogLibraryComponent', () => { - let component: HistoryLogLibraryComponent; - let fixture: ComponentFixture; - - const location = { - library: { - name: 'library name', - pid: '1' - } - }; - - beforeEach(async () => { - await TestBed.configureTestingModule({ - declarations: [HistoryLogLibraryComponent] - }) - .compileComponents(); - }); - - beforeEach(() => { - fixture = TestBed.createComponent(HistoryLogLibraryComponent); - component = fixture.componentInstance; - component.location = location; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/projects/admin/src/app/circulation/patron/history/history-log-library/history-log-library.component.ts b/projects/admin/src/app/circulation/patron/history/history-log-library/history-log-library.component.ts deleted file mode 100644 index 8b04dafeb..000000000 --- a/projects/admin/src/app/circulation/patron/history/history-log-library/history-log-library.component.ts +++ /dev/null @@ -1,28 +0,0 @@ -/* - * RERO ILS UI - * Copyright (C) 2021 RERO - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, version 3 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -import { Component, Input } from '@angular/core'; - -@Component({ - selector: 'admin-history-log-library', - templateUrl: './history-log-library.component.html' -}) -export class HistoryLogLibraryComponent { - - /** Transaction location */ - @Input() location: any; -} diff --git a/projects/admin/src/app/circulation/patron/history/history-log/history-log.component.html b/projects/admin/src/app/circulation/patron/history/history-log/history-log.component.html index 7193680d1..f2851b3f0 100644 --- a/projects/admin/src/app/circulation/patron/history/history-log/history-log.component.html +++ b/projects/admin/src/app/circulation/patron/history/history-log/history-log.component.html @@ -18,12 +18,7 @@
@@ -99,7 +97,10 @@
Transaction history
{{ 'Checkout' | translate }}
- +
@@ -109,3 +110,12 @@
Transaction history
}
+ + + + @if (location.library) { + {{ location.library.name }} + } @else { + {{ location.name }} + } + diff --git a/projects/admin/src/app/circulation/patron/ill-request/ill-request-item/ill-request-item.component.html b/projects/admin/src/app/circulation/patron/ill-request/ill-request-item/ill-request-item.component.html index 4ed73d962..d91f1377b 100644 --- a/projects/admin/src/app/circulation/patron/ill-request/ill-request-item/ill-request-item.component.html +++ b/projects/admin/src/app/circulation/patron/ill-request/ill-request-item/ill-request-item.component.html @@ -18,11 +18,7 @@
- +
{{ record.metadata.document.title }}
{{ record.metadata.document.authors }}
@@ -31,15 +27,15 @@
{{ record.metadata.pickup_location.name }}
{{ record.created | dateTranslate:'medium'}}
- {{ record.metadata.loan_status }} +
@if (!isCollapsed) { @@ -88,13 +84,13 @@
Found in
{{ record.metadata.found_in.url }} - {{ record.metadata.found_in.source }} +
}
Request status
- {{ record.metadata.status }} +
@if (record.metadata.notes && record.metadata.notes.length > 0) { diff --git a/projects/admin/src/app/circulation/patron/loan/loan.component.html b/projects/admin/src/app/circulation/patron/loan/loan.component.html index 18dc7de79..d2bbcd8b0 100644 --- a/projects/admin/src/app/circulation/patron/loan/loan.component.html +++ b/projects/admin/src/app/circulation/patron/loan/loan.component.html @@ -25,7 +25,7 @@ (search)="searchValueUpdated($event)" [focus]="searchInputFocus" [disabled]="searchInputDisabled" - > + />
@@ -56,8 +56,7 @@ ]" [useIcon]="true" (selectChange)="selectingSortCriteria($event)" - > - + />
@@ -69,7 +68,7 @@ (extendLoanClicked)="applyItems([$event])" (extendAllLoansClicked)="applyItems($event)" (hasFeesEmitter)="hasFees($event)" - > + />
diff --git a/projects/admin/src/app/circulation/patron/main/main.component.html b/projects/admin/src/app/circulation/patron/main/main.component.html index efdd19c65..91b4c1bf6 100644 --- a/projects/admin/src/app/circulation/patron/main/main.component.html +++ b/projects/admin/src/app/circulation/patron/main/main.component.html @@ -30,7 +30,14 @@ {{ item.label }} @if (item.tag?.statistics && item.tag?.statistics()[item.id] && item.tag?.statistics()[item.id] > 0) { - + @if (item.tag.withCurrency) { + + } @else { + + } } diff --git a/projects/admin/src/app/circulation/patron/main/main.component.ts b/projects/admin/src/app/circulation/patron/main/main.component.ts index 67086a003..ec342d886 100644 --- a/projects/admin/src/app/circulation/patron/main/main.component.ts +++ b/projects/admin/src/app/circulation/patron/main/main.component.ts @@ -22,12 +22,11 @@ import { PatronService } from '@app/admin/service/patron.service'; import { HotkeysService } from '@ngneat/hotkeys'; import { TranslateService } from '@ngx-translate/core'; import { RecordService } from '@rero/ng-core'; +import { MenuItem } from 'primeng/api'; import { Subscription } from 'rxjs'; import { OperationLogsApiService } from '../../../api/operation-logs-api.service'; import { CirculationService } from '../../services/circulation.service'; import { PatronTransactionService } from '../../services/patron-transaction.service'; -import { MenuItem } from 'primeng/api'; -import { CurrencyPipe } from '@angular/common'; @Component({ selector: 'admin-main', @@ -45,7 +44,6 @@ export class MainComponent implements OnInit, OnDestroy { private circulationService: CirculationService = inject(CirculationService); private operationLogsApiService: OperationLogsApiService = inject(OperationLogsApiService); private recordService: RecordService = inject(RecordService); - private currencyPipe: CurrencyPipe = inject(CurrencyPipe); // COMPONENT ATTRIBUTES ==================================================== /** shortcuts for patron tabs */ @@ -101,9 +99,6 @@ export class MainComponent implements OnInit, OnDestroy { /** the current patron barcode */ barcode: string; - /** the total amount of all fees related to the current patron */ - feesTotalAmount = 0; - /** Subscription to current patron */ private _patronSubscription$: Subscription; @@ -175,18 +170,11 @@ export class MainComponent implements OnInit, OnDestroy { } this.patronService.getCirculationInformations(patron.pid).subscribe((data) => { this.circulationService.clear(); - this.feesTotalAmount = data.fees.engaged + data.fees.preview; + this.circulationService.statisticsIncrease('fees', data.fees.engaged + data.fees.preview); this._parseStatistics(data.statistics || {}); for (const message of (data.messages || [])) { this.circulationService.addCirculationMessage(message as any); } - // subscribe to fees accounting operations for this patron - this._patronFeesOperationSubscription$ = this.patronTransactionService.patronFeesOperationSubject$.subscribe( - (amount) => { - const total = this.feesTotalAmount + amount; - this.feesTotalAmount = (total > 0) ? total : 0; - } - ); this.initializeMenu(); }); } @@ -295,8 +283,9 @@ export class MainComponent implements OnInit, OnDestroy { label: this.translateService.instant('Fees'), routerLink: ['/circulation', 'patron', this.barcode, 'fees'], tag: { - severity: 'info', - value: this.currencyPipe.transform(this.feesTotalAmount, this.organisation.default_currency) + severity: 'warning', + statistics: this.circulationService.statistics, + withCurrency: true, } } ]; diff --git a/projects/admin/src/app/circulation/patron/patron-transactions/overdue-transaction/overdue-transaction.component.html b/projects/admin/src/app/circulation/patron/patron-transactions/overdue-transaction/overdue-transaction.component.html index 4ac3ac9da..d6058937a 100644 --- a/projects/admin/src/app/circulation/patron/patron-transactions/overdue-transaction/overdue-transaction.component.html +++ b/projects/admin/src/app/circulation/patron/patron-transactions/overdue-transaction/overdue-transaction.component.html @@ -18,10 +18,7 @@
- + {{ transaction.loan.end_date.toDate() | dateTranslate :'shortDate' }}
@@ -67,7 +64,7 @@
Transaction history
+ /> }
diff --git a/projects/admin/src/app/circulation/patron/patron-transactions/patron-fee/patron-fee.component.html b/projects/admin/src/app/circulation/patron/patron-transactions/patron-fee/patron-fee.component.html index 4095cb254..6a9dd471b 100644 --- a/projects/admin/src/app/circulation/patron/patron-transactions/patron-fee/patron-fee.component.html +++ b/projects/admin/src/app/circulation/patron/patron-transactions/patron-fee/patron-fee.component.html @@ -14,23 +14,12 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . --> -@if (form) { -
{{ loan.metadata.pickup_location_pid | getRecord: 'locations' : 'field' : 'pickup_name' | async }} @@ -40,6 +40,6 @@ }
- +
} diff --git a/projects/admin/src/app/circulation/patron/pickup/pickup.component.html b/projects/admin/src/app/circulation/patron/pickup/pickup.component.html index 5c32e1ad7..8949f7df8 100644 --- a/projects/admin/src/app/circulation/patron/pickup/pickup.component.html +++ b/projects/admin/src/app/circulation/patron/pickup/pickup.component.html @@ -30,7 +30,7 @@ [loan]="loan" class="row p-2 mb-1 border rounded align-middle" (cancelRequestEvent)="cancelRequest($event)" - > + /> }
} @else { diff --git a/projects/admin/src/app/circulation/patron/profile/profile.component.html b/projects/admin/src/app/circulation/patron/profile/profile.component.html index 2976501f5..7a1457401 100644 --- a/projects/admin/src/app/circulation/patron/profile/profile.component.html +++ b/projects/admin/src/app/circulation/patron/profile/profile.component.html @@ -117,9 +117,12 @@ @if (canUpdate()) { - + } @@ -232,10 +235,12 @@
Patron Information
} @if (canUpdate()) { - + } diff --git a/projects/admin/src/app/circulation/services/patron-transaction.service.ts b/projects/admin/src/app/circulation/services/patron-transaction.service.ts index 7c54e9814..935aa385c 100644 --- a/projects/admin/src/app/circulation/services/patron-transaction.service.ts +++ b/projects/admin/src/app/circulation/services/patron-transaction.service.ts @@ -28,6 +28,7 @@ import { UserService } from '@rero/shared'; import { MessageService } from 'primeng/api'; import { BehaviorSubject, Observable, Subject } from 'rxjs'; import { map } from 'rxjs/operators'; +import { CirculationService } from './circulation.service'; @Injectable({ providedIn: 'root' @@ -39,11 +40,10 @@ export class PatronTransactionService { private routeToolService: RouteToolService = inject(RouteToolService); private translateService: TranslateService = inject(TranslateService); private messageService = inject(MessageService); + private circulationService: CirculationService = inject(CirculationService); /** subject containing current loaded PatronTransactions */ patronTransactionsSubject$: BehaviorSubject> = new BehaviorSubject([]); - /** subject emitting accounting transaction about patron fees */ - patronFeesOperationSubject$: Subject = new Subject(); /** * Allow to build the query to send through the API to retrieve desired data @@ -89,7 +89,7 @@ export class PatronTransactionService { ).pipe( map((data: Record) => data.hits), map(hits => this.recordService.totalHits(hits.total) === 0 ? [] : hits.hits), - map(hits => hits.map( hit => new PatronTransaction(hit.metadata))) + map(hits => hits.map(hit => new PatronTransaction(hit.metadata))) ); } @@ -195,8 +195,7 @@ export class PatronTransactionService { record.type = PatronTransactionEventType.PAYMENT; record.subtype = paymentMethod; record.amount = amount; - this.patronFeesOperationSubject$.next(0 - amount); - this._createTransactionEvent(record, transaction.patron.pid); + this._createTransactionEvent(record, transaction.patron.pid, amount); } /** @@ -222,8 +221,7 @@ export class PatronTransactionService { record.type = PatronTransactionEventType.CANCEL; record.amount = amount; record.note = reason; - this.patronFeesOperationSubject$.next(0 - amount); - this._createTransactionEvent(record, transaction.patron.pid); + this._createTransactionEvent(record, transaction.patron.pid, amount); } /** @@ -231,24 +229,24 @@ export class PatronTransactionService { * @param record - data to send through the API * @param affectedPatron - the user pid affected by this new transaction event */ - private _createTransactionEvent(record: any, affectedPatron: string) { - this.recordService.create('patron_transaction_events', record).subscribe( - () => { + private _createTransactionEvent(record: any, affectedPatron: string, amount: number = 0) { + const translateType = this.translateService.instant(record.type); + this.recordService.create('patron_transaction_events', record).subscribe({ + next: () => { + this.circulationService.statisticsDecrease('fees', amount); this.emitPatronTransactionByPatron(affectedPatron, undefined, 'open'); - const translateType = this.translateService.instant(record.type); this.messageService.add({ severity: 'success', summary: this.translateService.instant('Patron'), - detail: this.translateService.instant('{{ type }} registered', {type: translateType}), + detail: this.translateService.instant('{{ type }} registered', { type: translateType }), life: CONFIG.MESSAGE_LIFE }); }, - (error) => { + error: (error) => { const errorMessage = (error.hasOwnProperty('message') && error.message().hasOwnProperty('message')) ? error.message.message : 'Server error :: ' + (error.title || error.toString()); const message = '[' + error.status + ' - ' + error.statusText + '] ' + errorMessage; - const translateType = this.translateService.instant(record.type); this.messageService.add({ severity: 'error', summary: this.translateService.instant('{{ type }} creation failed!', { type: translateType }), @@ -257,6 +255,6 @@ export class PatronTransactionService { closable: true }); } - ); + }); } } diff --git a/projects/admin/src/app/utils/utils.ts b/projects/admin/src/app/utils/utils.ts index 31afb1947..b7d6d182a 100644 --- a/projects/admin/src/app/utils/utils.ts +++ b/projects/admin/src/app/utils/utils.ts @@ -1,6 +1,6 @@ /* * RERO ILS UI - * Copyright (C) 2020 RERO + * Copyright (C) 2020-2024 RERO * Copyright (C) 2020 UCLouvain * * This program is free software: you can redistribute it and/or modify @@ -17,18 +17,17 @@ */ /** Convert a level string to boostrap level - * See : https://getbootstrap.com/docs/4.5/components/alerts/ * @param level - string: the level string to convert - * @return the bootstrap level corresponding (info by default) + * @return the severity of message (info by default) */ -export function getBootstrapLevel(level: string) { +export function getSeverity(level: string) { switch (level) { case 'error': - return 'danger'; + return 'error'; case 'warning': - return 'warning'; + return 'warn'; case 'debug': - return 'dark'; + return 'secondary'; default: return 'info'; } diff --git a/projects/shared/src/lib/component/open-close-button.component.ts b/projects/shared/src/lib/component/open-close-button.component.ts index a5e38e2c2..621a5ea26 100644 --- a/projects/shared/src/lib/component/open-close-button.component.ts +++ b/projects/shared/src/lib/component/open-close-button.component.ts @@ -14,7 +14,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -import { Component, input, OnChanges, output, signal, SimpleChanges } from '@angular/core'; +import { Component, input, OnChanges, output, SimpleChanges } from '@angular/core'; @Component({ selector: 'shared-open-close-button',