Skip to content

Commit

Permalink
document: filter results by org in admin view
Browse files Browse the repository at this point in the history
* Fixes display of organisation facet in dcoument brief view.
* Modifies links to documents brief view to include current organisation as a default parameter.
* Closes #140.
* Removes useless code.

Co-Authored-by: Alicia Zangger <alicia.zangger@rero.ch>
Co-Authored-by: Johnny Mariéthoz <Johnny.Mariethoz@rero.ch>
  • Loading branch information
Alicia Zangger and jma committed Apr 14, 2020
1 parent b138199 commit ad42c61
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</div>
<ul class="list-group list-group-flush" *ngIf="item.entries">
<li class="list-group-item p-0" *ngFor="let entry of item.entries">
<a class="list-group-item btn btn-light text-left text-wrap" [routerLink]="entry.routerLink"><i *ngIf="entry.iconCssClass"
<a class="list-group-item btn btn-light text-left text-wrap" [routerLink]="entry.routerLink" [queryParams]="entry.queryParams"><i *ngIf="entry.iconCssClass"
[ngClass]="entry.iconCssClass" aria-hidden="true"></i> {{ entry.name | translate }}</a>
</li>
</ul>
Expand Down
1 change: 0 additions & 1 deletion projects/admin/src/app/routes/documents-route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ export class DocumentsRoute extends BaseRoute implements RouteInterface {
'author__en',
'author__de',
'author__it',
'library',
'organisation',
'language',
'subject',
Expand Down
12 changes: 5 additions & 7 deletions projects/admin/src/app/routes/route-tool.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,15 +213,13 @@ export class RouteToolService {
private aggFilter(aggregations: object) {
const aggs = {};
Object.keys(aggregations).map(aggregation => {
if ('organisation' !== aggregation) {
if (aggregation.indexOf('__') > -1) {
const splitted = aggregation.split('__');
if (this._translateService.currentLang === splitted[1]) {
aggs[aggregation] = aggregations[aggregation];
}
} else {
if (aggregation.indexOf('__') > -1) {
const splitted = aggregation.split('__');
if (this._translateService.currentLang === splitted[1]) {
aggs[aggregation] = aggregations[aggregation];
}
} else {
aggs[aggregation] = aggregations[aggregation];
}
});
return aggs;
Expand Down
21 changes: 20 additions & 1 deletion projects/admin/src/app/service/menu.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class MenuService {
entries: [{
name: this._translateService.instant('Documents'),
routerLink: '/records/documents',
queryParams: this._myDocumentsQueryParams(),
iconCssClass: 'fa fa-file-o'
}, {
name: this._translateService.instant('Create a bibliographic record'),
Expand Down Expand Up @@ -75,7 +76,7 @@ export class MenuService {
iconCssClass: 'fa fa-users'
}, {
name: this._translateService.instant('My organisation'),
routerLink: `/records/organisations/detail/${this._userService.getCurrentUser().library.organisation.pid}`,
routerLink: this._myOrganisationRouterLink(),
iconCssClass: 'fa fa-university'
}, {
name: this._translateService.instant('My library'),
Expand All @@ -90,12 +91,30 @@ export class MenuService {
]
};

/**
* Constructor
* @param _translateService : TranslateService
* @param _userService : UserService
*/
constructor(
private _translateService: TranslateService,
private _userService: UserService,
) {}

/** Router link to my library */
private _myLibraryRouterLink() {
return `/records/libraries/detail/${this._userService.getCurrentUser().currentLibrary}`;
}

/** Router link to my organisation */
private _myOrganisationRouterLink() {
return `/records/organisations/detail/${this._userService.getCurrentUser().library.organisation.pid}`;
}

/** Query params to filter documents by organisation
* @return organisation pid as a dictionary
*/
private _myDocumentsQueryParams() {
return {organisation: this._userService.getCurrentUser().library.organisation.pid};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ export class RoutingInitService {
* @return array of value
*/
private aggregationFilter(aggregations: object) {
// TODO replace organisation facet by library facet when the viewcode is not global (needs backend adaptation)
const aggs = {};
Object.keys(aggregations).forEach(aggregation => {
if (aggregation.indexOf('__') > -1) {
Expand Down

0 comments on commit ad42c61

Please sign in to comment.