Skip to content
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
1 change: 1 addition & 0 deletions src/breeding-insight/model/Observation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export class Observation {
season?: Season;
level?: string;
value?: any;
observationTimeStamp?: string;

constructor(id?: string,
studyId?: string,
Expand Down
5 changes: 4 additions & 1 deletion src/breeding-insight/model/import/ImportPreview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ import {ImportPreviewStatistics} from "@/breeding-insight/model/import/ImportPre
export class ImportPreview {
statistics?: {[key: string]: ImportPreviewStatistics};
rows?: any[];
dynamicColumnNames?: string[];

constructor({statistics, rows}: ImportPreview) {
constructor({statistics, rows, dynamicColumnNames}: ImportPreview) {
this.statistics = statistics;
this.rows = rows;
this.dynamicColumnNames = dynamicColumnNames;

}
}
26 changes: 14 additions & 12 deletions src/views/import/ImportExperiment.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
v-bind:loading="false"
v-bind:pagination="previewData.pagination"
v-on:show-error-notification="$emit('show-error-notification', $event)"
scrollable
>
<!-- Germplasm Name -->
<b-table-column field="germplasmName" label="Germplasm Name" v-slot="props" :th-attrs="(column) => ({scope:'col'})"
Expand Down Expand Up @@ -128,9 +129,9 @@
<b-table-column field="expTreatmentFactorName" label="Treatment Factors" v-slot="props" :th-attrs="(column) => ({scope:'col'})">
{{ getTreatment(props.row.data.observationUnit) }}
</b-table-column>

<!-- Dynamic Phenotype and Timestamp Columns -->
<b-table-column v-for="variable in phenotypeColumns" :key="variable" :label="variable" v-slot="props" :th-attrs="(column) => ({scope:'col'})">
{{ props.row.data.observations.filter(observation => observation.brAPIObject.observationVariableName === variable)[0].brAPIObject.value }}
<p> {{ retrieveDynamicColVal(props.row.data.observations, variable) }}</p>
</b-table-column>

<template v-slot:emptyMessage>
Expand Down Expand Up @@ -231,21 +232,22 @@ export default class ImportExperiment extends ProgramsBase {

importFinished(){}

previewDataLoaded(data: any[]) {
if (data.length > 0) {
const firstRow = data[0];
if (firstRow.observations && firstRow.observations.length > 0) {
this.phenotypeColumns = firstRow.observations.map((observation: any) =>
{
return observation.brAPIObject.observationVariableName;
});
}
}
previewDataLoaded(dynamicColumns: String[]) {
this.phenotypeColumns = dynamicColumns;
}

isExisting(rows: any[]) {
return rows.length && rows[0].trial.state === ImportObjectState.EXISTING;
}

retrieveDynamicColVal(importReturnObject: any, column: string){
if (column.startsWith('TS:')) {
//Is timestamp
return importReturnObject.filter((observation: { brAPIObject: { observationVariableName: string; }; }) => observation.brAPIObject.observationVariableName === column.replace(/TS:\s*/,""))[0].brAPIObject.observationTimeStamp;
} else {
//Is phenotype observation
return importReturnObject.filter((observation: { brAPIObject: { observationVariableName: string; }; }) => observation.brAPIObject.observationVariableName === column)[0].brAPIObject.value
}
}
}
</script>
4 changes: 3 additions & 1 deletion src/views/import/ImportTemplate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ export default class ImportTemplate extends ProgramsBase {
private previewData: any[] = [];
private previewTotalRows: number = 0;
private newObjectCounts: any = [];
private dynamicColumns: string[] | undefined = [];

private file : File | null = null;
private import_errors: ValidationError | String | null = null;
Expand Down Expand Up @@ -493,7 +494,8 @@ export default class ImportTemplate extends ProgramsBase {
this.previewTotalRows = previewResponse.preview.rows.length;
this.previewData = previewResponse.preview.rows as any[];
this.newObjectCounts = previewResponse.preview.statistics;
this.$emit('preview-data-loaded', this.previewData);
this.dynamicColumns = previewResponse.preview.dynamicColumnNames;
this.$emit('preview-data-loaded', this.dynamicColumns);
this.importService.send(ImportEvent.IMPORT_SUCCESS);
// TODO: Temp pagination
this.pagination.totalCount = previewResponse.preview.rows.length;
Expand Down