diff --git a/projects/admin/src/app/record/search-view/document-record-search/document-record-search.component.html b/projects/admin/src/app/record/search-view/document-record-search/document-record-search.component.html
index 76ff9757d..527d9d5d3 100644
--- a/projects/admin/src/app/record/search-view/document-record-search/document-record-search.component.html
+++ b/projects/admin/src/app/record/search-view/document-record-search/document-record-search.component.html
@@ -15,9 +15,18 @@
along with this program. If not, see .
-->
-
diff --git a/projects/admin/src/app/routes/base-route.ts b/projects/admin/src/app/routes/base-route.ts
index 844ed6917..214efa1b2 100644
--- a/projects/admin/src/app/routes/base-route.ts
+++ b/projects/admin/src/app/routes/base-route.ts
@@ -30,7 +30,7 @@ export class BaseRoute {
/**
* Constructor
- * @param routeToolService - RouteToolService
+ * @param _routeToolService - RouteToolService
*/
constructor(
protected _routeToolService: RouteToolService
diff --git a/projects/admin/src/app/routes/documents-route.ts b/projects/admin/src/app/routes/documents-route.ts
index 43b702723..783e275bc 100644
--- a/projects/admin/src/app/routes/documents-route.ts
+++ b/projects/admin/src/app/routes/documents-route.ts
@@ -40,7 +40,7 @@ export class DocumentsRoute extends BaseRoute implements RouteInterface {
* @return Object
*/
getConfiguration() {
- return {
+ const config = {
matcher: (url: any) => this.routeMatcher(url, this.name),
children: [
{ path: '', component: DocumentRecordSearchComponent, canActivate: [ PermissionGuard ], data: { permissions: [ PERMISSIONS.DOC_ACCESS, PERMISSIONS.DOC_SEARCH ], operator: PERMISSION_OPERATOR.AND } },
@@ -159,5 +159,12 @@ export class DocumentsRoute extends BaseRoute implements RouteInterface {
]
}
};
+
+ this._routeToolService.organisationService.onOrganisationLoaded$.subscribe((org) => {
+ config.data.types[0]['defaultSearchInputFilters'] = [{
+ 'key': 'organisation', 'values': [org.pid]
+ }];
+ });
+ return config;
}
}
diff --git a/projects/admin/src/app/routes/route-tool.service.ts b/projects/admin/src/app/routes/route-tool.service.ts
index c40630203..149d09fcf 100644
--- a/projects/admin/src/app/routes/route-tool.service.ts
+++ b/projects/admin/src/app/routes/route-tool.service.ts
@@ -18,6 +18,7 @@ import { DatePipe } from '@angular/common';
import { HttpClient } from '@angular/common/http';
import { AbstractType, Injectable, InjectionToken, Injector, Type } from '@angular/core';
import { ActivatedRoute, Router, UrlSerializer } from '@angular/router';
+import { OrganisationService } from '@app/admin/service/organisation.service';
import { TranslateService } from '@ngx-translate/core';
import { ActionStatus, ApiService, RecordService } from '@rero/ng-core';
import { PermissionsService, UserService } from '@rero/shared';
@@ -47,6 +48,14 @@ export class RouteToolService {
return this._injector.get(TranslateService);
}
+
+ /** Proxy for organisation service
+ * @return OrganisationService
+ */
+ get organisationService() {
+ return this._injector.get(OrganisationService);
+ }
+
/**
* Proxy for user service
* @return UserService
diff --git a/projects/admin/src/app/service/organisation.service.ts b/projects/admin/src/app/service/organisation.service.ts
index 425666206..0d243f559 100644
--- a/projects/admin/src/app/service/organisation.service.ts
+++ b/projects/admin/src/app/service/organisation.service.ts
@@ -25,47 +25,42 @@ import { map } from 'rxjs/operators';
})
export class OrganisationService {
- /**
- * Observable on Record Organisation
- */
- private _onOrganisationLoaded: Subject = new Subject();
+ // SERVICE ATTRIBUTES =======================================================
- /**
- * Organisation record
- */
+ /** Observable on Record Organisation */
+ private _onOrganisationLoaded: Subject = new Subject();
+ /** Organisation record */
private _record: any;
- /**
- * return observable of organisation
- */
- get onOrganisationLoaded() {
+ // GETTER & SETTER ==========================================================
+ /** Return observable of organisation */
+ get onOrganisationLoaded$() {
return this._onOrganisationLoaded.asObservable();
}
-
- /**
- * get current organisation
- */
+ /** Get current organisation*/
get organisation() {
return this._record;
}
+ // CONSTRUCTOR ==============================================================
/**
* Constructor
- * @param recordService - RecordService
+ * @param _recordService - RecordService
*/
- constructor(private _recordService: RecordService) { }
+ constructor(
+ private _recordService: RecordService
+ ) { }
/**
* Load organisation record
* @param pid - string
*/
loadOrganisationByPid(pid: string) {
- this._recordService.getRecord('organisations', pid)
- .pipe(
- map((record: any) => this._record = record.metadata)
- )
- .subscribe((organisation: any) => {
- this._onOrganisationLoaded.next(organisation);
- });
+ this._recordService
+ .getRecord('organisations', pid)
+ .subscribe((orgRecord: any) => {
+ this._record = orgRecord.metadata;
+ this._onOrganisationLoaded.next(this._record);
+ });
}
}
diff --git a/projects/shared/src/lib/service/user.service.ts b/projects/shared/src/lib/service/user.service.ts
index 8970b9fe9..0499152da 100644
--- a/projects/shared/src/lib/service/user.service.ts
+++ b/projects/shared/src/lib/service/user.service.ts
@@ -73,9 +73,9 @@ export class UserService {
this._permissionsService.setPermissions(loggedUser.permissions);
}
this._user = new User(loggedUser);
- this._loaded.next(this._user);
- return this._user;
- })
+ this._loaded.next(this._user);
+ return this._user;
+ })
);
}
}