Skip to content

Commit

Permalink
documents: display all fields on the detail view
Browse files Browse the repository at this point in the history
Co-Authored-by: Bertrand Zuchuat <bertrand.zuchuat@rero.ch>
  • Loading branch information
Garfield-fr committed Aug 4, 2021
1 parent b169a1a commit 395414f
Show file tree
Hide file tree
Showing 18 changed files with 1,157 additions and 398 deletions.
14 changes: 13 additions & 1 deletion projects/admin/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ 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 { MarcPipe } from './pipe/marc.pipe';
import { NotesFormatPipe } from './pipe/notes-format.pipe';
Expand Down Expand Up @@ -108,6 +109,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 @@ -266,7 +274,11 @@ export function appInitFactory(appInitService: AppInitService) {
CirculationLogsComponent,
CirculationLogsDialogComponent,
CirculationLogComponent,
ItemInCollectionPipe
ItemInCollectionPipe,
DocumentDescriptionComponent,
OtherEditionComponent,
DescriptionZoneComponent,
DocumentProvisionActivityPipe
],
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;
}
}
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

0 comments on commit 395414f

Please sign in to comment.