+
-
-
-
diff --git a/projects/ng-core-tester/src/app/app.component.ts b/projects/ng-core-tester/src/app/app.component.ts
index 35453b7f..057a7d42 100644
--- a/projects/ng-core-tester/src/app/app.component.ts
+++ b/projects/ng-core-tester/src/app/app.component.ts
@@ -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 { Component, OnInit } from '@angular/core';
-import { CoreConfigService, MenuItem, RecordEvent, RecordService, TitleMetaService, TranslateService } from '@rero/ng-core';
-import { BsLocaleService } from 'ngx-bootstrap/datepicker';
-import { ToastrService } from 'ngx-toastr';
-import { AppMenuService } from './service/app-menu.service';
+import { Component, OnInit, inject } from '@angular/core';
+import { CoreConfigService, RecordEvent, RecordService, TitleMetaService, TranslateService } from '@rero/ng-core';
+import { MenuItem, MessageService } from 'primeng/api';
/**
* Main component of the application.
@@ -28,6 +26,14 @@ import { AppMenuService } from './service/app-menu.service';
templateUrl: './app.component.html'
})
export class AppComponent implements OnInit {
+
+ /** Service injection */
+ translateService = inject(TranslateService);
+ configService = inject(CoreConfigService);
+ titleMetaService = inject(TitleMetaService);
+ recordService = inject(RecordService);
+ messageService = inject(MessageService);
+
// Current lang of the application
lang: string = document.documentElement.lang;
@@ -42,28 +48,6 @@ export class AppComponent implements OnInit {
// Application language menu
languageMenu: MenuItem;
-
- /**
- * Constructor.
- * @param _translateService Translate service.
- * @param _configService Configuration service.
- * @param _titleMetaService Meta service.
- * @param _recordService Record service.
- * @param _toastrService Toast service.
- * @param _bsLocaleService Locale service for bootstrap.
- * @param _menuService Interface menu
- */
- constructor(
- private _translateService: TranslateService,
- private _configService: CoreConfigService,
- private _titleMetaService: TitleMetaService,
- private _recordService: RecordService,
- private _toastrService: ToastrService,
- private _bsLocaleService: BsLocaleService,
- private _appMenuService: AppMenuService
- ) {
- }
-
/**
* Component initialization.
*
@@ -73,52 +57,30 @@ export class AppComponent implements OnInit {
*/
ngOnInit() {
this.initializeEvents();
- this._translateService.setLanguage(this.lang);
- this.appMenu = this._appMenuService.generateApplicationMenu();
- this.languageMenu = this._appMenuService.generateLanguageMenu(
- this._configService.languages,
- this.lang
- );
+ this.translateService.setLanguage(this.lang);
// Set default title window when application start
- const prefix = this._configService.prefixWindow;
+ const prefix = this.configService.prefixWindow;
if (prefix) {
- this._titleMetaService.setPrefix(prefix);
+ this.titleMetaService.setPrefix(prefix);
}
- this._titleMetaService.setTitle('Welcome');
- }
-
- /**
- * Event change language
- * @param item - MenuItem
- */
- eventChangeLang(item: MenuItem) {
- this.languageMenu.getChildren().forEach((menu: MenuItem) => {
- if (menu.isActive()) {
- menu.deleteLabelAttribute('class');
- menu.setActive(false);
- }
- });
- item.setLabelAttribute('class', 'font-weight-bold')
- .setActive(true);
- this._translateService.setLanguage(item.getName());
- this._bsLocaleService.use(item.getName());
+ this.titleMetaService.setTitle('Welcome');
}
/**
* Initializes listening of events when a record is changed.
*/
private initializeEvents() {
- this._recordService.onCreate$.subscribe((recordEvent: RecordEvent) => {
- const pid = recordEvent.data.record.pid;
- this._toastrService.info(`Call Record Event on create (Record Pid: ${pid})`);
+ this.recordService.onCreate$.subscribe((recordEvent: RecordEvent) => {
+ const {pid} = recordEvent.data.record;
+ this.messageService.add({ severity: 'info', summary: 'Record', detail: `Call Record Event on create (Record Pid: ${pid})`});
});
- this._recordService.onUpdate$.subscribe((recordEvent: RecordEvent) => {
- const pid = recordEvent.data.record.pid;
- this._toastrService.info(`Call Record Event on update (Record Pid: ${pid})`);
+ this.recordService.onUpdate$.subscribe((recordEvent: RecordEvent) => {
+ const {pid} = recordEvent.data.record;
+ this.messageService.add({ severity: 'info', summary: 'Record', detail: `Call Record Event on update (Record Pid: ${pid})`});
});
- this._recordService.onDelete$.subscribe((recordEvent: RecordEvent) => {
- const pid = recordEvent.data.pid;
- this._toastrService.info(`Call Record Event on delete (Record Pid: ${pid})`);
+ this.recordService.onDelete$.subscribe((recordEvent: RecordEvent) => {
+ const {pid} = recordEvent.data.record;
+ this.messageService.add({ severity: 'info', summary: 'Record', detail: `Call Record Event on delete (Record Pid: ${pid})`});
});
}
}
diff --git a/projects/ng-core-tester/src/app/app.module.ts b/projects/ng-core-tester/src/app/app.module.ts
index 8338201f..0f117d10 100644
--- a/projects/ng-core-tester/src/app/app.module.ts
+++ b/projects/ng-core-tester/src/app/app.module.ts
@@ -20,21 +20,25 @@ import { FormsModule } from '@angular/forms';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { TranslateLoader as BaseTranslateLoader, TranslateModule } from '@ngx-translate/core';
-import { CoreConfigService, RecordModule, RecordService, TranslateLoader } from '@rero/ng-core';
+import { CoreConfigService, RecordModule, RecordService, RemoteAutocompleteService, TranslateLoader } from '@rero/ng-core';
import { defineLocale } from 'ngx-bootstrap/chronos';
import { CollapseModule } from 'ngx-bootstrap/collapse';
-import { BsLocaleService } from 'ngx-bootstrap/datepicker';
import { deLocale, enGbLocale, frLocale, itLocale } from 'ngx-bootstrap/locale';
import { TypeaheadModule } from 'ngx-bootstrap/typeahead';
+import { MenubarModule } from 'primeng/menubar';
import { AppConfigService } from './app-config.service';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
+import { AppDialogComponent } from './home/dialog/app-dialog.component';
import { HomeComponent } from './home/home.component';
+import { ToastComponent } from './home/toast/toast.component';
import { DetailComponent } from './record/document/detail/detail.component';
import { DocumentComponent } from './record/document/document.component';
import { EditorComponent } from './record/editor/editor.component';
-import { SearchBarComponent } from './search-bar/search-bar.component';
import { RecordServiceMock } from './record/editor/record-service-mock';
+import { SearchBarComponent } from './search-bar/search-bar.component';
+import { MenuComponent } from './menu/menu.component';
+import { AppRemoteAutocompleteService } from './service/app-remote-autocomplete.service';
@NgModule({
declarations: [
@@ -43,7 +47,10 @@ import { RecordServiceMock } from './record/editor/record-service-mock';
HomeComponent,
DetailComponent,
SearchBarComponent,
- EditorComponent
+ EditorComponent,
+ ToastComponent,
+ AppDialogComponent,
+ MenuComponent
],
imports: [
BrowserModule,
@@ -60,17 +67,21 @@ import { RecordServiceMock } from './record/editor/record-service-mock';
deps: [CoreConfigService, HttpClient]
}
}),
- RecordModule
+ RecordModule,
+ MenubarModule,
],
providers: [
{
- provide: CoreConfigService,
- useClass: AppConfigService
+ provide: CoreConfigService,
+ useClass: AppConfigService
+ },
+ {
+ provide: RecordService,
+ useClass: RecordServiceMock
},
- BsLocaleService,
{
- provide: RecordService,
- useClass: RecordServiceMock
+ provide: RemoteAutocompleteService,
+ useClass: AppRemoteAutocompleteService
}
],
bootstrap: [AppComponent]
diff --git a/projects/ng-core-tester/src/app/home/dialog/app-dialog.component.html b/projects/ng-core-tester/src/app/home/dialog/app-dialog.component.html
new file mode 100644
index 00000000..a40bb608
--- /dev/null
+++ b/projects/ng-core-tester/src/app/home/dialog/app-dialog.component.html
@@ -0,0 +1,17 @@
+
+
diff --git a/projects/ng-core-tester/src/app/home/dialog/app-dialog.component.ts b/projects/ng-core-tester/src/app/home/dialog/app-dialog.component.ts
new file mode 100644
index 00000000..b0b0cfe6
--- /dev/null
+++ b/projects/ng-core-tester/src/app/home/dialog/app-dialog.component.ts
@@ -0,0 +1,58 @@
+/*
+ * RERO angular core
+ * Copyright (C) 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
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see
.
+ */
+import { Component, inject } from '@angular/core';
+import { TranslateService } from '@ngx-translate/core';
+import { ConfirmationService, MessageService } from 'primeng/api';
+
+@Component({
+ selector: 'app-dialog',
+ templateUrl: './app-dialog.component.html'
+})
+export class AppDialogComponent {
+ translate = inject(TranslateService);
+ confirmationService = inject(ConfirmationService);
+ messageService = inject(MessageService);
+
+ confirm(event: Event): void {
+ this.confirmationService.confirm({
+ target: event.target as EventTarget,
+ acceptLabel: this.translate.instant('Yes'),
+ rejectLabel: this.translate.instant('No'),
+ message: this.translate.instant('Are you sure that you want to proceed?'),
+ header: this.translate.instant('Confirmation'),
+ icon: 'pi pi-exclamation-triangle',
+ acceptIcon:"none",
+ rejectIcon:"none",
+ rejectButtonStyleClass:"p-button-text",
+ accept: () => {
+ this.messageService.add({
+ severity: 'info',
+ summary: this.translate.instant('Confirmed'),
+ detail: this.translate.instant('You have accepted')
+ });
+ },
+ reject: () => {
+ this.messageService.add({
+ severity: 'error',
+ summary: this.translate.instant('Rejected'),
+ detail: this.translate.instant('You have rejected'),
+ life: 3000
+ });
+ }
+ });
+ }
+}
diff --git a/projects/ng-core-tester/src/app/home/home.component.html b/projects/ng-core-tester/src/app/home/home.component.html
index 4c3fb7bb..341d9433 100644
--- a/projects/ng-core-tester/src/app/home/home.component.html
+++ b/projects/ng-core-tester/src/app/home/home.component.html
@@ -1,6 +1,6 @@
-
Search component
-
+
+
+
-
Alert component
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
Dialog component
-
-
-
Search input
-
-
-
API Data
-
{{ apiData | json }}
-
-
Language translation
-
Translate "fr" code in french: {{ testLanguageTranslation }}
-
-
Nl2br pipe
-
+
+
-
Translate Language pipe
-
Translate "fr" code in deutsch: {{ 'fr' | translateLanguage: 'de' }}
-
Translate "zzz" code in italian: {{ 'zzz' | translateLanguage: 'it' }} (code not available)
-
Translate "fr" code in not language loaded: {{ 'fr' | translateLanguage: 'pt' }} (return initial
+
+ Translate "fre" code in german: {{ 'fre' | translateLanguage: 'de' }}
+ Translate "zzz" code in italian: {{ 'zzz' | translateLanguage: 'it' }} (code not available)
+ Translate "fre" code in not language loaded: {{ 'fre' | translateLanguage: 'pt' }} (return initial
value)
+
-
Menu
-
-
-
Spinner
-
+
+
+
-
Markdown pipe
-
-
+
+
+
+
diff --git a/projects/ng-core-tester/src/app/home/home.component.ts b/projects/ng-core-tester/src/app/home/home.component.ts
index 297ea323..3e9b942d 100644
--- a/projects/ng-core-tester/src/app/home/home.component.ts
+++ b/projects/ng-core-tester/src/app/home/home.component.ts
@@ -1,6 +1,6 @@
/*
* RERO angular core
- * 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
@@ -14,23 +14,19 @@
* 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 { ApiService, DialogService, MenuItem, RecordSearchService, TranslateLanguageService } from '@rero/ng-core';
+import { Component, inject, OnInit } from '@angular/core';
+import { RecordSearchService } from '@rero/ng-core';
import { NgxSpinnerService } from 'ngx-spinner';
-import { ToastrService } from 'ngx-toastr';
import { DocumentComponent } from '../record/document/document.component';
-import { MenuService } from '../service/menu.service';
@Component({
selector: 'app-home',
templateUrl: './home.component.html'
})
export class HomeComponent implements OnInit {
- // Object containing API paths.
- apiData: any;
-
- // Contains the full translated language of a language code.
- testLanguageTranslation: string;
+ // Inject
+ private recordSearchService = inject(RecordSearchService);
+ private spinner = inject(NgxSpinnerService);
// Configuration for resources.
recordConfig: Array
= [
@@ -62,150 +58,21 @@ export class HomeComponent implements OnInit {
}
];
- // Menu
- menuApplication: MenuItem;
-
- // Menu click
- menuClick: MenuItem;
-
// Markdown text
markdownText = '*Hello* **world**';
- /**
- * Component initialization
- *
- * - Initializes application menu
- */
- ngOnInit() {
- this.menuApplication = this._menuService.generateApplicationMenu();
- }
-
- /**
- * Menu selected by user
- * @param item - Menu Item
- */
- eventMenuClick(item: MenuItem) {
- this._toastrService.success(`menu ${item.getName()} clicked`);
+ ngOnInit(): void {
+ // Initializes aggregations filters to launch the first search.
+ this.recordSearchService.setAggregationsFilters([]);
}
-
/**
* Show spinner for 5 seconds
*/
showSpinner() {
- this._spinner.show();
+ this.spinner.show();
setTimeout(() => {
- this._spinner.hide();
- }, 5000);
- }
-
- /**
- * Constructor.
- *
- * - Initializes API object paths.
- * - Stores translated language.
- * - Empties aggregations filters.
- *
- * @param _dialogService Dialog service.
- * @param _apiService API service.
- * @param _translateLanguageService Translate language service.
- * @param _toastrService Toastr service.
- * @param _recordSearchService Record search service.
- * @param _spinner Spinner service
- */
- constructor(
- private _dialogService: DialogService,
- private _apiService: ApiService,
- private _translateLanguageService: TranslateLanguageService,
- private _toastrService: ToastrService,
- private _recordSearchService: RecordSearchService,
- private _spinner: NgxSpinnerService,
- private _menuService: MenuService
- ) {
- this.apiData = {
- relative: this._apiService.getEndpointByType('documents'),
- absolute: this._apiService.getEndpointByType('documents', true),
- };
-
- this.testLanguageTranslation = this._translateLanguageService.translate('fr', 'fr');
-
- // Initializes aggregations filters to launch the first search.
- this._recordSearchService.setAggregationsFilters([]);
- }
-
- /**
- * Show a confirmation dialog box.
- */
- showDialog() {
- const config = {
- ignoreBackdropClick: true,
- initialState: {
- title: 'Confirmation',
- body: 'Exit without saving changes?',
- confirmButton: true,
- cancelTitleButton: 'Abort',
- confirmTitleButton: 'Confirm'
- }
- };
-
- this._dialogService.show(config).subscribe((confirm: boolean) => {
- if (confirm) {
- console.log('Confirmed !');
- }
- });
- }
-
- /**
- * Simulates a search by only log infos.
- *
- * @param searchText String to search.
- */
- doSearch(searchText: string) {
- console.log(`You search for: ${searchText}`);
- }
-
- /**
- * Shows an alert message with toastr.
- */
- addAlert() {
- const type = (document.getElementById('alert-type')) as HTMLSelectElement;
- const message = (document.getElementById('alert-message')) as HTMLInputElement;
- switch (type.value) {
- // Checkbox controls
- case 'success':
- this._toastrService.success(message.value);
- break;
- case 'info':
- this._toastrService.info(message.value);
- break;
- case 'warning':
- this._toastrService.warning(message.value);
- break;
- case 'danger':
- this._toastrService.error(message.value);
- break;
- }
- }
-
- /**
- * Show a message when item menu is clicked.
- *
- * @param item Menu item.
- */
- clickLinkItemMenu(item: any) {
- this._toastrService.success(`menu ${item.name} clicked`);
- }
-
- /**
- * Whether a menu item is visible or not.
- *
- * @param itemMenu Menu item.
- * @return True if the menu is visible.
- */
- isItemMenuVisible(itemMenu: any) {
- if (itemMenu.name === 'Hidden') {
- return false;
- }
- return true;
+ this.spinner.hide();
+ }, 3000);
}
}
diff --git a/projects/ng-core-tester/src/app/home/toast/toast.component.html b/projects/ng-core-tester/src/app/home/toast/toast.component.html
new file mode 100644
index 00000000..41196516
--- /dev/null
+++ b/projects/ng-core-tester/src/app/home/toast/toast.component.html
@@ -0,0 +1,32 @@
+
+
diff --git a/projects/ng-core-tester/src/app/home/toast/toast.component.ts b/projects/ng-core-tester/src/app/home/toast/toast.component.ts
new file mode 100644
index 00000000..e18be9c3
--- /dev/null
+++ b/projects/ng-core-tester/src/app/home/toast/toast.component.ts
@@ -0,0 +1,71 @@
+/*
+ * RERO angular core
+ * Copyright (C) 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
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+import { Component, OnInit, inject } from '@angular/core';
+import { TranslateService } from '@ngx-translate/core';
+import { Message, MessageService } from 'primeng/api';
+
+interface IToastType {
+ name: string;
+ code: string;
+}
+
+@Component({
+ selector: 'app-toast',
+ templateUrl: './toast.component.html'
+})
+export class ToastComponent implements OnInit {
+
+ translateService = inject(TranslateService);
+ messageService = inject(MessageService);
+
+ toastTypes: IToastType[];
+
+ toastType: any;
+
+ toastMessage: string;
+
+ ngOnInit(): void {
+ this.toastMessage = this.translateService.instant('This is the message');
+ this.toastTypes = [
+ { name: this.translateService.instant('Success'), code: 'success' },
+ { name: this.translateService.instant('Info'), code: 'info' },
+ { name: this.translateService.instant('Warn'), code: 'warn' },
+ { name: this.translateService.instant('Error'), code: 'error' },
+ ];
+ this.translateService.onLangChange.subscribe(() => {
+ this.toastMessage = this.translateService.instant('This is the message');
+ this.toastTypes.forEach((type: any) => {
+ type.name = this.translateService.instant(type.code);
+ });
+ this.toastType = undefined;
+ });
+ }
+
+ showToast(): void {
+ const message: Message = {
+ severity: 'error',
+ summary: this.translateService.instant('Error'),
+ detail: this.translateService.instant('Please select a type')
+ };
+ if (this.toastType) {
+ message.severity = this.toastType.code;
+ message.summary = this.toastType.name;
+ message.detail = this.toastMessage;
+ }
+ this.messageService.add(message);
+ }
+}
diff --git a/projects/ng-core-tester/src/app/menu/menu.component.html b/projects/ng-core-tester/src/app/menu/menu.component.html
new file mode 100644
index 00000000..a981f82d
--- /dev/null
+++ b/projects/ng-core-tester/src/app/menu/menu.component.html
@@ -0,0 +1,65 @@
+
+
+
+
+
+
+
+
+ @if (item.routerLink && !item.url) {
+
+ }
+ @if (item.url && !item.routerLink) {
+
+ }
+ @if (!item.url && !item.routerLink) {
+
+ }
+
+
+
diff --git a/projects/ng-core-tester/src/app/menu/menu.component.scss b/projects/ng-core-tester/src/app/menu/menu.component.scss
new file mode 100644
index 00000000..af9a8ea5
--- /dev/null
+++ b/projects/ng-core-tester/src/app/menu/menu.component.scss
@@ -0,0 +1,3 @@
+:host ::ng-deep .p-submenu-list {
+ z-index: 1000;
+}
diff --git a/projects/ng-core-tester/src/app/menu/menu.component.ts b/projects/ng-core-tester/src/app/menu/menu.component.ts
new file mode 100644
index 00000000..42fb2b8f
--- /dev/null
+++ b/projects/ng-core-tester/src/app/menu/menu.component.ts
@@ -0,0 +1,191 @@
+/*
+ * RERO angular core
+ * Copyright (C) 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
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+import { Component, OnInit, inject } from '@angular/core';
+import { MenuItem, MessageService } from 'primeng/api';
+import { Router } from '@angular/router';
+import { CoreConfigService } from '@rero/ng-core';
+import { LangChangeEvent, TranslateService } from '@ngx-translate/core';
+
+@Component({
+ selector: 'app-menu',
+ templateUrl: './menu.component.html',
+ styleUrl: './menu.component.scss'
+})
+export class MenuComponent implements OnInit {
+
+ messageService = inject(MessageService);
+ translateService = inject(TranslateService);
+ router = inject(Router);
+ config = inject(CoreConfigService);
+
+ menuItems: MenuItem[];
+
+ ngOnInit(): void {
+ this.menuItems = [
+ {
+ label: this.translateService.instant('home'),
+ untranslatedLabel: 'home',
+ icon: 'pi pi-home',
+ command: () => {
+ this.router.navigate(['/']);
+ this.messageService.add({ severity: 'success', detail: 'Home menu selected', life: 2000 });
+ }
+ },
+ {
+ label: this.translateService.instant('Records'),
+ untranslatedLabel: 'Records',
+ id: 'records',
+ items: [
+ {
+ label: this.translateService.instant('Global records'),
+ untranslatedLabel: 'Global records',
+ icon: 'fa fa-book',
+ routerLink: ['/record', 'search', 'documents']
+ },
+ {
+ label: this.translateService.instant('UNISI records'),
+ untranslatedLabel: 'UNISI records',
+ icon: 'fa fa-book',
+ routerLink: ['/unisi', 'record', 'search', 'documents']
+ },
+ {
+ label: this.translateService.instant('Backend records'),
+ untranslatedLabel: 'Backend records',
+ icon: 'fa fa-book',
+ routerLink: ['/admin', 'record', 'search', 'documents']
+ },
+ {
+ label: this.translateService.instant('Documents'),
+ untranslatedLabel: 'Documents',
+ icon: 'fa fa-book',
+ items: [
+ {
+ label: this.translateService.instant('Document records'),
+ untranslatedLabel: 'Document records',
+ icon: 'fa fa-book',
+ routerLink: ['/records', 'documents']
+ },
+ {
+ label: this.translateService.instant('Document records with query params'),
+ untranslatedLabel: 'Document records with query params',
+ icon: 'fa fa-book',
+ routerLink: ['/records', 'documents'],
+ queryParams: { q: 'anatomic', page: 1, size: 10 }
+ }
+ ]
+ },
+ {
+ label: this.translateService.instant('Organisation'),
+ untranslatedLabel: 'Organisation',
+ icon: 'fa fa-industry',
+ routerLink: ['/records', 'organisations']
+ },
+ {
+ separator: true
+ },
+ {
+ label: this.translateService.instant('Editor'),
+ untranslatedLabel: 'Editor',
+ icon: 'fa fa-pencil-square-o',
+ items: [
+ {
+ label: this.translateService.instant('Long mode'),
+ items: [
+ {
+ label: this.translateService.instant('Add mode'),
+ untranslatedLabel: 'Add mode',
+ icon: 'fa fa-pencil-square-o',
+ routerLink: ['/editor', 'demo']
+ },
+ {
+ label: this.translateService.instant('Edit mode'),
+ untranslatedLabel: 'Edit mode',
+ icon: 'fa fa-pencil-square-o',
+ routerLink: ['/editor', 'demo', '1']
+ }
+ ]
+ },
+ {
+ label: this.translateService.instant('Simple mode'),
+ items: [
+ {
+ label: this.translateService.instant('Add mode'),
+ untranslatedLabel: 'Add mode',
+ icon: 'fa fa-pencil-square-o',
+ routerLink: ['/editor', 'normal']
+ },
+ {
+ label: this.translateService.instant('Edit mode'),
+ untranslatedLabel: 'Edit mode',
+ icon: 'fa fa-pencil-square-o',
+ routerLink: ['/editor', 'normal', '1']
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ },
+ {
+ label: 'Rero website',
+ id: 'rero_website',
+ icon: 'fa fa-external-link',
+ url: 'https://www.rero.ch',
+ target: '_blank'
+ },
+ {
+ label: this.translateService.instant('Language'),
+ untranslatedLabel: 'Language',
+ id: 'language',
+ icon: 'fa fa-language',
+ items: []
+ }
+ ];
+
+ const languageMenu = this.menuItems.find((item: MenuItem) => item.id === 'language');
+ this.config.languages.map((language: string) => {
+ const lang = {
+ label: this.translateService.instant(language),
+ untranslatedLabel: language,
+ id: language,
+ styleClass: undefined,
+ command: () => {
+ this.translateService.use(language);
+ this.messageService.add({ severity: 'info', detail: `Language change to ${language}`, life: 2000 });
+ }
+ }
+ languageMenu.items.push(lang);
+ });
+ this.translateService.onLangChange.subscribe((event: LangChangeEvent) => {
+ this.translateItems(this.menuItems)
+ languageMenu.items.map((item: MenuItem) => {
+ item.styleClass = item.id === event.lang ? 'font-bold': ''
+ });
+ });
+ }
+
+ private translateItems(menuItems: MenuItem[]): void {
+ menuItems.map((item: MenuItem) => {
+ if (item.untranslatedLabel) {
+ item.label = this.translateService.instant(item.untranslatedLabel);
+ }
+ if (item.items) {
+ this.translateItems(item.items);
+ }
+ })
+ }
+}
diff --git a/projects/ng-core-tester/src/app/record/document/detail/detail.component.html b/projects/ng-core-tester/src/app/record/document/detail/detail.component.html
index 5edb41b9..a50841f2 100644
--- a/projects/ng-core-tester/src/app/record/document/detail/detail.component.html
+++ b/projects/ng-core-tester/src/app/record/document/detail/detail.component.html
@@ -15,15 +15,8 @@
along with this program. If not, see .
-->
@if (record) {
- {{ record.metadata.title[0].mainTitle[0].value }}
-
- @for (author of record.metadata.authors; track author) {
- {{ author.name }}
- }
-
- @if (record.metadata.abstracts) {
-
- {{ record.metadata.abstracts[0].value }}
-
- }
+ Record display
+
+ {{ record.metadata | json }}
+
}
diff --git a/projects/ng-core-tester/src/app/record/document/detail/detail.component.ts b/projects/ng-core-tester/src/app/record/document/detail/detail.component.ts
index 5c5d5d79..1182546e 100644
--- a/projects/ng-core-tester/src/app/record/document/detail/detail.component.ts
+++ b/projects/ng-core-tester/src/app/record/document/detail/detail.component.ts
@@ -1,6 +1,6 @@
/*
* RERO angular core
- * 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
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
-import { Component, OnInit } from '@angular/core';
+import { Component, inject, OnInit } from '@angular/core';
import { TitleMetaService } from '@rero/ng-core';
import { DetailRecord } from '@rero/ng-core/lib/record/detail/view/detail-record';
import { Observable } from 'rxjs';
@@ -27,6 +27,9 @@ import { Observable } from 'rxjs';
templateUrl: './detail.component.html'
})
export class DetailComponent implements DetailRecord, OnInit {
+ // Inject
+ private titleMetaService = inject(TitleMetaService);
+
// Observable resolving record data
record$: Observable;
@@ -36,21 +39,8 @@ export class DetailComponent implements DetailRecord, OnInit {
// Record data
record: any;
- /**
- * Constructor
- *
- * @param _titleMetaService Title meta service.
- */
- constructor(private _titleMetaService: TitleMetaService) { }
-
- /**
- * Component initialization.
- *
- * Set meta title.
- * Subscribe to record observable.
- */
ngOnInit(): void {
- this._titleMetaService.setTitle('Detail of ' + this.type);
+ this.titleMetaService.setTitle('Detail of ' + this.type);
this.record$.subscribe((record) => {
this.record = record;
diff --git a/projects/ng-core-tester/src/app/record/document/document.component.html b/projects/ng-core-tester/src/app/record/document/document.component.html
index cabcfab4..76a18203 100644
--- a/projects/ng-core-tester/src/app/record/document/document.component.html
+++ b/projects/ng-core-tester/src/app/record/document/document.component.html
@@ -34,6 +34,6 @@
{{ author.name }}
}
-@if (record.metadata.abstracts) {
+
diff --git a/projects/ng-core-tester/src/app/record/document/document.component.ts b/projects/ng-core-tester/src/app/record/document/document.component.ts
index 06727f1a..f678d97f 100644
--- a/projects/ng-core-tester/src/app/record/document/document.component.ts
+++ b/projects/ng-core-tester/src/app/record/document/document.component.ts
@@ -1,6 +1,6 @@
/*
* RERO angular core
- * 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
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
-import { Component, Input, OnInit } from '@angular/core';
+import { Component, inject, Input, OnInit } from '@angular/core';
import { ResultItem, TitleMetaService } from '@rero/ng-core';
/**
@@ -24,31 +24,19 @@ import { ResultItem, TitleMetaService } from '@rero/ng-core';
templateUrl: './document.component.html'
})
export class DocumentComponent implements OnInit, ResultItem {
+ // Inject
+ private titleMetaService = inject(TitleMetaService);
+
// Record data.
- @Input()
- record: any;
+ @Input() record: any;
// Type of resource.
- @Input()
- type: string;
+ @Input() type: string;
// Object containing link to detail.
- @Input()
- detailUrl: { link: string, external: boolean };
-
- /**
- * Constructor
- *
- * @param _titleMetaService TitleMetaService
- */
- constructor(private _titleMetaService: TitleMetaService) { }
+ @Input() detailUrl: { link: string, external: boolean };
- /**
- * Component initialization.
- *
- * Set meta title.
- */
ngOnInit() {
- this._titleMetaService.setTitle(this.type);
+ this.titleMetaService.setTitle(this.type);
}
}
diff --git a/projects/ng-core-tester/src/app/record/editor/editor.component.html b/projects/ng-core-tester/src/app/record/editor/editor.component.html
index e3c32882..848f1e71 100644
--- a/projects/ng-core-tester/src/app/record/editor/editor.component.html
+++ b/projects/ng-core-tester/src/app/record/editor/editor.component.html
@@ -15,12 +15,12 @@
along with this program. If not, see .
-->
-
-
+
+
+
+
+
-
diff --git a/projects/ng-core-tester/src/app/record/editor/editor.component.spec.ts b/projects/ng-core-tester/src/app/record/editor/editor.component.spec.ts
index bb47ebec..3aabbc5e 100644
--- a/projects/ng-core-tester/src/app/record/editor/editor.component.spec.ts
+++ b/projects/ng-core-tester/src/app/record/editor/editor.component.spec.ts
@@ -18,10 +18,9 @@
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
-import { RouterTestingModule } from '@angular/router/testing';
+import { RouterModule } from '@angular/router';
import { TranslateModule } from '@ngx-translate/core';
import { RecordModule } from '@rero/ng-core';
-
import { EditorComponent } from './editor.component';
describe('EditorComponent', () => {
@@ -34,7 +33,7 @@ describe('EditorComponent', () => {
RecordModule,
HttpClientTestingModule,
TranslateModule.forRoot(),
- RouterTestingModule,
+ RouterModule.forRoot([]),
BrowserAnimationsModule
],
declarations: [ EditorComponent ]
diff --git a/projects/ng-core-tester/src/app/record/editor/editor.component.ts b/projects/ng-core-tester/src/app/record/editor/editor.component.ts
index 119361b9..bbee7fdf 100644
--- a/projects/ng-core-tester/src/app/record/editor/editor.component.ts
+++ b/projects/ng-core-tester/src/app/record/editor/editor.component.ts
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see
.
*/
-import { AfterContentChecked, Component, OnChanges, OnInit, SimpleChanges } from '@angular/core';
+import { AfterContentChecked, Component, inject, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
@Component({
@@ -22,6 +22,8 @@ import { ActivatedRoute } from '@angular/router';
templateUrl: './editor.component.html'
})
export class EditorComponent implements OnInit, AfterContentChecked {
+ // Inject
+ private route = inject(ActivatedRoute);
/* form initial values */
model = {};
@@ -32,12 +34,6 @@ export class EditorComponent implements OnInit, AfterContentChecked {
/** Edit or New mode */
mode: 'Edit' | 'New' = 'New';
- /**
- * Constructor
- * @param route - ActivatedRoute
- */
- constructor(private route: ActivatedRoute) {}
-
/** OnInit hook */
ngOnInit(): void {
this.mode = 'pid' in this.route.snapshot.params ? 'Edit' : 'New';
diff --git a/projects/ng-core-tester/src/app/record/editor/record-service-mock.ts b/projects/ng-core-tester/src/app/record/editor/record-service-mock.ts
index 8a8f6f44..3e6d62a1 100644
--- a/projects/ng-core-tester/src/app/record/editor/record-service-mock.ts
+++ b/projects/ng-core-tester/src/app/record/editor/record-service-mock.ts
@@ -18,13 +18,19 @@ import { Error, RecordService } from "@rero/ng-core";
import { Observable, of } from "rxjs";
import data from './recordData.json';
import JSONSchema from './schema.json';
+import SimpleJSONSchema from './simple-schema.json';
+import simpleData from './simple-record-data.json';
+import { Injectable } from "@angular/core";
+@Injectable({
+ providedIn: 'root'
+})
export class RecordServiceMock extends RecordService {
getSchemaForm(recordType: string): Observable
{
- return of({ schema: JSONSchema });
+ return of({ schema: recordType === 'demo' ? JSONSchema : SimpleJSONSchema });
}
getRecord(type: string, pid: string, resolve = 0, headers: any = {}): Observable {
- return of(data);
+ return of(type === 'demo' ? data : simpleData);
}
}
diff --git a/projects/ng-core-tester/src/app/record/editor/recordData.json b/projects/ng-core-tester/src/app/record/editor/recordData.json
index 27a673e0..0165fbba 100644
--- a/projects/ng-core-tester/src/app/record/editor/recordData.json
+++ b/projects/ng-core-tester/src/app/record/editor/recordData.json
@@ -16,6 +16,7 @@
"hidden_with_default": "Default hidden",
"readonly_changeable": "Value 1",
"hide_with_required_expression_control": "Optional",
+ "treeSelect": "node5",
"selectMultiple": ["value2", "value3"],
"markdown": "Hello **world**.\nGreat day.",
"array_with_multicheckbox": ["checkbox1", "checkbox2"],
@@ -26,7 +27,9 @@
"type": "staff_note",
"content": "test"
}
- ]
+ ],
+ "date_only": "2024-08-06",
+ "date_range": ["2024-08-06", "2024-08-20"]
},
"updated": "2024-03-06T07:47:33.944197+00:00"
}
diff --git a/projects/ng-core-tester/src/app/record/editor/schema.json b/projects/ng-core-tester/src/app/record/editor/schema.json
index 51885b01..a48c3357 100644
--- a/projects/ng-core-tester/src/app/record/editor/schema.json
+++ b/projects/ng-core-tester/src/app/record/editor/schema.json
@@ -29,7 +29,7 @@
"hide_with_required_expression",
"hidden_sub_property_hide_expr",
"array_of_objects_with_sub_objects",
- "select",
+ "treeSelect",
"selectGroup",
"selectMultiple",
"selectMultipleWithLabelTranslation",
@@ -38,10 +38,11 @@
"email",
"date_time",
"date_only",
+ "date_range",
"password",
"array_with_multicheckbox",
- "remoteTypeaheadWithoutFilters",
- "remoteTypeaheadWithFilters",
+ "remoteAutoCompleteWithFilters",
+ "remoteAutocompleteWithoutFilters",
"input_with_default_value",
"name_with_definition",
"field_expressions",
@@ -76,7 +77,6 @@
"default": "staff_note",
"widget": {
"formlyConfig": {
- "type": "selectWithSort",
"props": {
"options": [
{
@@ -702,14 +702,7 @@
"enum": [
"optional",
"required"
- ],
- "widget": {
- "formlyConfig": {
- "props": {
- "cssClass": "w-md-25"
- }
- }
- }
+ ]
},
"hide_with_required_expression": {
"title": "Hidden Property with required expression.",
@@ -804,7 +797,7 @@
]
}
},
- "select": {
+ "treeSelect": {
"title": "Select with option tree",
"type": "string",
"enum": [
@@ -814,50 +807,48 @@
],
"widget": {
"formlyConfig": {
+ "type": "tree-select",
"props": {
"options": [
{
- "label": "3 Value",
- "value": "value3"
+ "label": "Node 1",
+ "data": "node1"
},
{
- "label": "Group",
+ "label": "Node 2",
+ "selectable": false,
"children": [
{
- "label": "2 Value",
- "value": "value2"
+ "label": "Node 3",
+ "data": "node3"
},
{
- "label": "1 Value",
- "value": "value1",
+ "label": "Node 4",
+ "selectable": false,
"children": [
{
- "label": "3 Value",
- "value": "value3",
- "preferred": true
+ "label": "Node 5",
+ "data": "node5"
},
{
- "label": "2 Value",
- "value": "value2",
- "disabled": true
+ "label": "Node 6",
+ "data": "node6"
}
]
}
]
},
{
- "label": "2 Value",
- "value": "value2",
- "preferred": true
+ "label": "Node 7",
+ "data": "node7"
}
- ],
- "minItemsToDisplaySearch": 3
+ ]
}
}
}
},
"selectGroup": {
- "title": "Select group (compatibility)",
+ "title": "Select with group",
"type": "string",
"enum": [
"value1",
@@ -867,20 +858,29 @@
"widget": {
"formlyConfig": {
"props": {
+ "group": true,
"options": [
{
- "label": "3 Value",
- "value": "value3",
- "group": "test"
- },
- {
- "label": "1 Value",
- "value": "value1"
+ "label": "Default",
+ "items": [
+ {
+ "label": "Value 1",
+ "value": "value1"
+ }
+ ]
},
{
- "label": "2 Value",
- "value": "value2",
- "group": "test"
+ "label": "Test",
+ "items": [
+ {
+ "label": "Value 3",
+ "value": "value3"
+ },
+ {
+ "label": "Value 2",
+ "value": "value2"
+ }
+ ]
}
]
}
@@ -888,7 +888,7 @@
}
},
"selectMultiple": {
- "title": "Multiple select",
+ "title": "Select Multiple",
"type": "array",
"minItems": 1,
"uniqueItems": true,
@@ -906,6 +906,7 @@
},
"widget": {
"formlyConfig": {
+ "type": "multi-select",
"props": {
"options": [
{
@@ -941,6 +942,7 @@
},
"widget": {
"formlyConfig": {
+ "type": "multi-select",
"props": {
"options": [
{
@@ -971,7 +973,10 @@
"default": "Hello **world**",
"widget": {
"formlyConfig": {
- "type": "markdown"
+ "type": "markdown",
+ "props": {
+ "minHeight": "300px"
+ }
}
}
},
@@ -1032,14 +1037,32 @@
"pattern": "^[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$",
"widget": {
"formlyConfig": {
- "type": "datepicker",
+ "type": "datePicker",
"props": {
"placement": "top",
"validation": {
"messages": {
"patternMessage": "Should be in the following format: 2022-12-31 (YYYY-MM-DD)."
}
- }
+ },
+ "disabledDates": [
+ "2024-08-10",
+ "2024-08-12"
+ ]
+ }
+ }
+ }
+ },
+ "date_range": {
+ "title": "Date picker range",
+ "type": "string",
+ "widget": {
+ "formlyConfig": {
+ "type": "datePicker",
+ "props": {
+ "selectionMode": "range",
+ "numberOfMonths": 2,
+ "showButtonBar": true
}
}
}
@@ -1062,8 +1085,8 @@
"type": "multicheckbox",
"minItems": 1,
"default": [
- "checkbox1",
- "checkbox2"
+ "checkbox2",
+ "checkbox3"
],
"items": {
"type": "string",
@@ -1076,8 +1099,9 @@
},
"widget": {
"formlyConfig": {
+ "type": "multi-checkbox",
"props": {
- "type": "array",
+ "style": "inline",
"options": [
{
"label": "Checkbox 1",
@@ -1101,46 +1125,53 @@
}
}
},
- "remoteTypeaheadWithFilters": {
- "title": "Remote typeahead with filters",
+ "remoteAutoCompleteWithFilters": {
+ "title": "Remote Autocomplete with filters",
"type": "string",
"widget": {
"formlyConfig": {
- "type": "remoteTypeahead",
+ "type": "remoteAutoComplete",
"props": {
- "remoteTypeahead": {
- "enableGroupField": true,
- "filters": {
- "default": "value2",
- "options": [
- {
- "label": "Value 1",
- "value": "value1"
- },
- {
- "label": "Value 2",
- "value": "value2"
- },
- {
- "label": "Value 3",
- "value": "value3"
- }
- ]
- }
+ "group": true,
+ "scrollHeight": "300px",
+ "queryOptions": {
+ "type": "documents",
+ "maxOfResult": 10
+ },
+ "filters": {
+ "selected": "value2",
+ "options": [
+ {
+ "label": "Value 1",
+ "value": "value1"
+ },
+ {
+ "label": "Value 2",
+ "value": "value2"
+ },
+ {
+ "label": "Value 3",
+ "value": "value3"
+ }
+ ]
}
}
}
}
},
- "remoteTypeaheadWithoutFilters": {
+
+ "remoteAutocompleteWithoutFilters": {
"title": "Remote typeahead without filters",
"type": "string",
"widget": {
"formlyConfig": {
- "type": "remoteTypeahead",
+ "type": "remoteAutoComplete",
"props": {
- "remoteTypeahead": {
- "enableGroupField": true
+ "group": true,
+ "scrollHeight": "300px",
+ "queryOptions": {
+ "type": "documents",
+ "maxOfResult": 10
}
}
}
diff --git a/projects/ng-core-tester/src/app/record/editor/simple-record-data.json b/projects/ng-core-tester/src/app/record/editor/simple-record-data.json
new file mode 100644
index 00000000..85d2a274
--- /dev/null
+++ b/projects/ng-core-tester/src/app/record/editor/simple-record-data.json
@@ -0,0 +1,13 @@
+{
+ "created": "2024-03-06T07:47:33.944191+00:00",
+ "id": "1",
+ "links": {
+ "self": "https://ilsdev.test.rero.ch/api/demo/1"
+ },
+ "metadata": {
+ "$schema": "https://bib.rero.ch/schemas/demo/demo.json",
+ "pid": "normal",
+ "required": "value required",
+ "textarea": "Le Lorem Ipsum est simplement du faux texte employé dans la composition et la mise en page avant impression. Le Lorem Ipsum est le faux texte standard de l'imprimerie depuis les années 1500, quand un imprimeur anonyme assembla ensemble des morceaux de texte pour réaliser un livre spécimen de polices de texte. Il n'a pas fait que survivre cinq siècles, mais s'est aussi adapté à la bureautique informatique, sans que son contenu n'en soit modifié. Il a été popularisé dans les années 1960 grâce à la vente de feuilles Letraset contenant des passages du Lorem Ipsum, et, plus récemment, par son inclusion dans des applications de mise en page de texte, comme Aldus PageMaker."
+ }
+}
diff --git a/projects/ng-core-tester/src/app/record/editor/simple-schema.json b/projects/ng-core-tester/src/app/record/editor/simple-schema.json
new file mode 100644
index 00000000..ced22e33
--- /dev/null
+++ b/projects/ng-core-tester/src/app/record/editor/simple-schema.json
@@ -0,0 +1,77 @@
+{
+ "schema": "http://json-schema.org/draft-07/schema#",
+ "type": "object",
+ "title": "Test editor",
+ "additionalProperties": false,
+ "required": [
+ "required"
+ ],
+ "propertiesOrder": [
+ "optional",
+ "required",
+ "essential",
+ "textarea"
+ ],
+ "properties": {
+ "$schema": {
+ "title": "Schema",
+ "type": "string",
+ "minLength": 9,
+ "default": "https://bib.rero.ch/schemas/demo/demo.json"
+ },
+ "pid": {
+ "title": "Demo ID",
+ "type": "string",
+ "minLength": 1
+ },
+ "optional": {
+ "title": "Optional",
+ "type": "string",
+ "minLength": 3
+ },
+ "required": {
+ "title": "Required",
+ "type": "string",
+ "minLength": 3,
+ "widget": {
+ "formlyConfig": {
+ "props": {
+ "doNotSubmitOnEnter": true
+ }
+ }
+ }
+ },
+ "essential": {
+ "title": "Essential",
+ "type": "string",
+ "minLength": 3,
+ "widget": {
+ "formlyConfig": {
+ "props": {
+ "hide": true,
+ "navigation": {
+ "essential": true
+ }
+ }
+ }
+ }
+ },
+ "textarea": {
+ "title": "Textarea",
+ "type": "string",
+ "widget": {
+ "formlyConfig": {
+ "type": "textarea",
+ "props": {
+ "placeholder": "Type your text here",
+ "displayChars": true,
+ "displayWords": true,
+ "limitChars": 200,
+ "limitWords": 10,
+ "rows": 5
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/projects/ng-core-tester/src/app/routes/documents-route.ts b/projects/ng-core-tester/src/app/routes/documents-route.ts
index 8d4b61a6..5b353c7d 100644
--- a/projects/ng-core-tester/src/app/routes/documents-route.ts
+++ b/projects/ng-core-tester/src/app/routes/documents-route.ts
@@ -31,6 +31,7 @@ import { DocumentComponent } from '../record/document/document.component';
* Routes for document resources
*/
export class DocumentsRoute implements RouteInterface {
+
// Route name
readonly name = 'documents';
@@ -127,12 +128,12 @@ export class DocumentsRoute implements RouteInterface {
message: ''
});
},
- deleteMessage: (pid: string): Observable => {
+ deleteMessage: (): string[] => {
// If you want to translate the strings, you have to do it here
- return of([
+ return [
this.translateService.instant('Document: Do you really want to delete this record?'),
this.translateService.instant('Attached items will also be deleted.')
- ]);
+ ];
}
}
]
diff --git a/projects/ng-core-tester/src/app/routes/route.service.ts b/projects/ng-core-tester/src/app/routes/route.service.ts
index 9604ea96..455b8963 100644
--- a/projects/ng-core-tester/src/app/routes/route.service.ts
+++ b/projects/ng-core-tester/src/app/routes/route.service.ts
@@ -1,6 +1,6 @@
/*
* RERO angular core
- * 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
@@ -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 { Router } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
import { RouteCollectionService } from '@rero/ng-core';
@@ -27,27 +27,17 @@ import { DocumentsRoute } from './documents-route';
providedIn: 'root'
})
export class RouteService {
- /**
- * Constructor.
- *
- * @param _routeCollectionService RouteCollectionService.
- * @param _router Router.
- */
- constructor(
- private _routeCollectionService: RouteCollectionService,
- private _router: Router,
- private _translateService: TranslateService
- ) { }
+ // Inject
+ private routeCollectionService = inject(RouteCollectionService);
+ private router = inject(Router);
+ private translateService = inject(TranslateService);
- /**
- * Initialize routes.
- */
initializeRoutes() {
- this._routeCollectionService
- .addRoute(new DocumentsRoute(this._translateService));
+ this.routeCollectionService
+ .addRoute(new DocumentsRoute(this.translateService));
- this._routeCollectionService.getRoutes().map((route: any) => {
- this._router.config.push(route);
+ this.routeCollectionService.getRoutes().map((route: any) => {
+ this.router.config.push(route);
});
}
}
diff --git a/projects/ng-core-tester/src/app/search-bar/search-bar.component.html b/projects/ng-core-tester/src/app/search-bar/search-bar.component.html
index 39d57b10..58b471e4 100644
--- a/projects/ng-core-tester/src/app/search-bar/search-bar.component.html
+++ b/projects/ng-core-tester/src/app/search-bar/search-bar.component.html
@@ -1,6 +1,6 @@
-
-
+
diff --git a/projects/ng-core-tester/src/app/search-bar/search-bar.component.spec.ts b/projects/ng-core-tester/src/app/search-bar/search-bar.component.spec.ts
deleted file mode 100644
index 25e0940d..00000000
--- a/projects/ng-core-tester/src/app/search-bar/search-bar.component.spec.ts
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * RERO angular core
- * Copyright (C) 2020 RERO
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, version 3 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-import { HttpClientModule } from '@angular/common/http';
-import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
-import { FormsModule, ReactiveFormsModule } from '@angular/forms';
-import { RouterTestingModule } from '@angular/router/testing';
-import { TranslateModule } from '@ngx-translate/core';
-import { AutocompleteComponent, CoreModule } from '@rero/ng-core';
-import { TypeaheadModule } from 'ngx-bootstrap/typeahead';
-import { SearchBarComponent } from './search-bar.component';
-
-describe('SearchBarComponent', () => {
- let component: SearchBarComponent;
- let fixture: ComponentFixture;
-
- beforeEach(waitForAsync(() => {
- TestBed.configureTestingModule({
- declarations: [ SearchBarComponent, AutocompleteComponent ],
- imports: [
- RouterTestingModule,
- HttpClientModule,
- FormsModule,
- ReactiveFormsModule,
- TranslateModule.forRoot(),
- TypeaheadModule.forRoot(),
- CoreModule
- ]
- })
- .compileComponents();
- }));
-
- beforeEach(() => {
- fixture = TestBed.createComponent(SearchBarComponent);
- component = fixture.componentInstance;
- fixture.detectChanges();
- });
-
- it('should create', () => {
- expect(component).toBeTruthy();
- });
-});
diff --git a/projects/ng-core-tester/src/app/search-bar/search-bar.component.ts b/projects/ng-core-tester/src/app/search-bar/search-bar.component.ts
index eedee563..d3d8fc6f 100644
--- a/projects/ng-core-tester/src/app/search-bar/search-bar.component.ts
+++ b/projects/ng-core-tester/src/app/search-bar/search-bar.component.ts
@@ -1,6 +1,6 @@
/*
* RERO angular core
- * 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
@@ -14,8 +14,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, input, OnInit } from '@angular/core';
+import { Router } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
+import { IAutoComplete, IRecordType, Record } from '@rero/ng-core';
+import { MessageService } from 'primeng/api';
/**
* Component showing the search bar for searching records.
@@ -25,120 +28,96 @@ import { TranslateService } from '@ngx-translate/core';
templateUrl: './search-bar.component.html'
})
export class SearchBarComponent implements OnInit {
- // Code of the organisation.
- @Input() viewcode: string;
+ // Inject
+ private translateService = inject(TranslateService);
+ private messageService = inject(MessageService);
+ private router = inject(Router);
- // Size.
- @Input() size: string = undefined;
-
- // Suggestions max length.
- @Input() maxLengthSuggestion = 100;
+ viewcode = input();
// List of resource type
- recordTypes = [];
-
- /**
- * Returns person name for given metadata.
- *
- * @param metadata Metadata.
- * @return Person name.
- */
- static getPersonName(metadata: string) {
- for (const source of ['rero', 'bnf', 'gnd']) {
- if (metadata[source] && metadata[source].preferred_name_for_person) {
- return metadata[source].preferred_name_for_person;
- }
- }
- }
+ recordTypes: IRecordType[] = [];
- /**
- * Constructor.
- *
- * @param _translateService Translate service.
- */
- constructor(private _translateService: TranslateService) { }
+ value: string = undefined;
- /**
- * Component initialization.
- *
- * Initializes record types.
- */
ngOnInit() {
- this.recordTypes = [{
- type: 'documents',
- field: 'title',
- getSuggestions: (query: string, persons: any) => this.getDocumentsSuggestions(query, persons),
- preFilters: this.viewcode ? { view: this.viewcode } : {}
- }, {
- type: 'organisations',
- field: 'name',
- getSuggestions: (query: string, persons: any) => this.getOrganisationsSuggestions(query, persons),
- component: this,
- preFilters: this.viewcode ? { view: this.viewcode } : {}
- }];
+ this.recordTypes = [
+ {
+ index: 'documents',
+ field: 'title',
+ groupLabel: this.translateService.instant('Documents'),
+ processSuggestions: (data: any, query: string) => this.processDocuments(data, query),
+ preFilters: this.viewcode() ? { view: this.viewcode() } : {}
+ },
+ {
+ index: 'organisations',
+ field: 'name',
+ groupLabel: this.translateService.instant('Organisations'),
+ processSuggestions: (data: any) => this.processOrganisations(data),
+ preFilters: this.viewcode() ? { view: this.viewcode() } : {}
+ }
+ ];
}
- /**
- * Link to record search.
- *
- * @return Link to record search.
- */
- get action(): string {
- return `/records/documents`;
+ onSelect(event: IAutoComplete) {
+ const label = event.originalLabel ? event.originalLabel : event.label;
+ const doc = new DOMParser().parseFromString(label, 'text/html');
+ this.value = doc.body.textContent || '';
+ switch(event.index) {
+ case 'documents':
+ this.messageService.add({
+ severity: 'success',
+ summary: 'DOCUMENTS',
+ detail: 'navigate to document: ' + event.value
+ });
+ this.router.navigate(['/record', 'search', 'documents', 'detail', event.value]);
+ break;
+ case 'organisations':
+ this.messageService.add({
+ severity: 'success',
+ summary: 'ORGANISATIONS',
+ detail: 'navigate to organisation: ' + event.value
+ });
+ break;
+ }
}
- /**
- * Return a list of suggestions for organisations.
- *
- * @param query String query.
- * @param organisations List of organisations.
- * @return List of suggestions.
- */
- getOrganisationsSuggestions(query: string, organisations: any): Array {
- const values = [];
- organisations.hits.hits.map((hit: any) => {
- let text = hit.metadata.name;
- text = text.replace(new RegExp(query, 'gi'), `${query}`);
+ private processDocuments(data: Record, query: string): any {
+ const values: IAutoComplete[] = [];
+ data.hits.hits.map((hit: any) => {
+ const title = hit.metadata.title[0].mainTitle[0].value.replace(/[:\-\[\]()/"]/g, ' ').replace(/\s\s+/g, ' ');
values.push({
- text,
- query: '',
- index: 'organisations',
- category: this._translateService.instant('direct links'),
- href: `/records/organisations/detail/${hit.id}`,
- iconCssClass: 'fa fa-bank'
+ iconClass: 'fa fa-book',
+ index: 'documents',
+ label: this.processLabel(title, query, 80),
+ value: hit.metadata.pid,
+ originalLabel: title,
});
});
+
return values;
}
- /**
- * Return a list of suggestions for documents.
- *
- * @param query String query.
- * @param documents List of documents.
- * @return List of suggestions.
- */
- getDocumentsSuggestions(query: string, documents: any): Array {
- const values = [];
- documents.hits.hits.map((hit: any) => {
- let text = hit.metadata.title;
- let truncate = false;
- if (text.length > this.maxLengthSuggestion) {
- truncate = true;
- text = hit.metadata.title.substr(0, this.maxLengthSuggestion);
- }
- text = text.replace(new RegExp(query, 'gi'), `${query}`);
- if (truncate) {
- text += ' ...';
- }
+ private processOrganisations(data: Record): any {
+ const values: IAutoComplete[] = [];
+ data.hits.hits.map((hit: any) => {
values.push({
- text,
- query: hit.metadata.title.replace(/[:\-\[\]()/"]/g, ' ').replace(/\s\s+/g, ' '),
- index: 'documents',
- category: this._translateService.instant('documents')
- // href: `/${this.viewcode}/documents/${hit.id}`
+ iconClass: 'fa fa-industry',
+ id: hit.metadata.pid,
+ index: 'organisations',
+ label: hit.metadata.name,
+ value: hit.metadata.pid,
});
});
+
return values;
}
+
+ private processLabel(label: string, query: string, truncateSize?: number): string {
+ if (truncateSize && label.length > truncateSize) {
+ label = label.substring(0, truncateSize) + '…';
+ }
+
+ return label.replace(new RegExp(query, 'gi'), `${query}`);
+ }
}
diff --git a/projects/ng-core-tester/src/app/service/app-menu.service.spec.ts b/projects/ng-core-tester/src/app/service/app-menu.service.spec.ts
deleted file mode 100644
index ff5441ee..00000000
--- a/projects/ng-core-tester/src/app/service/app-menu.service.spec.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * RERO angular core
- * Copyright (C) 2020 RERO
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, version 3 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-/* tslint:disable:no-unused-variable */
-
-import { inject, TestBed } from '@angular/core/testing';
-import { TranslateModule } from '@ngx-translate/core';
-import { AppMenuService } from './app-menu.service';
-
-describe('Service: AppMenu', () => {
- beforeEach(() => {
- TestBed.configureTestingModule({
- providers: [AppMenuService],
- imports: [TranslateModule.forRoot()]
- });
- });
-
- it('should ...', inject([AppMenuService], (service: AppMenuService) => {
- expect(service).toBeTruthy();
- }));
-});
diff --git a/projects/ng-core-tester/src/app/service/app-menu.service.ts b/projects/ng-core-tester/src/app/service/app-menu.service.ts
deleted file mode 100644
index 461ec437..00000000
--- a/projects/ng-core-tester/src/app/service/app-menu.service.ts
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * RERO angular core
- * Copyright (C) 2020 RERO
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, version 3 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-import { Injectable } from '@angular/core';
-import { TranslateService } from '@ngx-translate/core';
-import { MenuFactory, MenuItem } from '@rero/ng-core';
-
-@Injectable({
- providedIn: 'root'
-})
-export class AppMenuService {
-
- /** Menu Factory */
- private _factory: MenuFactory;
-
- /**
- * Constructor
- * @param _translate - TranslateService
- */
- constructor(private _translate: TranslateService) {
- this._factory = new MenuFactory();
- }
-
- /**
- * Application Menu
- * @return MenuItem
- */
- generateApplicationMenu() {
- const menu = this._factory.createItem('Application');
-
- /* Home */
- menu
- .addChild('Home')
- .setAttribute('id', 'home')
- .setExtra('iconClass', 'fa fa-home')
- .setRouterLink(['/']);
-
- const records = menu.addChild('Records');
- this._recordsMenu(records);
-
- return menu;
- }
-
- /**
- * Menu Languages
- * @return MenuItem
- */
- generateLanguageMenu(languages: string[], currentLanguage: string) {
- const languagesMenu = this._factory.createItem('Language');
- languages.forEach(lang => {
- const languageMenu = languagesMenu
- .addChild(this._translate.instant(lang));
- if (lang === currentLanguage) {
- languageMenu
- .setLabelAttribute('class', 'font-weight-bold')
- .setActive(true);
- }
- });
-
- return languagesMenu;
- }
-
- /**
- * Sub Menu Records
- * @param menu - MenuItem
- */
- private _recordsMenu(menu: MenuItem) {
- menu.addChild('Global records')
- .setAttribute('id', 'app-global-records')
- .setExtra('iconClass', 'fa fa-book')
- .setRouterLink(['/record', 'search', 'documents']);
- menu.addChild('UNISI records')
- .setRouterLink(['/unisi', 'record', 'search', 'documents']);
- menu.addChild('Backend records')
- .setRouterLink(['/admin', 'record', 'search', 'documents']);
- menu.addChild('Document records')
- .setRouterLink(['/records', 'documents']);
- menu.addChild('Organisation records')
- .setRouterLink(['/records', 'organisations']);
- menu.addChild('Editor')
- .setRouterLink(['/editor', 'demo'])
- .setExtra('iconClass', 'fa fa-edit');
- menu.addChild('Editor mode edit')
- .setRouterLink(['/editor', 'demo', '1'])
- .setExtra('iconClass', 'fa fa-edit');
- }
-}
diff --git a/projects/ng-core-tester/src/app/service/app-remote-autocomplete.service.spec.ts b/projects/ng-core-tester/src/app/service/app-remote-autocomplete.service.spec.ts
new file mode 100644
index 00000000..ba77dfb2
--- /dev/null
+++ b/projects/ng-core-tester/src/app/service/app-remote-autocomplete.service.spec.ts
@@ -0,0 +1,16 @@
+import { TestBed } from '@angular/core/testing';
+
+import { AppRemoteAutocompleteService } from './app-remote-autocomplete.service';
+
+describe('AppRemoteAutocompleteService', () => {
+ let service: AppRemoteAutocompleteService;
+
+ beforeEach(() => {
+ TestBed.configureTestingModule({});
+ service = TestBed.inject(AppRemoteAutocompleteService);
+ });
+
+ it('should be created', () => {
+ expect(service).toBeTruthy();
+ });
+});
diff --git a/projects/ng-core-tester/src/app/service/app-remote-autocomplete.service.ts b/projects/ng-core-tester/src/app/service/app-remote-autocomplete.service.ts
new file mode 100644
index 00000000..2fd17dbd
--- /dev/null
+++ b/projects/ng-core-tester/src/app/service/app-remote-autocomplete.service.ts
@@ -0,0 +1,68 @@
+/*
+ * RERO angular core
+ * Copyright (C) 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
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+import { Injectable } from "@angular/core";
+import { IQueryOptions, IRemoteAutocomplete, ISuggestionItem } from "@rero/prime/remote-autocomplete";
+import { Observable, of } from "rxjs";
+
+@Injectable({
+ providedIn: 'root'
+})
+export class AppRemoteAutocompleteService implements IRemoteAutocomplete {
+
+ private data: ISuggestionItem[] = [
+ { label: 'House', value: 'house' , summary: 'House description' },
+ { label: 'Mystery', value: 'mystery' },
+ ];
+
+ public getSuggestions(query: string, queryOptions: IQueryOptions = {}, currentPid: string): Observable {
+ if (!query) {
+ return of([]);
+ }
+ if (query.startsWith('*')) {
+ return of(this.processName(queryOptions.filter));
+ }
+
+ return of(this.processName(queryOptions.filter).filter((element: ISuggestionItem) =>
+ element.label.toLowerCase().includes(query.toLowerCase())
+ ));
+ }
+
+ getValueAsHTML(queryOptions: IQueryOptions, item: ISuggestionItem): Observable {
+ if (!item) {
+ return of(undefined);
+ }
+
+ let value = item.label;
+ if (item.summary) {
+ value += '
' + item.summary + '';
+ }
+
+ return of(value);
+ }
+
+ private processName(filter?: string): ISuggestionItem[] {
+ if (filter) {
+ return structuredClone(this.data).map((element: ISuggestionItem) => {
+ element.label = `${filter} - ${element.label}`;
+
+ return element;
+ });
+ } else {
+ return this.data;
+ }
+ }
+}
diff --git a/projects/ng-core-tester/src/app/service/menu.service.ts b/projects/ng-core-tester/src/app/service/menu.service.ts
deleted file mode 100644
index b20c9435..00000000
--- a/projects/ng-core-tester/src/app/service/menu.service.ts
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * RERO angular core
- * Copyright (C) 2020 RERO
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, version 3 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-import { Injectable } from '@angular/core';
-import { MenuFactory, MenuItem } from '@rero/ng-core';
-
-@Injectable({
- providedIn: 'root'
-})
-export class MenuService {
-
- /**
- * Menu Application
- * @return MenuItem
- */
- generateApplicationMenu() {
- const factory = new MenuFactory();
- const menu = factory.createItem('Demo');
- /**
- * Definition with short syntax
- */
- menu.addChild(
- 'Home',
- {
- attributes: { id: 'home' },
- labelAttributes: { hideLabel: true },
- extras: { iconClass: 'fa fa-home'}, routerlink: ['/'],
- }
- );
- /**
- * Same menu with fluid syntax
- * menu.addChild('Home')
- * .setAttribute('id', 'home')
- * .setExtra('iconClass', 'fa fa-home')
- * .setRouterLink(['/']);
- */
- menu.addChild('No link')
- .disable();
-
-
- this._recordsMenu(menu);
-
- /**
- * Menu with multiples attributes definition
- */
- menu.addChild('Sonar')
- .setUri('http://sonar.ch')
- .setAttributes({ id: 'sonar-link', target: '_blank' })
- .setExtra('iconClass', 'fa fa-external-link')
- .setActive(true);
-
- this._externalLinks(menu);
-
- return menu;
- }
-
- /**
- * Generate records menu
- * @param menu - MenuItem
- */
- private _recordsMenu(menu: MenuItem) {
- const records = menu.addChild('Records')
- .setAttribute('class', 'dropdown-menu-right');
- records.addChild('Global records')
- .setAttribute('id', 'global-records')
- .setExtra('iconClass', 'fa fa-book')
- .setRouterLink(['/record', 'search', 'documents']);
- records.addChild('UNISI records')
- .setRouterLink(['/unisi', 'record', 'search', 'documents'])
- .disable();
- records.addChild('Backend records')
- .setPrefix('[admin]', 'mr-2')
- .setSuffix('[search]', 'ml-2 text-warning')
- .setRouterLink(['/admin', 'record', 'search', 'documents'])
- .setExtra('divider', 'dropdown-divider');
- records.addChild('Document records')
- .setRouterLink(['/records', 'documents']);
- records.addChild('Document records')
- .setSuffix('[with query params]', 'ml-2 font-weight-bold')
- .setRouterLink(['/records', 'documents'])
- .setQueryParams({
- q: 'anatomic',
- page: 1,
- size: 10
- })
- .setExtra('divider', 'dropdown-divider');
- records.addChild('Organisation records')
- .setRouterLink(['/records', 'organisations']);
- }
-
- /**
- * Generate external menu links
- * @param menu - MenuItem
- */
- private _externalLinks(menu: MenuItem) {
- const external = menu.addChild('External links');
- external.addChild('RERO')
- .setUri('https://www.rero.ch')
- .setAttributes({ id: 'rero-link', target: '_blank' });
- }
-}
diff --git a/projects/ng-core-tester/src/assets/angular.svg b/projects/ng-core-tester/src/assets/angular.svg
new file mode 100644
index 00000000..79e613f0
--- /dev/null
+++ b/projects/ng-core-tester/src/assets/angular.svg
@@ -0,0 +1,33 @@
+
+
\ No newline at end of file
diff --git a/projects/ng-core-tester/src/assets/i18n/de.json b/projects/ng-core-tester/src/assets/i18n/de.json
index 71a7eb99..94c78119 100644
--- a/projects/ng-core-tester/src/assets/i18n/de.json
+++ b/projects/ng-core-tester/src/assets/i18n/de.json
@@ -5,5 +5,26 @@
"library": "Bibliothek",
"German": "Deutsch",
"from": "Von",
- "day(s)": "Tag(e)"
+ "day(s)": "Tag(e)",
+ "Language": "Sprache",
+ "Yes": "Ja",
+ "No": "Nein",
+ "Are you sure that you want to proceed?": "Sind Sie sicher, dass Sie fortfahren wollen?",
+ "Confirmation": "Konfirmation",
+ "Confirmed": "Bestätigt",
+ "You have accepted": "Sie haben akzeptiert",
+ "Rejected": "Abgelehnt",
+ "You have rejected": "Sie haben abgelehnt",
+ "info": "Info",
+ "success": "Erfolg",
+ "error": "Fehler",
+ "warn": "warnen",
+ "This is the message": "Dies ist die Nachricht",
+ "Select a toast type": "Wählen Sie eine Toastart",
+ "Records": "Aufzeichnungen",
+ "Editor": "Herausgeber",
+ "Add mode": "hinzufügenmodus",
+ "Please select a type": "Bitte wählen Sie einen Typ",
+ "Full-text": "Volltext",
+ "Main title": "Haupttitel"
}
diff --git a/projects/ng-core-tester/src/assets/i18n/en.json b/projects/ng-core-tester/src/assets/i18n/en.json
index 90273088..c16bb627 100644
--- a/projects/ng-core-tester/src/assets/i18n/en.json
+++ b/projects/ng-core-tester/src/assets/i18n/en.json
@@ -2,5 +2,9 @@
"location": "Location",
"created year": "Creation year",
"library": "Library",
- "German": "German"
+ "German": "German",
+ "info": "Info",
+ "success": "Success",
+ "error": "Error",
+ "warn": "Warn"
}
diff --git a/projects/ng-core-tester/src/assets/i18n/fr.json b/projects/ng-core-tester/src/assets/i18n/fr.json
index 71c13e45..6cbbd08e 100644
--- a/projects/ng-core-tester/src/assets/i18n/fr.json
+++ b/projects/ng-core-tester/src/assets/i18n/fr.json
@@ -21,5 +21,26 @@
"Hidden field with a default value.": "Champ caché avec une valeur par défaut.",
"Hidden field with a default value must not be added to the form.": "Les champs cachés avec une valeur par défaut ne doivent pas être ajoutés au formulaire.",
"Readonly values must not be changeable.": "Les valeurs en lecture seule ne doivent pas être modifiables.",
- "Hidden Property with required expression control": "Propriété cachée avec contrôle de l'expression requise."
+ "Hidden Property with required expression control": "Propriété cachée avec contrôle de l'expression requise.",
+ "Language": "Langue",
+ "Yes": "oui",
+ "No": "Non",
+ "Are you sure that you want to proceed?": "Êtes-vous sûr de vouloir continuer?",
+ "Confirmation": "Confirmation",
+ "Confirmed": "Confirmé",
+ "You have accepted": "Vous avez accepté",
+ "Rejected": "Rejeté",
+ "You have rejected": "Vous avez rejeté",
+ "info": "Information",
+ "success": "Succès",
+ "error": "Erreur",
+ "warn": "Avertir",
+ "This is the message": "Ceci est un message",
+ "Select a toast type": "Sélectionner un type de toast",
+ "Records": "Enregistrements",
+ "Editor": "Editeur",
+ "Add mode": "Mode ajout",
+ "Please select a type": "Veuillez sélectionner un type",
+ "Full-text": "Texte complet",
+ "Main title": "Titre principal"
}
diff --git a/projects/ng-core-tester/src/assets/i18n/it.json b/projects/ng-core-tester/src/assets/i18n/it.json
index a0b843c9..1fd25fdf 100644
--- a/projects/ng-core-tester/src/assets/i18n/it.json
+++ b/projects/ng-core-tester/src/assets/i18n/it.json
@@ -5,5 +5,26 @@
"library": "Biblioteca",
"German": "Tedesco",
"from": "Da",
- "day(s)": "giorni"
+ "day(s)": "giorni",
+ "Language": "Lingua",
+ "Yes": "Sì",
+ "No": "No",
+ "Are you sure that you want to proceed?": "È sicuro di voler procedere?",
+ "Confirmation": "Conferma",
+ "Confirmed": "Confermato",
+ "You have accepted": "Avete accettato",
+ "Rejected": "Rifiutato",
+ "You have rejected": "Avete rifiutato",
+ "info": "Info",
+ "success": "Successo",
+ "error": "Errore",
+ "warn": "Avvertire",
+ "This is the message": "Questo è il messaggio",
+ "Select a toast type": "Selezionare un tipo di toast",
+ "Records": "Registrazioni",
+ "Editor": "Editore",
+ "Add mode": "Aggiungi modalità",
+ "Please select a type": "Selezionare un tipo",
+ "Full-text": "Testo integrale",
+ "Main title": "Titolo principale"
}
diff --git a/projects/ng-core-tester/src/styles.scss b/projects/ng-core-tester/src/styles.scss
index 29602a60..e404ce20 100644
--- a/projects/ng-core-tester/src/styles.scss
+++ b/projects/ng-core-tester/src/styles.scss
@@ -1,6 +1,6 @@
/*
* RERO angular core
- * 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
@@ -16,42 +16,59 @@
*/
$fa-font-path: "~font-awesome/fonts";
-@import "bootstrap/scss/bootstrap.scss";
+// @import "bootstrap/scss/bootstrap.scss";
@import "font-awesome/scss/font-awesome.scss";
-@import "ngx-toastr/toastr-bs4-alert";
+// @import "ngx-toastr/toastr-bs4-alert";
-// Styles for markdown editor
+@import "../../rero/ng-core/assets/scss/ng-core.scss";
+@import "node_modules/primeng/resources/themes/lara-light-blue/theme.css";
+@import "node_modules/primeng/resources/primeng.min.css";
+@import "node_modules/primeflex/primeflex.min.css";
+@import "node_modules/primeicons/primeicons.css";
@import "easymde/dist/easymde.min";
-.CodeMirror, .CodeMirror-scroll {
- min-height: 120px;
-}
-ng-core-formly-field-primeng-input > input,
-formly-field > input {
- width: 100%;
+.p-menubar {
+ background-color: white;
+ border: none;
+ margin-bottom: 0;
}
-input {
- padding: 0.5em;
+.container {
+ padding: 1.5rem;
+ border: 1px solid #e5e7eb;
+ border-radius: 6px;
}
-input[type="number"] {
- padding: 0.1em;
-}
+// .CodeMirror, .CodeMirror-scroll {
+// min-height: 120px;
+// }
+// ng-core-formly-field-primeng-input > input,
+// formly-field > input {
+// width: 100%;
+// }
-// 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 {
- padding-top: 0;
- padding-bottom: 0;
-}
+// input {
+// padding: 0.5em;
+// }
-dt, dl, dd {
- margin-bottom: 0;
- padding-bottom: 0;
-}
+// input[type="number"] {
+// padding: 0.1em;
+// }
-div.object .row {
- margin-left: 4px !important;
- margin-top: 0.4rem;
-}
+
+// // 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 {
+// padding-top: 0;
+// padding-bottom: 0;
+// }
+
+// dt, dl, dd {
+// margin-bottom: 0;
+// padding-bottom: 0;
+// }
+
+// div.object .row {
+// margin-left: 4px !important;
+// margin-top: 0.4rem;
+// }
diff --git a/projects/rero/ng-core/assets/scss/_border.scss b/projects/rero/ng-core/assets/scss/_border.scss
new file mode 100644
index 00000000..9113b875
--- /dev/null
+++ b/projects/rero/ng-core/assets/scss/_border.scss
@@ -0,0 +1,21 @@
+/*
+ * RERO angular core
+ * Copyright (C) 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
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+.border { border: $border-width solid $border-color !important; }
+.border-top { border-top: $border-width solid $border-color !important; }
+.border-right { border-right: $border-width solid $border-color !important; }
+.border-bottom { border-bottom: $border-width solid $border-color !important; }
+.border-left { border-left: $border-width solid $border-color !important; }
diff --git a/projects/rero/ng-core/src/lib/record/editor/type/custom-select/interfaces.ts b/projects/rero/ng-core/assets/scss/_button.scss
similarity index 68%
rename from projects/rero/ng-core/src/lib/record/editor/type/custom-select/interfaces.ts
rename to projects/rero/ng-core/assets/scss/_button.scss
index 38f80103..54f8024b 100644
--- a/projects/rero/ng-core/src/lib/record/editor/type/custom-select/interfaces.ts
+++ b/projects/rero/ng-core/assets/scss/_button.scss
@@ -1,6 +1,6 @@
/*
* RERO angular core
- * Copyright (C) 2020 RERO
+ * Copyright (C) 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,17 +14,18 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
+.button-bar {
+ height: 3rem;
+}
-/**
- * Interface representing an option in select box.
- */
-export interface SelectOption {
- label: string;
- translatedLabel?: string;
- value?: string;
- group?: string;
- disabled?: boolean;
- preferred?: boolean;
- level?: number;
- children?: Array;
+p-button:disabled, p-button.disabled {
+ color: $color-white;
+ pointer-events: none;
+ border-color: $button-disabled-background-color;
+ opacity: 0.65;
+}
+
+button:focus {
+ outline: none;
+ box-shadow: none;
}
diff --git a/projects/rero/ng-core/assets/scss/_style.scss b/projects/rero/ng-core/assets/scss/_style.scss
new file mode 100644
index 00000000..a7f8cfb7
--- /dev/null
+++ b/projects/rero/ng-core/assets/scss/_style.scss
@@ -0,0 +1,98 @@
+/*
+ * RERO angular core
+ * Copyright (C) 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
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+ @layer reset, ng-core, primeng;
+
+ @layer ng-core {
+ html, body {
+ line-height: normal;
+ font-size: 14px;
+ }
+
+ .header {
+ margin-top: 0.5em;
+ }
+
+ .invalid-feedback {
+ color: red;
+ }
+
+ formly-field {
+ .p-button {
+ padding: 0px;
+ }
+ .p-button.p-button-icon-only {
+ width: 1.5rem;
+ }
+ }
+
+ ng-core-card-wrapper {
+ p-card > .p-card > .p-card-header {
+ padding-top: 1rem;
+ margin-left: 1rem;
+ font-size: 1.2rem;
+ }
+
+ .p-card {
+ .p-card-body {
+ padding: 1.25rem 1rem;
+ }
+ .p-card-content {
+ padding: 0.25rem 0;
+ }
+ }
+ }
+
+ ng-core-editor-add-field-editor {
+ .p-button-label {
+ font-weight: 500;
+ }
+ }
+
+ ng-core-editor-formly-object-type {
+ margin-top: 1.5rem
+ }
+
+ ng-core-editor-formly-field-textarea,
+ ng-core-formly-field-primeng-input,
+ ng-core-tree-select,
+ ng-core-multi-select,
+ ng-core-primeng-select,
+ ng-core-date-picker {
+ width: 100%;
+ }
+
+ .list-result {
+ padding: 0;
+ margin: 0 10px;
+ }
+
+ .list-unstyled {
+ padding-left: 0;
+ list-style: none;
+ }
+
+ .add-field-info {
+ margin-top: .5rem;
+ }
+ }
+
+ @layer reset {
+ a {
+ text-decoration: none;
+ }
+ }
diff --git a/projects/rero/ng-core/assets/scss/_typography.scss b/projects/rero/ng-core/assets/scss/_typography.scss
new file mode 100644
index 00000000..79bcfd53
--- /dev/null
+++ b/projects/rero/ng-core/assets/scss/_typography.scss
@@ -0,0 +1,73 @@
+/*
+ * RERO angular core
+ * Copyright (C) 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
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+h1, h2, h3, h4, h5, h6 {
+ margin-top: 0;
+ margin-bottom: 0.5rem;
+}
+
+h1, h2, h3, h4, h5, h6,
+.h1, .h2, .h3, .h4, .h5, .h6 {
+ margin-bottom: 0.5rem;
+ font-weight: 500;
+ line-height: 1.2;
+}
+
+h1, .h1 {
+ font-size: 2.5rem;
+}
+
+h2, .h2 {
+ font-size: 2rem;
+}
+
+h3, .h3 {
+ font-size: 1.75rem;
+}
+
+h4, .h4 {
+ font-size: 1.5rem;
+}
+
+h5, .h5 {
+ font-size: 1.25rem;
+}
+
+h6, .h6 {
+ font-size: 1rem;
+}
+
+label {
+ display: inline-block;
+ margin-bottom: .5rem;
+}
+
+legend {
+ display: block;
+ width: 100%;
+ max-width: 100%;
+ padding: 0;
+ margin-bottom: .5rem;
+ font-size: 1.5rem;
+ line-height: inherit;
+ color: inherit;
+ white-space: normal;
+}
+
+.border-bottom {
+ border-bottom: 1px solid #dee2e6 !important;
+}
diff --git a/projects/ng-core-tester/src/app/service/menu.service.spec.ts b/projects/rero/ng-core/assets/scss/_variables.scss
similarity index 63%
rename from projects/ng-core-tester/src/app/service/menu.service.spec.ts
rename to projects/rero/ng-core/assets/scss/_variables.scss
index 70956e88..3a464061 100644
--- a/projects/ng-core-tester/src/app/service/menu.service.spec.ts
+++ b/projects/rero/ng-core/assets/scss/_variables.scss
@@ -1,6 +1,6 @@
/*
* RERO angular core
- * Copyright (C) 2020 RERO
+ * Copyright (C) 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,17 +14,15 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
-import { TestBed, inject } from '@angular/core/testing';
-import { MenuService } from './menu.service';
-describe('Service: Menu', () => {
- beforeEach(() => {
- TestBed.configureTestingModule({
- providers: [MenuService]
- });
- });
+// Color
+$gray-300: #dee2e6 !default;
+$color-white: #fff;
- it('should ...', inject([MenuService], (service: MenuService) => {
- expect(service).toBeTruthy();
- }));
-});
+// Border
+$border-width: 1px !default;
+$border-color: $gray-300 !default;
+
+// Button
+$button-disabled-background-color: #198754;
+$button-disabled-opacity: 0.65;
diff --git a/projects/rero/ng-core/assets/scss/ng-core.scss b/projects/rero/ng-core/assets/scss/ng-core.scss
new file mode 100644
index 00000000..f00adc1b
--- /dev/null
+++ b/projects/rero/ng-core/assets/scss/ng-core.scss
@@ -0,0 +1,22 @@
+/*
+ * RERO angular core
+ * Copyright (C) 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
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+@import "./variables";
+@import "./border";
+@import "./button";
+@import "./style";
+@import "./typography";
diff --git a/projects/rero/ng-core/ng-package.json b/projects/rero/ng-core/ng-package.json
index e11805c6..af14cf8b 100644
--- a/projects/rero/ng-core/ng-package.json
+++ b/projects/rero/ng-core/ng-package.json
@@ -1,6 +1,7 @@
{
"$schema": "../../../node_modules/ng-packagr/ng-package.schema.json",
"dest": "../../../dist/rero/ng-core",
+ "assets": ["./assets"],
"lib": {
"entryFile": "src/public-api.ts"
}
diff --git a/projects/rero/ng-core/package.json b/projects/rero/ng-core/package.json
index 334fcbdb..f08653e4 100644
--- a/projects/rero/ng-core/package.json
+++ b/projects/rero/ng-core/package.json
@@ -30,7 +30,10 @@
"ngx-toastr": "^18.0.0",
"easymde": "^2.18.0",
"marked": "^10.0.0",
- "@types/marked": "^4.0.8"
+ "@types/marked": "^4.0.8",
+ "primeflex": "^3.3.1",
+ "primeicons": "^7.0.0",
+ "primeng": "^17.18.0"
},
"publishConfig": {
"access": "public"
diff --git a/projects/rero/ng-core/src/lib/core.module.ts b/projects/rero/ng-core/src/lib/core.module.ts
index 5a373fbf..81d1ed10 100644
--- a/projects/rero/ng-core/src/lib/core.module.ts
+++ b/projects/rero/ng-core/src/lib/core.module.ts
@@ -1,6 +1,6 @@
/*
* RERO angular core
- * 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
@@ -23,6 +23,7 @@ import { BsDropdownModule } from 'ngx-bootstrap/dropdown';
import { ModalModule } from 'ngx-bootstrap/modal';
import { NgxSpinnerModule } from 'ngx-spinner';
import { ToastrModule } from 'ngx-toastr';
+import { ConfirmationService, MessageService } from 'primeng/api';
import { CoreConfigService } from './core-config.service';
import { DialogComponent } from './dialog/dialog.component';
import { AutofocusDirective } from './directives/autofocus.directive';
@@ -67,7 +68,7 @@ import { SortListComponent } from './widget/sort-list/sort-list.component';
SortListComponent,
NgVarDirective,
MarkdownPipe,
- AutofocusDirective
+ AutofocusDirective,
],
imports: [
CommonModule,
@@ -83,7 +84,7 @@ import { SortListComponent } from './widget/sort-list/sort-list.component';
BsDropdownModule.forRoot(),
ToastrModule.forRoot(),
NgxSpinnerModule,
- PrimeNgCoreModule
+ PrimeNgCoreModule,
],
exports: [
PrimeNgCoreModule,
@@ -109,10 +110,12 @@ import { SortListComponent } from './widget/sort-list/sort-list.component';
SortListComponent,
NgVarDirective,
MarkdownPipe,
- AutofocusDirective
+ AutofocusDirective,
],
providers: [
- ComponentCanDeactivateGuard
+ ComponentCanDeactivateGuard,
+ ConfirmationService,
+ MessageService
]
})
export class CoreModule { }
diff --git a/projects/rero/ng-core/src/lib/prime-ng-core-module.ts b/projects/rero/ng-core/src/lib/prime-ng-core-module.ts
index 496baaaf..056eae5d 100644
--- a/projects/rero/ng-core/src/lib/prime-ng-core-module.ts
+++ b/projects/rero/ng-core/src/lib/prime-ng-core-module.ts
@@ -16,16 +16,65 @@
*/
import { ClipboardModule } from "@angular/cdk/clipboard";
import { NgModule } from "@angular/core";
+import { ConfirmationService, MessageService } from "primeng/api";
+import { AutoCompleteModule } from 'primeng/autocomplete';
+import { AutoFocusModule } from 'primeng/autofocus';
+import { BadgeModule } from 'primeng/badge';
+import { ButtonModule } from 'primeng/button';
import { CalendarModule } from "primeng/calendar";
+import { CardModule } from 'primeng/card';
+import { CheckboxModule } from 'primeng/checkbox';
+import { ConfirmDialogModule } from 'primeng/confirmdialog';
+import { DropdownModule } from "primeng/dropdown";
+import { InputGroupModule } from 'primeng/inputgroup';
+import { InputGroupAddonModule } from 'primeng/inputgroupaddon';
+import { InputSwitchModule } from 'primeng/inputswitch';
+import { InputTextModule } from 'primeng/inputtext';
+import { InputTextareaModule } from 'primeng/inputtextarea';
+import { MessagesModule } from 'primeng/messages';
import { PaginatorModule } from 'primeng/paginator';
+import { PanelModule } from 'primeng/panel';
import { RadioButtonModule } from "primeng/radiobutton";
+import { SplitButtonModule } from 'primeng/splitbutton';
+import { TabViewModule } from 'primeng/tabview';
+import { TagModule } from 'primeng/tag';
+import { TieredMenuModule } from 'primeng/tieredmenu';
+import { ToastModule } from 'primeng/toast';
+import { TooltipModule } from 'primeng/tooltip';
+import { TriStateCheckboxModule } from 'primeng/tristatecheckbox';
@NgModule({
+ providers: [
+ MessageService,
+ ConfirmationService
+ ],
exports: [
+ AutoCompleteModule,
+ AutoFocusModule,
+ BadgeModule,
+ ButtonModule,
CalendarModule,
+ CardModule,
+ CheckboxModule,
ClipboardModule,
+ ConfirmDialogModule,
+ DropdownModule,
+ InputGroupModule,
+ InputGroupAddonModule,
+ InputSwitchModule,
+ InputTextModule,
+ InputTextareaModule,
+ MessagesModule,
PaginatorModule,
+ PanelModule,
RadioButtonModule,
+ SplitButtonModule,
+ TabViewModule,
+ TagModule,
+ TieredMenuModule,
+ ToastModule,
+ TooltipModule,
+ TriStateCheckboxModule,
]
})
export class PrimeNgCoreModule { }
diff --git a/projects/rero/ng-core/src/lib/record/autocomplete/autocomplete.component.html b/projects/rero/ng-core/src/lib/record/autocomplete/autocomplete.component.html
deleted file mode 100644
index f6667c90..00000000
--- a/projects/rero/ng-core/src/lib/record/autocomplete/autocomplete.component.html
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
- @if (model.iconCssClass) {
-
- }
-
-
-
-
diff --git a/projects/rero/ng-core/src/lib/record/autocomplete/autocomplete.component.spec.ts b/projects/rero/ng-core/src/lib/record/autocomplete/autocomplete.component.spec.ts
deleted file mode 100644
index 113f7ebf..00000000
--- a/projects/rero/ng-core/src/lib/record/autocomplete/autocomplete.component.spec.ts
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * RERO angular core
- * Copyright (C) 2020 RERO
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, version 3 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-import { HttpClientModule } from '@angular/common/http';
-import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
-import { FormsModule } from '@angular/forms';
-import { RouterTestingModule } from '@angular/router/testing';
-import { TranslateModule } from '@ngx-translate/core';
-import { TypeaheadModule } from 'ngx-bootstrap/typeahead';
-import { CoreModule } from '../../core.module';
-import { AutocompleteComponent } from './autocomplete.component';
-
-describe('AutocompleteComponent', () => {
- let component: AutocompleteComponent;
- let fixture: ComponentFixture;
-
- beforeEach(waitForAsync(() => {
- TestBed.configureTestingModule({
- imports: [
- HttpClientModule,
- FormsModule,
- TypeaheadModule.forRoot(),
- RouterTestingModule,
- TranslateModule.forRoot(),
- CoreModule
- ],
- declarations: [ AutocompleteComponent ]
- })
- .compileComponents();
- }));
-
- beforeEach(() => {
- fixture = TestBed.createComponent(AutocompleteComponent);
- component = fixture.componentInstance;
- fixture.detectChanges();
- });
-
- it('should create', () => {
- expect(component).toBeTruthy();
- });
-});
diff --git a/projects/rero/ng-core/src/lib/record/autocomplete/autocomplete.component.ts b/projects/rero/ng-core/src/lib/record/autocomplete/autocomplete.component.ts
deleted file mode 100644
index 4e515c59..00000000
--- a/projects/rero/ng-core/src/lib/record/autocomplete/autocomplete.component.ts
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * RERO angular core
- * 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
- * the Free Software Foundation, version 3 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-import { Component, Input, OnInit, ViewChild } from '@angular/core';
-import { ActivatedRoute, Router } from '@angular/router';
-import { TypeaheadMatch } from 'ngx-bootstrap/typeahead';
-import { combineLatest, Observable, of, Subscriber } from 'rxjs';
-import { map, switchMap } from 'rxjs/operators';
-import { RecordService } from '../record.service';
-
-@Component({
- selector: 'ng-core-autocomplete',
- templateUrl: './autocomplete.component.html'
-})
-export class AutocompleteComponent implements OnInit {
- // The submit button css class.
- @Input() buttonCssClass = 'btn btn-light';
-
- // The form action i.e. '/search'
- @Input() action: string;
-
- // The autocomplete record type configuration.
- @Input() recordTypes: Array = [];
-
- // The search input field size: small or large
- @Input() size: string;
-
- // The search input field placeholder.
- @Input() placeholder: string;
-
- // The routing mode, angular for internal or href for external.
- @Input() internalRouting = true;
-
- // The minimal number of characters that needs to be entered before typeahead kicks-in.
- @Input() typeaheadMinLength = 3;
-
- // The minimal wait time after last character typed before typeahead kicks-in.
- @Input() typeaheadWaitMs = 300;
-
- // The maximum length of the total number of suggestions in the list. The default value is 10.
- @Input() typeaheadOptionsLimit = 10;
-
- // Additional query parameters
- @Input() extraQueryParams = { page: '1', size: '10' };
-
- // The current selected suggestion.
- asyncSelected = {
- text: undefined,
- query: undefined,
- index: undefined,
- category: undefined,
- href: undefined
- };
-
- // The remote suggestions loading status.
- typeaheadLoading: boolean;
-
- // The remote suggestions list.
- dataSource: Observable;
-
- // The current form object from the template.
- @ViewChild('form')
- form: any;
-
- // The suggestion list subscriber, used to close the dropdown
- suggestions$: Subscriber