-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
documents: display all fields on the detail view
Co-Authored-by: Bertrand Zuchuat <bertrand.zuchuat@rero.ch>
- Loading branch information
1 parent
b169a1a
commit 395414f
Showing
18 changed files
with
1,157 additions
and
398 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
projects/admin/src/app/pipe/document-provision-activity.pipe.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
45
projects/admin/src/app/pipe/document-provision-activity.pipe.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...ocument-detail-view/document-description/description-zone/description-zone.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
41 changes: 41 additions & 0 deletions
41
...ment-detail-view/document-description/description-zone/description-zone.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); |
23 changes: 23 additions & 0 deletions
23
.../document-detail-view/document-description/description-zone/description-zone.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { } |
Oops, something went wrong.