diff --git a/.gitignore b/.gitignore index 0dc6ff06f..0b48d09ae 100644 --- a/.gitignore +++ b/.gitignore @@ -42,6 +42,7 @@ npm-debug.log yarn-error.log testem.log /typings +.nx # System Files .DS_Store diff --git a/angular.json b/angular.json index 443835830..b0a96f2e5 100644 --- a/angular.json +++ b/angular.json @@ -406,8 +406,19 @@ "output": "/assets/" } ], - "styles": [], - "scripts": [] + "styles": [ + "node_modules/primeng/resources/themes/bootstrap4-light-blue/theme.css", + "node_modules/primeng/resources/primeng.min.css", + "node_modules/primeicons/primeicons.css", + "node_modules/primeflex/primeflex.min.css" + ], + "scripts": [], + "vendorChunk": true, + "extractLicenses": false, + "buildOptimizer": false, + "sourceMap": true, + "optimization": false, + "namedChunks": true }, "configurations": { "production": { diff --git a/package-lock.json b/package-lock.json index e21ae42de..f2edf09c4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -38,12 +38,11 @@ "issn": "^1.0.6", "js-generate-password": "^0.1.9", "lodash-es": "^4.17.21", - "luxon": "^3.4.0", + "luxon": "^3.5.0", "marked": "^10.0.0", "moment": "^2.30.1", "ngx-bootstrap": "^12.0.0", "ngx-spinner": "^16.0.0", - "ngx-toastr": "^18.0.0", "primeflex": "^3.3.1", "primeicons": "^6.0.1", "primeng": "^17.14.1", @@ -75,6 +74,7 @@ "karma-jasmine-html-reporter": "~2.1.0", "karma-spec-reporter": "0.0.36", "ng-packagr": "^17.1.1", + "primelocale": "^1.0.3", "typescript": "~5.3.3" } }, @@ -10923,9 +10923,9 @@ } }, "node_modules/luxon": { - "version": "3.4.4", - "resolved": "https://registry.npmjs.org/luxon/-/luxon-3.4.4.tgz", - "integrity": "sha512-zobTr7akeGHnv7eBOXcRgMeCP6+uyYsczwmeRCauvpvaAltgNyTbLH/+VaEAPUeWBT+1GuNmz4wC/6jtQzbbVA==", + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/luxon/-/luxon-3.5.0.tgz", + "integrity": "sha512-rh+Zjr6DNfUYR3bPwJEnuwDdqMbxZW7LOQfUN4B54+Cl+0o5zaU9RJ6bcidfDtC1cWCZXQ+nvX8bf6bAji37QQ==", "engines": { "node": ">=12" } @@ -11612,6 +11612,7 @@ "version": "18.0.0", "resolved": "https://registry.npmjs.org/ngx-toastr/-/ngx-toastr-18.0.0.tgz", "integrity": "sha512-jZ3rOG6kygl8ittY8OltIMSo47P1VStuS01igm3MZXK6InJwHVvxU7wDHI/HGMlXSyNvWncyOuFHnnMEAifsew==", + "peer": true, "dependencies": { "tslib": "^2.3.0" }, @@ -12914,17 +12915,27 @@ "resolved": "https://registry.npmjs.org/primeicons/-/primeicons-6.0.1.tgz", "integrity": "sha512-KDeO94CbWI4pKsPnYpA1FPjo79EsY9I+M8ywoPBSf9XMXoe/0crjbUK7jcQEDHuc0ZMRIZsxH3TYLv4TUtHmAA==" }, + "node_modules/primelocale": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/primelocale/-/primelocale-1.0.3.tgz", + "integrity": "sha512-a0VuhQLgUge4IJG2RKpMJSDYHuYIAd2kcqQy/quyx8UyM1/m7Uvt9hFKoFL0QAbZZyHIVHobVmGWAOJN8d7COQ==", + "dev": true, + "engines": { + "node": ">=12.0.0", + "npm": ">=6.0.0" + } + }, "node_modules/primeng": { - "version": "17.16.1", - "resolved": "https://registry.npmjs.org/primeng/-/primeng-17.16.1.tgz", - "integrity": "sha512-bNCUxdXgT4ikOG/aKA2PW9FCFnD/EtB+fLoGLuQXAGB1PJU72x5c0yQoGFDQcAgx78o3d/4LjZOdOPYwovN9Lg==", + "version": "17.18.10", + "resolved": "https://registry.npmjs.org/primeng/-/primeng-17.18.10.tgz", + "integrity": "sha512-P3UskInOZ7qYICxSYvf0K8nUEb7DmndiXmyvLGU1wch+XcVWmVs4FZsWKNfdvK7TUdxxYj8WW44nodNV/epr3A==", "dependencies": { "tslib": "^2.3.0" }, "peerDependencies": { - "@angular/common": "^17.0.0", - "@angular/core": "^17.0.0", - "@angular/forms": "^17.0.0", + "@angular/common": "^17.0.0 || ^18.0.0", + "@angular/core": "^17.0.0 || ^18.0.0", + "@angular/forms": "^17.0.0 || ^18.0.0", "rxjs": "^6.0.0 || ^7.8.1", "zone.js": "~0.14.0" } diff --git a/package.json b/package.json index d0ac0f1ff..733e09f3d 100644 --- a/package.json +++ b/package.json @@ -96,12 +96,11 @@ "issn": "^1.0.6", "js-generate-password": "^0.1.9", "lodash-es": "^4.17.21", - "luxon": "^3.4.0", + "luxon": "^3.5.0", "marked": "^10.0.0", "moment": "^2.30.1", "ngx-bootstrap": "^12.0.0", "ngx-spinner": "^16.0.0", - "ngx-toastr": "^18.0.0", "primeflex": "^3.3.1", "primeicons": "^6.0.1", "primeng": "^17.14.1", @@ -133,6 +132,7 @@ "karma-jasmine-html-reporter": "~2.1.0", "karma-spec-reporter": "0.0.36", "ng-packagr": "^17.1.1", + "primelocale": "^1.0.3", "typescript": "~5.3.3" }, "files": [ diff --git a/projects/admin/src/app/acquisition/acquisition.module.ts b/projects/admin/src/app/acquisition/acquisition.module.ts index 926c038d2..d328e8017 100644 --- a/projects/admin/src/app/acquisition/acquisition.module.ts +++ b/projects/admin/src/app/acquisition/acquisition.module.ts @@ -19,12 +19,14 @@ import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; import { ReactiveFormsModule } from '@angular/forms'; -import { FormlyModule, FORMLY_CONFIG } from '@ngx-formly/core'; +import { FORMLY_CONFIG, FormlyModule } from '@ngx-formly/core'; +import { FormlyPrimeNGModule } from '@ngx-formly/primeng'; import { TranslateService } from '@ngx-translate/core'; import { ApiService, CoreModule, RecordModule } from '@rero/ng-core'; +import { SharedModule } from '@rero/shared'; import { BsDropdownModule } from 'ngx-bootstrap/dropdown'; -import { PopoverModule } from 'ngx-bootstrap/popover'; -import { TabsModule } from 'ngx-bootstrap/tabs'; +import { PreviewEmailModule } from '../shared/preview-email/preview-email.module'; +import { PrimengImportModule } from '../shared/primeng-import/primeng-import.module'; import { AcquisitionRoutingModule } from './acquisition-routing.module'; import { AcqAccountApiService } from './api/acq-account-api.service'; import { AcqOrderApiService } from './api/acq-order-api.service'; @@ -39,29 +41,26 @@ import { OrderBriefViewComponent } from './components/order/order-brief-view/ord import { OrderDetailViewComponent } from './components/order/order-detail-view/order-detail-view.component'; import { OrderLineComponent } from './components/order/order-detail-view/order-line/order-line.component'; import { OrderLinesComponent } from './components/order/order-detail-view/order-lines/order-lines.component'; +import { OrderEmailFormComponent } from './components/order/order-email-form/order-email-form.component'; +import { OrderSummaryComponent } from './components/order/order-summary/order-summary.component'; +import { ReceiptDetailViewComponent } from './components/receipt/receipt-detail-view/receipt-detail-view.component'; import { OrderReceipt } from './components/receipt/receipt-form/order-receipt'; import { OrderReceiptForm } from './components/receipt/receipt-form/order-receipt-form'; import { OrderReceiptViewComponent } from './components/receipt/receipt-form/order-receipt-view.component'; -import { OrderSummaryComponent } from './components/order/order-summary/order-summary.component'; import { ReceiptListComponent } from './components/receipt/receipt-list/receipt-list.component'; +import { ReceiptSummaryComponent } from './components/receipt/receipt-summary/receipt-summary.component'; import { registerFormlyExtension } from './formly/extension'; import { FieldDocumentBriefViewTypeComponent } from './formly/type/field-document-brief-view.type'; import { FieldRefTypeComponent } from './formly/type/field-ref.type'; import { RepeatTypeComponent } from './formly/type/repeat-section.type'; import { SelectAccountComponent } from './formly/type/select-account/select-account.component'; import { InputNoLabelWrapperComponent } from './formly/wrapper/input-no-label.wrapper'; +import { AccountAvailableAmountPipe } from './pipes/account-available-amount.pipe'; import { NegativeAmountPipe } from './pipes/negative-amount.pipe'; -import { ReceiptSummaryComponent } from './components/receipt/receipt-summary/receipt-summary.component'; -import { ReceiptDetailViewComponent } from './components/receipt/receipt-detail-view/receipt-detail-view.component'; import { NoteBadgeColorPipe } from './pipes/note-badge-color.pipe'; -import { AccountAvailableAmountPipe } from './pipes/account-available-amount.pipe'; -import { ReceptionDatesPipe } from './pipes/reception-dates.pipe'; import { PreviewContentPipe } from './pipes/preview-content.pipe'; import { ReceiptLineTotalAmountPipe } from './pipes/receipt-line-total-amount.pipe'; -import { PermissionsService, SharedModule } from '@rero/shared'; -import { OrderEmailFormComponent } from './components/order/order-email-form/order-email-form.component'; -import { PreviewEmailModule } from '../shared/preview-email/preview-email.module'; -import { FormlyPrimeNGModule } from '@ngx-formly/primeng'; +import { ReceptionDatesPipe } from './pipes/reception-dates.pipe'; @NgModule({ declarations: [ @@ -96,7 +95,6 @@ import { FormlyPrimeNGModule } from '@ngx-formly/primeng'; ], imports: [ BsDropdownModule.forRoot(), - PopoverModule.forRoot(), CommonModule, AcquisitionRoutingModule, FormlyModule, @@ -114,10 +112,10 @@ import { FormlyPrimeNGModule } from '@ngx-formly/primeng'; ] }), RecordModule, - TabsModule, CoreModule, SharedModule, - PreviewEmailModule + PreviewEmailModule, + PrimengImportModule ], providers: [ { provide: FORMLY_CONFIG, multi: true, useFactory: registerFormlyExtension, deps: [TranslateService] }, diff --git a/projects/admin/src/app/acquisition/api/acq-account-api.service.ts b/projects/admin/src/app/acquisition/api/acq-account-api.service.ts index e60a23353..fd9179f99 100644 --- a/projects/admin/src/app/acquisition/api/acq-account-api.service.ts +++ b/projects/admin/src/app/acquisition/api/acq-account-api.service.ts @@ -1,6 +1,6 @@ /* * RERO ILS UI - * Copyright (C) 2021 RERO + * Copyright (C) 2021-2024 RERO * Copyright (C) 2021 UCLouvain * * This program is free software: you can redistribute it and/or modify @@ -17,7 +17,7 @@ */ import { HttpClient, HttpParams } from '@angular/common/http'; -import { Injectable } from '@angular/core'; +import { inject, Injectable } from '@angular/core'; import { Record, RecordService } from '@rero/ng-core'; import { Error } from '@rero/ng-core/lib/error/error'; import { Observable } from 'rxjs'; @@ -29,6 +29,9 @@ import { IAcqAccount } from '../classes/account'; }) export class AcqAccountApiService { + private httpClient: HttpClient = inject(HttpClient); + private recordService: RecordService = inject(RecordService); + // SERVICES ATTRIBUTES ====================================================== /** The resource name of acquisition account */ resourceName = 'acq_accounts'; @@ -57,17 +60,6 @@ export class AcqAccountApiService { remaining_balance: this.allocatedAmountDefaultData }; - // SERVICE CONSTRUCTORS ===================================================== - /** - * Constructor - * @param _http: HttpClient - * @param _recordService - RecordService - */ - constructor( - private _http: HttpClient, - private _recordService: RecordService - ) {} - // SERVICES FUNCTIONS ======================================================= /** @@ -76,10 +68,10 @@ export class AcqAccountApiService { * @returns the corresponding account */ getAccount(accountPid: string): Observable { - return this._recordService + return this.recordService .getRecords(this.resourceName, `pid:${accountPid}`, 1, 1) .pipe( - map((result: Record) => this._recordService.totalHits(result.hits.total) === 0 ? [] : result.hits.hits), + map((result: Record) => this.recordService.totalHits(result.hits.total) === 0 ? [] : result.hits.hits), map((hits: any[]) => hits.map((hit: any) => ({...this.accountDefaultData, ...hit.metadata}) )), map((hits: IAcqAccount[]) => hits.find(Boolean)) // Get first element of array if exists ); @@ -103,10 +95,10 @@ export class AcqAccountApiService { } const query = defaultQueryParams.join(' AND '); options = { ...{sort: 'name'}, ...options }; // add some default params - return this._recordService + return this.recordService .getRecords(this.resourceName, query, 1, RecordService.MAX_REST_RESULTS_SIZE, undefined, undefined, undefined, options.sort) .pipe( - map((result: Record) => this._recordService.totalHits(result.hits.total) === 0 ? [] : result.hits.hits), + map((result: Record) => this.recordService.totalHits(result.hits.total) === 0 ? [] : result.hits.hits), map((hits: any[]) => hits.map(hit => ({...this.accountDefaultData, ...hit.metadata}) )) ); } @@ -117,7 +109,7 @@ export class AcqAccountApiService { * @return The observable on delete REST call. */ delete(pid: string): Observable { - return this._recordService.delete(this.resourceName, pid); + return this.recordService.delete(this.resourceName, pid); } /** @@ -133,6 +125,6 @@ export class AcqAccountApiService { .set('source', sourcePid) .set('target', targetPid) .set('amount', amount.toString()); - return this._http.get(apiUrl, { params }); + return this.httpClient.get(apiUrl, { params }); } } diff --git a/projects/admin/src/app/acquisition/api/acq-budget-api.service.ts b/projects/admin/src/app/acquisition/api/acq-budget-api.service.ts index 9cc003f79..a91e09504 100644 --- a/projects/admin/src/app/acquisition/api/acq-budget-api.service.ts +++ b/projects/admin/src/app/acquisition/api/acq-budget-api.service.ts @@ -1,6 +1,6 @@ /* * RERO ILS UI - * Copyright (C) 2021 RERO + * Copyright (C) 2021-2024 RERO * Copyright (C) 2021 UCLouvain * * This program is free software: you can redistribute it and/or modify @@ -15,33 +15,25 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -import { Injectable } from '@angular/core'; +import { inject, Injectable } from '@angular/core'; import { Record, RecordService } from '@rero/ng-core'; import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; -import { AcqAccountApiService } from './acq-account-api.service'; import { IAcqAccount } from '../classes/account'; import { AcqBudget } from '../classes/budget'; +import { AcqAccountApiService } from './acq-account-api.service'; @Injectable({ providedIn: 'root' }) export class AcqBudgetApiService { + private recordService: RecordService = inject(RecordService); + private acqAccountApiService: AcqAccountApiService = inject(AcqAccountApiService); + /** The resource name of acquisition budget */ resourceName = 'budgets'; - /** - * Constructor - * @param _recordService - RecordService - * @param _acqAccountApiService - AcqAccountApiService - */ - constructor( - private _recordService: RecordService, - private _acqAccountApiService: AcqAccountApiService - ) { } - - /** * Get the budget corresponding to filters. * @param query: query to apply to find records @@ -49,9 +41,9 @@ export class AcqBudgetApiService { */ getBudgets(query?: string): Observable { query = query || ''; - return this._recordService.getRecords(this.resourceName, query, 1, RecordService.MAX_REST_RESULTS_SIZE) + return this.recordService.getRecords(this.resourceName, query, 1, RecordService.MAX_REST_RESULTS_SIZE) .pipe( - map((result: Record) => this._recordService.totalHits(result.hits.total) === 0 ? [] : result.hits.hits), + map((result: Record) => this.recordService.totalHits(result.hits.total) === 0 ? [] : result.hits.hits), map((hits: any[]) => hits.map((hit: any) => new AcqBudget(hit.metadata))) ); } @@ -62,11 +54,11 @@ export class AcqBudgetApiService { * @return An observable with the total amount for this budget. */ getBudgetTotalAmount(budgetPid: string): Observable { - return this._recordService + return this.recordService .getRecords('acq_accounts', `budget.pid:${budgetPid} AND depth:0`, 1, RecordService.MAX_REST_RESULTS_SIZE) .pipe( - map((result: Record) => this._recordService.totalHits(result.hits.total) === 0 ? [] : result.hits.hits), - map((hits: any[]) => hits.map((hit: any) => ({...this._acqAccountApiService.accountDefaultData, ...hit.metadata}) )), + map((result: Record) => this.recordService.totalHits(result.hits.total) === 0 ? [] : result.hits.hits), + map((hits: any[]) => hits.map((hit: any) => ({...this.acqAccountApiService.accountDefaultData, ...hit.metadata}) )), map((accounts: IAcqAccount[]) => accounts.reduce((total, acc) => total + acc.allocated_amount, 0)) ); } diff --git a/projects/admin/src/app/acquisition/api/acq-order-api.service.ts b/projects/admin/src/app/acquisition/api/acq-order-api.service.ts index 8b74d4dad..1e53074f0 100644 --- a/projects/admin/src/app/acquisition/api/acq-order-api.service.ts +++ b/projects/admin/src/app/acquisition/api/acq-order-api.service.ts @@ -1,6 +1,6 @@ /* * RERO ILS UI - * Copyright (C) 2019-2022 RERO + * Copyright (C) 2019-2024 RERO * Copyright (C) 2019-2022 UCLouvain * * This program is free software: you can redistribute it and/or modify @@ -16,7 +16,8 @@ * along with this program. If not, see . */ import { HttpClient } from '@angular/common/http'; -import { Injectable } from '@angular/core'; +import { inject, Injectable } from '@angular/core'; +import { IPreview } from '@app/admin/shared/preview-email/IPreviewInterface'; import { ApiService, Record, RecordService, RecordUiService } from '@rero/ng-core'; import { BaseApi } from '@rero/shared'; import { BehaviorSubject, Observable, Subject } from 'rxjs'; @@ -31,13 +32,17 @@ import { IAcqOrder, IAcqOrderLine } from '../classes/order'; -import { IPreview } from '@app/admin/shared/preview-email/IPreviewInterface'; @Injectable({ providedIn: 'root' }) export class AcqOrderApiService extends BaseApi { + private httpClient: HttpClient = inject(HttpClient); + private recordService: RecordService = inject(RecordService); + private recordUiService: RecordUiService = inject(RecordUiService); + private apiService: ApiService = inject(ApiService); + // SERVICES ATTRIBUTES ====================================================== /** Default values */ public readonly orderDefaultData = { @@ -68,23 +73,6 @@ export class AcqOrderApiService extends BaseApi { /** expose _deletedOrderLineSubject$ in 'readonly' mode */ get deletedOrderLineSubject$(): Observable { return this._deletedOrderLineSubject$.asObservable(); } - // CONSTRUCTOR ============================================================== - /** - * Constructor - * @param _http - HttpClient - * @param _recordService - RecordService - * @param _recordUiService - RecordUiService - * @param _apiService - ApiService - */ - constructor( - private _http: HttpClient, - private _recordService: RecordService, - private _recordUiService: RecordUiService, - private _apiService: ApiService - ) { - super(); - } - // SERVICE PUBLIC FUNCTIONS ================================================= /** * Load an order from this pid @@ -92,7 +80,7 @@ export class AcqOrderApiService extends BaseApi { * @return: the corresponding AcqOrder */ getOrder(orderPid: string): Observable { - return this._recordService.getRecord('acq_orders', orderPid, 0, BaseApi.reroJsonheaders).pipe( + return this.recordService.getRecord('acq_orders', orderPid, 0, BaseApi.reroJsonheaders).pipe( map(data => ({...this.orderDefaultData, ...data.metadata}) ) ); } @@ -103,7 +91,7 @@ export class AcqOrderApiService extends BaseApi { */ getOrderPreview(orderPid: string): Observable { const apiUrl = `/api/acq_order/${orderPid}/acquisition_order/preview`; - return this._http.get(apiUrl); + return this.httpClient.get(apiUrl); } /** @@ -113,7 +101,7 @@ export class AcqOrderApiService extends BaseApi { */ sendOrder(orderPid: string, emails: AcqAddressRecipient[]): Observable { const apiUrl = `/api/acq_order/${orderPid}/send_order`; - return this._http.post(apiUrl, {emails}).pipe( + return this.httpClient.post(apiUrl, {emails}).pipe( map((data: any) => new Notification(data.data)) ); } @@ -121,7 +109,7 @@ export class AcqOrderApiService extends BaseApi { getOrderHistory(orderPid: string) { // check if orderPid is already present into the previously loaded history items. // If YES :: not needed to reload the history, just update the `current` attribute of history items - const orderRef = new URL(this._apiService.getRefEndpoint('acq_orders', orderPid)); + const orderRef = new URL(this.apiService.getRefEndpoint('acq_orders', orderPid)); const idx = this._acqOrderHistory.findIndex(item => item.$ref === orderRef.toString()); if (idx !== -1) { if (!this._acqOrderHistory[idx].current) { @@ -132,7 +120,7 @@ export class AcqOrderApiService extends BaseApi { } else { // If NO :: Load the acquisition order history const apiUrl = `/api/acq_order/${orderPid}/history`; - this._http + this.httpClient .get(apiUrl) .subscribe(versions => { versions.map(version => version.current = version.$ref === orderRef.toString()); @@ -153,10 +141,10 @@ export class AcqOrderApiService extends BaseApi { if (extraQuery) { query += ` ${extraQuery}`; } - return this._recordService + return this.recordService .getRecords('acq_order_lines', query, 1, RecordService.MAX_REST_RESULTS_SIZE, undefined, undefined, undefined, 'priority') .pipe( - map((result: Record) => this._recordService.totalHits(result.hits.total) === 0 ? [] : result.hits.hits), + map((result: Record) => this.recordService.totalHits(result.hits.total) === 0 ? [] : result.hits.hits), map((hits: any[]) => hits.map(hit => ({...this.orderDefaultData, ...hit.metadata}) )) ); } @@ -168,7 +156,7 @@ export class AcqOrderApiService extends BaseApi { * @param orderLine: the order line to delete */ deleteOrderLine(orderLine: IAcqOrderLine): void { - this._recordUiService + this.recordUiService .deleteRecord('acq_order_lines', orderLine.pid) .subscribe((success: boolean) => { if (success) { diff --git a/projects/admin/src/app/acquisition/api/acq-receipt-api.service.ts b/projects/admin/src/app/acquisition/api/acq-receipt-api.service.ts index 7142e3a2f..671f3de7f 100644 --- a/projects/admin/src/app/acquisition/api/acq-receipt-api.service.ts +++ b/projects/admin/src/app/acquisition/api/acq-receipt-api.service.ts @@ -1,6 +1,6 @@ /* * RERO ILS UI - * Copyright (C) 2021 RERO + * Copyright (C) 2021-2024 RERO * Copyright (C) 2021 UCLouvain * * This program is free software: you can redistribute it and/or modify @@ -16,12 +16,12 @@ * along with this program. If not, see . */ import { HttpClient } from '@angular/common/http'; -import { Injectable } from '@angular/core'; +import { inject, Injectable } from '@angular/core'; import { TranslateService } from '@ngx-translate/core'; import { Record, RecordService, RecordUiService } from '@rero/ng-core'; +import { BaseApi } from '@rero/shared'; import { Observable, of, Subject } from 'rxjs'; import { catchError, map } from 'rxjs/operators'; -import { BaseApi } from '@rero/shared'; import { IAcqReceipt, IAcqReceiptLine } from '../classes/receipt'; import { AcqResponseReceiptLineStatus, ICreateLineMessage, IResponseReceiptLine } from '../components/receipt/receipt-form/order-receipt'; @@ -30,6 +30,11 @@ import { AcqResponseReceiptLineStatus, ICreateLineMessage, IResponseReceiptLine }) export class AcqReceiptApiService { + private apiService: RecordService = inject(RecordService); + private recordUiService: RecordUiService = inject(RecordUiService); + private httpClient: HttpClient = inject(HttpClient); + private translateService: TranslateService = inject(TranslateService); + // SERVICES ATTRIBUTES ====================================================== /** The resource name for an acquisition receipt */ readonly resourceName = 'acq_receipts'; @@ -63,21 +68,6 @@ export class AcqReceiptApiService { get deletedReceiptSubject$(): Observable { return this._deletedReceiptSubject$.asObservable(); } get deletedReceiptLineSubject$(): Observable { return this._deletedReceiptLineSubject$.asObservable(); } - // CONSTRUCTOR ============================================================== - /** - * Constructor - * @param _recordService - RecordService - * @param _recordUiService - RecordUiService - * @param _http - HttpClient - * @param _translateService - TranslateService - */ - constructor( - private _recordService: RecordService, - private _recordUiService: RecordUiService, - private _http: HttpClient, - private _translateService: TranslateService - ) {} - // READ/LIST FUNCTIONS ====================================================== /** * Get acquisition receipt record. @@ -85,7 +75,7 @@ export class AcqReceiptApiService { * @returns ElasticSearch response for this receipt or null if error occurred. */ getReceipt(pid: string): Observable { - return this._recordService + return this.apiService .getRecord(this.resourceName, pid, 1, BaseApi.reroJsonheaders) .pipe( map(data => ({...this.receiptDefaultData, ...data.metadata}) ) @@ -103,10 +93,10 @@ export class AcqReceiptApiService { sort?: string }): Observable { options = {...this._defaultRecordOptions, ...options}; // add some default params - return this._recordService + return this.apiService .getRecords(this.resourceName, query, 1, RecordService.MAX_REST_RESULTS_SIZE, undefined, undefined, options.headers, options.sort) .pipe( - map((result: Record) => this._recordService.totalHits(result.hits.total) === 0 ? [] : result.hits.hits), + map((result: Record) => this.apiService.totalHits(result.hits.total) === 0 ? [] : result.hits.hits), map((hits: any[]) => hits.map(hit => ({...this.receiptDefaultData, ...hit.metadata}) )) ); } @@ -127,11 +117,11 @@ export class AcqReceiptApiService { */ getReceiptLines(receiptPid: string): Observable { const query = `acq_receipt.pid:${receiptPid}`; - return this._recordService + return this.apiService .getRecords('acq_receipt_lines', query, 1, RecordService.MAX_REST_RESULTS_SIZE, undefined, undefined, BaseApi.reroJsonheaders, 'receipt_date') .pipe( - map((result: Record) => this._recordService.totalHits(result.hits.total) === 0 ? [] : result.hits.hits), + map((result: Record) => this.apiService.totalHits(result.hits.total) === 0 ? [] : result.hits.hits), map((hits: any[]) => hits.map(hit => ({...this.receiptLineDefaultData, ...hit.metadata}) )) ); } @@ -143,7 +133,7 @@ export class AcqReceiptApiService { * @returns created receipt data if success or null if failed */ createReceipt(record: any): Observable { - return this._recordService + return this.apiService .create(this.resourceName, record) .pipe( map((data: any) => ({...this.receiptDefaultData, ...data.metadata}) ) @@ -157,9 +147,9 @@ export class AcqReceiptApiService { * @returns the list of performed data. Each line has a status to specify if the creation was well done. */ createReceiptLines(receiptPid: string, lines: IAcqReceiptLine[]): Observable { - const generalErrorMessage = this._translateService.instant('Error proceeding receipt lines creation'); + const generalErrorMessage = this.translateService.instant('Error proceeding receipt lines creation'); const url = `/api/acq_receipt/${receiptPid}/lines`; - return this._http + return this.httpClient .post(url, lines) .pipe( map((response: IResponseReceiptLine) => response.response), @@ -186,7 +176,7 @@ export class AcqReceiptApiService { * @returns the API response with receipt data or null if operation failed. */ updateReceipt(receiptPid: string, record: any): Observable { - return this._recordService + return this.apiService .update(this.resourceName, receiptPid, record) .pipe( map((response: any) => ({ ...this.receiptDefaultData, ...response.metadata}) ) @@ -200,7 +190,7 @@ export class AcqReceiptApiService { * @param receipt - the receipt to delete */ delete(receipt: IAcqReceipt): void { - this._recordUiService + this.recordUiService .deleteRecord(this.resourceName, receipt.pid) .subscribe((success: boolean) => { if (success) { @@ -216,7 +206,7 @@ export class AcqReceiptApiService { * @param receiptLine - the receipt line to delete */ deleteReceiptLine(receiptLine: IAcqReceiptLine): void { - this._recordUiService + this.recordUiService .deleteRecord('acq_receipt_lines', receiptLine.pid) .subscribe((success: boolean) => { if (success) { diff --git a/projects/admin/src/app/acquisition/classes/budget.ts b/projects/admin/src/app/acquisition/classes/budget.ts index 0c011c347..d617bb039 100644 --- a/projects/admin/src/app/acquisition/classes/budget.ts +++ b/projects/admin/src/app/acquisition/classes/budget.ts @@ -18,7 +18,6 @@ /* tslint:disable */ // required as json properties is not lowerCamelCase - import { ObjectReference } from '@rero/shared'; /** Wrapping class to describe an AcqAccount */ @@ -35,7 +34,7 @@ export class AcqBudget { * Constructor * @param obj - the JSON parsed object to load. */ - constructor(obj?: any){ + constructor(obj?: any) { Object.assign(this, obj); } } diff --git a/projects/admin/src/app/acquisition/classes/order.ts b/projects/admin/src/app/acquisition/classes/order.ts index b2d2bb25b..fee577dfb 100644 --- a/projects/admin/src/app/acquisition/classes/order.ts +++ b/projects/admin/src/app/acquisition/classes/order.ts @@ -126,7 +126,7 @@ export class AcqOrderHistoryVersion { * Constructor * @param obj - the JSON parsed object to load. */ - constructor(obj?: any){ + constructor(obj?: any) { Object.assign(this, obj); this.active = obj.current; this.pid = extractIdOnRef(obj.$ref); diff --git a/projects/admin/src/app/acquisition/components/account/account-brief-view/account-brief-view.component.html b/projects/admin/src/app/acquisition/components/account/account-brief-view/account-brief-view.component.html index 40a4a6050..f582933fd 100644 --- a/projects/admin/src/app/acquisition/components/account/account-brief-view/account-brief-view.component.html +++ b/projects/admin/src/app/acquisition/components/account/account-brief-view/account-brief-view.component.html @@ -60,22 +60,27 @@
@if (permissions.update.can) { - + } @if (permissions.delete.can) { - + } @else { - -
+ + + + }
diff --git a/projects/admin/src/app/acquisition/components/account/account-brief-view/account-brief-view.component.ts b/projects/admin/src/app/acquisition/components/account/account-brief-view/account-brief-view.component.ts index 1483f293f..178465629 100644 --- a/projects/admin/src/app/acquisition/components/account/account-brief-view/account-brief-view.component.ts +++ b/projects/admin/src/app/acquisition/components/account/account-brief-view/account-brief-view.component.ts @@ -16,15 +16,16 @@ * along with this program. If not, see . */ -import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; -import { TranslateService } from '@ngx-translate/core'; -import { UserService } from '@rero/shared'; -import { ToastrService } from 'ngx-toastr'; +import { Component, EventEmitter, inject, Input, OnInit, Output } from '@angular/core'; import { RecordPermissions } from '@app/admin/classes/permissions'; import { OrganisationService } from '@app/admin/service/organisation.service'; import { RecordPermissionService } from '@app/admin/service/record-permission.service'; -import { IAcqAccount } from '../../../classes/account'; +import { TranslateService } from '@ngx-translate/core'; +import { CONFIG } from '@rero/ng-core'; +import { UserService } from '@rero/shared'; +import { MessageService } from 'primeng/api'; import { AcqAccountApiService } from '../../../api/acq-account-api.service'; +import { IAcqAccount } from '../../../classes/account'; @Component({ selector: 'admin-account-brief-view', @@ -33,6 +34,13 @@ import { AcqAccountApiService } from '../../../api/acq-account-api.service'; }) export class AccountBriefViewComponent implements OnInit { + private recordPermissionService: RecordPermissionService = inject(RecordPermissionService); + private organisationService: OrganisationService = inject(OrganisationService); + private accountApiService: AcqAccountApiService = inject(AcqAccountApiService); + private translateService: TranslateService = inject(TranslateService); + private userService: UserService = inject(UserService); + private messageService = inject(MessageService); + // COMPONENT ATTRIBUTES ======================================================== /** the account to display */ @Input() account: IAcqAccount = null; @@ -66,25 +74,6 @@ export class AccountBriefViewComponent implements OnInit { return this.recordPermissionService.generateDeleteMessage(this.permissions.delete.reasons); } - // CONSTRUCTOR & HOOKS ======================================================== - /** - * Constructor - * @param recordPermissionService - RecordPermissionService - * @param organisationService - OrganisationService - * @param accountApiService - AcqAccountApiService - * @param toastrService - ToastrService - * @param translateService - TranslateService - * @param userService - UserService - */ - constructor( - private recordPermissionService: RecordPermissionService, - private organisationService: OrganisationService, - private accountApiService: AcqAccountApiService, - private toastrService: ToastrService, - private translateService: TranslateService, - private userService: UserService - ) { } - /** OnInit hook */ ngOnInit(): void { if (this.account) { @@ -108,7 +97,12 @@ export class AccountBriefViewComponent implements OnInit { this.accountApiService .delete(this.account.pid) .subscribe(() => { - this.toastrService.success(this.translateService.instant('Account deleted')); + this.messageService.add({ + severity: 'success', + summary: this.translateService.instant('Account'), + detail: this.translateService.instant('Account deleted'), + life: CONFIG.MESSAGE_LIFE + }); this.deleteAccount.emit(this.account); }); } diff --git a/projects/admin/src/app/acquisition/components/account/account-detail-view/account-detail-view.component.html b/projects/admin/src/app/acquisition/components/account/account-detail-view/account-detail-view.component.html index 5245cadff..a104e2290 100644 --- a/projects/admin/src/app/acquisition/components/account/account-detail-view/account-detail-view.component.html +++ b/projects/admin/src/app/acquisition/components/account/account-detail-view/account-detail-view.component.html @@ -22,32 +22,27 @@ }

{{ account.name }}

-
-
Details
-
-
-
Account number
-
{{ account.number }}
-
Budget
-
{{ account.budget.pid | getRecord: 'budgets': 'field': 'name' | async }}
-
Library
-
{{ account.library.pid | getRecord: 'libraries': 'field': 'name' | async }}
- @if (account.parent) { -
Parent account
-
- - {{ account.parent.pid | getRecord: 'acq_accounts': 'field': 'name' | async }} - -
- } -
-
-
+ +
+
Account number
+
{{ account.number }}
+
Budget
+
{{ account.budget.pid | getRecord: 'budgets': 'field': 'name' | async }}
+
Library
+
{{ account.library.pid | getRecord: 'libraries': 'field': 'name' | async }}
+ @if (account.parent) { +
Parent account
+
+ + {{ account.parent.pid | getRecord: 'acq_accounts': 'field': 'name' | async }} + +
+ } +
+
-
-
Accounting informations
-
+ @@ -115,6 +110,5 @@
Accounting informations
-
-
+ } diff --git a/projects/admin/src/app/acquisition/components/account/account-detail-view/account-detail-view.component.ts b/projects/admin/src/app/acquisition/components/account/account-detail-view/account-detail-view.component.ts index 59dcd5f38..39cc44c86 100644 --- a/projects/admin/src/app/acquisition/components/account/account-detail-view/account-detail-view.component.ts +++ b/projects/admin/src/app/acquisition/components/account/account-detail-view/account-detail-view.component.ts @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import { Component, OnInit } from '@angular/core'; +import { Component, inject, OnInit } from '@angular/core'; import { DetailRecord } from '@rero/ng-core/lib/record/detail/view/detail-record'; import { Observable } from 'rxjs'; import { OrganisationService } from '../../../../service/organisation.service'; @@ -30,6 +30,9 @@ import { IAcqAccount } from '../../../classes/account'; }) export class AccountDetailViewComponent implements OnInit, DetailRecord { + private acqAccountApiService: AcqAccountApiService = inject(AcqAccountApiService); + private organisationService: OrganisationService = inject(OrganisationService); + // COMPONENT ATTRIBUTES ======================================================= /** Observable resolving record data */ record$: Observable; @@ -44,22 +47,10 @@ export class AccountDetailViewComponent implements OnInit, DetailRecord { return this.organisationService.organisation; } - // CONSTRUCTOR & HOOKS ======================================================== - /** - * Constructor - * @param acqAccountApiService - AcqAccountApiService - * @param organisationService - OrganisationService - */ - constructor( - private acqAccountApiService: AcqAccountApiService, - private organisationService: OrganisationService - ) { } - /** OnInit hook */ ngOnInit(): void { this.record$.subscribe((data: any) => { this.esRecord$ = this.acqAccountApiService.getAccount(data.metadata.pid); }); } - } diff --git a/projects/admin/src/app/acquisition/components/account/account-list/account-list.component.html b/projects/admin/src/app/acquisition/components/account/account-list/account-list.component.html index 7b79144a2..4c9229bfd 100644 --- a/projects/admin/src/app/acquisition/components/account/account-list/account-list.component.html +++ b/projects/admin/src/app/acquisition/components/account/account-list/account-list.component.html @@ -20,33 +20,33 @@

Acquisition accounts

-
+
Amount
Available
diff --git a/projects/admin/src/app/acquisition/components/account/account-list/account-list.component.ts b/projects/admin/src/app/acquisition/components/account/account-list/account-list.component.ts index 404f262ba..a62d350f3 100644 --- a/projects/admin/src/app/acquisition/components/account/account-list/account-list.component.ts +++ b/projects/admin/src/app/acquisition/components/account/account-list/account-list.component.ts @@ -15,15 +15,15 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -import { Component, OnInit } from '@angular/core'; -import { IPermissions, PERMISSIONS, UserService } from '@rero/shared'; -import { OrganisationService } from '@app/admin/service/organisation.service'; -import { IAcqAccount } from '@app/admin/acquisition/classes/account'; +import { HttpParams } from '@angular/common/http'; +import { Component, inject, OnInit } from '@angular/core'; import { AcqAccountApiService } from '@app/admin/acquisition/api/acq-account-api.service'; -import { ApiService, RecordService } from '@rero/ng-core'; -import { TranslateService } from '@ngx-translate/core'; +import { IAcqAccount } from '@app/admin/acquisition/classes/account'; import { exportFormats } from '@app/admin/acquisition/routes/accounts-route'; -import { HttpParams } from '@angular/common/http'; +import { OrganisationService } from '@app/admin/service/organisation.service'; +import { TranslateService } from '@ngx-translate/core'; +import { ApiService, RecordService } from '@rero/ng-core'; +import { IPermissions, PERMISSIONS, UserService } from '@rero/shared'; @Component({ selector: 'admin-account-list', @@ -31,6 +31,12 @@ import { HttpParams } from '@angular/common/http'; }) export class AccountListComponent implements OnInit { + private userService: UserService = inject(UserService); + private acqAccountApiService: AcqAccountApiService = inject(AcqAccountApiService); + private organisationService: OrganisationService = inject(OrganisationService); + private apiService: ApiService = inject(ApiService); + private translateService: TranslateService = inject(TranslateService); + // COMPONENT ATTRIBUTES ======================================================= /** Root account to display */ rootAccounts: IAcqAccount[] = []; @@ -65,23 +71,6 @@ export class AccountListComponent implements OnInit { ); } - // CONSTRUCTOR & HOOKS ======================================================== - /** - * Constructor - * @param userService: UserService - * @param acqAccountApiService: AcqAccountApiService - * @param organisationService: OrganisationService - * @param apiService: ApiService - * @param translateService: TranslateService - */ - constructor( - private userService: UserService, - private acqAccountApiService: AcqAccountApiService, - private organisationService: OrganisationService, - private apiService: ApiService, - private translateService: TranslateService, - ) { } - /** OnInit hook */ ngOnInit(): void { this._libraryPid = this.userService.user.currentLibrary; diff --git a/projects/admin/src/app/acquisition/components/account/account-transfer/account-transfer.component.html b/projects/admin/src/app/acquisition/components/account/account-transfer/account-transfer.component.html index c85c79d6d..6a75c6584 100644 --- a/projects/admin/src/app/acquisition/components/account/account-transfer/account-transfer.component.html +++ b/projects/admin/src/app/acquisition/components/account/account-transfer/account-transfer.component.html @@ -16,9 +16,9 @@ along with this program. If not, see . --> @if (accountsToDisplay && organisation) { -
-

Fund transfer

-
+

Fund transfer

+
+ @if (budgets.length > 1) { } +
+
Source
+
+
Amount
+
Available
+
Target
+
+
+ @if (accountsToDisplay.length > 0) { + @for (account of accountsToDisplay; track account) { + + } + } @else { + {{ 'No account available' | translate }} + } +
+ +
} diff --git a/projects/admin/src/app/acquisition/components/account/account-transfer/account-transfer.component.ts b/projects/admin/src/app/acquisition/components/account/account-transfer/account-transfer.component.ts index 8b800f5ab..50bc4c540 100644 --- a/projects/admin/src/app/acquisition/components/account/account-transfer/account-transfer.component.ts +++ b/projects/admin/src/app/acquisition/components/account/account-transfer/account-transfer.component.ts @@ -17,13 +17,14 @@ */ import { getCurrencySymbol } from '@angular/common'; -import { Component, OnInit } from '@angular/core'; +import { Component, inject, OnInit } from '@angular/core'; import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms'; import { Router } from '@angular/router'; import { OrganisationService } from '@app/admin/service/organisation.service'; import { TranslateService } from '@ngx-translate/core'; +import { CONFIG } from '@rero/ng-core'; import { UserService } from '@rero/shared'; -import { ToastrService } from 'ngx-toastr'; +import { MessageService } from 'primeng/api'; import { AcqAccountApiService } from '../../../api/acq-account-api.service'; import { IAcqAccount } from '../../../classes/account'; import { orderAccountsAsTree } from '../../../utils/account'; @@ -35,6 +36,14 @@ import { orderAccountsAsTree } from '../../../utils/account'; }) export class AccountTransferComponent implements OnInit { + private acqAccountApiService: AcqAccountApiService = inject(AcqAccountApiService); + private organisationService: OrganisationService = inject(OrganisationService); + private formBuilder: UntypedFormBuilder = inject(UntypedFormBuilder); + private translateService: TranslateService = inject(TranslateService); + private router: Router = inject(Router); + private userService: UserService = inject(UserService); + private messageService = inject(MessageService); + // COMPONENT ATTRIBUTES ======================================================= /** the accounts available for transfer */ accountsToDisplay: IAcqAccount[] = []; @@ -60,25 +69,7 @@ export class AccountTransferComponent implements OnInit { } // CONSTRUCTOR & HOOKS ======================================================== - /** - * Constructor - * @param acqAccountApiService - AcqAccountApiService - * @param organisationService - OrganisationService - * @param formBuilder - FormBuilder, - * @param toastrService - ToastrService, - * @param translateService - TranslateService - * @param router - Router - * @param userService - UserService - */ - constructor( - private acqAccountApiService: AcqAccountApiService, - private organisationService: OrganisationService, - private formBuilder: UntypedFormBuilder, - private toastrService: ToastrService, - private translateService: TranslateService, - private router: Router, - private userService: UserService - ) { + constructor() { this.form = this.formBuilder.group({ source: [undefined, Validators.required], target: [undefined, Validators.required], @@ -123,13 +114,24 @@ export class AccountTransferComponent implements OnInit { submit(): void { this.acqAccountApiService .transferFunds(this.form.value.source.pid, this.form.value.target.pid, this.form.value.amount) - .subscribe( - () => { - this.toastrService.success(this.translateService.instant('Fund transfer successful!')); + .subscribe({ + next: () => { + this.messageService.add({ + severity: 'success', + summary: this.translateService.instant('Account'), + detail: this.translateService.instant('Fund transfer successful!'), + life: CONFIG.MESSAGE_LIFE + }); this.router.navigate(['/', 'acquisition', 'accounts']); }, - (err) => { this.toastrService.error(this.translateService.instant(err.error.message)); } - ); + error: (err) => this.messageService.add({ + severity: 'error', + summary: this.translateService.instant('Account'), + detail:this.translateService.instant(err.error.message), + sticky: true, + closable: true + }), + }); } /** diff --git a/projects/admin/src/app/acquisition/components/budget/budget-brief-view/budgets-brief-view.component.ts b/projects/admin/src/app/acquisition/components/budget/budget-brief-view/budgets-brief-view.component.ts index 4126e8e3e..26c7ac9c2 100644 --- a/projects/admin/src/app/acquisition/components/budget/budget-brief-view/budgets-brief-view.component.ts +++ b/projects/admin/src/app/acquisition/components/budget/budget-brief-view/budgets-brief-view.component.ts @@ -16,14 +16,14 @@ * along with this program. If not, see . */ -import { Component, Input } from '@angular/core'; +import { Component, inject, Input } from '@angular/core'; import { TranslateService } from '@ngx-translate/core'; import { ResultItem } from '@rero/ng-core'; @Component({ selector: 'admin-budgets-brief-view', template: ` -
+
@if (!record.metadata.is_active) { -
Fiscal year closed
+ } -
+

{{ record.metadata.name }}

-
+
Total
{{ totalAmount | currency:currencyCode:'symbol' }}
diff --git a/projects/admin/src/app/acquisition/components/budget/budget-detail-view/budget-detail-view.component.ts b/projects/admin/src/app/acquisition/components/budget/budget-detail-view/budget-detail-view.component.ts index 0f4f11b30..d3c487610 100644 --- a/projects/admin/src/app/acquisition/components/budget/budget-detail-view/budget-detail-view.component.ts +++ b/projects/admin/src/app/acquisition/components/budget/budget-detail-view/budget-detail-view.component.ts @@ -15,7 +15,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -import { Component, OnDestroy, OnInit } from '@angular/core'; +import { Component, inject, OnDestroy, OnInit } from '@angular/core'; import { OrganisationService } from '@app/admin/service/organisation.service'; import { DetailRecord } from '@rero/ng-core/lib/record/detail/view/detail-record'; import { Observable, Subscription } from 'rxjs'; @@ -28,6 +28,9 @@ import { AcqBudgetApiService } from '../../../api/acq-budget-api.service'; }) export class BudgetDetailViewComponent implements DetailRecord, OnInit, OnDestroy { + private budgetApiService: AcqBudgetApiService = inject(AcqBudgetApiService); + private organisationService: OrganisationService = inject(OrganisationService); + // COMPONENT ATTRIBUTES ===================================================== /** Record observable */ record$: Observable; @@ -45,17 +48,6 @@ export class BudgetDetailViewComponent implements DetailRecord, OnInit, OnDestro return this.organisationService.organisation.default_currency; } - // CONSTRUCTOR & HOOKS ====================================================== - /** - * Constructor - * @param budgetApiService - AcqBudgetApiService - * @param organisationService - OrganisationService - */ - constructor( - private budgetApiService: AcqBudgetApiService, - private organisationService: OrganisationService - ) {} - /** OnInit hook */ ngOnInit() { this._subscriptions.add( diff --git a/projects/admin/src/app/acquisition/components/editor/widget/select-account-editor-widget/select-account-editor-widget.component.ts b/projects/admin/src/app/acquisition/components/editor/widget/select-account-editor-widget/select-account-editor-widget.component.ts index ba56274fd..6d272357a 100644 --- a/projects/admin/src/app/acquisition/components/editor/widget/select-account-editor-widget/select-account-editor-widget.component.ts +++ b/projects/admin/src/app/acquisition/components/editor/widget/select-account-editor-widget/select-account-editor-widget.component.ts @@ -16,7 +16,7 @@ * along with this program. If not, see . */ import { getCurrencySymbol } from '@angular/common'; -import { ChangeDetectorRef, Component, OnInit } from '@angular/core'; +import { ChangeDetectorRef, Component, inject, OnInit } from '@angular/core'; import { IAcqAccount } from '@app/admin/acquisition/classes/account'; import { OrganisationService } from '@app/admin/service/organisation.service'; import { FieldType } from '@ngx-formly/core'; @@ -32,6 +32,12 @@ import { orderAccountsAsTree } from '../../../../utils/account'; }) export class SelectAccountEditorWidgetComponent extends FieldType implements OnInit { + private acqAccountApiService: AcqAccountApiService = inject(AcqAccountApiService); + private organisationService: OrganisationService = inject(OrganisationService); + private apiService: ApiService = inject(ApiService); + private userService: UserService = inject(UserService); + private changeDetectorRef: ChangeDetectorRef = inject(ChangeDetectorRef); + // COMPONENT ATTRIBUTES ======================================================= /** accounts list */ accountList: IAcqAccount[] = []; @@ -49,24 +55,6 @@ export class SelectAccountEditorWidgetComponent extends FieldType implements OnI return getCurrencySymbol(this.organisation.default_currency, 'wide'); } - // CONSTRUCTOR & HOOKS ====================================================== - /** - * Constructor - * @param acqAccountApiService - AcqAccountApiService - * @param organisationService - OrganisationService - * @param apiService - ApiService - * @param userService - UserService - */ - constructor( - private acqAccountApiService: AcqAccountApiService, - private organisationService: OrganisationService, - private apiService: ApiService, - private userService: UserService, - private changeDetectorRef: ChangeDetectorRef - ) { - super(); - } - /** OnInit hook */ ngOnInit(): void { const libraryPid = this.userService.user.currentLibrary; diff --git a/projects/admin/src/app/acquisition/components/order/order-brief-view/order-brief-view.component.html b/projects/admin/src/app/acquisition/components/order/order-brief-view/order-brief-view.component.html index 630369169..14f4f9766 100644 --- a/projects/admin/src/app/acquisition/components/order/order-brief-view/order-brief-view.component.html +++ b/projects/admin/src/app/acquisition/components/order/order-brief-view/order-brief-view.component.html @@ -16,7 +16,7 @@ along with this program. If not, see . --> @if (order) { -
+
{{ order.reference }}
diff --git a/projects/admin/src/app/acquisition/components/order/order-brief-view/order-brief-view.component.ts b/projects/admin/src/app/acquisition/components/order/order-brief-view/order-brief-view.component.ts index 88372b165..b8110ebd4 100644 --- a/projects/admin/src/app/acquisition/components/order/order-brief-view/order-brief-view.component.ts +++ b/projects/admin/src/app/acquisition/components/order/order-brief-view/order-brief-view.component.ts @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import { Component, Input, OnInit } from '@angular/core'; +import { Component, inject, Input, OnInit } from '@angular/core'; import { ResultItem } from '@rero/ng-core'; import { AcqOrderApiService } from '../../../api/acq-order-api.service'; import { AcqNoteType } from '../../../classes/common'; @@ -29,6 +29,8 @@ import { AcqOrderStatus, IAcqOrder } from '../../../classes/order'; }) export class OrderBriefViewComponent implements ResultItem, OnInit { + private acqOrderApiService: AcqOrderApiService = inject(AcqOrderApiService); + // COMPONENTS ATTRIBUTES ==================================================== /** the record to display */ @Input() record: any; @@ -79,13 +81,6 @@ export class OrderBriefViewComponent implements ResultItem, OnInit { return (this.order.account_statement.expenditure.quantity > 0); } - // CONSTRUCTOR & HOOKS ====================================================== - /** - * constructor - * @param acqOrderApiService - AcqOrderApiService - */ - constructor(private acqOrderApiService: AcqOrderApiService) {} - /** OnInit hook */ ngOnInit(): void { const metadata = {...this.acqOrderApiService.orderDefaultData, ...this.record.metadata}; diff --git a/projects/admin/src/app/acquisition/components/order/order-detail-view/order-detail-view.component.html b/projects/admin/src/app/acquisition/components/order/order-detail-view/order-detail-view.component.html index f3bfd5b1b..d566d9896 100644 --- a/projects/admin/src/app/acquisition/components/order/order-detail-view/order-detail-view.component.html +++ b/projects/admin/src/app/acquisition/components/order/order-detail-view/order-detail-view.component.html @@ -34,7 +34,12 @@
@if (!order.is_current_budget) { -
Fiscal year closed
+ }

{{ order.reference }}

@@ -52,9 +57,8 @@

{{ order.reference }}

} - - - + + @if (isPermissionsLoaded) { @@ -90,16 +94,14 @@
} - - - + + @if (isPermissionsLoaded) { } - - + @if (historyVersions && historyVersions.length > 1) { - +
@@ -109,8 +111,8 @@
{{ event.description }} - + } - +
} diff --git a/projects/admin/src/app/acquisition/components/order/order-detail-view/order-detail-view.component.ts b/projects/admin/src/app/acquisition/components/order/order-detail-view/order-detail-view.component.ts index 5296ea787..9c1c4d7e9 100644 --- a/projects/admin/src/app/acquisition/components/order/order-detail-view/order-detail-view.component.ts +++ b/projects/admin/src/app/acquisition/components/order/order-detail-view/order-detail-view.component.ts @@ -16,18 +16,19 @@ * along with this program. If not, see . */ import { ViewportScroller } from '@angular/common'; -import { Component, OnDestroy, OnInit } from '@angular/core'; +import { Component, inject, OnDestroy, OnInit } from '@angular/core'; import { AcqOrderApiService } from '@app/admin/acquisition/api/acq-order-api.service'; import { RecordPermissions } from '@app/admin/classes/permissions'; import { RecordPermissionService } from '@app/admin/service/record-permission.service'; import { CurrentLibraryPermissionValidator } from '@app/admin/utils/permissions'; +import { extractIdOnRef } from '@rero/ng-core'; import { DetailRecord } from '@rero/ng-core/lib/record/detail/view/detail-record'; -import { BsModalService } from 'ngx-bootstrap/modal'; +import { DialogService, DynamicDialogRef } from 'primeng/dynamicdialog'; import { Observable, Subscription } from 'rxjs'; import { map } from 'rxjs/operators'; import { AcqOrderHistoryVersion, AcqOrderHistoryVersionResponseInterface, AcqOrderStatus, IAcqOrder } from '../../../classes/order'; import { OrderEmailFormComponent } from '../order-email-form/order-email-form.component'; -import { extractIdOnRef } from '@rero/ng-core'; +import { TranslateService } from '@ngx-translate/core'; @Component({ selector: 'admin-acquisition-order-detail-view', @@ -36,6 +37,13 @@ import { extractIdOnRef } from '@rero/ng-core'; }) export class OrderDetailViewComponent implements DetailRecord, OnInit, OnDestroy { + private dialogService: DialogService = inject(DialogService); + private scroller: ViewportScroller = inject(ViewportScroller); + private recordPermissionService: RecordPermissionService = inject(RecordPermissionService); + private acqOrderService: AcqOrderApiService = inject(AcqOrderApiService); + private permissionValidator: CurrentLibraryPermissionValidator = inject(CurrentLibraryPermissionValidator); + private translateService: TranslateService = inject(TranslateService); + // COMPONENT ATTRIBUTES ===================================================== /** Observable resolving record data */ record$: Observable; @@ -57,6 +65,8 @@ export class OrderDetailViewComponent implements DetailRecord, OnInit, OnDestroy /** all component subscription */ private subscriptions = new Subscription(); + modalRef: DynamicDialogRef | undefined; + // GETTER & SETTER ========================================================== /** Determine if the order could be "placed/ordered" */ get canPlaceOrder(): boolean { @@ -68,24 +78,8 @@ export class OrderDetailViewComponent implements DetailRecord, OnInit, OnDestroy return this.order.status !== AcqOrderStatus.PENDING; } - // CONSTRUCTOR & HOOKS ====================================================== - /** Constructor - * @param scroller - ViewportScroller - * @param modalService - BsModalService - * @param recordPermissionService - RecordPermissionService - * @param permissionValidator - CurrentLibraryPermissionValidator - * @param acqOrderService - AcqOrderApiService - */ - constructor( - private scroller: ViewportScroller, - private modalService: BsModalService, - private recordPermissionService: RecordPermissionService, - private acqOrderService: AcqOrderApiService, - private permissionValidator: CurrentLibraryPermissionValidator - ) { } - /** OnInit hook */ - ngOnInit() { + ngOnInit(): void { this.subscriptions.add(this.record$.subscribe( (record: any) => { this.order = record.metadata; @@ -130,19 +124,17 @@ export class OrderDetailViewComponent implements DetailRecord, OnInit, OnDestroy * Open a modal dialog to allow user to validate the order. * If the user submit the form (and submitting is success), then update the order to get the updated data. */ - placeOrderDialog() { - const modalRef = this.modalService.show(OrderEmailFormComponent, { - ignoreBackdropClick: true, - keyboard: true, - class: 'modal-xl', - initialState: { + placeOrderDialog(): void { + this.modalRef = this.dialogService.open(OrderEmailFormComponent, { + header: this.translateService.instant('Place order'), + width: '60vw', + dismissableMask: true, + data: { order: this.order } }); - // Event to allow the closing of the dialog - modalRef.content.closeDialog.subscribe((close: boolean) => modalRef.hide()); - modalRef.content.recordChange.subscribe((order: IAcqOrder) => { - if (this.order.pid === order.pid) { + this.modalRef.onClose.subscribe((order?: IAcqOrder) => { + if (order && this.order.pid === order.pid) { if (order.vendor.$ref) { order.vendor.pid = extractIdOnRef(order.vendor.$ref); } diff --git a/projects/admin/src/app/acquisition/components/order/order-detail-view/order-line/order-line.component.html b/projects/admin/src/app/acquisition/components/order/order-detail-view/order-line/order-line.component.html index 1db0795ae..6065289b7 100644 --- a/projects/admin/src/app/acquisition/components/order/order-detail-view/order-line/order-line.component.html +++ b/projects/admin/src/app/acquisition/components/order/order-detail-view/order-line/order-line.component.html @@ -18,11 +18,14 @@
@if (orderLine && account) {
- +
@if (recordPermissions) { - - + /> - - + /> } @else {   } diff --git a/projects/admin/src/app/acquisition/components/order/order-detail-view/order-line/order-line.component.ts b/projects/admin/src/app/acquisition/components/order/order-detail-view/order-line/order-line.component.ts index aa2d654e6..b3da7f3e3 100644 --- a/projects/admin/src/app/acquisition/components/order/order-detail-view/order-line/order-line.component.ts +++ b/projects/admin/src/app/acquisition/components/order/order-detail-view/order-line/order-line.component.ts @@ -15,12 +15,12 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -import { Component, Input, OnDestroy, OnInit } from '@angular/core'; +import { Component, inject, Input, OnDestroy, OnInit } from '@angular/core'; import { RecordPermissions } from '@app/admin/classes/permissions'; import { RecordPermissionService } from '@app/admin/service/record-permission.service'; import { CurrentLibraryPermissionValidator } from '@app/admin/utils/permissions'; import { RecordService } from '@rero/ng-core'; -import { Subscription, forkJoin } from 'rxjs'; +import { forkJoin, Subscription } from 'rxjs'; import { map } from 'rxjs/operators'; import { AcqOrderApiService } from '../../../../api/acq-order-api.service'; import { AcqOrderLineStatus, IAcqOrderLine } from '../../../../classes/order'; @@ -33,6 +33,11 @@ import { AcqOrderLineStatus, IAcqOrderLine } from '../../../../classes/order'; }) export class OrderLineComponent implements OnInit, OnDestroy { + private recordPermissionService: RecordPermissionService = inject(RecordPermissionService); + private recordService: RecordService = inject(RecordService); + private acqOrderApiService: AcqOrderApiService = inject(AcqOrderApiService); + private permissionValidator: CurrentLibraryPermissionValidator = inject(CurrentLibraryPermissionValidator); + // COMPONENT ATTRIBUTES ===================================================== /** order line */ @Input() orderLine: IAcqOrderLine; @@ -67,20 +72,6 @@ export class OrderLineComponent implements OnInit, OnDestroy { : null; } - // CONSTRUCTOR & HOOKS ====================================================== - /** Constructor - * @param recordPermissionService - RecordPermissionService - * @param recordService - RecordService - * @param acqOrderApiService - AcqOrderApiService - * @param permissionValidator - CurrentLibraryPermissionValidator - */ - constructor( - private recordPermissionService: RecordPermissionService, - private recordService: RecordService, - private acqOrderApiService: AcqOrderApiService, - private permissionValidator: CurrentLibraryPermissionValidator - ) { } - /** OnInit hook */ ngOnInit() { const account$ = this.recordService.getRecord('acq_accounts', this.orderLine.acq_account.pid); diff --git a/projects/admin/src/app/acquisition/components/order/order-detail-view/order-lines/order-lines.component.html b/projects/admin/src/app/acquisition/components/order/order-detail-view/order-lines/order-lines.component.html index da3d87af3..6be406878 100644 --- a/projects/admin/src/app/acquisition/components/order/order-detail-view/order-lines/order-lines.component.html +++ b/projects/admin/src/app/acquisition/components/order/order-detail-view/order-lines/order-lines.component.html @@ -21,18 +21,25 @@
Order lines
@if (recordPermissions) { @if (recordPermissions.update.can) { - - {{ 'Add' | translate }} … - + /> } @else { - -
+ + + + } } @else {   diff --git a/projects/admin/src/app/acquisition/components/order/order-detail-view/order-lines/order-lines.component.ts b/projects/admin/src/app/acquisition/components/order/order-detail-view/order-lines/order-lines.component.ts index 5fbe2d04d..ea863ee14 100644 --- a/projects/admin/src/app/acquisition/components/order/order-detail-view/order-lines/order-lines.component.ts +++ b/projects/admin/src/app/acquisition/components/order/order-detail-view/order-lines/order-lines.component.ts @@ -15,7 +15,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, OnDestroy, OnInit, SimpleChanges } from '@angular/core'; +import { Component, inject, Input, OnChanges, OnDestroy, OnInit, SimpleChanges } from '@angular/core'; import { RecordPermissions } from '@app/admin/classes/permissions'; import { RecordPermissionService } from '@app/admin/service/record-permission.service'; import { Subscription } from 'rxjs'; @@ -28,6 +28,9 @@ import { IAcqOrder, IAcqOrderLine } from '../../../../classes/order'; }) export class OrderLinesComponent implements OnInit, OnChanges, OnDestroy { + private acqOrderApiService: AcqOrderApiService = inject(AcqOrderApiService); + private recordPermissionService: RecordPermissionService = inject(RecordPermissionService); + // COMPONENTS ATTRIBUTES ==================================================== /** Acquisition order pid */ @Input() order: IAcqOrder; @@ -48,17 +51,6 @@ export class OrderLinesComponent implements OnInit, OnChanges, OnDestroy { return this.recordPermissionService.generateTooltipMessage(this.recordPermissions.update.reasons, 'create'); } - // CONSTRUCTOR & HOOKS ====================================================== - /** - * Constructor - * @param acqOrderApiService - AcqOrderApiService - * @param recordPermissionService - RecordPermissionService - */ - constructor( - private acqOrderApiService: AcqOrderApiService, - private recordPermissionService: RecordPermissionService - ) { } - /** OnInit hook */ ngOnInit(): void { this.loadOrderLines(); diff --git a/projects/admin/src/app/acquisition/components/order/order-email-form/order-email-form.component.html b/projects/admin/src/app/acquisition/components/order/order-email-form/order-email-form.component.html index d345597f4..85982686e 100644 --- a/projects/admin/src/app/acquisition/components/order/order-email-form/order-email-form.component.html +++ b/projects/admin/src/app/acquisition/components/order/order-email-form/order-email-form.component.html @@ -23,10 +23,9 @@ [preview]="response.preview" [previewPosition]="'bottom'" [prePopulateRecipients]="suggestions.recipients" - (closeDialog)="closeEmailDialog()" + (closeDialog)="closeDialog()" (data)="confirmOrder($event)" > - {{ 'Place order' | translate }}

You're about to send the order.

diff --git a/projects/admin/src/app/acquisition/components/order/order-email-form/order-email-form.component.ts b/projects/admin/src/app/acquisition/components/order/order-email-form/order-email-form.component.ts index e45fa253e..78a5ad407 100644 --- a/projects/admin/src/app/acquisition/components/order/order-email-form/order-email-form.component.ts +++ b/projects/admin/src/app/acquisition/components/order/order-email-form/order-email-form.component.ts @@ -15,14 +15,16 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core'; +import { Component, inject, Input, OnDestroy, OnInit } from '@angular/core'; import { AcqOrderApiService } from '@app/admin/acquisition/api/acq-order-api.service'; import { IAcqOrder } from '@app/admin/acquisition/classes/order'; import { Notification } from '@app/admin/classes/notification'; import { IPreview, ITypeEmail } from '@app/admin/shared/preview-email/IPreviewInterface'; import { Tools } from '@app/admin/shared/preview-email/utils/tools'; import { TranslateService } from '@ngx-translate/core'; -import { ToastrService } from 'ngx-toastr'; +import { CONFIG } from '@rero/ng-core'; +import { MessageService } from 'primeng/api'; +import { DynamicDialogConfig, DynamicDialogRef } from 'primeng/dynamicdialog'; import { Subscription } from 'rxjs'; @Component({ @@ -31,15 +33,15 @@ import { Subscription } from 'rxjs'; }) export class OrderEmailFormComponent implements OnInit, OnDestroy { + private messageService: MessageService = inject(MessageService); + private dynamicDialogConfig: DynamicDialogConfig = inject(DynamicDialogConfig); + private dynamicDialogRef: DynamicDialogRef = inject(DynamicDialogRef); + private acqOrderApiService: AcqOrderApiService = inject(AcqOrderApiService); + private translateService: TranslateService = inject(TranslateService); + /** the related order */ @Input() order: IAcqOrder; - /** Closing event for the modal dialog */ - @Output() closeDialog = new EventEmitter(false); - - /** Reload data event to enable detection of data loading */ - @Output() recordChange = new EventEmitter(); - /** Available recipient types */ emailTypes = ['to', 'cc', 'bcc', 'reply_to']; @@ -55,20 +57,9 @@ export class OrderEmailFormComponent implements OnInit, OnDestroy { /** all component subscription */ private subscriptions = new Subscription(); - /** - * Constructor - * @param acqOrderApiService - AcqOrderApiService - * @param toastrService - ToastrService - * @param translateService - TranslateService - */ - constructor( - private acqOrderApiService: AcqOrderApiService, - private toastrService: ToastrService, - private translateService: TranslateService - ) { } - /** onInit hook */ ngOnInit(): void { + this.order = this.dynamicDialogConfig.data.order; this.subscriptions.add(this.acqOrderApiService .getOrderPreview(this.order.pid) .subscribe((response: IPreview) => { @@ -90,40 +81,41 @@ export class OrderEmailFormComponent implements OnInit, OnDestroy { confirmOrder(recipients: ITypeEmail[]): void { this.acqOrderApiService .sendOrder(this.order.pid, recipients) - .subscribe( - (notification: Notification) => { + .subscribe({ + next: (notification: Notification) => { if (notification.notification_sent) { - this.toastrService.success( - this.translateService.instant('order has been sent'), - this.translateService.instant('Order sent') - ); + this.messageService.add({ + severity: 'success', + summary: this.translateService.instant('Order sent'), + detail: this.translateService.instant('order has been sent'), + life: CONFIG.MESSAGE_LIFE + }); } else { - this.toastrService.warning( - this.translateService.instant('order not yet send'), - this.translateService.instant('Order delayed'), - { disableTimeOut: true, closeButton: true } - ); + this.messageService.add({ + severity: 'warn', + summary: this.translateService.instant('Order delayed'), + detail: this.translateService.instant('order not yet send'), + life: CONFIG.MESSAGE_LIFE + }); } - this.closeEmailDialog(); this.acqOrderApiService .getOrder(this.order.pid) - .subscribe((order: IAcqOrder) => this.recordChange.next(order)); + .subscribe((order: IAcqOrder) => this.closeDialog(order)); }, - (error: any) => { - this.toastrService.error( - error.error.message, - this.translateService.instant('Error when placing an order !'), - { disableTimeOut: true, closeButton: true } - ); - }); + error: (error: any) => { + this.messageService.add({ + severity: 'error', + summary: this.translateService.instant('Error when placing an order !'), + detail: error.error.message, + sticky: true, + closable: true + }); + } + }); } - /** - * Close email dialog - * Send the event to trigger the closing of the dialog - * from the child to the parent - */ - closeEmailDialog(): void { - this.closeDialog.emit(true); + /** Close email dialog */ + closeDialog(data?: IAcqOrder): void { + this.dynamicDialogRef.close(data); } } diff --git a/projects/admin/src/app/acquisition/components/order/order-summary/order-summary.component.html b/projects/admin/src/app/acquisition/components/order/order-summary/order-summary.component.html index c7f6332d3..4081d298e 100644 --- a/projects/admin/src/app/acquisition/components/order/order-summary/order-summary.component.html +++ b/projects/admin/src/app/acquisition/components/order/order-summary/order-summary.component.html @@ -16,7 +16,7 @@ along with this program. If not, see . --> @if (order) { -
+
diff --git a/projects/admin/src/app/acquisition/components/order/order-summary/order-summary.component.ts b/projects/admin/src/app/acquisition/components/order/order-summary/order-summary.component.ts index 49a52f281..00e03bd7e 100644 --- a/projects/admin/src/app/acquisition/components/order/order-summary/order-summary.component.ts +++ b/projects/admin/src/app/acquisition/components/order/order-summary/order-summary.component.ts @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import { Component, Input, OnDestroy, OnInit } from '@angular/core'; +import { Component, inject, Input, OnDestroy, OnInit } from '@angular/core'; import { Subscription } from 'rxjs'; import { AcqOrderApiService } from '../../../api/acq-order-api.service'; import { AcqReceiptApiService } from '../../../api/acq-receipt-api.service'; @@ -30,6 +30,9 @@ import { IAcqReceipt } from '../../../classes/receipt'; }) export class OrderSummaryComponent implements OnInit, OnDestroy { + private acqOrderApiService: AcqOrderApiService = inject(AcqOrderApiService); + private acqReceiptApiService: AcqReceiptApiService = inject(AcqReceiptApiService); + // COMPONENTS ATTRIBUTES ==================================================== @Input() order: IAcqOrder; @@ -39,18 +42,6 @@ export class OrderSummaryComponent implements OnInit, OnDestroy { /** all component subscription */ private subscriptions = new Subscription(); - // CONSTRUCTOR & HOOKS ====================================================== - - /** - * Constructor - * @param acqOrderApiService - AcqOrderApiService - * @param acqReceiptApiService - AcqReceiptApiService - */ - constructor( - private acqOrderApiService: AcqOrderApiService, - private acqReceiptApiService: AcqReceiptApiService - ) { } - /** OnInit hook */ ngOnInit(): void { // Subscription when an order line is deleted diff --git a/projects/admin/src/app/acquisition/components/receipt/receipt-detail-view/receipt-detail-view.component.html b/projects/admin/src/app/acquisition/components/receipt/receipt-detail-view/receipt-detail-view.component.html index 78530ec98..433fbfa1c 100644 --- a/projects/admin/src/app/acquisition/components/receipt/receipt-detail-view/receipt-detail-view.component.html +++ b/projects/admin/src/app/acquisition/components/receipt/receipt-detail-view/receipt-detail-view.component.html @@ -66,23 +66,21 @@

{{ receipt.reference }}

@if (permissions) { - - + /> - - + /> }
} @else { diff --git a/projects/admin/src/app/acquisition/components/receipt/receipt-detail-view/receipt-detail-view.component.ts b/projects/admin/src/app/acquisition/components/receipt/receipt-detail-view/receipt-detail-view.component.ts index a4648a5d1..5335e6d6d 100644 --- a/projects/admin/src/app/acquisition/components/receipt/receipt-detail-view/receipt-detail-view.component.ts +++ b/projects/admin/src/app/acquisition/components/receipt/receipt-detail-view/receipt-detail-view.component.ts @@ -15,9 +15,9 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -import { Component, OnDestroy, OnInit } from '@angular/core'; +import { Component, inject, OnDestroy, OnInit } from '@angular/core'; import { DetailRecord } from '@rero/ng-core/lib/record/detail/view/detail-record'; -import { Observable, Subscription, forkJoin } from 'rxjs'; +import { forkJoin, Observable, Subscription } from 'rxjs'; import { RecordPermissions } from '../../../../classes/permissions'; import { RecordPermissionService } from '../../../../service/record-permission.service'; import { CurrentLibraryPermissionValidator } from '../../../../utils/permissions'; @@ -31,6 +31,10 @@ import { IAcqReceipt, IAcqReceiptLine } from '../../../classes/receipt'; }) export class ReceiptDetailViewComponent implements OnInit, OnDestroy, DetailRecord { + private acqReceiptApiService: AcqReceiptApiService = inject(AcqReceiptApiService); + private recordPermissionService: RecordPermissionService = inject(RecordPermissionService); + private currentLibraryPermissionValidator: CurrentLibraryPermissionValidator = inject(CurrentLibraryPermissionValidator); + // COMPONENT ATTRIBUTES ===================================================== /** Observable resolving record data */ record$: Observable; @@ -63,19 +67,6 @@ export class ReceiptDetailViewComponent implements OnInit, OnDestroy, DetailReco } } - // CONSTRUCTOR & HOOKS ====================================================== - /** - * Constructor - * @param acqReceiptApiService - AcqReceiptApiService - * @param recordPermissionService - RecordPermissionService - * @param currentLibraryPermissionValidator - CurrentLibraryPermissionValidator - */ - constructor( - private acqReceiptApiService: AcqReceiptApiService, - private recordPermissionService: RecordPermissionService, - private currentLibraryPermissionValidator: CurrentLibraryPermissionValidator - ) { } - /** OnInit hook */ ngOnInit() { this.record$.subscribe((record: any) => { diff --git a/projects/admin/src/app/acquisition/components/receipt/receipt-form/order-receipt-form.ts b/projects/admin/src/app/acquisition/components/receipt/receipt-form/order-receipt-form.ts index 299258d11..3182ca738 100644 --- a/projects/admin/src/app/acquisition/components/receipt/receipt-form/order-receipt-form.ts +++ b/projects/admin/src/app/acquisition/components/receipt/receipt-form/order-receipt-form.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 { Injectable } from '@angular/core'; +import { inject, Injectable } from '@angular/core'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; import { FormlyFieldConfig } from '@ngx-formly/core'; import { ApiService, extractIdOnRef } from '@rero/ng-core'; @@ -42,6 +42,11 @@ function lineAction($event: Event, action: string, fields: any): void { }) export class OrderReceiptForm { + private acqOrderApiService: AcqOrderApiService = inject(AcqOrderApiService); + private acqAccountApiService: AcqAccountApiService = inject(AcqAccountApiService); + private apiService: ApiService = inject(ApiService); + private orderReceipt: OrderReceipt = inject(OrderReceipt); + /** Order Record */ private orderRecord: any; @@ -51,20 +56,6 @@ export class OrderReceiptForm { /** Form fields config */ private config: any; - /** - * Constructor - * @param acqOrderApiService - AcqOrderApiService - * @param acqAccountApiService - AcqAccountApiService - * @param apiService - ApiService - * @param orderReceipt - OrderReceipt - */ - constructor( - private acqOrderApiService: AcqOrderApiService, - private acqAccountApiService: AcqAccountApiService, - private apiService: ApiService, - private orderReceipt: OrderReceipt - ) {} - /** * Set model * @param model - IReceiptModel @@ -194,7 +185,7 @@ export class OrderReceiptForm { }, { key: 'receiptDate', - type: 'datepicker', + type: 'datePicker', props: { type: 'date', label: _('Reception date'), diff --git a/projects/admin/src/app/acquisition/components/receipt/receipt-form/order-receipt-view.component.ts b/projects/admin/src/app/acquisition/components/receipt/receipt-form/order-receipt-view.component.ts index 4b7afd3fe..17e0a6976 100644 --- a/projects/admin/src/app/acquisition/components/receipt/receipt-form/order-receipt-view.component.ts +++ b/projects/admin/src/app/acquisition/components/receipt/receipt-form/order-receipt-view.component.ts @@ -14,12 +14,13 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -import { Component, OnInit } from '@angular/core'; +import { Component, inject, OnInit } from '@angular/core'; import { UntypedFormGroup } from '@angular/forms'; import { ActivatedRoute, Router } from '@angular/router'; import { FormlyFieldConfig } from '@ngx-formly/core'; import { TranslateService } from '@ngx-translate/core'; -import { ToastrService } from 'ngx-toastr'; +import { CONFIG } from '@rero/ng-core'; +import { MessageService } from 'primeng/api'; import { finalize, tap } from 'rxjs/operators'; import { AcqReceiptApiService } from '../../../api/acq-receipt-api.service'; import { IAcqReceipt } from '../../../classes/receipt'; @@ -33,6 +34,14 @@ import { OrderReceiptForm } from './order-receipt-form'; }) export class OrderReceiptViewComponent implements OnInit { + private route: ActivatedRoute = inject(ActivatedRoute); + private router: Router = inject(Router); + private orderReceipt: OrderReceipt = inject(OrderReceipt); + private acqReceiptApiService: AcqReceiptApiService = inject(AcqReceiptApiService); + private translateService: TranslateService = inject(TranslateService); + private orderReceiptForm: OrderReceiptForm = inject(OrderReceiptForm); + private messageService = inject(MessageService); + // COMPONENTS ATTRIBUTES ==================================================== /** order pid */ orderPid: string; @@ -68,27 +77,6 @@ export class OrderReceiptViewComponent implements OnInit { return this._fields; } - // CONSTRUCTOR & HOOKS ====================================================== - /** - * Constructor - * @param route - ActivatedRoute - * @param router - Router - * @param orderReceipt - OrderReceipt - * @param acqReceiptApiService - AcqReceiptApiService - * @param toastrService - ToastrService - * @param translateService - TranslateService - * @param orderReceiptForm - OrderReceiptForm - */ - constructor( - private route: ActivatedRoute, - private router: Router, - private orderReceipt: OrderReceipt, - private acqReceiptApiService: AcqReceiptApiService, - private toastrService: ToastrService, - private translateService: TranslateService, - private orderReceiptForm: OrderReceiptForm - ) {} - /** OnInit hook */ ngOnInit(): void { this.orderPid = this.route.snapshot.paramMap.get('pid'); @@ -112,15 +100,16 @@ export class OrderReceiptViewComponent implements OnInit { : this.acqReceiptApiService.updateReceipt(record.pid, record); receiptApi$ .pipe(finalize(() => this.orderSend = false)) - .subscribe( - (receipt: IAcqReceipt) => this.createLinesAndMessage(model, receipt), - (err) => { - this.toastrService.error( - err.title, this.translateService.instant('Receipt'), - { disableTimeOut: true, closeButton: true } - ); - } - ); + .subscribe({ + next: (receipt: IAcqReceipt) => this.createLinesAndMessage(model, receipt), + error: (err) => this.messageService.add({ + severity: 'error', + summary: this.translateService.instant('Receipt'), + detail: err.title, + sticky: true, + closable: true + }) + }); } // COMPONENT PRIVATE FUNCTIONS ============================================== @@ -165,24 +154,30 @@ export class OrderReceiptViewComponent implements OnInit { .createReceiptLines(model.pid, lines) .subscribe((result: ICreateLineMessage) => { if (result.success) { - this.toastrService.success( - this.translateService.instant('Receipt operations were successful'), - this.translateService.instant('Receipt') - ); + this.messageService.add({ + severity: 'success', + summary: this.translateService.instant('Receipt'), + detail: this.translateService.instant('Receipt operations were successful'), + life: CONFIG.MESSAGE_LIFE + }); } else { - this.toastrService.error( - this.translateService.instant(result.messages), - this.translateService.instant('Receipt'), - {disableTimeOut: true, closeButton: true} - ); + this.messageService.add({ + severity: 'error', + summary: this.translateService.instant('Receipt'), + detail: this.translateService.instant(result.messages), + sticky: true, + closable: true + }); } this.redirectToOrder(); }); } else { - this.toastrService.success( - this.translateService.instant('Receipt operations were successful'), - this.translateService.instant('Receipt') - ); + this.messageService.add({ + severity: 'success', + summary: this.translateService.instant('Receipt'), + detail: this.translateService.instant('Receipt operations were successful'), + life: CONFIG.MESSAGE_LIFE + }); this.redirectToOrder(); } } diff --git a/projects/admin/src/app/acquisition/components/receipt/receipt-form/order-receipt.ts b/projects/admin/src/app/acquisition/components/receipt/receipt-form/order-receipt.ts index e5fb569ad..302760057 100644 --- a/projects/admin/src/app/acquisition/components/receipt/receipt-form/order-receipt.ts +++ b/projects/admin/src/app/acquisition/components/receipt/receipt-form/order-receipt.ts @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -import { Injectable } from '@angular/core'; +import { inject, Injectable } from '@angular/core'; import { ApiService } from '@rero/ng-core'; import moment from 'moment'; import { IAcqNote } from '../../../classes/common'; @@ -73,9 +73,7 @@ export interface ICreateLineMessage { }) export class OrderReceipt { - constructor( - private _apiService: ApiService - ) {} + private apiService: ApiService = inject(ApiService); /** Model */ get model(): IAcqReceiptModel { @@ -119,9 +117,9 @@ export class OrderReceipt { return { pid: record.pid, $schema: record.$schema, - acq_order: { $ref: this._apiService.getRefEndpoint('acq_orders', record.acq_order.pid) }, - library: { $ref: this._apiService.getRefEndpoint('libraries', record.library.pid) }, - organisation: { $ref: this._apiService.getRefEndpoint('organisation', record.organisation.pid) }, + acq_order: { $ref: this.apiService.getRefEndpoint('acq_orders', record.acq_order.pid) }, + library: { $ref: this.apiService.getRefEndpoint('libraries', record.library.pid) }, + organisation: { $ref: this.apiService.getRefEndpoint('organisation', record.organisation.pid) }, reference: record.reference, exchange_rate: record.exchange_rate, amount_adjustments: record.amount_adjustments, diff --git a/projects/admin/src/app/acquisition/components/receipt/receipt-list/receipt-list.component.html b/projects/admin/src/app/acquisition/components/receipt/receipt-list/receipt-list.component.html index fc7fff347..47aa79a11 100644 --- a/projects/admin/src/app/acquisition/components/receipt/receipt-list/receipt-list.component.html +++ b/projects/admin/src/app/acquisition/components/receipt/receipt-list/receipt-list.component.html @@ -24,17 +24,24 @@
@if (recordPermissions) { @if (recordPermissions.create.can) { - - {{ 'Add' | translate }} … - + /> } @else { - -
+ + + + } } @else {   diff --git a/projects/admin/src/app/acquisition/components/receipt/receipt-list/receipt-list.component.ts b/projects/admin/src/app/acquisition/components/receipt/receipt-list/receipt-list.component.ts index e04877868..d270bbf36 100644 --- a/projects/admin/src/app/acquisition/components/receipt/receipt-list/receipt-list.component.ts +++ b/projects/admin/src/app/acquisition/components/receipt/receipt-list/receipt-list.component.ts @@ -15,11 +15,11 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -import { Component, Input, OnChanges, OnDestroy, OnInit, SimpleChanges } from '@angular/core'; +import { Component, inject, Input, OnChanges, OnDestroy, OnInit, SimpleChanges } from '@angular/core'; import { RecordPermissions } from '@app/admin/classes/permissions'; import { RecordPermissionService } from '@app/admin/service/record-permission.service'; import { CurrentLibraryPermissionValidator } from '@app/admin/utils/permissions'; -import { Subscription, of } from 'rxjs'; +import { of, Subscription } from 'rxjs'; import { map } from 'rxjs/operators'; import { AcqReceiptApiService } from '../../../api/acq-receipt-api.service'; import { IAcqOrder } from '../../../classes/order'; @@ -32,6 +32,11 @@ import { ReceivedOrderPermissionValidator } from '../../../utils/permissions'; }) export class ReceiptListComponent implements OnInit, OnChanges, OnDestroy { + private acqReceiptApiService: AcqReceiptApiService = inject(AcqReceiptApiService); + private recordPermissionService: RecordPermissionService = inject(RecordPermissionService); + private currentLibraryPermissionValidator: CurrentLibraryPermissionValidator = inject(CurrentLibraryPermissionValidator); + private receivedOrderPermissionValidator: ReceivedOrderPermissionValidator = inject(ReceivedOrderPermissionValidator); + // COMPONENT ATTRIBUTES ===================================================== /** the order for which we want to display receipts */ @Input() order: IAcqOrder; @@ -60,21 +65,6 @@ export class ReceiptListComponent implements OnInit, OnChanges, OnDestroy { return (this.receipts) ? this.receipts.length : 0; } - // CONSTRUCTOR & HOOKS ====================================================== - /** - * Constructor - * @param acqReceiptApiService - AcqReceiptApiService - * @param recordPermissionService - RecordPermissionService - * @param currentLibraryPermissionValidator - CurrentLibraryPermissionValidator - * @param receivedOrderPermissionValidator - ReceivedOrderPermissionValidator - */ - constructor( - private acqReceiptApiService: AcqReceiptApiService, - private recordPermissionService: RecordPermissionService, - private currentLibraryPermissionValidator: CurrentLibraryPermissionValidator, - private receivedOrderPermissionValidator: ReceivedOrderPermissionValidator - ) { } - /** OnInit hook */ ngOnInit(): void { this._loadPermissions(); diff --git a/projects/admin/src/app/acquisition/components/receipt/receipt-summary/receipt-summary.component.html b/projects/admin/src/app/acquisition/components/receipt/receipt-summary/receipt-summary.component.html index 525d70e8d..16651da53 100644 --- a/projects/admin/src/app/acquisition/components/receipt/receipt-summary/receipt-summary.component.html +++ b/projects/admin/src/app/acquisition/components/receipt/receipt-summary/receipt-summary.component.html @@ -112,33 +112,31 @@
- {{ 'Resume' | translate }} - + /> - - + /> - - + />
} } @else { diff --git a/projects/admin/src/app/acquisition/components/receipt/receipt-summary/receipt-summary.component.ts b/projects/admin/src/app/acquisition/components/receipt/receipt-summary/receipt-summary.component.ts index 5398c509d..0cf6ee51d 100644 --- a/projects/admin/src/app/acquisition/components/receipt/receipt-summary/receipt-summary.component.ts +++ b/projects/admin/src/app/acquisition/components/receipt/receipt-summary/receipt-summary.component.ts @@ -15,7 +15,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -import { Component, Input, OnInit } from '@angular/core'; +import { Component, inject, Input, OnInit } from '@angular/core'; import { RecordPermissions } from '@app/admin/classes/permissions'; import { RecordPermissionService } from '@app/admin/service/record-permission.service'; import { CurrentLibraryPermissionValidator } from '@app/admin/utils/permissions'; @@ -32,6 +32,12 @@ import { ReceivedOrderPermissionValidator } from '../../../utils/permissions'; }) export class ReceiptSummaryComponent implements OnInit { + private recordPermissionService: RecordPermissionService = inject(RecordPermissionService); + private acqReceiptApiService: AcqReceiptApiService = inject(AcqReceiptApiService); + private acqOrderApiService: AcqOrderApiService = inject(AcqOrderApiService); + private currentLibraryPermissionValidator: CurrentLibraryPermissionValidator = inject(CurrentLibraryPermissionValidator); + private receivedOrderPermissionValidator: ReceivedOrderPermissionValidator = inject(ReceivedOrderPermissionValidator); + // COMPONENT ATTRIBUTES ===================================================== /** The receipt pid to load */ @Input() receiptPid: string; @@ -66,23 +72,6 @@ export class ReceiptSummaryComponent implements OnInit { : ''; } - // CONSTRUCTOR & HOOKS ====================================================== - /** - * Constructor - * @param recordPermissionService - RecordPermissionService - * @param acqReceiptApiService - AcqReceiptApiService - * @param acqOrderApiService - AcqOrderApiService - * @param currentLibraryPermissionValidator - CurrentLibraryPermissionValidator - * @param receivedOrderPermissionValidator - ReceivedOrderPermissionValidator - */ - constructor( - private recordPermissionService: RecordPermissionService, - private acqReceiptApiService: AcqReceiptApiService, - private acqOrderApiService: AcqOrderApiService, - private currentLibraryPermissionValidator: CurrentLibraryPermissionValidator, - private receivedOrderPermissionValidator: ReceivedOrderPermissionValidator - ) { } - /** OnInit hook */ ngOnInit(): void { if (!this.collapsable){ diff --git a/projects/admin/src/app/acquisition/formly/type/field-document-brief-view.type.ts b/projects/admin/src/app/acquisition/formly/type/field-document-brief-view.type.ts index 7d0408c0e..52b1dab9b 100644 --- a/projects/admin/src/app/acquisition/formly/type/field-document-brief-view.type.ts +++ b/projects/admin/src/app/acquisition/formly/type/field-document-brief-view.type.ts @@ -1,6 +1,6 @@ /* * RERO ILS UI - * Copyright (C) 2019-2023 RERO + * Copyright (C) 2019-2024 RERO * Copyright (C) 2019-2023 UCLouvain * * This program is free software: you can redistribute it and/or modify @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import { ChangeDetectorRef, Component, OnInit } from '@angular/core'; +import { ChangeDetectorRef, Component, inject, OnInit } from '@angular/core'; import { FieldType } from '@ngx-formly/core'; import { RecordService } from '@rero/ng-core'; @@ -30,21 +30,12 @@ import { RecordService } from '@rero/ng-core'; }) export class FieldDocumentBriefViewTypeComponent extends FieldType implements OnInit { + private recordService: RecordService = inject(RecordService); + private changeDetectorRef: ChangeDetectorRef = inject(ChangeDetectorRef); + /** record */ record: any; - /** - * Constructor - * @param recordService - RecordService - * @param changeDetectorRef - ChangeDetectorRef - */ - constructor( - private recordService: RecordService, - private changeDetectorRef: ChangeDetectorRef - ) { - super(); - } - /** OnInit hook */ ngOnInit(): void { this.recordService diff --git a/projects/admin/src/app/acquisition/formly/type/field-ref.type.ts b/projects/admin/src/app/acquisition/formly/type/field-ref.type.ts index e9d49db25..d86001b1e 100644 --- a/projects/admin/src/app/acquisition/formly/type/field-ref.type.ts +++ b/projects/admin/src/app/acquisition/formly/type/field-ref.type.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 { ChangeDetectorRef, Component, OnInit } from '@angular/core'; +import { ChangeDetectorRef, Component, inject, OnInit } from '@angular/core'; import { FieldType } from '@ngx-formly/core'; import { RecordService } from '@rero/ng-core'; @@ -28,18 +28,12 @@ import { RecordService } from '@rero/ng-core'; }) export class FieldRefTypeComponent extends FieldType implements OnInit { + private recordService: RecordService = inject(RecordService); + private ref: ChangeDetectorRef = inject(ChangeDetectorRef); + /** value */ value: string; - /** - * Constructor - * @param recordService - RecordService - * @param ref - ChangeDetectorRef - */ - constructor(private recordService: RecordService, private ref: ChangeDetectorRef) { - super(); - } - /** OnInit hook */ ngOnInit(): void { this.recordService.getRecords(this.props.resource, `pid:${this.model[this.props.resourceKey]}`) diff --git a/projects/admin/src/app/acquisition/formly/type/repeat-section.type.ts b/projects/admin/src/app/acquisition/formly/type/repeat-section.type.ts index 9cbeb42ac..c44184c87 100644 --- a/projects/admin/src/app/acquisition/formly/type/repeat-section.type.ts +++ b/projects/admin/src/app/acquisition/formly/type/repeat-section.type.ts @@ -20,6 +20,74 @@ import { FieldArrayType } from '@ngx-formly/core'; @Component({ selector: 'admin-formly-repeat-section', template: ` + + + @if (field.props.label || field.props.addButton) { + + } + + @if (field.fieldGroup.length > 0) { +
+
+
+
+ @for (field of field.fieldGroup[0].fieldGroup; track field) { + @if (field.className) { +
+ {{ field.props.label|translate }} + @if (field.props.required) { +  * + } +
+ } + } +
+
+
+ @for (f of field.fieldGroup; track f; let i = $index) { +
+ @if (f.fieldGroup.length > 0) { + + @if (field.props.trashButton) { +
+ @if (showTrash) { + + } @else { +   + } +
+ } + } +
+ } +
+ } +
+ ` }) export class RepeatTypeComponent extends FieldArrayType { diff --git a/projects/admin/src/app/acquisition/formly/type/select-account/select-account.component.ts b/projects/admin/src/app/acquisition/formly/type/select-account/select-account.component.ts index f18c9d44c..be5c20722 100644 --- a/projects/admin/src/app/acquisition/formly/type/select-account/select-account.component.ts +++ b/projects/admin/src/app/acquisition/formly/type/select-account/select-account.component.ts @@ -15,7 +15,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -import { ChangeDetectorRef, Component, OnInit } from '@angular/core'; +import { ChangeDetectorRef, Component, inject, OnInit } from '@angular/core'; import { IAcqAccount } from '@app/admin/acquisition/classes/account'; import { FieldType } from '@ngx-formly/core'; import { ApiService } from '@rero/ng-core'; @@ -27,6 +27,9 @@ import { ApiService } from '@rero/ng-core'; }) export class SelectAccountComponent extends FieldType implements OnInit { + private changeDetectorRef: ChangeDetectorRef = inject(ChangeDetectorRef); + private apiService: ApiService = inject(ApiService); + /** accounts list */ accountList: IAcqAccount[] = []; /** the selected account */ @@ -34,17 +37,6 @@ export class SelectAccountComponent extends FieldType implements OnInit { /** currency */ currency: string; - /** - * Constructor - * @param changeDetectorRef - ChangeDetectorRef - * @param apiService - ApiService - */ - constructor( - private changeDetectorRef: ChangeDetectorRef, - private apiService: ApiService) { - super(); - } - /** OnInit Hook */ ngOnInit() { this.props.options.forEach((option: any) => this.accountList.push(option)); diff --git a/projects/admin/src/app/acquisition/routes/accounts-route.ts b/projects/admin/src/app/acquisition/routes/accounts-route.ts index 8af7a7508..792df312a 100644 --- a/projects/admin/src/app/acquisition/routes/accounts-route.ts +++ b/projects/admin/src/app/acquisition/routes/accounts-route.ts @@ -57,7 +57,7 @@ export class AccountsRoute extends BaseRoute implements RouteInterface { key: this.name, label: _('Acquisition account'), detailComponent: AccountDetailViewComponent, - permissions: (record: any) => this._routeToolService.permissions(record, this.recordType), + permissions: (record: any) => this.routeToolService.permissions(record, this.recordType), preCreateRecord: (data: any) => this._addDefaultInformation(data), redirectUrl: () => of('/acquisition/accounts'), formFieldMap: (field: FormlyFieldConfig, jsonSchema: JSONSchema7): FormlyFieldConfig => { @@ -79,12 +79,12 @@ export class AccountsRoute extends BaseRoute implements RouteInterface { * @return the enrich data */ private _addDefaultInformation(data: any): any { - const { user } = this._routeToolService.userService; + const { user } = this.routeToolService.userService; data.library = { - $ref: this._routeToolService.apiService.getRefEndpoint('libraries', user.currentLibrary) + $ref: this.routeToolService.apiService.getRefEndpoint('libraries', user.currentLibrary) }; data.budget = { - $ref: this._routeToolService.apiService.getRefEndpoint('budgets', this._routeToolService.getRouteQueryParam('budget')) + $ref: this.routeToolService.apiService.getRefEndpoint('budgets', this.routeToolService.getRouteQueryParam('budget')) }; return data; } @@ -95,7 +95,7 @@ export class AccountsRoute extends BaseRoute implements RouteInterface { * @return The updated configuration. */ private _amountSymbol(field: FormlyFieldConfig): FormlyFieldConfig { - const service = this._routeToolService.getInjectorToken(OrganisationService); + const service = this.routeToolService.getInjectorToken(OrganisationService); if (service.organisation) { field.props.addonLeft = [ getCurrencySymbol(service.organisation.default_currency, 'wide') diff --git a/projects/admin/src/app/acquisition/routes/budgets-route.ts b/projects/admin/src/app/acquisition/routes/budgets-route.ts index 6d503367e..1b228731c 100644 --- a/projects/admin/src/app/acquisition/routes/budgets-route.ts +++ b/projects/admin/src/app/acquisition/routes/budgets-route.ts @@ -1,6 +1,6 @@ /* * RERO ILS UI - * Copyright (C) 2021-2022 RERO + * Copyright (C) 2021-2024 RERO * Copyright (C) 2021-2022 UCLouvain * * This program is free software: you can redistribute it and/or modify @@ -15,11 +15,11 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ +import { BaseRoute } from '@app/admin/routes/base-route'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; import { DetailComponent, RecordSearchPageComponent, RouteInterface } from '@rero/ng-core'; import { PERMISSIONS, PERMISSION_OPERATOR } from '@rero/shared'; -import { BaseRoute } from '@app/admin/routes/base-route'; -import { CanAccessGuard, CAN_ACCESS_ACTIONS } from '../../guard/can-access.guard'; +import { CAN_ACCESS_ACTIONS, CanAccessGuard } from '../../guard/can-access.guard'; import { PermissionGuard } from '../../guard/permission.guard'; import { BudgetsBriefViewComponent } from '../components/budget/budget-brief-view/budgets-brief-view.component'; import { BudgetDetailViewComponent } from '../components/budget/budget-detail-view/budget-detail-view.component'; diff --git a/projects/admin/src/app/acquisition/routes/guards/abstract-can-add.guard.ts b/projects/admin/src/app/acquisition/routes/guards/abstract-can-add.guard.ts index 94e402d70..a9e8f17f9 100644 --- a/projects/admin/src/app/acquisition/routes/guards/abstract-can-add.guard.ts +++ b/projects/admin/src/app/acquisition/routes/guards/abstract-can-add.guard.ts @@ -14,6 +14,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ +import { inject } from '@angular/core'; import { ActivatedRouteSnapshot, Router } from '@angular/router'; import { RecordService } from '@rero/ng-core'; import { BaseApi } from '@rero/shared'; @@ -22,15 +23,8 @@ import { catchError, map } from 'rxjs/operators'; export abstract class AbstractCanAddGuard { - /** - * Constructor - * @param recordService - RecordService - * @param router - Router - */ - protected constructor( - protected recordService: RecordService, - protected router: Router - ) {} + protected recordService: RecordService = inject(RecordService); + protected router: Router = inject(Router); /** * Allow to access to the resource diff --git a/projects/admin/src/app/acquisition/routes/guards/can-add-account.guard.spec.ts b/projects/admin/src/app/acquisition/routes/guards/can-add-account.guard.spec.ts index d08cfc889..0ee6f21e4 100644 --- a/projects/admin/src/app/acquisition/routes/guards/can-add-account.guard.spec.ts +++ b/projects/admin/src/app/acquisition/routes/guards/can-add-account.guard.spec.ts @@ -1,6 +1,6 @@ /* * RERO ILS UI - * Copyright (C) 2022 RERO + * Copyright (C) 2022-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,11 +14,9 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -import { fakeAsync, TestBed, tick } from '@angular/core/testing'; - import { HttpClientTestingModule } from '@angular/common/http/testing'; -import { Router } from '@angular/router'; -import { RouterTestingModule } from '@angular/router/testing'; +import { fakeAsync, TestBed, tick } from '@angular/core/testing'; +import { Router, RouterModule } from '@angular/router'; import { TranslateModule } from '@ngx-translate/core'; import { ErrorPageComponent } from '../../../error/error-page/error-page.component'; import { CanAddAccountGuard } from './can-add-account.guard'; @@ -40,7 +38,7 @@ describe('CanAddAccountGuard', () => { beforeEach(() => { TestBed.configureTestingModule({ imports: [ - RouterTestingModule.withRoutes(routes), + RouterModule.forRoot(routes), HttpClientTestingModule, TranslateModule.forRoot() ] diff --git a/projects/admin/src/app/acquisition/routes/guards/can-add-account.guard.ts b/projects/admin/src/app/acquisition/routes/guards/can-add-account.guard.ts index 09aed693d..35fd4b596 100644 --- a/projects/admin/src/app/acquisition/routes/guards/can-add-account.guard.ts +++ b/projects/admin/src/app/acquisition/routes/guards/can-add-account.guard.ts @@ -15,8 +15,7 @@ * along with this program. If not, see . */ import { Injectable } from '@angular/core'; -import { ActivatedRouteSnapshot, Router } from '@angular/router'; -import { RecordService } from '@rero/ng-core'; +import { ActivatedRouteSnapshot } from '@angular/router'; import { Observable, of } from 'rxjs'; import { AbstractCanAddGuard } from './abstract-can-add.guard'; @@ -25,18 +24,6 @@ import { AbstractCanAddGuard } from './abstract-can-add.guard'; }) export class CanAddAccountGuard extends AbstractCanAddGuard { - /** - * Constructor - * @param recordService - RecordService - * @param router - Router - */ - constructor( - recordService: RecordService, - router: Router - ) { - super(recordService, router); - } - /** * Allow the loading if the budget pid is present and check * if the record is in current fiscal year diff --git a/projects/admin/src/app/acquisition/routes/guards/can-add-order-line.guard.spec.ts b/projects/admin/src/app/acquisition/routes/guards/can-add-order-line.guard.spec.ts index f9ca75002..cf091ecca 100644 --- a/projects/admin/src/app/acquisition/routes/guards/can-add-order-line.guard.spec.ts +++ b/projects/admin/src/app/acquisition/routes/guards/can-add-order-line.guard.spec.ts @@ -1,6 +1,6 @@ /* * RERO ILS UI - * Copyright (C) 2022 RERO + * Copyright (C) 2022-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,16 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ +import { HttpClient, HttpErrorResponse } from '@angular/common/http'; import { HttpClientTestingModule } from '@angular/common/http/testing'; import { fakeAsync, TestBed, tick } from '@angular/core/testing'; -import { Router } from '@angular/router'; -import { RouterTestingModule } from '@angular/router/testing'; +import { Router, RouterModule } from '@angular/router'; import { TranslateModule } from '@ngx-translate/core'; import { CoreModule, RecordService } from '@rero/ng-core'; -import { ErrorPageComponent } from '../../../error/error-page/error-page.component'; - import { cloneDeep } from 'lodash-es'; -import { CanAddOrderLineGuard } from './can-add-order-line.guard'; import { of, throwError } from 'rxjs'; -import { HttpClient, HttpErrorResponse } from '@angular/common/http'; +import { ErrorPageComponent } from '../../../error/error-page/error-page.component'; +import { CanAddOrderLineGuard } from './can-add-order-line.guard'; describe('CanAddOrderLineGuard', () => { let guard: CanAddOrderLineGuard; @@ -61,7 +59,7 @@ describe('CanAddOrderLineGuard', () => { beforeEach(() => { TestBed.configureTestingModule({ imports: [ - RouterTestingModule.withRoutes(routes), + RouterModule.forRoot(routes), HttpClientTestingModule, TranslateModule.forRoot(), CoreModule diff --git a/projects/admin/src/app/acquisition/routes/guards/can-add-order-line.guard.ts b/projects/admin/src/app/acquisition/routes/guards/can-add-order-line.guard.ts index fc419e6db..586c09b88 100644 --- a/projects/admin/src/app/acquisition/routes/guards/can-add-order-line.guard.ts +++ b/projects/admin/src/app/acquisition/routes/guards/can-add-order-line.guard.ts @@ -15,8 +15,7 @@ * along with this program. If not, see . */ import { Injectable } from '@angular/core'; -import { ActivatedRouteSnapshot, Router } from '@angular/router'; -import { RecordService } from '@rero/ng-core'; +import { ActivatedRouteSnapshot } from '@angular/router'; import { Observable, of } from 'rxjs'; import { AbstractCanAddGuard } from './abstract-can-add.guard'; @@ -25,18 +24,6 @@ import { AbstractCanAddGuard } from './abstract-can-add.guard'; }) export class CanAddOrderLineGuard extends AbstractCanAddGuard { - /** - * Constructor - * @param recordService - RecordService - * @param router - Router - */ - constructor( - recordService: RecordService, - router: Router - ) { - super(recordService, router); - } - /** * Allow the loading if the order pid is present and check * if the record is in current fiscal year diff --git a/projects/admin/src/app/acquisition/routes/guards/can-order-receipt.guard.spec.ts b/projects/admin/src/app/acquisition/routes/guards/can-order-receipt.guard.spec.ts index 242955093..0957e3c6a 100644 --- a/projects/admin/src/app/acquisition/routes/guards/can-order-receipt.guard.spec.ts +++ b/projects/admin/src/app/acquisition/routes/guards/can-order-receipt.guard.spec.ts @@ -1,6 +1,6 @@ /* * RERO ILS UI - * Copyright (C) 2022 RERO + * Copyright (C) 2022-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 @@ -17,8 +17,7 @@ import { HttpClientTestingModule } from '@angular/common/http/testing'; import { fakeAsync, TestBed, tick } from '@angular/core/testing'; -import { Router } from '@angular/router'; -import { RouterTestingModule } from '@angular/router/testing'; +import { Router, RouterModule } from '@angular/router'; import { TranslateModule } from '@ngx-translate/core'; import { CoreModule } from '@rero/ng-core'; import { UserService } from '@rero/shared'; @@ -105,7 +104,7 @@ describe('CanOrderReceiptGuard', () => { beforeEach(() => { TestBed.configureTestingModule({ imports: [ - RouterTestingModule.withRoutes(routes), + RouterModule.forRoot(routes), HttpClientTestingModule, TranslateModule.forRoot(), CoreModule diff --git a/projects/admin/src/app/acquisition/routes/guards/can-order-receipt.guard.ts b/projects/admin/src/app/acquisition/routes/guards/can-order-receipt.guard.ts index acaaecd60..4c4c661cf 100644 --- a/projects/admin/src/app/acquisition/routes/guards/can-order-receipt.guard.ts +++ b/projects/admin/src/app/acquisition/routes/guards/can-order-receipt.guard.ts @@ -14,11 +14,11 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -import { Injectable } from '@angular/core'; +import { inject, Injectable } from '@angular/core'; import { ActivatedRouteSnapshot, Router } from '@angular/router'; import { extractIdOnRef } from '@rero/ng-core'; import { UserService } from '@rero/shared'; -import { Observable, combineLatest, of } from 'rxjs'; +import { combineLatest, Observable, of } from 'rxjs'; import { catchError, map } from 'rxjs/operators'; import { AcqOrderApiService } from '../../api/acq-order-api.service'; import { AcqReceiptApiService } from '../../api/acq-receipt-api.service'; @@ -30,19 +30,10 @@ import { IAcqReceipt } from '../../classes/receipt'; }) export class CanOrderReceiptGuard { - /** - * Constructor - * @param acqOrderApiService - AcqOrderApiService - * @param acqReceiptApiService - AcqReceiptApiService - * @param router - Router - * @param userService - UserService - */ - constructor( - private acqOrderApiService: AcqOrderApiService, - private acqReceiptApiService: AcqReceiptApiService, - private router: Router, - private userService: UserService - ) {} + private acqOrderApiService: AcqOrderApiService = inject(AcqOrderApiService); + private acqReceiptApiService: AcqReceiptApiService = inject(AcqReceiptApiService); + private router: Router = inject(Router); + private userService: UserService = inject(UserService); /** * Can activate diff --git a/projects/admin/src/app/acquisition/routes/guards/is-budget-active.guard.spec.ts b/projects/admin/src/app/acquisition/routes/guards/is-budget-active.guard.spec.ts index 8f596871a..7fb90fbee 100644 --- a/projects/admin/src/app/acquisition/routes/guards/is-budget-active.guard.spec.ts +++ b/projects/admin/src/app/acquisition/routes/guards/is-budget-active.guard.spec.ts @@ -1,6 +1,6 @@ /* * RERO ILS UI - * Copyright (C) 2022 RERO + * Copyright (C) 2022-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 @@ -16,8 +16,7 @@ */ import { HttpClientTestingModule } from '@angular/common/http/testing'; import { fakeAsync, TestBed, tick } from '@angular/core/testing'; -import { Router } from '@angular/router'; -import { RouterTestingModule } from '@angular/router/testing'; +import { Router, RouterModule } from '@angular/router'; import { TranslateModule } from '@ngx-translate/core'; import { CoreModule, RecordService } from '@rero/ng-core'; import { cloneDeep } from 'lodash-es'; @@ -65,7 +64,7 @@ describe('IsBudgetActiveGuard', () => { beforeEach(() => { TestBed.configureTestingModule({ imports: [ - RouterTestingModule.withRoutes(routes), + RouterModule.forRoot(routes), HttpClientTestingModule, TranslateModule.forRoot(), CoreModule diff --git a/projects/admin/src/app/acquisition/routes/guards/is-budget-active.guard.ts b/projects/admin/src/app/acquisition/routes/guards/is-budget-active.guard.ts index 565003807..230f4e0a4 100644 --- a/projects/admin/src/app/acquisition/routes/guards/is-budget-active.guard.ts +++ b/projects/admin/src/app/acquisition/routes/guards/is-budget-active.guard.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 { Injectable } from '@angular/core'; +import { inject, Injectable } from '@angular/core'; import { ActivatedRouteSnapshot, Router } from '@angular/router'; import { RecordService } from '@rero/ng-core'; import { BaseApi } from '@rero/shared'; @@ -26,15 +26,8 @@ import { map } from 'rxjs/operators'; }) export class IsBudgetActiveGuard { - /** - * Constructor - * @param recordService - RecordService - * @param router - Router - */ - constructor( - private recordService: RecordService, - private router: Router - ) {} + private recordService: RecordService = inject(RecordService); + private router: Router = inject(Router); /** * Can activate diff --git a/projects/admin/src/app/acquisition/routes/order-lines-route.ts b/projects/admin/src/app/acquisition/routes/order-lines-route.ts index 7b514ea66..f4a790be6 100644 --- a/projects/admin/src/app/acquisition/routes/order-lines-route.ts +++ b/projects/admin/src/app/acquisition/routes/order-lines-route.ts @@ -52,8 +52,8 @@ export class OrderLinesRoute extends BaseRoute implements RouteInterface { editorSettings: { longMode: true, }, - canAdd: () => of({ can: this._routeToolService.permissionsService.canAccess(PERMISSIONS.ACOL_CREATE) }), - permissions: (record: any) => this._routeToolService.permissions(record, this.recordType, true), + canAdd: () => of({ can: this.routeToolService.permissionsService.canAccess(PERMISSIONS.ACOL_CREATE) }), + permissions: (record: any) => this.routeToolService.permissions(record, this.recordType, true), preCreateRecord: (data: any) => this._addDefaultInformation(data), preUpdateRecord: (data: any) => this.fieldsToRemoved(data, ['is_current_budget']), redirectUrl: (record: any) => this.redirectUrl(record.metadata.acq_order, '/records/acq_orders/detail'), @@ -77,7 +77,7 @@ export class OrderLinesRoute extends BaseRoute implements RouteInterface { */ private _addDefaultInformation(data: any): any { data.acq_order = { - $ref: this._routeToolService.apiService.getRefEndpoint('acq_orders', this._routeToolService.getRouteQueryParam('order')) + $ref: this.routeToolService.apiService.getRefEndpoint('acq_orders', this.routeToolService.getRouteQueryParam('order')) }; return data; } @@ -90,7 +90,7 @@ export class OrderLinesRoute extends BaseRoute implements RouteInterface { private _amountSymbol(field: FormlyFieldConfig): FormlyFieldConfig { // TODO :: This isn't the organisation currency that we need to use, it's the order related vendor currency // But how to retrieve the order from here ??? and how get quickly currency to use into - const service = this._routeToolService.getInjectorToken(OrganisationService); + const service = this.routeToolService.getInjectorToken(OrganisationService); field.props.addonLeft = [ getCurrencySymbol(service.organisation.default_currency, 'wide') ]; diff --git a/projects/admin/src/app/acquisition/routes/orders-route.ts b/projects/admin/src/app/acquisition/routes/orders-route.ts index b9d62fd73..a94b06e93 100644 --- a/projects/admin/src/app/acquisition/routes/orders-route.ts +++ b/projects/admin/src/app/acquisition/routes/orders-route.ts @@ -1,6 +1,6 @@ /* * RERO ILS UI - * Copyright (C) 2021-2023 RERO + * Copyright (C) 2021-2024 RERO * Copyright (C) 2021-2023 UCLouvain * * This program is free software: you can redistribute it and/or modify @@ -53,11 +53,11 @@ export class OrdersRoute extends BaseRoute implements RouteInterface { searchFilters: [ this.expertSearchFilter() ], - canAdd: () => of({ can: this._routeToolService.permissionsService.canAccess(PERMISSIONS.ACOR_CREATE) }), - permissions: (record: any) => this._routeToolService.permissions(record, this.recordType, true), + canAdd: () => of({ can: this.routeToolService.permissionsService.canAccess(PERMISSIONS.ACOR_CREATE) }), + permissions: (record: any) => this.routeToolService.permissions(record, this.recordType, true), preCreateRecord: (data: any) => this._addDefaultInformation(data), preUpdateRecord: (data: any) => this._cleanRecord(data), - aggregations: (aggregations: any) => this._routeToolService.aggregationFilter(aggregations), + aggregations: (aggregations: any) => this.routeToolService.aggregationFilter(aggregations), aggregationsExpand: [ 'library', 'order_date', @@ -112,7 +112,7 @@ export class OrdersRoute extends BaseRoute implements RouteInterface { { label: 'CSV', format: 'csv', - endpoint: this._routeToolService.apiService.getExportEndpointByType(this.recordType), + endpoint: this.routeToolService.apiService.getExportEndpointByType(this.recordType), disableMaxRestResultsSize: true, }, ], @@ -128,12 +128,12 @@ export class OrdersRoute extends BaseRoute implements RouteInterface { * @return: the enrich data */ private _addDefaultInformation(data: any): any { - const user = this._routeToolService.userService.user; + const user = this.routeToolService.userService.user; data.organisation = { - $ref: this._routeToolService.apiService.getRefEndpoint('organisations', user.currentOrganisation) + $ref: this.routeToolService.apiService.getRefEndpoint('organisations', user.currentOrganisation) }; data.library = { - $ref: this._routeToolService.apiService.getRefEndpoint('libraries', user.currentLibrary) + $ref: this.routeToolService.apiService.getRefEndpoint('libraries', user.currentLibrary) }; return data; } diff --git a/projects/admin/src/app/acquisition/routes/receipt-lines-route.ts b/projects/admin/src/app/acquisition/routes/receipt-lines-route.ts index 3f022de87..d1a0b29ca 100644 --- a/projects/admin/src/app/acquisition/routes/receipt-lines-route.ts +++ b/projects/admin/src/app/acquisition/routes/receipt-lines-route.ts @@ -48,9 +48,9 @@ export class ReceiptLinesRoute extends BaseRoute implements RouteInterface { editorSettings: { longMode: true, }, - canAdd: () => of({ can: this._routeToolService.permissionsService.canAccess(PERMISSIONS.ACRL_CREATE) }), + canAdd: () => of({ can: this.routeToolService.permissionsService.canAccess(PERMISSIONS.ACRL_CREATE) }), preUpdateRecord: (data: any) => this.fieldsToRemoved(data, ['is_current_budget']), - permissions: (record: any) => this._routeToolService.permissions(record, this.recordType, true), + permissions: (record: any) => this.routeToolService.permissions(record, this.recordType, true), redirectUrl: (record: any) => this.redirectUrl(record.metadata.acq_receipt, '/records/acq_receipts/detail'), formFieldMap: (field: FormlyFieldConfig, jsonSchema: JSONSchema7): FormlyFieldConfig => { const formWidget = jsonSchema.widget; @@ -74,7 +74,7 @@ export class ReceiptLinesRoute extends BaseRoute implements RouteInterface { private _amountSymbol(field: FormlyFieldConfig): FormlyFieldConfig { // TODO :: This isn't the organisation currency that we need to use, it's the order related vendor currency // But how to retrieve the order from here ??? and how get quickly currency to use into - const service = this._routeToolService.getInjectorToken(OrganisationService); + const service = this.routeToolService.getInjectorToken(OrganisationService); field.props.addonLeft = [ getCurrencySymbol(service.organisation.default_currency, 'wide') ]; diff --git a/projects/admin/src/app/acquisition/routes/receipts-route.ts b/projects/admin/src/app/acquisition/routes/receipts-route.ts index 1a07f2c88..55d440b84 100644 --- a/projects/admin/src/app/acquisition/routes/receipts-route.ts +++ b/projects/admin/src/app/acquisition/routes/receipts-route.ts @@ -1,6 +1,6 @@ /* * RERO ILS UI - * Copyright (C) 2021-2023 RERO + * Copyright (C) 2021-2024 RERO * Copyright (C) 2021-2023 UCLouvain * * This program is free software: you can redistribute it and/or modify @@ -53,8 +53,8 @@ export class ReceiptsRoute extends BaseRoute implements RouteInterface { this.expertSearchFilter() ], preUpdateRecord: (data: any) => this._cleanRecord(data), - permissions: (record: any) => this._routeToolService.permissions(record, this.recordType, true), - aggregations: (aggregations: any) => this._routeToolService.aggregationFilter(aggregations), + permissions: (record: any) => this.routeToolService.permissions(record, this.recordType, true), + aggregations: (aggregations: any) => this.routeToolService.aggregationFilter(aggregations), aggregationsBucketSize: 10, itemHeaders: { Accept: 'application/rero+json, application/json' diff --git a/projects/admin/src/app/api/circulation-policy-api.service.ts b/projects/admin/src/app/api/circulation-policy-api.service.ts index 93a9c0b76..b03e0d08e 100644 --- a/projects/admin/src/app/api/circulation-policy-api.service.ts +++ b/projects/admin/src/app/api/circulation-policy-api.service.ts @@ -1,6 +1,6 @@ /* * RERO ILS UI - * Copyright (C) 2021 RERO + * Copyright (C) 2021-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,7 +14,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -import { Injectable } from '@angular/core'; +import { inject, Injectable } from '@angular/core'; import { Record, RecordService } from '@rero/ng-core'; import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; @@ -24,11 +24,7 @@ import { map } from 'rxjs/operators'; }) export class CirculationPolicyApiService { - /** - * Constructor - * @param _recordService - RecordService - */ - constructor(private _recordService: RecordService) {} + private recordService: RecordService = inject(RecordService); /** * Get All @@ -37,7 +33,7 @@ export class CirculationPolicyApiService { */ getAll(excludedPid?: string): Observable { const query = excludedPid ? `NOT pid:${excludedPid}` : ''; - return this._recordService + return this.recordService .getRecords('circ_policies', query, 1, RecordService.MAX_REST_RESULTS_SIZE) .pipe(map((response: Record) => response.hits.hits)); } diff --git a/projects/admin/src/app/api/document-api.service.ts b/projects/admin/src/app/api/document-api.service.ts index acc792da7..82ae12960 100644 --- a/projects/admin/src/app/api/document-api.service.ts +++ b/projects/admin/src/app/api/document-api.service.ts @@ -1,6 +1,6 @@ /* * RERO ILS UI - * Copyright (C) 2019-2023 RERO + * Copyright (C) 2019-2024 RERO * Copyright (C) 2019-2023 UCLouvain * * This program is free software: you can redistribute it and/or modify @@ -16,7 +16,7 @@ * along with this program. If not, see . */ import { HttpClient } from '@angular/common/http'; -import { Injectable } from '@angular/core'; +import { inject, Injectable } from '@angular/core'; import { Record, RecordService } from '@rero/ng-core'; import { IAvailability, IAvailabilityService } from '@rero/shared'; import { Observable } from 'rxjs'; @@ -29,28 +29,20 @@ import { IAdvancedSearchConfig } from '../record/search-view/document-advanced-s }) export class DocumentApiService implements IAvailabilityService { + private recordService: RecordService = inject(RecordService); + private httpClient: HttpClient = inject(HttpClient); + private appConfigService: AppConfigService = inject(AppConfigService); + /** Resource name */ readonly RESOURCE_NAME = 'documents'; - /** - * Constructor - * @param _recordService - RecordService - * @param _httpClient - HttpClient - * @param _appConfigService - AppConfigService - */ - constructor( - private _recordService: RecordService, - private _httpClient: HttpClient, - private _appConfigService: AppConfigService - ) { } - /** * Get count of linked document(s) from current document (partOf) * @param documentPid - document pid * @returns Observable */ getLinkedDocumentsCount(documentPid: string): Observable { - return this._recordService.getRecords( + return this.recordService.getRecords( this.RESOURCE_NAME, `partOf.document.pid:${documentPid}`, 1, 1 ).pipe(map((result: Record) => result.hits.total.value)); } @@ -61,8 +53,8 @@ export class DocumentApiService implements IAvailabilityService { * @returns Observable of availability data */ getAvailability(pid: string): Observable { - const url = `${this._appConfigService.apiEndpointPrefix}/document/${pid}/availability`; - return this._httpClient.get(url); + const url = `${this.appConfigService.apiEndpointPrefix}/document/${pid}/availability`; + return this.httpClient.get(url); } /** @@ -70,7 +62,7 @@ export class DocumentApiService implements IAvailabilityService { * @returns The advanced Search config */ getAdvancedSearchConfig(): Observable { - const url = `${this._appConfigService.apiEndpointPrefix}/document/advanced-search-config`; - return this._httpClient.get(url); + const url = `${this.appConfigService.apiEndpointPrefix}/document/advanced-search-config`; + return this.httpClient.get(url); } } diff --git a/projects/admin/src/app/api/holdings-api.service.ts b/projects/admin/src/app/api/holdings-api.service.ts index 327169904..032d95de5 100644 --- a/projects/admin/src/app/api/holdings-api.service.ts +++ b/projects/admin/src/app/api/holdings-api.service.ts @@ -1,6 +1,6 @@ /* * RERO ILS UI - * Copyright (C) 2021 RERO + * Copyright (C) 2021-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,7 +14,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -import { Injectable } from '@angular/core'; +import { inject, Injectable } from '@angular/core'; import { Record, RecordService } from '@rero/ng-core'; import { BaseApi } from '@rero/shared'; import { Observable } from 'rxjs'; @@ -25,18 +25,14 @@ import { map } from 'rxjs/operators'; }) export class HoldingsApiService { - /** Ressource name */ + private recordService: RecordService = inject(RecordService); + + /** Resource name */ readonly RESOURCE_NAME = 'holdings'; /** Items per page */ readonly ITEMS_PER_PAGE = 10; - /** - * Constructor - * @param _recordService - RecordService - */ - constructor(private _recordService: RecordService) { } - /** * * @param documentPid - Document pid @@ -56,7 +52,7 @@ export class HoldingsApiService { order: string = 'organisation_library_location' ): Observable { const query = this._queryOrganisation(documentPid, organisationPid, isCurrentOrganisation); - return this._recordService.getRecords( + return this.recordService.getRecords( this.RESOURCE_NAME, query, page, itemsPerPage, undefined, undefined, BaseApi.reroJsonheaders, order).pipe( map((result: Record) => result.hits.hits) ); @@ -71,8 +67,8 @@ export class HoldingsApiService { */ getHoldingsCount(documentPid: string, organisationPid: string, isCurrentOrganisation: boolean = true): Observable { const query = this._queryOrganisation(documentPid, organisationPid, isCurrentOrganisation); - return this._recordService.getRecords(this.RESOURCE_NAME, query, 1, 1).pipe( - map((result: Record) => this._recordService.totalHits(result.hits.total)) + return this.recordService.getRecords(this.RESOURCE_NAME, query, 1, 1).pipe( + map((result: Record) => this.recordService.totalHits(result.hits.total)) ); } diff --git a/projects/admin/src/app/api/ill-request-api.service.ts b/projects/admin/src/app/api/ill-request-api.service.ts index 279c81e23..b764b3f92 100644 --- a/projects/admin/src/app/api/ill-request-api.service.ts +++ b/projects/admin/src/app/api/ill-request-api.service.ts @@ -1,6 +1,6 @@ /* * RERO ILS UI - * Copyright (C) 2019-2023 RERO + * Copyright (C) 2019-2024 RERO * Copyright (C) 2019-2023 UCLouvain * * This program is free software: you can redistribute it and/or modify @@ -15,29 +15,22 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -import { Injectable } from '@angular/core'; +import { inject, Injectable } from '@angular/core'; import { Record, RecordService } from '@rero/ng-core'; +import { BaseApi } from '@rero/shared'; import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; -import { ILLRequestStatus } from '../classes/ill-request'; -import { BaseApi } from '@rero/shared'; @Injectable({ providedIn: 'root' }) export class IllRequestApiService extends BaseApi { + private recordService: RecordService = inject(RecordService); + /** Resource name */ readonly RESOURCE_NAME = 'ill_requests'; - /** - * Constructor - * @param _recordService - RecordService - */ - constructor(private _recordService: RecordService) { - super(); - } - /** * Get ills requests with pending status by patron pid * @param patronPid - The patron pid @@ -50,7 +43,7 @@ export class IllRequestApiService extends BaseApi { sort: string = '-created' ): Observable { const query = `patron.pid:${patronPid}`; - return this._recordService + return this.recordService .getRecords(this.RESOURCE_NAME, query , 1, RecordService.MAX_REST_RESULTS_SIZE, undefined, filters, BaseApi.reroJsonheaders, sort) .pipe(map((result: Record) => result.hits.hits)); diff --git a/projects/admin/src/app/api/import-source-api.service.ts b/projects/admin/src/app/api/import-source-api.service.ts index eeec6045c..959000d1b 100644 --- a/projects/admin/src/app/api/import-source-api.service.ts +++ b/projects/admin/src/app/api/import-source-api.service.ts @@ -1,7 +1,7 @@ /* * RERO ILS UI + * Copyright (C) 2021-2024 RERO * Copyright (C) 2021 UCLouvain - * 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 @@ -17,7 +17,7 @@ */ import { HttpClient } from '@angular/common/http'; -import { Injectable } from '@angular/core'; +import { inject, Injectable } from '@angular/core'; import { Observable } from 'rxjs'; import { catchError, map } from 'rxjs/operators'; import { ExternalSourceSetting } from '../classes/external-source'; @@ -27,20 +27,14 @@ import { ExternalSourceSetting } from '../classes/external-source'; }) export class ImportSourceApiService { - /** - * Constructor - * @param _httpClient - HttpClient - */ - constructor( - private _httpClient: HttpClient - ) { } + private httpClient: HttpClient = inject(HttpClient); /** * Get the configuration entrypoint for external sources * @return: an Observable on external sources list */ getSources(): Observable> { - return this._httpClient + return this.httpClient .get('/api/imports/config/') .pipe( map((sources: any[]) => sources.map(data => new ExternalSourceSetting(data))), diff --git a/projects/admin/src/app/api/item-api.service.ts b/projects/admin/src/app/api/item-api.service.ts index 561b8e606..3bf292c4f 100644 --- a/projects/admin/src/app/api/item-api.service.ts +++ b/projects/admin/src/app/api/item-api.service.ts @@ -1,6 +1,6 @@ /* * RERO ILS UI - * Copyright (C) 2019-2023 RERO + * Copyright (C) 2019-2024 RERO * Copyright (C) 2019-2023 UCLouvain * * This program is free software: you can redistribute it and/or modify @@ -16,7 +16,7 @@ * along with this program. If not, see . */ import { HttpClient, HttpHeaders } from '@angular/common/http'; -import { Injectable } from '@angular/core'; +import { inject, Injectable } from '@angular/core'; import { ApiService, Error, RecordService } from '@rero/ng-core'; import { IAvailability, IAvailabilityService } from '@rero/shared'; import { Observable, of } from 'rxjs'; @@ -29,32 +29,22 @@ import { ITypeEmail } from '../shared/preview-email/IPreviewInterface'; }) export class ItemApiService implements IAvailabilityService { + private appConfigService: AppConfigService = inject(AppConfigService); + private apiService: ApiService = inject(ApiService); + private recordService: RecordService = inject(RecordService); + private httpClient: HttpClient = inject(HttpClient); + // SERVICE ATTRIBUTES ======================================================= /** resource name */ static readonly RESOURCE_NAME = 'items'; /** http client options */ - private _httpOptions = { + private httpClientOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json' }) }; - // CONSTRUCTOR ============================================================== - /** - * Constructor - * @param _appConfigService: AppConfigService - * @param _apiService - ApiService - * @param _recordService - RecordService - * @param _http - HttpClient - */ - constructor( - private _appConfigService: AppConfigService, - private _apiService: ApiService, - private _recordService: RecordService, - private _http: HttpClient - ){ } - // SERVICE FUNCTIONS ======================================================== /** * Get an Item through the REST-API @@ -63,7 +53,7 @@ export class ItemApiService implements IAvailabilityService { * @returns: an `Observable` on REST-API item metadata result */ getItem(pid: string, resolve: boolean = false): Observable { - return this._recordService + return this.recordService .getRecord(ItemApiService.RESOURCE_NAME, pid, resolve ? 1 : 0) .pipe( map((result: any) => result.metadata) @@ -76,8 +66,8 @@ export class ItemApiService implements IAvailabilityService { * @param newLocationPid: the new owning location pid */ updateLocation(item: any, newLocationPid: string): Observable { - item.location.$ref = this._apiService.getRefEndpoint('locations', newLocationPid); - return this._recordService.update(ItemApiService.RESOURCE_NAME, item.pid, item); + item.location.$ref = this.apiService.getRefEndpoint('locations', newLocationPid); + return this.recordService.update(ItemApiService.RESOURCE_NAME, item.pid, item); } /** @@ -86,7 +76,7 @@ export class ItemApiService implements IAvailabilityService { * @returns Observable of the stats of item */ getStatsByItemPid(itemPid: string): Observable { - return this._http.get(`${this._appConfigService.apiEndpointPrefix}/item/${itemPid}/stats`); + return this.httpClient.get(`${this.appConfigService.apiEndpointPrefix}/item/${itemPid}/stats`); } /** @@ -95,9 +85,9 @@ export class ItemApiService implements IAvailabilityService { * @returns Observable of the Preview of a claim and suggested email addresses. */ getPreviewByItemPid(itemPid: string): Observable { - return this._http.get( - `${this._appConfigService.apiEndpointPrefix}/item/${itemPid}/issue/claims/preview`, - this._httpOptions + return this.httpClient.get( + `${this.appConfigService.apiEndpointPrefix}/item/${itemPid}/issue/claims/preview`, + this.httpClientOptions ).pipe(catchError((err: any) => of({ error: err.error.message }))); } @@ -108,8 +98,8 @@ export class ItemApiService implements IAvailabilityService { * @returns Observable with boolean */ addClaimIssue(itemPid: string, recipients: ITypeEmail[]): Observable { - const apiUrl = `${this._appConfigService.apiEndpointPrefix}/item/${itemPid}/issue/claims`; - return this._http.post(apiUrl, {recipients}).pipe( + const apiUrl = `${this.appConfigService.apiEndpointPrefix}/item/${itemPid}/issue/claims`; + return this.httpClient.post(apiUrl, {recipients}).pipe( map((_: unknown) => true), catchError(() => of(false)) ); @@ -121,7 +111,7 @@ export class ItemApiService implements IAvailabilityService { * @returns Observable of availability data */ getAvailability(pid: string): Observable { - const url = `${this._appConfigService.apiEndpointPrefix}/item/${pid}/availability?more_info=1`; - return this._http.get(url); + const url = `${this.appConfigService.apiEndpointPrefix}/item/${pid}/availability?more_info=1`; + return this.httpClient.get(url); } } diff --git a/projects/admin/src/app/api/item-type-api.service.ts b/projects/admin/src/app/api/item-type-api.service.ts index e032de28b..bd79ec9d2 100644 --- a/projects/admin/src/app/api/item-type-api.service.ts +++ b/projects/admin/src/app/api/item-type-api.service.ts @@ -1,6 +1,6 @@ /* * RERO ILS UI - * Copyright (C) 2021 RERO + * Copyright (C) 2021-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,7 +14,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -import { Injectable } from '@angular/core'; +import { inject, Injectable } from '@angular/core'; import { Record, RecordService } from '@rero/ng-core'; import { map } from 'rxjs/operators'; @@ -23,18 +23,14 @@ import { map } from 'rxjs/operators'; }) export class ItemTypeApiService { - /** - * Constructor - * @param _recordService - RecordService - */ - constructor(private _recordService: RecordService) {} + private recordService: RecordService = inject(RecordService); /** * Get All * @return Observable, array of records */ getAll() { - return this._recordService + return this.recordService .getRecords('item_types', '', 1, RecordService.MAX_REST_RESULTS_SIZE) .pipe(map((response: Record) => response.hits.hits)); } diff --git a/projects/admin/src/app/api/library-api.service.ts b/projects/admin/src/app/api/library-api.service.ts index 9684918d2..ebb4f13dd 100644 --- a/projects/admin/src/app/api/library-api.service.ts +++ b/projects/admin/src/app/api/library-api.service.ts @@ -1,6 +1,6 @@ /* * RERO ILS UI - * Copyright (C) 2021-2023 RERO + * Copyright (C) 2021-2024 RERO * Copyright (C) 2021-2023 UCLouvain * * This program is free software: you can redistribute it and/or modify @@ -16,7 +16,7 @@ * along with this program. If not, see . */ import { HttpClient } from '@angular/common/http'; -import { Injectable } from '@angular/core'; +import { inject, Injectable } from '@angular/core'; import { RecordService } from '@rero/ng-core'; import moment from 'moment'; import { Observable } from 'rxjs'; @@ -27,15 +27,8 @@ import { map } from 'rxjs/operators'; }) export class LibraryApiService { - /** - * constructor - * @param http - HttpClient - * @param recordService - RecordService - */ - constructor( - private http: HttpClient, - private recordService: RecordService - ) { } + private http: HttpClient = inject(HttpClient); + private recordService: RecordService = inject(RecordService); /** * Get library by pid diff --git a/projects/admin/src/app/api/loan-api.service.ts b/projects/admin/src/app/api/loan-api.service.ts index 4e127477c..038c1c702 100644 --- a/projects/admin/src/app/api/loan-api.service.ts +++ b/projects/admin/src/app/api/loan-api.service.ts @@ -1,6 +1,6 @@ /* * RERO ILS UI - * Copyright (C) 2021 RERO + * Copyright (C) 2021-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 @@ -15,7 +15,7 @@ * along with this program. If not, see . */ import { HttpClient } from '@angular/common/http'; -import { Injectable } from '@angular/core'; +import { inject, Injectable } from '@angular/core'; import { Observable } from 'rxjs'; import { LoanOverduePreview } from '../classes/loans'; @@ -24,14 +24,7 @@ import { LoanOverduePreview } from '../classes/loans'; }) export class LoanApiService { - /** - * Constructor - * @param _http - HttpClient - */ - constructor( - private _http: HttpClient - ) {} - + private httpClient: HttpClient = inject(HttpClient); /** * Get the preview overdue fees related to a specific loan @@ -39,6 +32,6 @@ export class LoanApiService { */ getPreviewOverdue(loanPid: string): Observable { const url = `/api/loan/${loanPid}/overdue/preview`; - return this._http.get(url); + return this.httpClient.get(url); } } diff --git a/projects/admin/src/app/api/local-field-api.service.ts b/projects/admin/src/app/api/local-field-api.service.ts index 142580c00..8493f1c86 100644 --- a/projects/admin/src/app/api/local-field-api.service.ts +++ b/projects/admin/src/app/api/local-field-api.service.ts @@ -1,6 +1,6 @@ /* * RERO ILS UI - * Copyright (C) 2020 RERO + * Copyright (C) 2020-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 @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -import { Injectable } from '@angular/core'; +import { inject, Injectable } from '@angular/core'; import { Record, RecordService, RecordUiService } from '@rero/ng-core'; import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; @@ -25,14 +25,8 @@ import { map } from 'rxjs/operators'; }) export class LocalFieldApiService { - /** - * Constructor - * @param _recordService - RecordService - */ - constructor( - private _recordService: RecordService, - private _recordUiService: RecordUiService - ) { } + private recordService: RecordService = inject(RecordService); + private recordUiService: RecordUiService = inject(RecordUiService); /** * Get Local field for current resource and organisation user @@ -44,11 +38,11 @@ export class LocalFieldApiService { getByResourceTypeAndResourcePidAndOrganisationId(resourceType: string, resourcePid: string, organisationPid: string): Observable { const query = `parent.type:${resourceType} AND parent.pid:${resourcePid} AND organisation.pid:${organisationPid}`; - return this._recordService + return this.recordService .getRecords('local_fields', query, 1, 1) .pipe( map((result: Record) => { - return this._recordService.totalHits(result.hits.total) === 0 + return this.recordService.totalHits(result.hits.total) === 0 ? {} : result.hits.hits[0]; }) @@ -61,6 +55,6 @@ export class LocalFieldApiService { * @return Observable */ delete(resourcePid: string) { - return this._recordUiService.deleteRecord('local_fields', resourcePid); + return this.recordUiService.deleteRecord('local_fields', resourcePid); } } diff --git a/projects/admin/src/app/api/notification-api.service.ts b/projects/admin/src/app/api/notification-api.service.ts index 57b35022b..40b088d2d 100644 --- a/projects/admin/src/app/api/notification-api.service.ts +++ b/projects/admin/src/app/api/notification-api.service.ts @@ -1,6 +1,6 @@ /* * RERO ILS UI - * Copyright (C) 2023 RERO + * Copyright (C) 2023-2024 RERO * Copyright (C) 2023 UCLouvain * * This program is free software: you can redistribute it and/or modify @@ -15,7 +15,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -import { Injectable } from '@angular/core'; +import { inject, Injectable } from '@angular/core'; import { RecordService } from '@rero/ng-core'; import { BaseApi } from '@rero/shared'; import { map } from 'rxjs/operators'; @@ -25,19 +25,13 @@ import { map } from 'rxjs/operators'; }) export class NotificationApiService extends BaseApi { + private recordService: RecordService = inject(RecordService); + /** Resource name */ readonly RESOURCE_NAME = 'notifications'; - /** - * Constructor - * @param _recordService - RecordService - */ - constructor(private _recordService: RecordService) { - super(); - } - getNotificationByPid(pid: string): any { - return this._recordService.getRecord(this.RESOURCE_NAME, pid).pipe( + return this.recordService.getRecord(this.RESOURCE_NAME, pid).pipe( map((result: any) => result.metadata) ); } diff --git a/projects/admin/src/app/api/operation-logs-api.service.ts b/projects/admin/src/app/api/operation-logs-api.service.ts index d0b5dbff6..4eca6a7ac 100644 --- a/projects/admin/src/app/api/operation-logs-api.service.ts +++ b/projects/admin/src/app/api/operation-logs-api.service.ts @@ -1,6 +1,6 @@ /* * RERO ILS UI - * Copyright (C) 2021-2023 RERO + * Copyright (C) 2021-2024 RERO * Copyright (C) 2021-2023 UCLouvain * * This program is free software: you can redistribute it and/or modify @@ -15,7 +15,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -import { Injectable } from '@angular/core'; +import { inject, Injectable } from '@angular/core'; import { Record, RecordService } from '@rero/ng-core'; import { Error } from '@rero/ng-core/lib/error/error'; import { BaseApi } from '@rero/shared'; @@ -28,13 +28,7 @@ import { map } from 'rxjs/operators'; }) export class OperationLogsApiService extends BaseApi { - /** - * Constructor - * @param _recordService - RecordService - */ - constructor(private _recordService: RecordService) { - super(); - } + private recordService: RecordService = inject(RecordService); /** * Get Operation logs by resource type and resource pid @@ -50,7 +44,7 @@ export class OperationLogsApiService extends BaseApi { resourceType: string, resourcePid: string, action: 'create'|'update', page: number, itemPerPage = 5, sort = 'mostrecent'): Observable { const query = `record.type:${resourceType} AND record.value:${resourcePid} AND operation:${action}`; - return this._recordService.getRecords('operation_logs', query, page, itemPerPage, undefined, undefined, BaseApi.reroJsonheaders, sort); + return this.recordService.getRecords('operation_logs', query, page, itemPerPage, undefined, undefined, BaseApi.reroJsonheaders, sort); } /** @@ -84,7 +78,7 @@ export class OperationLogsApiService extends BaseApi { }); query.push(`(${typeFilters.join(' OR ')})`); } - return this._recordService.getRecords('operation_logs', query.join(' AND '), page, itemPerPage, undefined, undefined, undefined, sort); + return this.recordService.getRecords('operation_logs', query.join(' AND '), page, itemPerPage, undefined, undefined, undefined, sort); } /** @@ -97,7 +91,7 @@ export class OperationLogsApiService extends BaseApi { getCheckInHistory(patronPid: string, page: number, itemsPerPage: number = 10): Observable { const date = moment().subtract(6, 'months').utc().format('YYYY-MM-DDTHH:mm:ss'); const query = `_exists_:loan AND record.type:loan AND loan.patron.pid:${patronPid} AND loan.trigger:checkin AND date:[${date} TO *]`; - return this._recordService.getRecords( + return this.recordService.getRecords( 'operation_logs', query, page, itemsPerPage, undefined, undefined, BaseApi.reroJsonheaders, 'mostrecent'); } @@ -109,9 +103,9 @@ export class OperationLogsApiService extends BaseApi { */ getHistoryByLoanPid(loanPid: string, type: string = 'checkin'): Observable { const query = `_exists_:loan AND loan.pid:${loanPid} AND loan.trigger:${type} AND record.type:loan`; - return this._recordService.getRecords('operation_logs', query, 1, 1, undefined, undefined, BaseApi.reroJsonheaders) + return this.recordService.getRecords('operation_logs', query, 1, 1, undefined, undefined, BaseApi.reroJsonheaders) .pipe(map((result: any) => { - return this._recordService.totalHits(result.hits.total) === 1 + return this.recordService.totalHits(result.hits.total) === 1 ? result.hits.hits[0] : {}; })); diff --git a/projects/admin/src/app/api/organisation-api.service.ts b/projects/admin/src/app/api/organisation-api.service.ts index 501f2205c..63b28a512 100644 --- a/projects/admin/src/app/api/organisation-api.service.ts +++ b/projects/admin/src/app/api/organisation-api.service.ts @@ -1,6 +1,6 @@ /* * RERO ILS UI - * Copyright (C) 2021-2023 RERO + * Copyright (C) 2021-2024 RERO * Copyright (C) 2021-2023 UCLouvain * * This program is free software: you can redistribute it and/or modify @@ -15,7 +15,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -import { Injectable } from '@angular/core'; +import { inject, Injectable } from '@angular/core'; import { RecordService } from '@rero/ng-core'; import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; @@ -25,11 +25,7 @@ import { map } from 'rxjs/operators'; }) export class OrganisationApiService { - /** - * Constructor - * @param recordService - RecordService - */ - constructor(private recordService: RecordService) { } + private recordService: RecordService = inject(RecordService); /** * Get Organisation by pid diff --git a/projects/admin/src/app/api/patron-transaction-api.service.ts b/projects/admin/src/app/api/patron-transaction-api.service.ts index de3106b2a..5205a52ec 100644 --- a/projects/admin/src/app/api/patron-transaction-api.service.ts +++ b/projects/admin/src/app/api/patron-transaction-api.service.ts @@ -1,6 +1,6 @@ /* * RERO ILS UI - * Copyright (C) 2022-2023 RERO + * Copyright (C) 2022-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 @@ -15,7 +15,7 @@ * along with this program. If not, see . */ import { HttpClient } from '@angular/common/http'; -import { Injectable } from '@angular/core'; +import { inject, Injectable } from '@angular/core'; import { ApiService, Record, RecordService } from '@rero/ng-core'; import { Observable, map } from 'rxjs'; import { FeeFormModel } from '../circulation/patron/patron-transactions/patron-fee/patron-fee.component'; @@ -25,22 +25,16 @@ import { FeeFormModel } from '../circulation/patron/patron-transactions/patron-f }) export class PatronTransactionApiService { - /** - * Constructor - * @param _httpClient - HttpClient - */ - constructor( - private _httpClient: HttpClient, - private _apiService: ApiService, - private recordService: RecordService - ) {} + private httpClient: HttpClient = inject(HttpClient); + private apiService: ApiService = inject(ApiService); + private recordService: RecordService = inject(RecordService); /** * Add fee * @return Observable, array of records */ addFee(model: FeeFormModel): Observable { - return this._httpClient.post(this._apiService.getEndpointByType('patron_transactions/'), model); + return this.httpClient.post(this.apiService.getEndpointByType('patron_transactions/'), model); } getActiveFeesByItemPid(itemPid: string): any { diff --git a/projects/admin/src/app/api/patron-type-api.service.ts b/projects/admin/src/app/api/patron-type-api.service.ts index 911e72917..3ce6de05d 100644 --- a/projects/admin/src/app/api/patron-type-api.service.ts +++ b/projects/admin/src/app/api/patron-type-api.service.ts @@ -1,6 +1,6 @@ /* * RERO ILS UI - * Copyright (C) 2021 RERO + * Copyright (C) 2021-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,7 +14,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -import { Injectable } from '@angular/core'; +import { inject, Injectable } from '@angular/core'; import { Record, RecordService } from '@rero/ng-core'; import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; @@ -24,18 +24,14 @@ import { map } from 'rxjs/operators'; }) export class PatronTypeApiService { - /** - * Constructor - * @param _recordService - RecordService - */ - constructor(private _recordService: RecordService) {} + private recordService: RecordService = inject(RecordService); /** * Get All * @return Observable, array of records */ getAll(): Observable { - return this._recordService + return this.recordService .getRecords('patron_types', '', 1, RecordService.MAX_REST_RESULTS_SIZE) .pipe(map((response: Record) => response.hits.hits)); } diff --git a/projects/admin/src/app/api/permission-api.service.ts b/projects/admin/src/app/api/permission-api.service.ts index 11097bb6c..05718b7e4 100644 --- a/projects/admin/src/app/api/permission-api.service.ts +++ b/projects/admin/src/app/api/permission-api.service.ts @@ -1,6 +1,6 @@ /* * RERO ILS UI - * Copyright (C) 2022 RERO + * Copyright (C) 2022-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 @@ -15,34 +15,31 @@ * along with this program. If not, see . */ import { HttpClient } from '@angular/common/http'; -import { Injectable } from '@angular/core'; +import { inject, Injectable } from '@angular/core'; import { Observable } from 'rxjs'; @Injectable({ providedIn: 'root' }) export class PermissionApiService { - /** - * Constructor - * @param _http - HttpClient - */ - constructor(private _http: HttpClient) {} + + private httpClient: HttpClient = inject(HttpClient); /** * Get All Permissions by role * @return Observable, array of IRolePermission */ getAllPermissionsByRole(): Observable { - return this._http.get('/api/permissions/by_role'); + return this.httpClient.get('/api/permissions/by_role'); } /** * - * @param pid - Partron pid + * @param pid - Patron pid * @returns Observable, array of permissions */ getUserPermissions(pid: string): Observable { - return this._http.get(`/api/permissions/by_patron/${pid}`); + return this.httpClient.get(`/api/permissions/by_patron/${pid}`); } } diff --git a/projects/admin/src/app/app-routing.module.ts b/projects/admin/src/app/app-routing.module.ts index 41657ed72..ec2a91085 100644 --- a/projects/admin/src/app/app-routing.module.ts +++ b/projects/admin/src/app/app-routing.module.ts @@ -1,6 +1,6 @@ /* * RERO ILS UI - * Copyright (C) 2019-2022 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,14 +14,13 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ - import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; -import { FrontpageComponent } from './widgets/frontpage/frontpage.component'; -import { RouteService } from './routes/route.service'; -import { PermissionDetailViewComponent } from './record/detail-view/permission-detail-view/permission-detail-view.component'; import { PERMISSIONS } from '@rero/shared'; import { PermissionGuard } from './guard/permission.guard'; +import { PermissionDetailViewComponent } from './record/detail-view/permission-detail-view/permission-detail-view.component'; +import { RouteService } from './routes/route.service'; +import { FrontpageComponent } from './widgets/frontpage/frontpage.component'; const routes: Routes = [ { @@ -47,11 +46,7 @@ const routes: Routes = [ }) export class AppRoutingModule { - /** - * Constructor - * @param _routeService - RouteService - */ - constructor(private _routeService: RouteService) { - this._routeService.initializeRoutes(); + constructor(private routeService: RouteService) { + this.routeService.initializeRoutes(); } } diff --git a/projects/admin/src/app/app.component.html b/projects/admin/src/app/app.component.html index e33e3310a..ca03c8421 100644 --- a/projects/admin/src/app/app.component.html +++ b/projects/admin/src/app/app.component.html @@ -20,12 +20,33 @@ @if (user) {
+ @if (user.hasAdminUiAccess) { - + }
@if (user.hasAdminUiAccess) {
+ + +
+
+ {{ message.summary }} +
+

+
+
+
+
} @else { diff --git a/projects/admin/src/app/app.component.scss b/projects/admin/src/app/app.component.scss index b92d61eea..aabf5d6c2 100644 --- a/projects/admin/src/app/app.component.scss +++ b/projects/admin/src/app/app.component.scss @@ -1,6 +1,6 @@ /* * RERO ILS UI - * Copyright (C) 2021 RERO + * Copyright (C) 2021-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,6 +14,10 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -.logo { - max-height: 40px !important; + #header-search { + padding: 0.5rem 2rem; +} + + #header-search img { + max-height: 40px!important; } diff --git a/projects/admin/src/app/app.component.ts b/projects/admin/src/app/app.component.ts index 0e9ac84e6..f14388f68 100644 --- a/projects/admin/src/app/app.component.ts +++ b/projects/admin/src/app/app.component.ts @@ -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 @@ -15,11 +15,10 @@ * along with this program. If not, see . */ -import { AfterViewInit, Component, OnInit } from '@angular/core'; +import { AfterViewInit, Component, inject, OnInit } from '@angular/core'; import { HotkeysService } from '@ngneat/hotkeys'; import { User, UserService } from '@rero/shared'; -import { BsModalService } from 'ngx-bootstrap/modal'; -import { NgxSpinnerService } from 'ngx-spinner'; +import { DialogService } from 'primeng/dynamicdialog'; import { KeyboardShortcutsService } from './service/keyboard-shortcuts.service'; import { CustomShortcutHelpComponent } from './widgets/custom-shortcut-help/custom-shortcut-help.component'; @@ -30,38 +29,25 @@ import { CustomShortcutHelpComponent } from './widgets/custom-shortcut-help/cust }) export class AppComponent implements OnInit, AfterViewInit { + private userService: UserService = inject(UserService); + private keyboardShortcutsService: KeyboardShortcutsService = inject(KeyboardShortcutsService); + private hotKeysService: HotkeysService = inject(HotkeysService); + private dialogService: DialogService = inject(DialogService); + /** user */ get user(): User { - return this._userService.user; + return this.userService.user; } - /** - * Constructor - * @param _userService - UserService - * @param _spinner - NgxSpinnerService - * @param _keyboardShortcutsService - KeyboardShortcutsService - * @param _hotKeysService - HotkeysService, - * @param _modalService - BsModalService - */ - constructor( - private _userService: UserService, - private _spinner: NgxSpinnerService, - private _keyboardShortcutsService: KeyboardShortcutsService, - private _hotKeysService: HotkeysService, - private _modalService: BsModalService - ) {} - /** Init hook */ ngOnInit() { - this._spinner.show(); - this._keyboardShortcutsService.initializeShortcuts(); - this._spinner.hide(); + this.keyboardShortcutsService.initializeShortcuts(); } /** AfterViewInit hook */ ngAfterViewInit() { - this._hotKeysService.registerHelpModal(() => { - this._modalService.show(CustomShortcutHelpComponent); + this.hotKeysService.registerHelpModal(() => { + this.dialogService.open(CustomShortcutHelpComponent, {}) }); } } diff --git a/projects/admin/src/app/app.module.ts b/projects/admin/src/app/app.module.ts index 5012b2770..69de42648 100644 --- a/projects/admin/src/app/app.module.ts +++ b/projects/admin/src/app/app.module.ts @@ -26,38 +26,29 @@ import { PrimengImportModule } from '@app/admin/shared/primeng-import/primeng-im import { HotkeysModule, HotkeysService } from '@ngneat/hotkeys'; import { FormlyModule } from '@ngx-formly/core'; import { FormlyFieldSelect } from '@ngx-formly/primeng/select'; -import { FileUploadModule } from 'primeng/fileupload'; import { LoadingBarHttpClientModule } from '@ngx-loading-bar/http-client'; -import { TranslateLoader as BaseTranslateLoader, TranslateModule } from '@ngx-translate/core'; +import { TranslateLoader as BaseTranslateLoader, TranslateModule, TranslateService } from '@ngx-translate/core'; import { BucketNameService as CoreBucketNameService, CoreConfigService, RecordHandleErrorService as CoreRecordHandleErrorService, - FilesService, - LocalStorageService, - RecordModule, RemoteTypeaheadService, - TranslateLoader, TranslateService, TruncateTextPipe + NgCoreTranslateService, + RecordModule, RemoteAutocompleteService, + TranslateLoader, TruncateTextPipe } from '@rero/ng-core'; -import { ItemHoldingsCallNumberPipe, MainTitlePipe, SharedModule, UserService } from '@rero/shared'; +import { AppSettingsService, ItemHoldingsCallNumberPipe, MainTitlePipe, SharedModule, UserService } from '@rero/shared'; import { NgxChartsModule } from '@swimlane/ngx-charts'; -import { CollapseModule } from 'ngx-bootstrap/collapse'; -import { BsDatepickerModule, BsLocaleService } from 'ngx-bootstrap/datepicker'; import { BsDropdownModule } from 'ngx-bootstrap/dropdown'; -import { PopoverModule } from 'ngx-bootstrap/popover'; -import { TabsModule } from 'ngx-bootstrap/tabs'; -import { TooltipModule } from 'ngx-bootstrap/tooltip'; -import { TypeaheadModule } from 'ngx-bootstrap/typeahead'; +import { FileUploadModule } from 'primeng/fileupload'; +import { MenubarModule } from 'primeng/menubar'; import { TableModule } from "primeng/table"; +import { Observable } from 'rxjs'; import { SelectAccountEditorWidgetComponent } from './acquisition/components/editor/widget/select-account-editor-widget/select-account-editor-widget.component'; import { ReceivedOrderPermissionValidator } from './acquisition/utils/permissions'; import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; -import { DocumentsTypeahead } from './classes/typeahead/documents-typeahead'; -import { ItemsTypeahead } from './classes/typeahead/items-typeahead'; -import { MefTypeahead } from './classes/typeahead/mef-typeahead'; -import { PatronsTypeahead } from './classes/typeahead/patrons-typeahead'; import { IssueEmailComponent } from './components/issues/issue-email/issue-email.component'; import { ItemSwitchLocationStandaloneComponent } from './components/items/switch-location/item-switch-location-standalone/item-switch-location-standalone.component'; import { ItemSwitchLocationComponent } from './components/items/switch-location/item-switch-location/item-switch-location.component'; @@ -65,15 +56,10 @@ import { TabOrderDirective } from './directives/tab-order.directive'; import { ErrorPageComponent } from './error/error-page/error-page.component'; import { NoCacheHeaderInterceptor } from './interceptor/no-cache-header.interceptor'; import { UserCurrentLibraryInterceptor } from './interceptor/user-current-library.interceptor'; +import { MenuAppComponent } from './menu/menu-app/menu-app.component'; import { MenuDashboardComponent } from './menu/menu-dashboard/menu-dashboard.component'; -import { MenuLanguageComponent } from './menu/menu-language/menu-language.component'; -import { MenuMobileComponent } from './menu/menu-mobile/menu-mobile.component'; -import { SubMenuComponent } from './menu/menu-mobile/sub-menu/sub-menu.component'; -import { MenuSwitchLibraryComponent } from './menu/menu-switch-library/menu-switch-library.component'; -import { MenuUserServicesComponent } from './menu/menu-user-services/menu-user-services.component'; +import { MenuDisplayComponent } from './menu/menu-display/menu-display.component'; import { MenuUserComponent } from './menu/menu-user/menu-user.component'; -import { MenuComponent } from './menu/menu.component'; -import { LibrarySwitchService } from './menu/service/library-switch.service'; import { CountryCodeTranslatePipe } from './pipe/country-code-translate.pipe'; import { DocumentProvisionActivityPipe } from './pipe/document-provision-activity.pipe'; import { ItemInCollectionPipe } from './pipe/item-in-collection.pipe'; @@ -127,6 +113,7 @@ import { DocumentDetailViewComponent } from './record/detail-view/document-detai import { DocumentDetailComponent } from './record/detail-view/document-detail-view/document-detail/document-detail.component'; import { EntitiesRelatedComponent } from './record/detail-view/document-detail-view/entities-related/entities-related.component'; import { FilesCollectionsComponent } from './record/detail-view/document-detail-view/files-collections/files-collections.component'; +import { UploadFilesComponent } from './record/detail-view/document-detail-view/files-collections/upload-files/upload-files.component'; import { HoldingDetailComponent } from './record/detail-view/document-detail-view/holding-detail/holding-detail.component'; import { HoldingOrganisationComponent @@ -189,14 +176,17 @@ import { ReportsListComponent } from './record/detail-view/statistics-cfg-detail import { StatisticsCfgDetailViewComponent } from './record/detail-view/statistics-cfg-detail-view/statistics-cfg-detail-view.component'; import { TemplateDetailViewComponent } from './record/detail-view/template-detail-view/template-detail-view.component'; import { VendorDetailViewComponent } from './record/detail-view/vendor-detail-view/vendor-detail-view.component'; +import { AddEntityLocalFormComponent } from './record/editor/formly/primeng/entity-autocomplete/add-entity-local-form/add-entity-local-form.component'; +import { remoteAutocompleteToken } from './record/editor/formly/primeng/remote-autocomplete/remote-autocomplete-factory.service'; +import { DocumentsRemoteService } from './record/editor/formly/primeng/remote-autocomplete/remote/documents-remote.service'; +import { ItemsRemoteService } from './record/editor/formly/primeng/remote-autocomplete/remote/items-remote.service'; +import { MefRemoteService } from './record/editor/formly/primeng/remote-autocomplete/remote/mef-remote.service'; +import { PatronsRemoteService } from './record/editor/formly/primeng/remote-autocomplete/remote/patrons-remote.service'; import { FieldCustomInputTypeComponent } from './record/editor/type/field-custom.type'; import { RepeatTypeComponent } from './record/editor/type/repeat-section.type'; import { IdentifiedbyValueComponent } from './record/editor/wrappers/identifiedby-value.component'; -import { UserIdComponent } from './record/editor/wrappers/user-id/user-id.component'; +import { UserIdComponent } from './record/editor/wrappers/user-id.component'; import { CipoPatronTypeItemTypeComponent } from './record/formly/type/cipo-patron-type-item-type/cipo-patron-type-item-type.component'; -import { AddEntityLocalFormComponent } from './record/formly/type/entity-typeahead/add-entity-local-form/add-entity-local-form.component'; -import { AddEntityLocalComponent } from './record/formly/type/entity-typeahead/add-entity-local.component'; -import { EntityTypeaheadComponent } from './record/formly/type/entity-typeahead/entity-typeahead.component'; import { OperationLogsDialogComponent } from './record/operation-logs/operation-logs-dialog/operation-logs-dialog.component'; import { OperationLogsComponent } from './record/operation-logs/operation-logs.component'; import { DocumentAdvancedSearchFormComponent } from './record/search-view/document-advanced-search-form/document-advanced-search-form.component'; @@ -211,18 +201,17 @@ import { AppInitializerService } from './service/app-initializer.service'; import { BucketNameService } from './service/bucket-name.service'; import { OrganisationService } from './service/organisation.service'; import { RecordHandleErrorService } from './service/record.handle-error.service'; -import { ResourcesFilesService } from './service/resources-files.service'; -import { TypeaheadFactoryService, typeaheadToken } from './service/typeahead-factory.service'; -import { UiRemoteTypeaheadService } from './service/ui-remote-typeahead.service'; import { PreviewEmailModule } from './shared/preview-email/preview-email.module'; import { CurrentLibraryPermissionValidator } from './utils/permissions'; import { CustomShortcutHelpComponent } from './widgets/custom-shortcut-help/custom-shortcut-help.component'; import { FrontpageComponent } from './widgets/frontpage/frontpage.component'; -import { UploadFilesComponent } from './record/detail-view/document-detail-view/files-collections/upload-files/upload-files.component'; + +import { EntityAutocompleteComponent } from './record/editor/formly/primeng/entity-autocomplete/entity-autocomplete.component'; +import { RemoteAutocompleteService as UiRemoteAutocompleteService } from './record/editor/formly/primeng/remote-autocomplete/remote-autocomplete.service'; /** Init application factory */ -export function appInitFactory(appInitializerService: AppInitializerService): () => Promise { - return () => appInitializerService.load().toPromise(); +export function appInitFactory(appInitializerService: AppInitializerService): () => Observable { + return () => appInitializerService.load(); } @NgModule({ @@ -239,7 +228,6 @@ export function appInitFactory(appInitializerService: AppInitializerService): () ItemTypeDetailViewComponent, LibrariesBriefViewComponent, LibraryComponent, - MenuComponent, PatronsBriefViewComponent, PatronTypesBriefViewComponent, PatronTypesDetailViewComponent, @@ -289,14 +277,8 @@ export function appInitFactory(appInitializerService: AppInitializerService): () IllRequestDetailViewComponent, CustomShortcutHelpComponent, HoldingItemNoteComponent, - MenuSwitchLibraryComponent, LocalFieldComponent, - MenuUserServicesComponent, - MenuLanguageComponent, - MenuUserComponent, MenuDashboardComponent, - MenuMobileComponent, - SubMenuComponent, HoldingItemTemporaryItemTypeComponent, OperationLogsComponent, HoldingSharedViewComponent, @@ -339,7 +321,6 @@ export function appInitFactory(appInitializerService: AppInitializerService): () ItemSwitchLocationStandaloneComponent, ItemSwitchLocationComponent, IssueEmailComponent, - EntityTypeaheadComponent, RemoteEntitiesDetailViewComponent, RemoteEntitiesOrganisationDetailViewComponent, EntitiesLocalDetailViewComponent, @@ -350,7 +331,7 @@ export function appInitFactory(appInitializerService: AppInitializerService): () LocalPlaceDetailViewComponent, LocalWorkDetailViewComponent, RemoteTopicDetailViewComponent, - AddEntityLocalComponent, + AddEntityLocalFormComponent, AddEntityLocalFormComponent, StatisticsCfgBriefViewComponent, StatisticsCfgDetailViewComponent, @@ -367,32 +348,31 @@ export function appInitFactory(appInitializerService: AppInitializerService): () LocalPageDetailComponent, RemotePageDetailComponent, ItemFeesComponent, - UploadFilesComponent + UploadFilesComponent, + MenuAppComponent, + MenuUserComponent, + MenuDisplayComponent, + EntityAutocompleteComponent, ], imports: [ AppRoutingModule, BrowserAnimationsModule, BrowserModule, - BsDatepickerModule.forRoot(), BsDropdownModule.forRoot(), NgxChartsModule, - CollapseModule.forRoot(), FormsModule, HttpClientModule, ReactiveFormsModule, RecordModule, - TabsModule.forRoot(), TableModule, - TooltipModule.forRoot(), - PopoverModule.forRoot(), FormlyModule.forRoot({ types: [ { name: "cipo-pt-it", component: CipoPatronTypeItemTypeComponent }, { name: "account-select", component: SelectAccountEditorWidgetComponent }, - { name: "entityTypeahead", component: EntityTypeaheadComponent }, - {name: 'repeat', component: RepeatTypeComponent}, - {name: 'select-formly', component: FormlyFieldSelect }, - {name: 'custom-field', component: FieldCustomInputTypeComponent } + { name: 'repeat', component: RepeatTypeComponent}, + { name: 'select-formly', component: FormlyFieldSelect }, + { name: 'custom-field', component: FieldCustomInputTypeComponent }, + { name: 'entity-autocomplete', component: EntityAutocompleteComponent } ], wrappers: [ { name: "user-id", component: UserIdComponent }, @@ -406,13 +386,13 @@ export function appInitFactory(appInitializerService: AppInitializerService): () deps: [CoreConfigService, HttpClient], }, }), - TypeaheadModule, HotkeysModule, SharedModule, LoadingBarHttpClientModule, PrimengImportModule, PreviewEmailModule, - FileUploadModule + FileUploadModule, + MenubarModule ], providers: [ { @@ -426,12 +406,10 @@ export function appInitFactory(appInitializerService: AppInitializerService): () deps: [ AppInitializerService, UserService, - AppConfigService, - TranslateService, OrganisationService, - LocalStorageService, - LibrarySwitchService, - TypeaheadFactoryService, + AppSettingsService, + AppConfigService, + TranslateService ], multi: true, }, @@ -445,28 +423,23 @@ export function appInitFactory(appInitializerService: AppInitializerService): () useClass: UserCurrentLibraryInterceptor, multi: true, }, - { provide: RemoteTypeaheadService, useExisting: UiRemoteTypeaheadService }, - // Use the "multi" parameter to allow the recovery of several services in the injector. - { provide: typeaheadToken, useExisting: DocumentsTypeahead, multi: true }, - { provide: typeaheadToken, useExisting: ItemsTypeahead, multi: true }, - { provide: typeaheadToken, useExisting: MefTypeahead, multi: true }, - { provide: typeaheadToken, useExisting: PatronsTypeahead, multi: true }, + { provide: TranslateService, useExisting: NgCoreTranslateService }, + + { provide: RemoteAutocompleteService, useExisting: UiRemoteAutocompleteService }, + { provide: remoteAutocompleteToken, useExisting: DocumentsRemoteService, multi: true }, + { provide: remoteAutocompleteToken, useExisting: ItemsRemoteService, multi: true }, + { provide: remoteAutocompleteToken, useExisting: MefRemoteService, multi: true }, + { provide: remoteAutocompleteToken, useExisting: PatronsRemoteService, multi: true }, { provide: CoreConfigService, useClass: AppConfigService, }, { provide: LOCALE_ID, - useFactory: (translate: TranslateService) => translate.currentLanguage, + useFactory: (translate: TranslateService) => translate.currentLang, deps: [TranslateService], }, - BsLocaleService, - MefTypeahead, - DocumentsTypeahead, - ItemsTypeahead, - PatronsTypeahead, MainTitlePipe, - MefTypeahead, TruncateTextPipe, CurrentLibraryPermissionValidator, ReceivedOrderPermissionValidator, @@ -481,7 +454,6 @@ export function appInitFactory(appInitializerService: AppInitializerService): () CountryCodeTranslatePipe, { provide: CoreBucketNameService, useClass: BucketNameService }, { provide: CoreRecordHandleErrorService, useClass: RecordHandleErrorService }, - { provide: FilesService, useClass: ResourcesFilesService }, ], bootstrap: [AppComponent], schemas: [CUSTOM_ELEMENTS_SCHEMA], 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 e9387b453..409f78995 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 @@ -1,6 +1,6 @@ -