Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

documents: display all fields on the detail view #679

Merged
merged 1 commit into from
Sep 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion projects/admin/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ import { MenuUserServicesComponent } from './menu/menu-user-services/menu-user-s
import { MenuUserComponent } from './menu/menu-user/menu-user.component';
import { MenuComponent } from './menu/menu.component';
import { LibrarySwitchService } from './menu/service/library-switch.service';
import { DocumentProvisionActivityPipe } from './pipe/document-provision-activity.pipe';
import { ItemInCollectionPipe } from './pipe/item-in-collection.pipe';
import { MainTitleRelationPipe } from './pipe/main-title-relation.pipe';
import { MarcPipe } from './pipe/marc.pipe';
import { NotesFormatPipe } from './pipe/notes-format.pipe';
import { SubjectProcessPipe } from './pipe/subject-process.pipe';
Expand Down Expand Up @@ -109,6 +111,13 @@ import {
} from './record/detail-view/contribution-detail-view/corporate-bodies-detail-view/corporate-bodies-detail-view.component';
import { PersonDetailViewComponent } from './record/detail-view/contribution-detail-view/person-detail-view/person-detail-view.component';
import { DialogImportComponent } from './record/detail-view/document-detail-view/dialog-import/dialog-import.component';
import { DescriptionZoneComponent } from './record/detail-view/document-detail-view/document-description/description-zone/description-zone.component';
import {
DocumentDescriptionComponent
} from './record/detail-view/document-detail-view/document-description/document-description.component';
import {
OtherEditionComponent
} from './record/detail-view/document-detail-view/document-description/other-edition/other-edition.component';
import { DocumentDetailViewComponent } from './record/detail-view/document-detail-view/document-detail-view.component';
import { HoldingDetailComponent } from './record/detail-view/document-detail-view/holding-detail/holding-detail.component';
import { HoldingSharedViewComponent } from './record/detail-view/document-detail-view/holding-shared-view/holding-shared-view.component';
Expand Down Expand Up @@ -267,7 +276,12 @@ export function appInitFactory(appInitService: AppInitService) {
CirculationLogsComponent,
CirculationLogsDialogComponent,
CirculationLogComponent,
ItemInCollectionPipe
ItemInCollectionPipe,
DocumentDescriptionComponent,
OtherEditionComponent,
DescriptionZoneComponent,
DocumentProvisionActivityPipe,
MainTitleRelationPipe
],
imports: [
AppRoutingModule,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* 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 { TestBed } from '@angular/core/testing';
import { DocumentProvisionActivityPipe } from './document-provision-activity.pipe';

describe('ProvisionActivityPipe', () => {

let pipe: DocumentProvisionActivityPipe;

const provisionActivity = [
{
_text: [{ language: 'default', value: 'Brussels : Ed. Artoria, [1999]'}],
place: [{ country: 'be', type: 'bf:place'}],
startDate: 1999,
statement: [
{
label: [{ value: 'Brussels'}],
type: 'bf:Place'
},
{
label: [{ value: 'Ed. Artoria'}],
type: 'bf:Agent'
},
{
label: [{ value: '[1999]'}],
type: 'Date'
}
],
type: 'bf:Publication'
},
{
_text: [{ language: 'default', value: 'Martigny'}],
statement: [
{
label: [{ value: 'Martigny'}],
type: 'bf:Place'
}
],
type: 'bf:Distribution'
}
];

const provisionActivityResult = {
'bf:Publication': [ 'Brussels : Ed. Artoria, [1999]' ],
'bf:Distribution': [ 'Martigny' ] };

beforeEach(() => {
TestBed.configureTestingModule({
providers: [
DocumentProvisionActivityPipe
]
});
pipe = TestBed.inject(DocumentProvisionActivityPipe);
});

it('create an instance', () => {
expect(pipe).toBeTruthy();
});

it('should transform the data', () => {
expect(pipe.transform(provisionActivity)).toEqual(provisionActivityResult);
});
});
45 changes: 45 additions & 0 deletions projects/admin/src/app/pipe/document-provision-activity.pipe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* 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 { Pipe, PipeTransform } from '@angular/core';

@Pipe({
name: 'documentProvisionActivity'
})
export class DocumentProvisionActivityPipe implements PipeTransform {

/**
* Process provision activity field
* @param provisionActivity - provision activity data
* @returns Object
*/
transform(provisionActivity: any): object {
if (undefined === provisionActivity) {
return [];
}
const results = {};
provisionActivity
.filter((element: any) => '_text' in element && 'statement' in element) // Keep only element with '_text'
.map((element: any) => {
const type = element.type;
if (!(type in results)) { // if type isn't yet init
results[type] = [];
}
element._text.map((e: { language: string, value: string }) => results[type].push(e.value));
});
return results;
}
}
47 changes: 47 additions & 0 deletions projects/admin/src/app/pipe/main-title-relation.pipe.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* 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 { MainTitleRelationPipe } from './main-title-relation.pipe';

describe('MainTitleRelationPipe', () => {
const title = [
{
mainTitle: [{value: 'J. Am. Med. Assoc.'}],
type: 'bf:AbbreviatedTitle'
},
{
mainTitle: [{value: 'J Am Med Assoc'}],
type: 'bf:KeyTitle'
},
{
_text: 'Journal of the American medical association',
mainTitle: [{
value: 'Journal of the American medical association'
}],
type: 'bf:Title'
}
];

it('create an instance', () => {
const pipe = new MainTitleRelationPipe();
expect(pipe).toBeTruthy();
});

it('should return only the main title', () => {
const pipe = new MainTitleRelationPipe();
expect(pipe.transform(title)).toContain('Journal of the American medical association');
});
});
34 changes: 34 additions & 0 deletions projects/admin/src/app/pipe/main-title-relation.pipe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* 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 { Pipe, PipeTransform } from '@angular/core';

@Pipe({
name: 'mainTitleRelation'
})
export class MainTitleRelationPipe implements PipeTransform {

/**
* Extract main title for relation
* @param value - array of title field
* @returns the first main title with _text field
*/
transform(value: any[]): string {
const mainTitle = value.filter((title: any) => title.type === 'bf:Title');
return mainTitle[0]._text;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!--
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="row">
<div class="font-weight-bold col-3">
<ng-content select="[label]"></ng-content>
</div>
<div class="col-9">
<ng-content select="[content]"></ng-content>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* 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 { DescriptionZoneComponent } from './description-zone.component';


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

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ DescriptionZoneComponent ]
})
.compileComponents();
});

beforeEach(() => {
fixture = TestBed.createComponent(DescriptionZoneComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* 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';

@Component({
selector: 'admin-description-zone',
templateUrl: './description-zone.component.html'
})
export class DescriptionZoneComponent { }
Loading