Skip to content

Commit

Permalink
document: refactoring provision activity field for new structure
Browse files Browse the repository at this point in the history
Co-Authored-by: Bertrand Zuchuat <[email protected]>
  • Loading branch information
Garfield-fr committed Jan 22, 2020
1 parent f2b72d4 commit 2dc5511
Showing 1 changed file with 7 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,24 +131,18 @@ export class DocumentDetailViewComponent implements DetailRecord, OnInit {
if (undefined === provisions) {
return [];
}

const results = {};
provisions.forEach((element: any) => {
const type = element.type;
if (!(type in results)) {
results[type] = [];
}
if ('_text' in element) {
if (('_text' in element)) {
const elementText = element._text;
const keys = Object.keys(elementText);
const indexDefault = keys.indexOf('default');
if (indexDefault > -1) {
results[type].push(elementText.default);
keys.splice(indexDefault, 1);
if (!(type in results)) {
results[type] = [];
}

keys.forEach(key => {
results[type].push(elementText[key]);
});
elementText.map(
(e: {language: string, value: string}) => results[type].push(e.value)
);
}
});

Expand Down

0 comments on commit 2dc5511

Please sign in to comment.