Skip to content

Commit

Permalink
document: check on the ISBN/ISSN type identifier and import function
Browse files Browse the repository at this point in the history
form: when an ISBN/ISSN identifier is entered on a document,
it is validated and searched in the instance to see if
a document with this reference exists (non-blocking validation).

When importing a document, all fields in the identifiedBy
field of the document are searched in the instance.

* Closes rero/rero-ils#1664

Co-Authored-by: Bertrand Zuchuat <bertrand.zuchuat@rero.ch>
  • Loading branch information
Garfield-fr committed Apr 16, 2021
1 parent 7a7cf37 commit 4fec0e0
Show file tree
Hide file tree
Showing 10 changed files with 458 additions and 25 deletions.
19 changes: 19 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
"document-register-element": "^1.14.10",
"font-awesome": "^4.7.0",
"https-proxy-agent": "^2.2.4",
"issn": "^1.0.6",
"jquery": "^3.6.0",
"lodash-es": "4.17.14",
"moment": "^2.29.1",
Expand All @@ -94,6 +95,7 @@
"ngx-spinner": "^10.0.1",
"ngx-toastr": "^13.2.1",
"rxjs": "^6.6.7",
"simple-isbn": "^1.1.5",
"tslib": "^2.1.0",
"zone.js": "~0.10.2"
},
Expand Down
14 changes: 9 additions & 5 deletions projects/admin/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ import { FrontpageComponent } from './widgets/frontpage/frontpage.component';
import { UserIdComponent } from './record/editor/wrappers/user-id/user-id.component';
import { UserIdEditorComponent } from './record/custom-editor/user-id-editor/user-id-editor.component';
import { RecordMaskedComponent } from './record/detail-view/record-masked/record-masked.component';
import { IdentifiedbyValueComponent } from './record/editor/wrappers/identifiedby-value.component';
import { DialogImportComponent } from './record/detail-view/document-detail-view/dialog-import/dialog-import.component';

/** Init application factory */
export function appInitFactory(appInitService: AppInitService) {
Expand Down Expand Up @@ -254,7 +256,9 @@ export function appInitFactory(appInitService: AppInitService) {
CipoPatronTypeItemTypeComponent,
UserIdComponent,
UserIdEditorComponent,
RecordMaskedComponent
RecordMaskedComponent,
IdentifiedbyValueComponent,
DialogImportComponent
],
imports: [
AppRoutingModule,
Expand All @@ -274,10 +278,10 @@ export function appInitFactory(appInitService: AppInitService) {
types: [
{ name: 'cipo-pt-it', component: CipoPatronTypeItemTypeComponent }
],
wrappers: [{
name: 'user-id',
component: UserIdComponent
}]
wrappers: [
{ name: 'user-id', component: UserIdComponent },
{ name: 'identifiedby-value', component: IdentifiedbyValueComponent }
]
}),
TranslateModule.forRoot({
loader: {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!--
RERO ILS UI
Copyright (C) 2021 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/>.
-->
<div class="modal-header">
<h4 class="modal-title pull-left" translate>Import</h4>
</div>
<div class="modal-body">
<h5 *ngIf="records.length < 2; else plurial" translate>A document is available</h5>
<ng-template #plurial>
<h5 translate>Documents are available</h5>
</ng-template>
<ul class="list-unstyled mb-0">
<li *ngFor="let record of records">
<a [routerLink]="['/records', 'documents', 'detail', record.metadata.pid]" (click)="close()">
<ng-container *ngIf="record.metadata.ui_title_text_responsibility; else noTitle">
{{ record.metadata.ui_title_text_responsibility }}
</ng-container>
<ng-template #noTitle>{{ 'Document' | translate }}</ng-template>
</a>
</li>
</ul>
<div class="font-weight-bold mt-3" translate>Do you want to import this document?</div>
</div>
<div class="modal-footer">
<button id="modal-cancel-button" type="button" class="btn btn-light" (click)="decline()" translate>Cancel</button>
<button id="modal-confirm-button" type="button" class="btn btn-primary" (click)="confirm()" translate>Import</button>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* RERO ILS UI
* Copyright (C) 2021 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 { ComponentFixture, TestBed } from '@angular/core/testing';
import { TranslateModule } from '@ngx-translate/core';
import { BsModalRef, ModalModule } from 'ngx-bootstrap/modal';
import { DialogImportComponent } from './dialog-import.component';


describe('DialogImportComponent', () => {
let component: DialogImportComponent;
let fixture: ComponentFixture<DialogImportComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [
ModalModule.forRoot(),
TranslateModule.forRoot()
],
declarations: [ DialogImportComponent ],
providers: [BsModalRef]
})
.compileComponents();
});

beforeEach(() => {
fixture = TestBed.createComponent(DialogImportComponent);
component = fixture.componentInstance;
component.records = [];
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* RERO ILS UI
* Copyright (C) 2021 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 { Component } from '@angular/core';
import { BsModalRef } from 'ngx-bootstrap/modal';
import { Subject } from 'rxjs';

@Component({
selector: 'admin-dialog-import',
templateUrl: './dialog-import.component.html'
})
export class DialogImportComponent {

/** Available record */
records: any[];

/** Observable for action */
confirmation$: Subject<boolean> = new Subject<boolean>();

/**
* Constructor
* @param _bsModalRef - BsModalRef
*/
constructor(private _bsModalRef: BsModalRef) {}

/** Confirm action */
confirm() {
this.confirmation$.next(true);
this.close();
}

/** Cancel action */
decline() {
this.confirmation$.next(false);
this.close();
}

/** Close modal box */
close() {
this._bsModalRef.hide();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
-->
<!-- import button for external source importation such as BNF -->
<div *ngIf="record && record.metadata && !record.metadata.pid && pid && source" class="float-right ml-4 mt-2 mb-4">
<a [routerLink]="['/records', 'documents', 'new']"
[queryParams]="{source: source, pid: pid}"
<a (click)="importDocument($event, record, { source: source, pid: pid })"
class="btn btn-sm btn-outline-primary"
translate>Import</a>
</div>
Expand Down
Loading

0 comments on commit 4fec0e0

Please sign in to comment.