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
13 changes: 10 additions & 3 deletions src/breeding-insight/model/DatasetTableRow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ export class DatasetTableRow {
obsUnitId?: string;
traitValues?: string[] = [];
treatmentFactors?: string;
subExpUnitId?: string;
subObsUnitId?: string;

constructor(germplasmName?: string,
gid?: string,
Expand All @@ -51,7 +53,9 @@ export class DatasetTableRow {
elevation?: number,
rtk?: string,
obsUnitId?: string,
traitValues?: string[]) {
traitValues?: string[],
subExpUnitId?: string,
subObsUnitId?: string) {
this.germplasmName = germplasmName;
this.gid = gid;
this.testOrCheck = testOrCheck;
Expand All @@ -69,7 +73,8 @@ export class DatasetTableRow {
this.rtk = rtk;
this.obsUnitId = obsUnitId;
this.traitValues = traitValues;

this.subExpUnitId = subExpUnitId;
this.subObsUnitId = subObsUnitId;
}

static assign(dataset: DatasetTableRow): DatasetTableRow {
Expand All @@ -91,7 +96,9 @@ export class DatasetTableRow {
dataset.elevation,
dataset.rtk,
dataset.obsUnitId,
dataset.traitValues
dataset.traitValues,
dataset.subExpUnitId,
dataset.subObsUnitId
);
}

Expand Down
57 changes: 55 additions & 2 deletions src/views/import/Dataset.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
v-bind:pagination="paginationController"
v-bind:debounce-search="400"
v-on:show-error-notification="$emit('show-error-notification', $event)"
v-bind:default-sort="['data.envLocation', 'desc']"
>
<b-table-column
v-slot="props"
Expand Down Expand Up @@ -131,6 +132,18 @@
>
{{ props.row.data.expUnitId }}
</b-table-column>
<b-table-column
v-if="isSubEntity"
v-slot="props"
field="data.subExpUnitId"
:custom-sort="sortSubUnitId"
label="Sub Unit ID"
sortable
searchable
:th-attrs="() => ({scope:'col'})"
>
{{ props.row.data.subExpUnitId }}
</b-table-column>
<b-table-column
v-slot="props"
field="data.expReplicate"
Expand Down Expand Up @@ -239,6 +252,18 @@
{{ props.row.data.obsUnitId }}
</b-table-column>

<b-table-column
v-if="isSubEntity"
v-slot="props"
field="data.subObsUnitId"
v-bind:label="subObsUnitIDLabel"
sortable
searchable
:th-attrs="() => ({scope:'col'})"
>
{{ props.row.data.subObsUnitId }}
</b-table-column>

<b-table-column
v-for="( observationVariable, index ) in this.datasetModel.observationVariables" :key="observationVariable.observationVariableName"
v-slot="props"
Expand Down Expand Up @@ -308,6 +333,9 @@ export default class Dataset extends ProgramsBase {
private datasetTableRows: DatasetTableRow[] = [];
private unitDbIdToTraitValues: any = {};
private obsUnitIDLabel :string = "ObsUnitID";
private subObsUnitIDLabel :string = "";
private isSubEntity = false;
private subObservationUnit = "";

mounted() {
this.load();
Expand Down Expand Up @@ -417,6 +445,18 @@ export default class Dataset extends ProgramsBase {
}
}

// This sorts the Sub Unit ID's in Alphanumeric order (ie. B300,BO2, B1 would sort to B1, B02, B300)
sortSubUnitId(a: any, b: any, isAsc: boolean) {
let first: any = (a.data.subExpUnitId);
let second: any = (b.data.subExpUnitId);
if (isAsc) {
return first.toString().localeCompare(second.toString(), 'en', {numeric: true});
} else {
return second.toString().localeCompare(first.toString(), 'en', {numeric: true});

}
}

/*
* remove the '[....]' found at the end of the string
* */
Expand Down Expand Up @@ -447,9 +487,17 @@ export default class Dataset extends ProgramsBase {

datasetTableRow.env = this.removeUnique(unit.studyName);
datasetTableRow.envLocation = this.removeUnique(unit.locationName);
datasetTableRow.expUnitId = this.removeUnique(unit.observationUnitName);
datasetTableRow.obsUnitId = BrAPIUtils.getBreedingInsightId(unit.externalReferences, "/observationunits");

if(!this.isSubEntity){
datasetTableRow.expUnitId = this.removeUnique(unit.observationUnitName);
datasetTableRow.obsUnitId = BrAPIUtils.getBreedingInsightId(unit.externalReferences, "/observationunits");
} else {
let parentObsInfo = unit.observationUnitPosition.observationLevelRelationships.find((val) => val.levelOrder === 0);
if (parentObsInfo) datasetTableRow.obsUnitId = this.removeUnique(parentObsInfo.levelCode);
datasetTableRow.expUnitId = unit.additionalInfo.expUnitID;
datasetTableRow.subExpUnitId = this.removeUnique(unit.observationUnitName);
datasetTableRow.subObsUnitId = BrAPIUtils.getBreedingInsightId(unit.externalReferences, "/observationunits");
}

// Env Year
datasetTableRow.envYear = "";
Expand Down Expand Up @@ -568,6 +616,7 @@ export default class Dataset extends ProgramsBase {

setObsUnitIDLabel(){
this.obsUnitIDLabel = this.observationUnit + " ObsUnitID"
if (this.isSubEntity) this.subObsUnitIDLabel = this.subObservationUnit + " ObsUnitID"
}

@Watch('$route')
Expand All @@ -592,6 +641,9 @@ export default class Dataset extends ProgramsBase {
if (response.isErr()) throw response.value;
this.datasetModel = response.value;

// Use this.datasetModel to determine if this table is for a top level or sub entity dataset
if (this.datasetModel.observationUnits[0].observationUnitPosition.observationLevelRelationships.length > 2) this.isSubEntity = true;

// Use this.datasetModel to initialize this.unitDbIdToTraitValues
this.unitDbIdToTraitValues = this.createUnitDbIdToTraitValues();

Expand All @@ -600,6 +652,7 @@ export default class Dataset extends ProgramsBase {
this.createDatasetTableRows();

// Set the obsUnitId label to include observation level
if (this.isSubEntity) this.subObservationUnit = this.datasetModel.observationUnits[0].additionalInfo.observationLevel;
this.setObsUnitIDLabel();

//Initialize the paginationController
Expand Down