diff --git a/projects/admin/src/app/record/formly/type/entity-typeahead/add-entity-local-form/add-entity-local-form.component.ts b/projects/admin/src/app/record/formly/type/entity-typeahead/add-entity-local-form/add-entity-local-form.component.ts
index b4d788a1d..da7ecf7e7 100644
--- a/projects/admin/src/app/record/formly/type/entity-typeahead/add-entity-local-form/add-entity-local-form.component.ts
+++ b/projects/admin/src/app/record/formly/type/entity-typeahead/add-entity-local-form/add-entity-local-form.component.ts
@@ -15,13 +15,13 @@
* 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, OnDestroy, OnInit } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { FormlyFieldConfig } from '@ngx-formly/core';
import { FormlyJsonschema } from '@ngx-formly/core/json-schema';
-import { TranslateService } from '@ngx-translate/core';
-import { RecordService, processJsonSchema } from '@rero/ng-core';
-import { ToastrService } from 'ngx-toastr';
+import { NgCoreTranslateService, processJsonSchema, RecordService } from '@rero/ng-core';
+import { MessageService } from 'primeng/api';
+import { DynamicDialogConfig, DynamicDialogRef } from 'primeng/dynamicdialog';
import { Subscription } from 'rxjs';
@Component({
@@ -30,17 +30,12 @@ import { Subscription } from 'rxjs';
})
export class AddEntityLocalFormComponent implements OnInit, OnDestroy {
- /** Available types on select typeahead */
- @Input() entityTypeFilters: any;
-
- /** Text searched by user */
- @Input() searchTerm: string;
-
- /** Event for close dialog */
- @Output() closeDialog: EventEmitter
= new EventEmitter();
-
- /** Event for record create */
- @Output() recordCreate: EventEmitter = new EventEmitter();
+ private messageService = inject(MessageService);
+ private dynamicDialogRef: DynamicDialogRef = inject(DynamicDialogRef);
+ private dynamicDialogConfig: DynamicDialogConfig = inject(DynamicDialogConfig);
+ private recordService: RecordService = inject(RecordService);
+ private formlyJsonschema: FormlyJsonschema = inject(FormlyJsonschema);
+ private translateService: NgCoreTranslateService = inject(NgCoreTranslateService);
/** TODO: Find a better solution for next iteration */
translatedTypes = {
@@ -68,32 +63,19 @@ export class AddEntityLocalFormComponent implements OnInit, OnDestroy {
/** all component subscription */
private subscriptions = new Subscription();
- /**
- * Constructor
- * @param recordService - RecordService
- * @param formlyJsonschema - FormlyJsonschema
- * @param translateService - TranslateService
- * @param toastrService - ToastrService
- */
- constructor(
- private recordService: RecordService,
- private formlyJsonschema: FormlyJsonschema,
- private translateService: TranslateService,
- private toastrService: ToastrService
- ) {}
-
/** OnInit hook */
ngOnInit(): void {
+ const { entityTypeFilters, searchTerm } = this.dynamicDialogConfig.data;
this.form = new FormGroup({});
let selectedType = undefined;
- if (this.entityTypeFilters.length === 1) {
+ if (entityTypeFilters.length === 1) {
// If there is only one possible choice, we take the first value.
- selectedType = this.entityTypeFilters[0].value;
+ selectedType = entityTypeFilters[0].value;
} else {
// If the select menu has not been touched, all values of the selected key are set to false.
// We take the first value.
- const selected = this.entityTypeFilters.filter((element: any) => element.selected);
- selectedType = (selected.length === 0) ? this.entityTypeFilters[0].value : selected[0].value;
+ const selected = entityTypeFilters.filter((element: any) => element.selected);
+ selectedType = (selected.length === 0) ? entityTypeFilters[0].value : selected[0].value;
}
this.subscriptions.add(this.recordService.getSchemaForm('local_entities').subscribe((schema) => {
schema = processJsonSchema(schema.schema);
@@ -105,7 +87,7 @@ export class AddEntityLocalFormComponent implements OnInit, OnDestroy {
map: (field: FormlyFieldConfig) => {
// Put the value typed by the user in the corresponding field
if (this.populateFields.includes(String(field.key))) {
- field.defaultValue = this.searchTerm;
+ field.defaultValue = searchTerm;
}
// If the type is concept-genreForm, we set the genreForm field flag
if (field.key === 'genreForm' && selectedType === 'concepts-genreForm') {
@@ -126,22 +108,22 @@ export class AddEntityLocalFormComponent implements OnInit, OnDestroy {
/** Submit form */
submit(): void {
if (this.form.valid) {
- this.subscriptions.add(this.recordService.create('local_entities', this.model).subscribe(
- (response: any) => {
- this.recordCreate.emit(response);
- this.closeModal();
+ this.subscriptions.add(this.recordService.create('local_entities', this.model).subscribe({
+ next: (response: any) => {
+ this.closeDialog(response);
},
- () => this.toastrService.error(
- this.translateService.instant('Data submission generated an error.'),
- this.translateService.instant('Add local entity')
- )
- ));
+ error: () => this.messageService.add({
+ severity: 'error',
+ summary: this.translateService.instant('Add local entity'),
+ detail: this.translateService.instant('Data submission generated an error.')
+ })
+ }));
}
}
/** Close the dialog */
- closeModal(): void {
- this.closeDialog.emit(true);
+ closeDialog(response?: any): void {
+ this.dynamicDialogRef.close(response);
}
/**
diff --git a/projects/admin/src/app/record/formly/type/entity-typeahead/add-entity-local.component.ts b/projects/admin/src/app/record/formly/type/entity-typeahead/add-entity-local.component.ts
index 3ff88b394..a57296f07 100644
--- a/projects/admin/src/app/record/formly/type/entity-typeahead/add-entity-local.component.ts
+++ b/projects/admin/src/app/record/formly/type/entity-typeahead/add-entity-local.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, EventEmitter, Input, Output } from '@angular/core';
-import { TranslateService } from '@ngx-translate/core';
-import { ApiService, SuggestionMetadata } from '@rero/ng-core';
+import { Component, EventEmitter, inject, Input, OnDestroy, Output } from '@angular/core';
+import { ApiService, NgCoreTranslateService, SuggestionMetadata } from '@rero/ng-core';
import { PERMISSIONS, PermissionsService } from '@rero/shared';
-import { BsModalService } from 'ngx-bootstrap/modal';
import { TypeaheadMatch } from 'ngx-bootstrap/typeahead';
+import { DialogService, DynamicDialogRef } from 'primeng/dynamicdialog';
+import { Subscription } from 'rxjs';
import { AddEntityLocalFormComponent } from './add-entity-local-form/add-entity-local-form.component';
import { EntityTypeFilter } from './entity-typeahead.interface';
@@ -35,7 +35,12 @@ import { EntityTypeFilter } from './entity-typeahead.interface';
}
`
})
-export class AddEntityLocalComponent {
+export class AddEntityLocalComponent implements OnDestroy {
+
+ private dialogService: DialogService = inject(DialogService);
+ private permissionService: PermissionsService = inject(PermissionsService);
+ private translateService: NgCoreTranslateService = inject(NgCoreTranslateService);
+ private apiService: ApiService = inject(ApiService);
/** Available types for typeahead select */
@Input() entityTypeFilters: EntityTypeFilter[];
@@ -46,6 +51,8 @@ export class AddEntityLocalComponent {
/** Event for record create */
@Output() recordCreate: EventEmitter = new EventEmitter();
+ private subscription = new Subscription();
+
/**
* Is the button available for adding a locale entity?
* @returns boolean
@@ -54,40 +61,31 @@ export class AddEntityLocalComponent {
return this.permissionService.canAccess(PERMISSIONS.LOCENT_CREATE);
}
- /**
- * Constructor
- * @param permissionService - PermissionsService
- * @param modalService - BsModalService
- * @param translateService - TranslateService
- * @param apiService - ApiService
- */
- constructor(
- private permissionService: PermissionsService,
- private modalService: BsModalService,
- private translateService: TranslateService,
- private apiService: ApiService
- ) {}
+ ngOnDestroy(): void {
+ this.subscription.unsubscribe();
+ }
/** Open the dialog to add an entity */
addEntity(): void {
- const modalRef = this.modalService.show(AddEntityLocalFormComponent, {
- ignoreBackdropClick: true,
- keyboard: true,
- class: 'modal-xl',
- initialState: {
+ const ref: DynamicDialogRef = this.dialogService.open(AddEntityLocalFormComponent, {
+ dismissableMask: true,
+ data: {
entityTypeFilters: this.entityTypeFilters,
searchTerm: this.searchTerm
}
});
- modalRef.content.closeDialog.subscribe(() => modalRef.hide());
- modalRef.content.recordCreate.subscribe((record: any) => {
- const item: SuggestionMetadata = {
- label: record.metadata.name,
- value: this.apiService.getRefEndpoint('local_entities', record.metadata.pid),
- externalLink: `/records/local_entities/detail/${record.metadata.pid}`,
- group: this.translateService.instant('link to local authority')
- };
- this.recordCreate.emit(new TypeaheadMatch(item, item.label))
- });
+ this.subscription.add(
+ ref.onClose.subscribe((record?: any) => {
+ if (record) {
+ const item: SuggestionMetadata = {
+ label: record.metadata.name,
+ value: this.apiService.getRefEndpoint('local_entities', record.metadata.pid),
+ externalLink: `/records/local_entities/detail/${record.metadata.pid}`,
+ group: this.translateService.instant('link to local authority')
+ };
+ this.recordCreate.emit(new TypeaheadMatch(item, item.label))
+ }
+ })
+ );
}
}
diff --git a/projects/admin/src/app/record/operation-logs/operation-logs-dialog/operation-logs-dialog.component.ts b/projects/admin/src/app/record/operation-logs/operation-logs-dialog/operation-logs-dialog.component.ts
index a7fcbc473..39157f68e 100644
--- a/projects/admin/src/app/record/operation-logs/operation-logs-dialog/operation-logs-dialog.component.ts
+++ b/projects/admin/src/app/record/operation-logs/operation-logs-dialog/operation-logs-dialog.component.ts
@@ -1,6 +1,6 @@
/*
* RERO ILS UI
- * Copyright (C) 2021-2022 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,9 +14,9 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
-import { Component, Input } from '@angular/core';
+import { Component, inject, Input } from '@angular/core';
import { IPermissions, PERMISSIONS } from '@rero/shared';
-import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal';
+import { DialogService } from 'primeng/dynamicdialog';
import { OperationLogsComponent } from '../operation-logs.component';
@Component({
@@ -25,39 +25,25 @@ import { OperationLogsComponent } from '../operation-logs.component';
})
export class OperationLogsDialogComponent {
+ private dialogService: DialogService = inject(DialogService);
+
/** Resource type */
@Input() resourceType: string;
/** Resource pid */
@Input() resourcePid: string;
- /** Modal ref */
- bsModalRef: BsModalRef;
-
/** return all permissions */
permissions: IPermissions = PERMISSIONS;
- /**
- * Constructor
- * @param modalService - BsModalService
- */
- constructor(private modalService: BsModalService) {}
-
/** Open operation logs dialog */
openDialog(): void {
- const config = {
- ignoreBackdropClick: false,
- keyboard: true,
- initialState: {
+ this.dialogService.open(OperationLogsComponent, {
+ dismissableMask: true,
+ data: {
resourceType: this.resourceType,
resourcePid: this.resourcePid
}
- };
- this.bsModalRef = this.modalService.show(OperationLogsComponent, config);
- this.bsModalRef.content.dialogClose$.subscribe((value: boolean) => {
- if (value) {
- this.bsModalRef.hide();
- }
});
}
}
diff --git a/projects/admin/src/app/record/operation-logs/operation-logs.component.ts b/projects/admin/src/app/record/operation-logs/operation-logs.component.ts
index 1a5325348..84bb74a31 100644
--- a/projects/admin/src/app/record/operation-logs/operation-logs.component.ts
+++ b/projects/admin/src/app/record/operation-logs/operation-logs.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, OnInit } from '@angular/core';
+import { Component, inject, OnInit } from '@angular/core';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
-import { TranslateService } from '@ngx-translate/core';
-import { Record } from '@rero/ng-core';
-import { BehaviorSubject, forkJoin, Observable } from 'rxjs';
+import { NgCoreTranslateService, Record } from '@rero/ng-core';
+import { DynamicDialogConfig, DynamicDialogRef } from 'primeng/dynamicdialog';
+import { forkJoin, Observable } from 'rxjs';
import { finalize, map } from 'rxjs/operators';
import { OperationLogsApiService } from '../../api/operation-logs-api.service';
import { OperationLogsService } from '../../service/operation-logs.service';
@@ -31,12 +31,17 @@ import { OperationLogsService } from '../../service/operation-logs.service';
})
export class OperationLogsComponent implements OnInit {
+ private dynamicDialogRef: DynamicDialogRef = inject(DynamicDialogRef);
+ private dynamicDialogConfig: DynamicDialogConfig = inject(DynamicDialogConfig);
+ private operationLogsApiService: OperationLogsApiService = inject(OperationLogsApiService);
+ private operationLogService: OperationLogsService = inject(OperationLogsService);
+ private translateService: NgCoreTranslateService = inject(NgCoreTranslateService);
+
// COMPONENT ATTRIBUTES =====================================================
/** Resource type */
- @Input() resourceType: string;
+ resourceType: string;
/** Resource pid */
- @Input() resourcePid: string;
-
+ resourcePid: string;
/** Resource key */
resourceKey: string;
/** Current page */
@@ -51,8 +56,6 @@ export class OperationLogsComponent implements OnInit {
records = [];
/** first loaded record */
loadedRecord = false;
- /** Event on dialog close */
- dialogClose$ = new BehaviorSubject(false);
// GETTER & SETTER ==========================================================
/** Show more link is visible ? */
@@ -70,21 +73,11 @@ export class OperationLogsComponent implements OnInit {
return this.translateService.instant(linkText, { counter: count });
}
- // CONSTRUCTOR & HOOKS ======================================================
- /**
- * Constructor
- * @param operationLogsApiService - OperationLogsApiService
- * @param operationLogService - OperationLogsService
- * @param translateService - TranslateService
- */
- constructor(
- private operationLogsApiService: OperationLogsApiService,
- private operationLogService: OperationLogsService,
- private translateService: TranslateService
- ) {}
-
+ // HOOKS ======================================================
/** OnInit hook */
ngOnInit(): void {
+ this.resourceType = this.dynamicDialogConfig?.data?.resourceType;
+ this.resourcePid = this.dynamicDialogConfig?.data?.resourcePid;
this.resourceKey = this.operationLogService.getResourceKeyByResourceName(this.resourceType);
forkJoin([this._operationLogsQuery(1, 'create'), this._operationLogsQuery(1, 'update')])
.pipe(
@@ -102,7 +95,7 @@ export class OperationLogsComponent implements OnInit {
// COMPONENT FUNCTIONS ======================================================
/** Close operation log dialog */
closeDialog(): void {
- this.dialogClose$.next(true);
+ this.dynamicDialogRef.close();
}
/** show more */
diff --git a/projects/admin/src/app/record/search-view/document-advanced-search-form/document-advanced-search-form.component.ts b/projects/admin/src/app/record/search-view/document-advanced-search-form/document-advanced-search-form.component.ts
index 285dae1e1..b12912c90 100644
--- a/projects/admin/src/app/record/search-view/document-advanced-search-form/document-advanced-search-form.component.ts
+++ b/projects/admin/src/app/record/search-view/document-advanced-search-form/document-advanced-search-form.component.ts
@@ -15,11 +15,12 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
-import { Component, EventEmitter, OnInit, Output } from '@angular/core';
+import { Component, inject, OnInit } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { ActivatedRoute } from '@angular/router';
import { FormlyFieldConfig, FormlyFormOptions } from '@ngx-formly/core';
import { LocalStorageService } from '@rero/ng-core';
+import { DynamicDialogRef } from 'primeng/dynamicdialog';
import { BehaviorSubject } from 'rxjs';
import { AdvancedSearchService } from './advanced-search.service';
import { IFieldsData, IFieldsType, ISearchModel } from './i-advanced-search-config-interface';
@@ -30,16 +31,15 @@ import { IFieldsData, IFieldsType, ISearchModel } from './i-advanced-search-conf
})
export class DocumentAdvancedSearchFormComponent implements OnInit {
+ private dynamicDialogRef: DynamicDialogRef = inject(DynamicDialogRef);
+ private route: ActivatedRoute = inject(ActivatedRoute);
+ private localeStorage: LocalStorageService = inject(LocalStorageService);
+ private advancedSearchService: AdvancedSearchService = inject(AdvancedSearchService);
+
/** Locale storage parameters */
private static LOCALE_STORAGE_NAME = 'advancedSearch';
private static LOCALE_STORAGE_EXPIRED_IN_SECONDS = 600;
- /** Closing event for the modal dialog */
- @Output() searchModel = new EventEmitter(false);
-
- /** Hide dialog event */
- @Output() hideDialog = new EventEmitter();
-
/** Configuration loaded from backend */
configurationLoaded: boolean = false;
@@ -74,18 +74,6 @@ export class DocumentAdvancedSearchFormComponent implements OnInit {
});
}
- /**
- * Constructor
- * @param route - ActivatedRoute
- * @param localeStorage - LocalStorageService
- * @param AdvancedSearchService - AdvancedSearchService
- */
- constructor(
- private route: ActivatedRoute,
- private localeStorage: LocalStorageService,
- private advancedSearchService: AdvancedSearchService
- ) {}
-
/** OnInit hook */
ngOnInit(): void {
const {q} = this.route.snapshot.queryParams;
@@ -99,7 +87,7 @@ export class DocumentAdvancedSearchFormComponent implements OnInit {
/** Event to notify dialog closure */
close(): void {
- this.hideDialog.emit(true);
+ this.dynamicDialogRef.close();
}
/** Clear the form and return it to its original state */
@@ -111,7 +99,7 @@ export class DocumentAdvancedSearchFormComponent implements OnInit {
/** Submit */
submit(): void {
this.localeStorage.set(DocumentAdvancedSearchFormComponent.LOCALE_STORAGE_NAME, this.model);
- this.searchModel.emit(this.generateQueryByModel(this.model));
+ this.dynamicDialogRef.close(this.generateQueryByModel(this.model))
}
/** Init formly model */
diff --git a/projects/admin/src/app/record/search-view/document-advanced-search.component.ts b/projects/admin/src/app/record/search-view/document-advanced-search.component.ts
index daa13b502..86c5722cb 100644
--- a/projects/admin/src/app/record/search-view/document-advanced-search.component.ts
+++ b/projects/admin/src/app/record/search-view/document-advanced-search.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, EventEmitter, OnDestroy, OnInit, Output } from '@angular/core';
+import { Component, EventEmitter, inject, OnDestroy, OnInit, Output } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
-import { BsModalService } from 'ngx-bootstrap/modal';
+import { DialogService, DynamicDialogRef } from 'primeng/dynamicdialog';
import { Subscription } from 'rxjs';
import { DocumentAdvancedSearchFormComponent } from './document-advanced-search-form/document-advanced-search-form.component';
@@ -34,6 +34,9 @@ import { DocumentAdvancedSearchFormComponent } from './document-advanced-search-
})
export class DocumentAdvancedSearchComponent implements OnInit, OnDestroy {
+ private dialogService: DialogService = inject(DialogService);
+ private route: ActivatedRoute = inject(ActivatedRoute);
+
/** Simple search */
simple: boolean = true;
@@ -41,21 +44,11 @@ export class DocumentAdvancedSearchComponent implements OnInit, OnDestroy {
@Output() queryString = new EventEmitter();
/** all component subscription */
- private subscriptions = new Subscription();
-
- /**
- * Constructor
- * @param route - ActivatedRoute
- * @param modalService - BsModalService
- */
- constructor(
- private route: ActivatedRoute,
- private modalService: BsModalService,
- ) { }
+ private subscription = new Subscription();
/** OnInit hook */
ngOnInit(): void {
- this.subscriptions.add(this.route.queryParams.subscribe((params: any) => {
+ this.subscription.add(this.route.queryParams.subscribe((params: any) => {
if (params.simple) {
if (Array.isArray(params.simple)) {
this.simple = params.simple.length > 0 ? ('1' === params.simple.pop()) : true;
@@ -70,20 +63,20 @@ export class DocumentAdvancedSearchComponent implements OnInit, OnDestroy {
/** OnDestroy hook */
ngOnDestroy(): void {
- this.subscriptions.unsubscribe();
+ this.subscription.unsubscribe();
}
/** Opening the advanced search dialog */
openModalBox(): void {
- const modalRef = this.modalService.show(DocumentAdvancedSearchFormComponent, {
- ignoreBackdropClick: true,
- keyboard: true,
- class: 'modal-xl',
- });
- modalRef.content.hideDialog.subscribe(() => modalRef.hide());
- modalRef.content.searchModel.subscribe((queryString: string) => {
- this.queryString.emit(queryString);
- modalRef.hide();
+ const ref: DynamicDialogRef = this.dialogService.open(DocumentAdvancedSearchFormComponent, {
+ dismissableMask: true
});
+ this.subscription.add(
+ ref.onClose.subscribe((queryString?: string) => {
+ if (queryString) {
+ this.queryString.emit(queryString);
+ }
+ })
+ );
}
}
diff --git a/projects/admin/src/app/scss/styles.scss b/projects/admin/src/app/scss/styles.scss
index 45ee8c95f..1b8f0480d 100644
--- a/projects/admin/src/app/scss/styles.scss
+++ b/projects/admin/src/app/scss/styles.scss
@@ -19,7 +19,6 @@
@import 'font-awesome/scss/font-awesome';
@import 'variables';
@import 'bootstrap/scss/bootstrap';
-@import 'ngx-toastr/toastr-bs4-alert';
html [type=button] {
@@ -102,10 +101,6 @@ button.disabled {
content: " \f08e";
}
-.toast-container .ngx-toastr {
- width: 450px !important; // override width for all toastr message
-}
-
span.no-data {
font-style: italic;
color: lightgray;
diff --git a/projects/admin/src/app/service/app-initializer.service.ts b/projects/admin/src/app/service/app-initializer.service.ts
index 59db2098e..d72208ae6 100644
--- a/projects/admin/src/app/service/app-initializer.service.ts
+++ b/projects/admin/src/app/service/app-initializer.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,6 @@
* along with this program. If not, see .
*/
import { Injectable } from '@angular/core';
-import { TranslateService } from '@rero/ng-core';
import { AppSettingsService, User, UserService } from '@rero/shared';
import { Observable } from 'rxjs';
import { switchMap, tap } from 'rxjs/operators';
@@ -25,6 +24,7 @@ import { LibrarySwitchService } from '../menu/service/library-switch.service';
import { AppConfigService } from './app-config.service';
import { OrganisationService } from './organisation.service';
import { TypeaheadFactoryService } from './typeahead-factory.service';
+import { TranslateService } from '@ngx-translate/core';
@Injectable({
providedIn: 'root'
@@ -87,6 +87,6 @@ export class AppInitializerService {
language = browserLang.match(this._appConfigService.languages.join('|')) ?
browserLang : this._appConfigService.defaultLanguage;
}
- return this._translateService.setLanguage(language);
+ return this._translateService.use(language);
}
}
diff --git a/projects/admin/src/app/service/issue.service.spec.ts b/projects/admin/src/app/service/issue.service.spec.ts
index 8d899b9ea..b9b7d5e09 100644
--- a/projects/admin/src/app/service/issue.service.spec.ts
+++ b/projects/admin/src/app/service/issue.service.spec.ts
@@ -15,21 +15,18 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
+import { CommonModule } from '@angular/common';
+import { HttpClientTestingModule } from '@angular/common/http/testing';
import { TestBed } from '@angular/core/testing';
-import { IssueService } from './issue.service';
-import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal';
+import { TranslateModule } from '@ngx-translate/core';
import { IssueItemStatus } from '@rero/shared';
+import { BsLocaleService } from 'ngx-bootstrap/datepicker';
import { IssueEmailComponent } from '../components/issues/issue-email/issue-email.component';
-import { HttpClientTestingModule } from '@angular/common/http/testing';
-import { TranslateCompiler, TranslateLoader, TranslateModule, TranslateService, TranslateStore } from '@ngx-translate/core';
-import { ToastrModule, ToastrService } from 'ngx-toastr';
-import { CommonModule } from '@angular/common';
import { PreviewEmailModule } from '../shared/preview-email/preview-email.module';
-import { BsLocaleService } from 'ngx-bootstrap/datepicker';
+import { IssueService } from './issue.service';
describe('IssueService', () => {
let service: IssueService;
- let modalService: BsModalService;
const record = {
metadata: {
@@ -45,18 +42,15 @@ describe('IssueService', () => {
imports: [
HttpClientTestingModule,
TranslateModule.forRoot(),
- ToastrModule.forRoot()
],
providers: [
PreviewEmailModule,
CommonModule,
- BsModalService,
BsLocaleService,
IssueService
]
});
service = TestBed.inject(IssueService);
- modalService = TestBed.inject(BsModalService);
});
it('should be created', () => {
@@ -72,7 +66,5 @@ describe('IssueService', () => {
it('should return the modal reference', () => {
const modal = service.openClaimEmailDialog(record);
- expect(modal).toBeInstanceOf(BsModalRef);
- modalService.hide();
});
});
diff --git a/projects/admin/src/app/service/issue.service.ts b/projects/admin/src/app/service/issue.service.ts
index d393a8383..bc6f938e0 100644
--- a/projects/admin/src/app/service/issue.service.ts
+++ b/projects/admin/src/app/service/issue.service.ts
@@ -1,6 +1,6 @@
/*
* RERO ILS UI
- * Copyright (C) 2022-2023 RERO
+ * Copyright (C) 2022-2024 RERO
* Copyright (C) 2022-2023 UCLouvain
*
* This program is free software: you can redistribute it and/or modify
@@ -15,19 +15,15 @@
* 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 { IssueItemStatus } from '@rero/shared';
-import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal';
+import { DialogService, DynamicDialogRef } from 'primeng/dynamicdialog';
import { IssueEmailComponent } from '../components/issues/issue-email/issue-email.component';
@Injectable()
export class IssueService {
- /**
- * Constructor
- * @param _modalService - BsModalService
- */
- constructor(private _modalService: BsModalService) { }
+ private dialogService: DialogService = inject(DialogService);
/**
* Is Allow claim
@@ -44,17 +40,12 @@ export class IssueService {
/**
* Opens a claim dialog
* @param record the item
- * @returns BsModalRef
+ * @return DynamicDialogRef
*/
- openClaimEmailDialog(record: any): BsModalRef {
- const bsModalRef = this._modalService.show(IssueEmailComponent, {
- ignoreBackdropClick: true,
- keyboard: true,
- class: 'modal-xl',
- initialState: { record }
+ openClaimEmailDialog(record: any): DynamicDialogRef {
+ return this.dialogService.open(IssueEmailComponent, {
+ dismissableMask: true,
+ data: { record }
});
- // Event to allow the closing of the dialog
- bsModalRef.content.closeDialog.subscribe((close: boolean) => bsModalRef.hide());
- return bsModalRef;
}
}
diff --git a/projects/admin/src/app/service/items.service.spec.ts b/projects/admin/src/app/service/items.service.spec.ts
index 7302cda2c..45ff59dcf 100644
--- a/projects/admin/src/app/service/items.service.spec.ts
+++ b/projects/admin/src/app/service/items.service.spec.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
@@ -17,25 +17,17 @@
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { TestBed } from '@angular/core/testing';
-import { RouterTestingModule } from '@angular/router/testing';
import { TranslateModule } from '@ngx-translate/core';
-import { BsModalRef, BsModalService, ModalModule } from 'ngx-bootstrap/modal';
-import { ToastrModule } from 'ngx-toastr';
import { ItemsService } from './items.service';
+import { RouterModule } from '@angular/router';
describe('ItemsService', () => {
beforeEach(() => TestBed.configureTestingModule({
imports: [
HttpClientTestingModule,
- ModalModule.forRoot(),
- ToastrModule.forRoot(),
TranslateModule.forRoot({}),
- RouterTestingModule,
+ RouterModule.forRoot([]),
],
- providers: [
- BsModalRef,
- BsModalService
- ]
}));
it('should be created', () => {
diff --git a/projects/admin/src/app/service/loan.service.ts b/projects/admin/src/app/service/loan.service.ts
index bc807aa61..5b48d792a 100644
--- a/projects/admin/src/app/service/loan.service.ts
+++ b/projects/admin/src/app/service/loan.service.ts
@@ -16,8 +16,8 @@
*/
import { HttpClient } from '@angular/common/http';
-import { Injectable } from '@angular/core';
-import { DialogService, RecordService } from '@rero/ng-core';
+import { inject, Injectable } from '@angular/core';
+import { RecordService } from '@rero/ng-core';
import { Record } from '@rero/ng-core/lib/record/record';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
@@ -25,12 +25,19 @@ import { CircPolicy } from '../classes/circ-policy';
import { LoanState } from '../classes/loans';
import { UserService } from '@rero/shared';
import { TranslateService } from '@ngx-translate/core';
+import { Confirmation, ConfirmationService } from 'primeng/api';
@Injectable({
providedIn: 'root'
})
export class LoanService {
+ recordService = inject(RecordService);
+ http = inject(HttpClient);
+ userService = inject(UserService);
+ translateService = inject(TranslateService);
+ confirmationService = inject(ConfirmationService);
+
// SERVICE CONSTANTS ========================================================
/** Statuses of a borrow loan */
static borrowStatuses = [
@@ -44,22 +51,6 @@ export class LoanService {
LoanState.ITEM_IN_TRANSIT_FOR_PICKUP
];
- // CONSTRUCTOR ==============================================================
- /**
- * Constructor
- * @param _recordService - RecordService
- * @param _http - HttpClient
- * @param _userService - UserService
- * @param _translateService - TranslateService
- */
- constructor(
- private _recordService: RecordService,
- private _http: HttpClient,
- private _userService: UserService,
- private _translateService: TranslateService,
- private _dialogService: DialogService
- ) { }
-
// SERVICES FUNCTIONS =======================================================
/**
* Return a borrowed loan records
@@ -105,12 +96,12 @@ export class LoanService {
*/
cancelLoan(itemPid: string, loanPid: string, transactionLibraryPid: string): Observable {
const url = '/api/item/cancel_item_request';
- return this._http.post(url, {
+ return this.http.post(url, {
item_pid: itemPid,
pid: loanPid,
transaction_library_pid: transactionLibraryPid,
// TODO: Fix this with multiple patron
- transaction_user_pid: this._userService.user.patrons[0].pid
+ transaction_user_pid: this.userService.user.patrons[0].pid
}).pipe(
map(data => {
const itemData = data.metadata;
@@ -138,7 +129,7 @@ export class LoanService {
*/
updateLoanPickupLocation(loanPid: string, pickupLocationPid: string): Observable {
const url = '/api/item/update_loan_pickup_location';
- return this._http.post(url, {
+ return this.http.post(url, {
pid: loanPid,
pickup_location_pid: pickupLocationPid
});
@@ -151,25 +142,28 @@ export class LoanService {
*/
getCirculationPolicy(loanPid: string): Observable {
const apiUrl = `/api/loan/${loanPid}/circulation_policy`;
- return this._http.get(apiUrl);
+ return this.http.get(apiUrl);
}
/**
* Cancel request dialog.
- * @returns Observable (true if the user confirms the cancellation)
*/
- cancelRequestDialog(): Observable {
- const config = {
- ignoreBackdropClick: true,
- initialState: {
- title: this._translateService.instant('Cancel request'),
- body: this._translateService.instant('Do you really want to cancel the request?'),
- confirmButton: true,
- cancelTitleButton: this._translateService.instant('No'),
- confirmTitleButton: this._translateService.instant('Yes')
- }
+ cancelRequestDialog(event: Event, accept?: Function, reject?: Function): void {
+ const confirmation: Confirmation = {
+ target: event.target as EventTarget,
+ header: this.translateService.instant('Cancel request'),
+ message: this.translateService.instant('Do you really want to cancel the request?'),
+ acceptLabel: this.translateService.instant('Yes'),
+ rejectLabel: this.translateService.instant('No'),
+ dismissableMask: true,
};
- return this._dialogService.show(config);
+ if (accept) {
+ confirmation.accept = accept;
+ }
+ if (reject) {
+ confirmation.reject = reject;
+ }
+ this.confirmationService.confirm(confirmation);
}
// PRIVATES SERVICE FUNCTIONS ===============================================
@@ -185,6 +179,6 @@ export class LoanService {
const states = statuses.join(' OR state:');
query += ` AND (state:${states})`;
}
- return this._recordService.getRecords('loans', query, 1, 100, [], undefined, undefined, 'created');
+ return this.recordService.getRecords('loans', query, 1, 100, [], undefined, undefined, 'created');
}
}
diff --git a/projects/admin/src/app/service/record.handle-error.service.ts b/projects/admin/src/app/service/record.handle-error.service.ts
index 45fa67d43..950c63363 100644
--- a/projects/admin/src/app/service/record.handle-error.service.ts
+++ b/projects/admin/src/app/service/record.handle-error.service.ts
@@ -15,11 +15,11 @@
* along with this program. If not, see .
*/
import { HttpErrorResponse } from '@angular/common/http';
-import { Injectable } from '@angular/core';
+import { inject, Injectable } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { RecordHandleErrorService as CoreRecordHandleErrorService } from '@rero/ng-core';
import { NgxSpinnerService } from 'ngx-spinner';
-import { ToastrService } from 'ngx-toastr';
+import { MessageService } from 'primeng/api';
import { NEVER, Observable } from 'rxjs';
@Injectable({
@@ -27,15 +27,15 @@ import { NEVER, Observable } from 'rxjs';
})
export class RecordHandleErrorService extends CoreRecordHandleErrorService {
+ private messageService = inject(MessageService);
+
/**
* Constructor
* @param translateService - TranslateService
- * @param toastrService - ToastrService
* @param spinner - NgxSpinnerService
*/
constructor(
protected translateService: TranslateService,
- private toastrService: ToastrService,
private spinner: NgxSpinnerService
) {
super(translateService);
@@ -49,13 +49,14 @@ export class RecordHandleErrorService extends CoreRecordHandleErrorService {
*/
handleError(error: HttpErrorResponse, resourceName?: string): Observable {
if (resourceName.startsWith('import_')) {
- this.toastrService.error(
- this.translateService.instant(
+ this.messageService.add({
+ severity: 'error',
+ summary: this.translateService.instant('Import from the web'),
+ detail: this.translateService.instant(
'Your request to the external server has failed. Try again later ({{ statusCode }}).', {
statusCode: error.status
- }),
- this.translateService.instant('Import from the web')
- );
+ })
+ });
this.spinner.hide();
return NEVER;
} else {
diff --git a/projects/admin/src/app/widgets/custom-shortcut-help/custom-shortcut-help.component.ts b/projects/admin/src/app/widgets/custom-shortcut-help/custom-shortcut-help.component.ts
index a088bdaf5..490df8758 100644
--- a/projects/admin/src/app/widgets/custom-shortcut-help/custom-shortcut-help.component.ts
+++ b/projects/admin/src/app/widgets/custom-shortcut-help/custom-shortcut-help.component.ts
@@ -16,10 +16,10 @@
* along with this program. If not, see .
*/
-import { Component, Input } from '@angular/core';
+import { Component, inject, Input } from '@angular/core';
import { HotkeysService } from '@ngneat/hotkeys';
import { TranslateService } from '@ngx-translate/core';
-import { BsModalRef } from 'ngx-bootstrap/modal';
+import { DynamicDialogRef } from 'primeng/dynamicdialog';
@Component({
selector: 'admin-custom-shortcut-help',
@@ -28,28 +28,18 @@ import { BsModalRef } from 'ngx-bootstrap/modal';
})
export class CustomShortcutHelpComponent {
+ private hotKeysService = inject(HotkeysService);
+ private translateService = inject(TranslateService);
+
+ private ref = inject(DynamicDialogRef);
+
/** the title of the modal window */
@Input() title = this.translateService.instant('Available Shortcuts');
+
/** the list of implemented shortcuts */
hotkeys = this.hotKeysService.getShortcuts();
- /**
- * Constructor
- * @param hotKeysService - HotkeysService
- * @param bsModalRef - BsModalRef
- * @param translateService - TranslateService
- */
- constructor(
- private hotKeysService: HotkeysService,
- protected bsModalRef: BsModalRef,
- private translateService: TranslateService
- ) {}
-
- /**
- * Close the modal
- */
closeModal() {
- this.bsModalRef.hide();
+ this.ref.close();
}
-
}
diff --git a/projects/public-search/src/app/patron-profile/patron-profile-loans/patron-profile-loan/patron-profile-loan.component.ts b/projects/public-search/src/app/patron-profile/patron-profile-loans/patron-profile-loan/patron-profile-loan.component.ts
index deed03880..b2a6b6584 100644
--- a/projects/public-search/src/app/patron-profile/patron-profile-loans/patron-profile-loan/patron-profile-loan.component.ts
+++ b/projects/public-search/src/app/patron-profile/patron-profile-loans/patron-profile-loan/patron-profile-loan.component.ts
@@ -14,12 +14,12 @@
* 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 { LoanOverduePreview } from '@app/admin/classes/loans';
import { TranslateService } from '@ngx-translate/core';
import { IOrganisation } from '@rero/shared';
import moment from 'moment';
-import { ToastrService } from 'ngx-toastr';
+import { MessageService } from 'primeng/api';
import { finalize } from 'rxjs/operators';
import { CanExtend, LoanApiService } from '../../../api/loan-api.service';
import { PatronProfileMenuService } from '../../patron-profile-menu.service';
@@ -32,6 +32,8 @@ import { PatronProfileService } from '../../patron-profile.service';
})
export class PatronProfileLoanComponent implements OnInit {
+ private messageService = inject(MessageService);
+
// COMPONENT ATTRIBUTES =====================================================
/** Loan record */
@Input() record: any;
@@ -74,14 +76,12 @@ export class PatronProfileLoanComponent implements OnInit {
* Constructor
* @param loanApiService - LoanApiService
* @param translateService - TranslateService
- * @param toastService - ToastrService
* @param patronProfileMenuService - PatronProfileMenuService
* @param patronProfileService - PatronProfileService
*/
constructor(
private loanApiService: LoanApiService,
private translateService: TranslateService,
- private toastService: ToastrService,
private patronProfileMenuService: PatronProfileMenuService,
private patronProfileService: PatronProfileService
) {}
@@ -122,15 +122,17 @@ export class PatronProfileLoanComponent implements OnInit {
if ('overdue' in this.record.metadata) {
delete this.record.metadata.overdue;
}
- this.toastService.success(
- this.translateService.instant('The item has been renewed.'),
- this.translateService.instant('Success')
- );
+ this.messageService.add({
+ severity: 'success',
+ summary: this.translateService.instant('Success'),
+ detail: this.translateService.instant('The item has been renewed.')
+ });
} else {
- this.toastService.error(
- this.translateService.instant('Error during the renewal of the item.'),
- this.translateService.instant('Error')
- );
+ this.messageService.add({
+ severity: 'error',
+ summary: this.translateService.instant('Error'),
+ detail: this.translateService.instant('Error during the renewal of the item.')
+ });
}
});
}
diff --git a/projects/public-search/src/app/patron-profile/patron-profile-password/patron-profile-password.component.spec.ts b/projects/public-search/src/app/patron-profile/patron-profile-password/patron-profile-password.component.spec.ts
index 5edfc11fe..b6f63cc7c 100644
--- a/projects/public-search/src/app/patron-profile/patron-profile-password/patron-profile-password.component.spec.ts
+++ b/projects/public-search/src/app/patron-profile/patron-profile-password/patron-profile-password.component.spec.ts
@@ -20,7 +20,6 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { FormlyModule } from '@ngx-formly/core';
import { FormlyPrimeNGModule } from '@ngx-formly/primeng';
import { TranslateModule } from '@ngx-translate/core';
-import { ToastrModule } from 'ngx-toastr';
import { PatronProfilePasswordComponent, fieldPasswordMatchValidator } from './patron-profile-password.component';
@@ -33,7 +32,6 @@ describe('PatronProfilePasswordComponent', () => {
declarations: [ PatronProfilePasswordComponent ],
imports: [
HttpClientTestingModule,
- ToastrModule.forRoot(),
TranslateModule.forRoot(),
FormsModule,
ReactiveFormsModule,
diff --git a/projects/public-search/src/app/patron-profile/patron-profile-password/patron-profile-password.component.ts b/projects/public-search/src/app/patron-profile/patron-profile-password/patron-profile-password.component.ts
index 700c18705..e9c5b59ed 100644
--- a/projects/public-search/src/app/patron-profile/patron-profile-password/patron-profile-password.component.ts
+++ b/projects/public-search/src/app/patron-profile/patron-profile-password/patron-profile-password.component.ts
@@ -15,13 +15,13 @@
* along with this program. If not, see .
*/
import { DOCUMENT } from '@angular/common';
-import { Component, ElementRef, Inject, Input } from '@angular/core';
+import { Component, ElementRef, inject, Inject, Input } from '@angular/core';
import { AbstractControl, UntypedFormControl, UntypedFormGroup } from '@angular/forms';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { FormlyFieldConfig } from '@ngx-formly/core';
import { TranslateService } from '@ngx-translate/core';
import { AppSettingsService } from '@rero/shared';
-import { ToastrService } from 'ngx-toastr';
+import { MessageService } from 'primeng/api';
import { of } from 'rxjs';
import { catchError, debounceTime, map } from 'rxjs/operators';
import { UserApiService } from '../../api/user-api.service';
@@ -47,6 +47,8 @@ export function fieldPasswordMatchValidator(control: AbstractControl) {
})
export class PatronProfilePasswordComponent {
+ private messageService = inject(MessageService);
+
/** Request referer */
@Input() referer: string | null;
@@ -115,14 +117,12 @@ export class PatronProfilePasswordComponent {
/**
* Constructor
*
- * @param toastrService - ToastrService
* @param translateService - TranslateService
* @param userApiService - UserApiService
* @param appSettingsService - AppSettingsService
* @param el - ElementRef
*/
constructor(
- private toastrService: ToastrService,
private translateService: TranslateService,
private userApiService: UserApiService,
private appSettingsService: AppSettingsService,
@@ -134,9 +134,11 @@ export class PatronProfilePasswordComponent {
submit() {
this.form.updateValueAndValidity();
if (this.form.valid === false) {
- this.toastrService.error(
- this.translateService.instant('The form contains errors.')
- );
+ this.messageService.add({
+ severity: 'error',
+ summary: this.translateService.instant('Error'),
+ detail: this.translateService.instant('The form contains errors.')
+ });
return;
}
@@ -150,9 +152,11 @@ export class PatronProfilePasswordComponent {
catchError((err: any) => of({ success: false, message: err.message, error: err.error.errors[0] }))
).subscribe((response: IPasswordResponse) => {
if (!('success' in response)) {
- this.toastrService.success(
- this.translateService.instant(response.message)
- );
+ this.messageService.add({
+ severity: 'success',
+ summary: this.translateService.instant('Success'),
+ detail: this.translateService.instant(response.message)
+ });
// Close password form and show personal data
this._redirect();
} else {
diff --git a/projects/public-search/src/app/patron-profile/patron-profile-personal-editor/patron-profile-personal-editor.component.spec.ts b/projects/public-search/src/app/patron-profile/patron-profile-personal-editor/patron-profile-personal-editor.component.spec.ts
index 085dce933..7751e1e32 100644
--- a/projects/public-search/src/app/patron-profile/patron-profile-personal-editor/patron-profile-personal-editor.component.spec.ts
+++ b/projects/public-search/src/app/patron-profile/patron-profile-personal-editor/patron-profile-personal-editor.component.spec.ts
@@ -21,7 +21,6 @@ import { FormlyModule } from '@ngx-formly/core';
import { FormlyPrimeNGModule } from '@ngx-formly/primeng';
import { TranslateModule } from '@ngx-translate/core';
import { UserService, testUserPatronWithSettings } from '@rero/shared';
-import { ToastrModule } from 'ngx-toastr';
import { PatronProfilePersonalEditorComponent } from './patron-profile-personal-editor.component';
@@ -38,7 +37,6 @@ describe('PatronProfilePersonalEditorComponent', () => {
imports: [
HttpClientTestingModule,
TranslateModule.forRoot(),
- ToastrModule.forRoot(),
FormsModule,
ReactiveFormsModule,
FormlyModule.forRoot(),
diff --git a/projects/public-search/src/app/patron-profile/patron-profile-personal-editor/patron-profile-personal-editor.component.ts b/projects/public-search/src/app/patron-profile/patron-profile-personal-editor/patron-profile-personal-editor.component.ts
index f0a94b1ae..86a8884f7 100644
--- a/projects/public-search/src/app/patron-profile/patron-profile-personal-editor/patron-profile-personal-editor.component.ts
+++ b/projects/public-search/src/app/patron-profile/patron-profile-personal-editor/patron-profile-personal-editor.component.ts
@@ -15,7 +15,7 @@
* along with this program. If not, see .
*/
import { DOCUMENT } from '@angular/common';
-import { Component, Inject, Input, OnDestroy, OnInit } from '@angular/core';
+import { Component, Inject, Input, OnDestroy, OnInit, inject } from '@angular/core';
import { UntypedFormControl, UntypedFormGroup } from '@angular/forms';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { FormlyFieldConfig } from '@ngx-formly/core';
@@ -23,7 +23,7 @@ import { FormlyJsonschema } from '@ngx-formly/core/json-schema';
import { TranslateService } from '@ngx-translate/core';
import { RecordService, processJsonSchema, removeEmptyValues } from '@rero/ng-core';
import { AppSettingsService, UserService } from '@rero/shared';
-import { ToastrService } from 'ngx-toastr';
+import { MessageService } from 'primeng/api';
import { Subscription, forkJoin, of } from 'rxjs';
import { debounceTime, map, tap } from 'rxjs/operators';
@@ -33,6 +33,8 @@ import { debounceTime, map, tap } from 'rxjs/operators';
})
export class PatronProfilePersonalEditorComponent implements OnInit, OnDestroy {
+ private messageService = inject(MessageService);
+
// COMPONENT ATTRIBUTES =====================================================
/** Request referer */
@Input() referer: string | null;
@@ -65,7 +67,6 @@ export class PatronProfilePersonalEditorComponent implements OnInit, OnDestroy {
*
* @param recordService - RecordService
* @param formlyJsonschema - FormlyJsonschema
- * @param toastrService - ToastrService
* @param translateService - TranslateService
* @param appSettingsService - AppSettingsService
* @param userService - UserService
@@ -74,7 +75,6 @@ export class PatronProfilePersonalEditorComponent implements OnInit, OnDestroy {
constructor(
private recordService: RecordService,
private formlyJsonschema: FormlyJsonschema,
- private toastrService: ToastrService,
private translateService: TranslateService,
private appSettingsService: AppSettingsService,
private userService: UserService,
@@ -186,22 +186,28 @@ export class PatronProfilePersonalEditorComponent implements OnInit, OnDestroy {
submit() {
this.form.updateValueAndValidity();
if (this.form.valid === false) {
- this.toastrService.error(
- this.translateService.instant('The form contains errors.')
- );
+ this.messageService.add({
+ severity: 'error',
+ summary: this.translateService.instant('Error'),
+ detail: this.translateService.instant('The form contains errors.')
+ });
return;
}
const data = removeEmptyValues(this.form.value);
// Update user record and reload logged user
this.recordService
.update('users', this.userService.user.id.toString(), data)
- .subscribe(
- () => {
- this.toastrService.success(this.translateService.instant('Your personal data has been updated.'));
+ .subscribe({
+ next: () => {
+ this.messageService.add({
+ severity: 'success',
+ summary: this.translateService.instant('Success'),
+ detail: this.translateService.instant('Your personal data has been updated.')
+ });
this.redirect();
},
- (error) => this.formError = error.title
- );
+ error: (error) => this.formError = error.title
+ });
}
// PRIVATE COMPONENT FUNCTIONS ==============================================
diff --git a/projects/public-search/src/app/patron-profile/patron-profile-requests/patron-profile-request/patron-profile-request.component.spec.ts b/projects/public-search/src/app/patron-profile/patron-profile-requests/patron-profile-request/patron-profile-request.component.spec.ts
index eb735f433..5b4439929 100644
--- a/projects/public-search/src/app/patron-profile/patron-profile-requests/patron-profile-request/patron-profile-request.component.spec.ts
+++ b/projects/public-search/src/app/patron-profile/patron-profile-requests/patron-profile-request/patron-profile-request.component.spec.ts
@@ -20,7 +20,6 @@ import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { TranslateModule } from '@ngx-translate/core';
import { SharedModule, testUserPatronWithSettings, UserApiService, UserService } from '@rero/shared';
import { cloneDeep } from 'lodash-es';
-import { ToastrModule } from 'ngx-toastr';
import { of } from 'rxjs';
import { PatronProfileMenuService } from '../../patron-profile-menu.service';
import { PatronProfileRequestComponent } from './patron-profile-request.component';
@@ -52,7 +51,6 @@ describe('PatronProfileRequestComponent', () => {
imports: [
HttpClientTestingModule,
TranslateModule.forRoot(),
- ToastrModule.forRoot(),
SharedModule
],
providers: [
diff --git a/projects/public-search/src/app/patron-profile/patron-profile-requests/patron-profile-request/patron-profile-request.component.ts b/projects/public-search/src/app/patron-profile/patron-profile-requests/patron-profile-request/patron-profile-request.component.ts
index 46bbad49a..daa0da21a 100644
--- a/projects/public-search/src/app/patron-profile/patron-profile-requests/patron-profile-request/patron-profile-request.component.ts
+++ b/projects/public-search/src/app/patron-profile/patron-profile-requests/patron-profile-request/patron-profile-request.component.ts
@@ -14,12 +14,12 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
-import { Component, Input } from '@angular/core';
+import { Component, inject, Input } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
-import { ToastrService } from 'ngx-toastr';
import { LoanApiService } from '../../../api/loan-api.service';
import { PatronProfileMenuService } from '../../patron-profile-menu.service';
import { PatronProfileService } from '../../patron-profile.service';
+import { MessageService } from 'primeng/api';
@Component({
selector: 'public-search-patron-profile-request',
@@ -28,6 +28,8 @@ import { PatronProfileService } from '../../patron-profile.service';
})
export class PatronProfileRequestComponent {
+ private messageService = inject(MessageService);
+
/** Request record */
@Input() record: any;
@@ -52,14 +54,12 @@ export class PatronProfileRequestComponent {
* Constructor
* @param loanApiService - LoanApiService
* @param translateService - TranslateService
- * @param toastService - ToastrService
* @param patronProfileService - PatronProfileService
* @param patronProfileMenuService - PatronProfileMenuService
*/
constructor(
private loanApiService: LoanApiService,
private translateService: TranslateService,
- private toastService: ToastrService,
private patronProfileService: PatronProfileService,
private patronProfileMenuService: PatronProfileMenuService
) {}
@@ -76,16 +76,18 @@ export class PatronProfileRequestComponent {
if (cancelLoan !== undefined) {
this.patronProfileService.cancelRequest(this.record.metadata.pid);
this.actionDone = true;
- this.toastService.success(
- this.translateService.instant('The request has been cancelled.'),
- this.translateService.instant('Success')
- );
+ this.messageService.add({
+ severity: 'success',
+ summary: this.translateService.instant('Success'),
+ detail: this.translateService.instant('The request has been cancelled.')
+ });
} else {
this.cancelInProgress = false;
- this.toastService.error(
- this.translateService.instant('Error during the cancellation of the request.'),
- this.translateService.instant('Error')
- );
+ this.messageService.add({
+ severity: 'error',
+ summary: this.translateService.instant('Error'),
+ detail: this.translateService.instant('Error during the cancellation of the request.')
+ });
}
});
}
diff --git a/projects/public-search/src/app/scss/styles.scss b/projects/public-search/src/app/scss/styles.scss
index 9f276a5d8..10cc670ac 100644
--- a/projects/public-search/src/app/scss/styles.scss
+++ b/projects/public-search/src/app/scss/styles.scss
@@ -19,7 +19,6 @@
@import 'bootstrap/scss/functions';
@import 'bootstrap/scss/variables';
@import 'bootstrap/scss/mixins';
-@import 'ngx-toastr/toastr-bs4-alert';
// ADJUST BOOTSTRAP / PRIMENG -------------------
.col, .col-1, .col-2, .col-3, .col-4, .col-5, .col-6, .col-7, .col-8, .col-9, .col-10, .col-11, .col-12 {
@@ -37,10 +36,6 @@ label {
align-items: baseline;
}
-.toast-container .ngx-toastr {
- width: 450px !important; // override width for all toastr message
-}
-
.label-title:after {
content: ":"
}
diff --git a/projects/shared/src/lib/component/documents/files/files.component.html b/projects/shared/src/lib/component/documents/files/files.component.html
index d99d75250..4b8af8533 100644
--- a/projects/shared/src/lib/component/documents/files/files.component.html
+++ b/projects/shared/src/lib/component/documents/files/files.component.html
@@ -112,7 +112,7 @@
type="button"
class="close pull-right"
aria-label="Close"
- (click)="previewModalRef.hide()"
+ (click)="previewModalRef.close()"
>
×
diff --git a/projects/shared/src/lib/component/documents/files/files.component.ts b/projects/shared/src/lib/component/documents/files/files.component.ts
index 610063edd..410750181 100644
--- a/projects/shared/src/lib/component/documents/files/files.component.ts
+++ b/projects/shared/src/lib/component/documents/files/files.component.ts
@@ -16,15 +16,15 @@
*/
import { HttpClient } from '@angular/common/http';
-import { Component, Input, OnDestroy, OnInit, TemplateRef, ViewChild, inject } from '@angular/core';
+import { Component, Input, OnDestroy, OnInit, Type, ViewChild, inject } from '@angular/core';
import { DomSanitizer, SafeUrl } from '@angular/platform-browser';
import { TranslateService } from '@ngx-translate/core';
import { ApiService, Record, RecordService } from '@rero/ng-core';
-import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal';
import { PrimeNGConfig } from 'primeng/api';
import { Observable, Subscription, forkJoin, map, of, switchMap, tap } from 'rxjs';
import { BreakpointObserver, BreakpointState, Breakpoints } from '@angular/cdk/layout';
+import { DialogService, DynamicDialogRef } from 'primeng/dynamicdialog';
// file interface
export interface File {
@@ -66,11 +66,10 @@ export class FilesComponent implements OnInit, OnDestroy {
url: SafeUrl;
};
// modal for the invenio previewer
- previewModalRef: BsModalRef;
+ previewModalRef: DynamicDialogRef;
// for modal
- @ViewChild('previewModal')
- previewModalTemplate: TemplateRef;
+ @ViewChild('previewModal') previewModalTemplate: Type;
// -------- Services -------------
// primeng configuration service
@@ -85,15 +84,15 @@ export class FilesComponent implements OnInit, OnDestroy {
private apiService = inject(ApiService);
// url sanitizer service
private sanitizer = inject(DomSanitizer);
- // modal service
- private modalService = inject(BsModalService);
// service to detect responsive breakpoints
private breakpointObserver = inject(BreakpointObserver);
+ // dialog service
+ private dialogService: DialogService = inject(DialogService);
/** all component subscription */
private subscriptions = new Subscription();
- // contructor
+ // constructor
constructor() {
// to avoid primeng error
// TODO: remove this when primeng will be fixed
@@ -247,7 +246,7 @@ export class FilesComponent implements OnInit, OnDestroy {
* @returns the css class of the icon
*/
getIcon(file): string {
- const mimetype = file.mimetype;
+ const { mimetype } = file;
if (mimetype == null) {
return 'fa-file-o';
}
@@ -278,8 +277,8 @@ export class FilesComponent implements OnInit, OnDestroy {
*/
preview(file: File): void {
- this.previewModalRef = this.modalService.show(this.previewModalTemplate, {
- class: 'modal-lg',
+ this.previewModalRef = this.dialogService.open(this.previewModalTemplate, {
+ dismissableMask: true
});
this.previewFile = {
label: file.label,