Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

documents: open aggregation with filters and add more facets for documents search #867

Merged
merged 2 commits into from
Aug 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ export class MenuUserServicesService extends MenuBase {
// ----- DOCUMENTS
this._documentsMenu = catalogMenu.addChild('Documents')
.setRouterLink(['/', 'records', 'documents'])
.setQueryParam('organisation', this._userService.user.currentOrganisation)
.setAttribute('id', 'documents-menu')
.setExtra('iconClass', 'fa fa-file-o');
this._translatedName(this._documentsMenu, 'Documents');
Expand Down Expand Up @@ -329,8 +328,6 @@ export class MenuUserServicesService extends MenuBase {
// USER SERVICES: COLLECTIONS, ILL REQUESTS
this._illRequestsMenu.setQueryParam('library', user.currentLibrary);
this._collectionsMenu.setQueryParam('library', user.currentLibrary);
// CATALOG: DOCUMENTS
this._documentsMenu.setQueryParam('organisation', user.currentOrganisation);
// ACQUISITION:
this._ordersMenu.setQueryParam('library', user.currentLibrary);
this._lateIssuesMenu.setQueryParam('library', user.currentLibrary);
Expand Down
38 changes: 33 additions & 5 deletions projects/admin/src/app/routes/documents-route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,17 @@ export class DocumentsRoute extends BaseRoute implements RouteInterface {
component: DocumentsBriefViewComponent,
detailComponent: DocumentDetailViewComponent,
searchFilters: [
this.expertSearchFilter()
this.expertSearchFilter(),
{
label: _('Online resources'),
filter: 'online',
value: 'true'
},
{
label: _('Physical resources'),
filter: 'not_online',
value: 'true'
}
],
permissions: (record: any) => this._routeToolService.permissions(record, this.recordType),
preprocessRecordEditor: (record: any) => {
Expand All @@ -74,18 +84,36 @@ export class DocumentsRoute extends BaseRoute implements RouteInterface {
aggregations: (aggregations: any) => this._routeToolService
.aggregationFilter(aggregations),
aggregationsName: {
organisation: _('Library')
online: _('Online resources'),
not_online: _('Physical resources'),
organisation: _('Library'),
genreForm: _('Genre, form'),
intendedAudience: _('Intended audience'),
year: _('Publication year'),
subject_fiction: _('Subject (fiction)'),
subject_no_fiction: _('Subject (non-fiction)'),
},
allowEmptySearch: false,
aggregationsOrder: [
'document_type',
'author',
'organisation',
'language',
'subject',
'year',
'author',
'subject_no_fiction',
'subject_fiction',
'genreForm',
'intendedAudience',
'status'
],
aggregationsExpand: ['document_type'],
aggregationsExpand: () => {
const expand = ['document_type'];
const queryParams = this._routeToolService.activatedRoute.snapshot.queryParams;
if (queryParams.location || queryParams.library) {
expand.push('organisation');
}
return expand;
},
aggregationsBucketSize: 10,
itemHeaders: {
Accept: 'application/rero+json, application/json'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/

import { TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same for this file, all changes could be removed

Copy link
Contributor Author

@vgranata vgranata Jun 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe these changes are needed because of the changes made in file documents-route.service.ts. The tests fail if I remove these changes.

import { TranslateModule } from '@ngx-translate/core';
import { DocumentsRouteService } from './documents-route.service';

Expand All @@ -25,7 +26,8 @@ describe('DocumentRouteService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
TranslateModule.forRoot()
TranslateModule.forRoot(),
RouterTestingModule
]
});
service = TestBed.inject(DocumentsRouteService);
Expand Down
58 changes: 51 additions & 7 deletions projects/public-search/src/app/routes/documents-route.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/

import { Injectable } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { TranslateService } from '@ngx-translate/core';
import { ContributionBriefComponent } from '@rero/shared';
Expand Down Expand Up @@ -52,10 +53,12 @@ export class DocumentsRouteService extends BaseRoute implements ResourceRouteInt
* Constructor
* @param translateService - TranslateService
* @param appConfigService - AppConfigService
* @param _route - ActivatedRoute
*/
constructor(
translateService: TranslateService,
private appConfigService: AppConfigService
private appConfigService: AppConfigService,
private _route: ActivatedRoute
) {
super(translateService);
}
Expand Down Expand Up @@ -95,11 +98,44 @@ export class DocumentsRouteService extends BaseRoute implements ResourceRouteInt
label: _('Documents'),
aggregations: (aggregations: any) => this.aggFilter(aggregations),
aggregationsName: {
organisation: _('Library')
online: _('Online resources'),
not_online: _('Physical resources'),
organisation: _('Library'),
genreForm: _('Genre, form'),
intendedAudience: _('Intended audience'),
year: _('Publication year'),
subject_fiction: _('Subject (fiction)'),
subject_no_fiction: _('Subject (non-fiction)'),
},
showFacetsIfNoResults: true,
aggregationsOrder: this.aggregations(viewcode),
aggregationsExpand: ['document_type'],
aggregationsExpand: () => {
const expand = ['document_type'];
const queryParams = this._route.snapshot.queryParams;
if (this.appConfigService.globalViewName === viewcode) {
if (queryParams.location || queryParams.library) {
expand.push('organisation');
}
} else {
if (queryParams.location) {
expand.push('library');
}
}
return expand;
},
aggregationsBucketSize: 10,
searchFilters: [
{
label: _('Online resources'),
filter: 'online',
value: 'true'
},
{
label: _('Physical resources'),
filter: 'not_online',
value: 'true'
}
],
preFilters: {
view: `${viewcode}`,
simple: 1
Expand Down Expand Up @@ -187,19 +223,27 @@ export class DocumentsRouteService extends BaseRoute implements ResourceRouteInt
if (this.appConfigService.globalViewName === viewcode) {
return [
_('document_type'),
_('author'),
_('organisation'),
_('language'),
_('subject'),
_('year'),
_('author'),
_('subject_no_fiction'),
_('subject_fiction'),
_('genreForm'),
_('intendedAudience'),
_('status')
];
} else {
return [
_('document_type'),
_('author'),
_('library'),
_('language'),
_('subject'),
_('year'),
_('author'),
_('subject_no_fiction'),
_('subject_fiction'),
_('genreForm'),
_('intendedAudience'),
_('status')
];
}
Expand Down
2 changes: 1 addition & 1 deletion projects/public-search/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
</head>
<body>
<div class="container">
Expand Down