Skip to content

Commit 3a3b175

Browse files
author
Nestor Diaz
committed
Merge branch 'beta'
2 parents f1f727f + c3ee338 commit 3a3b175

11 files changed

Lines changed: 118 additions & 50 deletions

File tree

src/app/pages/submission/submission-direct/direct-submit-file.component.html

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,25 @@
1818
</div>
1919
<h5 class="st-direct-submit-file-name m-0">{{file.name}}</h5>
2020
</div>
21-
<span *ngIf="!hasSubmitFailed && isStudy">
22-
{{project ? project : 'No project'}}
23-
</span>
21+
<div *ngIf="hasSubmitPassed">
22+
<p class="card-title">
23+
<strong>{{accno}}</strong>
24+
</p>
25+
<dl class="row mb-0">
26+
<dt class="col-sm-6" *ngIf="releaseDate">Release Date</dt>
27+
<dd class="col-sm-6" *ngIf="releaseDate">{{releaseDate | date: 'dd MMM yyyy'}}</dd>
28+
<dd class="col-sm-6" *ngIf="!releaseDate">No release date</dd>
29+
30+
<dt class="col-sm-6" *ngIf="isStudy">Project</dt>
31+
<dd class="col-sm-6" *ngIf="isStudy">{{project ? project : 'No project'}}</dd>
32+
</dl>
33+
</div>
2434
<span class="text-danger" *ngIf="hasSubmitFailed">
2535
{{error}}
2636
</span>
2737
<div class="overflow-auto" *ngIf="hasSubmitFailed">
2838
<st-subm-results-tree [log]="errorLog"></st-subm-results-tree>
2939
</div>
30-
<div *ngIf="hasSubmitPassed" class="text-right">
31-
<p class="card-title">
32-
<strong>{{accno}}</strong>
33-
</p>
34-
<span *ngIf="releaseDate">
35-
<i class="fa fa-bullhorn"></i>&nbsp; {{releaseDate | date: 'dd MMM yyyy'}}
36-
</span>
37-
<span *ngIf="!releaseDate">
38-
No release date
39-
</span>
40-
</div>
4140
</div>
4241
<div *ngIf="!hasSubmitFailed && !hasSubmitPassed" class="card-footer text-muted"
4342
(click)="handleOnIsStudyChange(!isStudy, fileName)">

src/app/pages/submission/submission-direct/direct-submit.component.html

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,9 @@ <h4>{{pluralise('Study')}} {{sidebar.submitType + 'd'}}</h4>
117117
<i class="fa fa-fw fa-external-link-square"></i>
118118
</a>
119119
</strong>
120-
<p>
121-
McEntyre J, Sarkans U, Brazma A (2015) The
122-
BioStudies database. <i>Mol. Syst. Biol.</i> 11(12):847.
123-
https://doi.org/10.15252/msb.20156658.
120+
<p>Sarkans U, Gostev M, Athar A, et al. <a href="http://doi.org/10.1093/nar/gkx965">The BioStudies
121+
database-one stop shop for all data supporting a life sciences study.</a>
122+
<i>Nucleic Acids Res.</i> 2018;46(D1):D1266-D1270. doi:10.1093/nar/gkx965
124123
</p>
125124
</ng-container>
126125
</div>

src/app/pages/submission/submission-direct/direct-submit.service.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,25 @@ export class DirectSubmitRequest {
8989
return this.directSubmissionReleaseDate;
9090
}
9191

92+
private extractReleaseDate(res: SubmitResponse): string {
93+
const { attributes = [], section } = res;
94+
let releaseDate;
95+
96+
if (attributes.length > 0) {
97+
const releaseDateAttribute = attributes.find((attribute) => attribute.name === 'ReleaseDate');
98+
99+
releaseDate = releaseDateAttribute ? releaseDateAttribute.value : null;
100+
}
101+
102+
if (!releaseDate && section && section.attributes && section.attributes.length > 0) {
103+
const releaseDateAttribute = section.attributes.find((attribute) => attribute.name === 'ReleaseDate');
104+
105+
releaseDate = releaseDateAttribute ? releaseDateAttribute.value : null;
106+
}
107+
108+
return releaseDate;
109+
}
110+
92111
/**
93112
* Handler for responses from conversion or final submission, updating request status accordingly.
94113
* @param res - Data object representative of response to the request.
@@ -110,6 +129,7 @@ export class DirectSubmitRequest {
110129

111130
// exposes the accession number
112131
this.directSubmissionAccno = res.accno;
132+
this.directSubmissionReleaseDate = this.extractReleaseDate(res);
113133
}
114134
}
115135
}

src/app/pages/submission/submission-edit/subm-form/field/subm-field.component.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ export class SubmFieldComponent {
6060
}
6161

6262
get isEmpty(): boolean {
63+
if (Array.isArray(this.fieldControl!.control.value)) {
64+
return this.fieldControl!.control.value.length === 0;
65+
}
66+
6367
return isStringEmpty(this.fieldControl!.control.value as string);
6468
}
6569

src/app/pages/submission/submission-shared/model/pagetab/pagetab-attributes.utils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ export function mergeAttributes(attrs1: PtAttribute[], attrs2: PtAttribute[]): P
2222
return merged.filter((attr) => !isAttributeEmpty(attr));
2323
}
2424

25+
export function findAttributesByName(name: string, attributes: PtAttribute[]): PtAttribute[] {
26+
return attributes.filter((attribute) => attribute.name === name);
27+
}
28+
2529
export function extractKeywordsFromAttributes(attributes: PtAttribute[]): PtAttribute[] {
2630
return attributes.filter((attribute) => attribute.name === 'Keyword');
2731
}

src/app/pages/submission/submission-shared/model/submission/submission.model.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ export class Feature {
182182
const rowValue = rowMap.valueFor(pair[1].id);
183183

184184
if (rowValue) {
185-
rowValue.value = pair[0].value || '';
185+
rowValue.value = (pair[0].value || '') as string;
186186
}
187187
});
188188
});
@@ -628,7 +628,7 @@ export interface AttributeData {
628628
name: string;
629629
reference?: boolean;
630630
terms?: NameAndValue[];
631-
value?: string;
631+
value?: string | string[];
632632
}
633633

634634
export interface FeatureData {

src/app/pages/submission/submission-shared/model/templates/bia.template.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export const biaTemplate = {
5454
display: 'required',
5555
valueType: {
5656
name: 'select',
57+
multiple: true,
5758
values: [
5859
'Homo sapiens (human)',
5960
'Mus musculus (mouse)',

src/app/pages/submission/submission-shared/model/templates/default.template.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export const defaultTemplate = {
4040
display: 'required',
4141
valueType: {
4242
name: 'select',
43+
multiple: true,
4344
values: [
4445
'Homo sapiens (human)',
4546
'Mus musculus (mouse)',

src/app/pages/submission/submission-shared/pagetab-to-submission.service.ts

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,19 @@ import {
77
PageTabSection,
88
PtAttribute,
99
authorsToContacts,
10-
extractKeywordsFromAttributes,
1110
mergeAttributes,
1211
pageTabToSubmissionProtocols,
1312
PtLink,
14-
PtFile
13+
PtFile,
14+
findAttributesByName
1515
} from './model/pagetab';
1616
import { AttributeData, FeatureData, SectionData, Submission, SubmissionData } from './model/submission';
1717
import { DEFAULT_TEMPLATE_NAME, READONLY_TEMPLATE_NAME, SubmissionType } from './model/templates';
1818
import { NameAndValue, PAGE_TAG, Tag } from './model/model.common';
1919
import { findAttribute } from './utils/pagetab.utils';
2020

21+
const multiValueAttributeNames = ['Organism'];
22+
2123
@Injectable()
2224
export class PageTabToSubmissionService {
2325
pageTab2Submission(pageTab: PageTab): Submission {
@@ -66,16 +68,37 @@ export class PageTabToSubmissionService {
6668
return hasSubsection || hasLinks || hasFiles || hasLibraryFile || hasPageTag;
6769
}
6870

71+
private attributeToAttributeData(attr: PtAttribute): AttributeData {
72+
return {
73+
name: attr.name || '',
74+
reference: attr.reference || attr.isReference,
75+
terms: (attr.valqual || []).map((t) => new NameAndValue(t.name, t.value)),
76+
value: attr.value
77+
};
78+
}
79+
6980
private pageTabAttributesToAttributeData(attrs: PtAttribute[]): AttributeData[] {
70-
return attrs.map(
71-
(at) =>
72-
({
73-
name: at.name,
74-
reference: at.reference || at.isReference,
75-
terms: (at.valqual || []).map((t) => new NameAndValue(t.name, t.value)),
76-
value: at.value
77-
} as AttributeData)
78-
);
81+
const attributesData: AttributeData[] = [];
82+
const otherAttributes = attrs.filter((attr) => !multiValueAttributeNames.includes(attr.name || ''));
83+
84+
multiValueAttributeNames.forEach((multiValueAttributeName) => {
85+
const multiValueAttributes = attrs.filter(
86+
(attr) => attr.name === multiValueAttributeName && attr.value !== undefined
87+
);
88+
89+
if (multiValueAttributes.length > 0) {
90+
const firstAttribute = multiValueAttributes[0];
91+
const values = multiValueAttributes.map((attr) => attr.value) as string[];
92+
93+
attributesData.push(this.attributeToAttributeData({ ...firstAttribute, value: values }));
94+
}
95+
});
96+
97+
otherAttributes.forEach((attr) => {
98+
attributesData.push(this.attributeToAttributeData(attr));
99+
});
100+
101+
return attributesData;
79102
}
80103

81104
private pageTabSectionToSectionData(ptSection: PageTabSection, parentAttributes: PtAttribute[] = []): SectionData {
@@ -91,7 +114,7 @@ export class PageTabToSubmissionService {
91114
const subsections = flatArray(ptSection.subsections || []);
92115
const contacts = authorsToContacts(subsections.filter((section) => !this.hasSubsections(section)));
93116
const featureSections = pageTabToSubmissionProtocols(contacts);
94-
const keywords = extractKeywordsFromAttributes(ptSection.attributes || []);
117+
const keywords = findAttributesByName('Keywords', ptSection.attributes || []);
95118

96119
const features: FeatureData[] = [];
97120
const hasLinks = links.length > 0;

src/app/pages/submission/submission-shared/submission-to-pagetab.service.ts

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
submissionToPageTabProtocols
1515
} from './model/pagetab';
1616
import { isArrayEmpty, isStringDefined, isEqualIgnoringCase, isAttributeEmpty, isDefinedAndNotEmpty } from 'app/utils';
17-
import { AttributeData, Feature, Section, Submission } from './model/submission';
17+
import { AttributeData, Feature, Field, Fields, Section, Submission } from './model/submission';
1818
import { DEFAULT_TEMPLATE_NAME, SubmissionType } from './model/templates';
1919
import { Injectable } from '@angular/core';
2020

@@ -192,24 +192,38 @@ export class SubmissionToPageTabService {
192192
return protocolSections.concat(section.sections.list().map((s) => this.sectionToPtSection(s, isSanitize)));
193193
}
194194

195-
private fieldsAsAttributes(section: Section, isSanitise: boolean): any[] {
196-
return section.fields
197-
.list()
198-
.map((field) => {
199-
if (field.valueType.isRich()) {
200-
const fieldValue: string = field.value || '';
201-
const [richValue] = fieldValue.split('@');
202-
203-
return {
204-
name: field.name,
205-
value: richValue,
206-
valqual: [{ name: 'display', value: 'html' }]
207-
} as PtAttribute;
208-
}
195+
private fieldAsAttribute(field: Field, displayType?: string): PtAttribute {
196+
if (displayType) {
197+
return {
198+
name: field.name,
199+
value: field.value,
200+
valqual: [{ name: 'display', value: displayType }]
201+
} as PtAttribute;
202+
}
203+
204+
return { name: field.name, value: field.value } as PtAttribute;
205+
}
206+
207+
private fieldsAsAttributes(section: Section, isSanitise: boolean): PtAttribute[] {
208+
const fields: Field[] = section.fields.list();
209+
const attributes: PtAttribute[] = [];
210+
211+
fields.forEach((field) => {
212+
if (field.valueType.isRich()) {
213+
const fieldValue: string = field.value || '';
214+
const [richValue] = fieldValue.split('@');
215+
216+
attributes.push(this.fieldAsAttribute({ name: field.name, value: richValue } as Field, 'html'));
217+
} else if (Array.isArray(field.value)) {
218+
field.value.forEach((value) => {
219+
attributes.push(this.fieldAsAttribute({ name: field.name, value } as Field));
220+
});
221+
} else {
222+
attributes.push({ name: field.name, value: field.value } as Field);
223+
}
224+
});
209225

210-
return { name: field.name, value: field.value } as PtAttribute;
211-
})
212-
.filter((attr) => (isSanitise && !isAttributeEmpty(attr)) || !isSanitise);
226+
return attributes.filter((attr) => (isSanitise && !isAttributeEmpty(attr)) || !isSanitise);
213227
}
214228

215229
private sectionToPtSection(section: Section, isSanitise: boolean = false): PageTabSection {

0 commit comments

Comments
 (0)