Skip to content

Commit

Permalink
admin: Wrong organisation on select menu
Browse files Browse the repository at this point in the history
* Closes rero#389

Co-Authored-by: Bertrand Zuchuat <[email protected]>
  • Loading branch information
Garfield-fr authored and rerowep committed Aug 22, 2019
1 parent 0b0c79a commit eb2adc0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"key": "organisation.$ref",
"type": "select",
"remoteRecordType": "organisations",
"remoteRecordFiltersByOwningOrganisation": "pid",
"readonly": "true"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"title": "Organisation",
"key": "organisation.$ref",
"type": "select",
"remoteRecordType": "organisations"
"remoteRecordType": "organisations",
"remoteRecordFiltersByOwningOrganisation": "pid"
},
{
"type": "flex",
Expand Down Expand Up @@ -59,4 +60,4 @@
}
]
}
]
]
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"key": "organisation.$ref",
"type": "select",
"remoteRecordType": "organisations",
"remoteRecordFiltersByOwningOrganisation": "pid",
"readonly": "true"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,14 @@ export class RemoteSelectComponent implements OnInit {
this.userService.loggedUser.subscribe(user => {
// TODO: find a cleanest way to do it
let query = '';
const fieldToFilter = this.options.remoteRecordFiltersByOwningLibrary;
let fieldToFilter = this.options.remoteRecordFiltersByOwningLibrary;
if (fieldToFilter && !user.roles.some(role => role === 'system_librarian')) {
query = `${fieldToFilter}:${user.library.pid}`;
}
fieldToFilter = this.options.remoteRecordFiltersByOwningOrganisation;
if (fieldToFilter && user.roles.some(role => role === 'system_librarian')) {
query = `${fieldToFilter}:${user.library.organisation.pid}`;
}
this.recordsService.getRecords('global', remoteRecordType, 1, 30, query).subscribe(data => {
data.hits.hits.map(record => {
const urlPrefix = this.apiService.getApiEntryPointByType(remoteRecordType, true);
Expand Down

0 comments on commit eb2adc0

Please sign in to comment.