Skip to content

Commit

Permalink
local fields: allow librarian to add local fields
Browse files Browse the repository at this point in the history
* Adds local fields on document, item and serial holding (serial type)
* Adds holding informations on the detail screen

Co-Authored-by: Bertrand Zuchuat <bertrand.zuchuat@rero.ch>
  • Loading branch information
Garfield-fr committed Nov 19, 2020
1 parent 8b19087 commit d9f004b
Show file tree
Hide file tree
Showing 17 changed files with 642 additions and 135 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

.holding-detail {
margin-left: 1em;
}
import { inject, TestBed } from '@angular/core/testing';
import { LocalFieldApiService } from './local-field-api.service';

describe('Service: LocalFieldApi', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [LocalFieldApiService]
});
});

it('should ...', inject([LocalFieldApiService], (service: LocalFieldApiService) => {
expect(service).toBeTruthy();
}));
});
71 changes: 71 additions & 0 deletions projects/admin/src/app/api/local-field-api.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* RERO ILS UI
* 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 <http://www.gnu.org/licenses/>.
*/

import { Injectable } from '@angular/core';
import { RecordService, RecordUiService } from '@rero/ng-core';
import { map } from 'rxjs/operators';

@Injectable({
providedIn: 'root'
})
export class LocalFieldApiService {

/**
* Constructor
* @param _recordService - RecordService
*/
constructor(
private _recordService: RecordService,
private _recordUiService: RecordUiService
) { }

/**
* Get Local field for current resource and organisation user
* @param resourceType - string, type of resource
* @param resourcePid - string, pid of resource
* @param organisationPid - string, pid of organisation
* @return Observable
*/
getByResourceTypeAndResourcePidAndOrganisationId(
resourceType: string,
resourcePid: string,
organisationPid: string
) {
const query = [
`parent_ref.type:${resourceType}`,
`parent_ref.pid:${resourcePid}`,
`organisation.pid:${organisationPid}`,
].join(' AND ');

return this._recordService.getRecords('local_fields', query, 1, 1).pipe(
map((result: any) => {
return this._recordService.totalHits(result.hits.total) > 0
? result.hits.hits[0]
: {};
})
);
}

/**
* Delete local fields by resource pid
* @param resourcePid - string, pid of resource
* @return Observable
*/
deleteByPid(resourcePid: string) {
return this._recordUiService.deleteRecord('local_fields', resourcePid);
}
}
4 changes: 3 additions & 1 deletion projects/admin/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ import { UiRemoteTypeaheadService } from './service/ui-remote-typeahead.service'
import { CustomShortcutHelpComponent } from './widgets/custom-shortcut-help/custom-shortcut-help.component';
import { FrontpageBoardComponent } from './widgets/frontpage/frontpage-board/frontpage-board.component';
import { FrontpageComponent } from './widgets/frontpage/frontpage.component';
import { LocalFieldComponent } from './record/detail-view/local-field/local-field.component';

/** Init application factory */
export function appInitFactory(appInitService: AppInitService) {
Expand Down Expand Up @@ -217,7 +218,8 @@ export function appInitFactory(appInitService: AppInitService) {
CustomShortcutHelpComponent,
ContributionDetailViewComponent,
PersonDetailViewComponent,
CorporateBodiesDetailViewComponent
CorporateBodiesDetailViewComponent,
LocalFieldComponent
],
imports: [
AppRoutingModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ <h3 id="{{'doc-altgr-title-' + i}}">{{ altgr_title }}</h3>
<i class="fa fa-bars mr-1"></i><span translate>Description</span>
</ng-template>
<div class="mt-2">
<dl class="row mb-0">
<dl class="row mb-0 ml-1">
<!-- RESPONSIBILITY -->
<ng-container *ngIf="record.metadata.ui_responsibilities">
<ng-container *ngFor="let responsibility of record.metadata.ui_responsibilities;
Expand Down Expand Up @@ -464,17 +464,11 @@ <h3 id="{{'doc-altgr-title-' + i}}">{{ altgr_title }}</h3>
[attr.id]="i | idAttribute:{prefix: 'doc-identifier'}">
<ng-container *ngIf="identifier.type === 'uri'; else stringBlock">
<a class="rero-ils-external-link" href="{{ identifier.value }}">{{ identifier.value }}</a>
<ng-container *ngIf="identifier.details">
- {{ identifier.details }}
</ng-container>
</ng-container>
<ng-template #stringBlock>
{{ identifier.value }}
<ng-container *ngIf="identifier.details">
- {{ identifier.details }}
</ng-container>
</ng-template>
<small class="badge badge-secondary text-uppercase ml-1" translate>
<small class="badge badge-secondary text-uppercase ml-1">
{{ identifier.type }}
</small>
</li>
Expand Down Expand Up @@ -518,8 +512,20 @@ <h3 id="{{'doc-altgr-title-' + i}}">{{ altgr_title }}</h3>
</div>
</tab>
<!-- END OF DESCRIPTION TAB --------------------------------------------->

<!-- LOCAL FIELDS TAB ------------------------------------------------------------>
<tab id="documents-local-field-tab" tabOrder="4" *ngIf="!record.metadata.harvested">
<ng-template tabHeading>
<i class="fa fa-list-ul mr-1"></i><span translate>Local fields</span>
</ng-template>
<div class="mt-2">
<admin-local-field [resourceType]="'documents'" [resourcePid]="record.metadata.pid"></admin-local-field>
</div>
</tab>
<!-- END OF LOCAL FIELDS TAB ---------------------------------------------------->

<!-- MARC TAB ------------------------------------------------------------>
<tab id="documents-marc-tab" tabOrder="4" *ngIf="marc$ | async as marc">
<tab id="documents-marc-tab" tabOrder="5" *ngIf="marc$ | async as marc">
<ng-template tabHeading>
<i class="fa fa-list-ul mr-1"></i><span translate>Marc</span>
</ng-template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->

<div *ngIf="holding" class="row col-sm-11 holding-detail">
<div *ngIf="holding" class="row col-sm-12">
<!-- CALL NUMBER -->
<ng-container *ngIf="holding.metadata.call_number || holding.metadata.second_call_number">
<div class="col-sm-3 font-weight-bold" translate>
Expand Down Expand Up @@ -84,4 +84,14 @@
</div>
</ng-container>
</ng-container>

<!-- VENDOR -->
<ng-container *ngIf="holding.metadata.vendor">
<div class="col-sm-3 font-weight-bold" translate>
Vendor
</div>
<div class="col-sm-9">
{{ holding.metadata.vendor.pid | getRecord: 'vendors' : 'field' : 'name' | async }}
</div>
</ng-container>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ import { Component, Input } from '@angular/core';

@Component({
selector: 'admin-holding-detail',
templateUrl: './holding-detail.component.html',
styleUrls: ['./holding-detail.component.scss']
templateUrl: './holding-detail.component.html'
})
export class HoldingDetailComponent {

Expand Down
Loading

0 comments on commit d9f004b

Please sign in to comment.