Skip to content
Open
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
68 changes: 42 additions & 26 deletions src/views/import/Dataset.vue
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
<b-table-column
v-slot="props"
field="data.expReplicate"
:custom-sort="sortExpReplicate"
label="Exp Replicate #"
sortable
searchable
Expand All @@ -157,6 +158,7 @@
v-slot="props"
field="data.expBlock"
label="Exp Block #"
:custom-sort="sortExpBlock"
sortable
searchable
:th-attrs="() => ({scope:'col'})"
Expand All @@ -167,6 +169,7 @@
v-slot="props"
field="data.row"
label="Row"
:custom-sort="sortRow"
sortable
searchable
:th-attrs="() => ({scope:'col'})"
Expand All @@ -177,6 +180,8 @@
v-slot="props"
field="data.column"
label="Column"
:custom-sort="sortColumn"

sortable
searchable
:th-attrs="() => ({scope:'col'})"
Expand Down Expand Up @@ -404,11 +409,8 @@ export default class Dataset extends ProgramsBase {
first = first ? first : ""; //convert null or undefined to an empty string
let second = b.data.traitValues[index];
second = second ? second : ""; //convert null or undefined to an empty string
if (isAsc) {
return first.localeCompare(second);
} else {
return second.localeCompare(first);
}
return this.sortAlphaAsNumeric(first, second, isAsc);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will change the sorting behavior for observations compared to what was here before. I'm not sure what the requirements are but I think some good test cases would be:

1, 2, 10
A1, A2, A10
1.2, 1.10, 1.3
-1, -2, -10
01, 1, 002, 2


}

//Filter GIDs by exact match
Expand All @@ -418,41 +420,55 @@ export default class Dataset extends ProgramsBase {
}

//sort GIDs numerically

sortGID(a: any, b: any, isAsc: boolean){
let first :number = parseInt(a.data.gid);
let second :number = parseInt(b.data.gid);
if (isAsc) {
if( first > second){ return 1; }
else if (first < second){ return -1;}
else return 0;
} else {
if( second > first ){ return 1; }
else if ( second < first){ return -1;}
else return 0;
}
return this.sortAlphaAsNumeric(first, second, isAsc);
}
sortColumn(a: any, b: any, isAsc: boolean) {

let first: any = a.data.column;
let second: any = b.data.column;
return this.sortAlphaAsNumeric(first, second, isAsc);
}

sortRow(a: any, b: any, isAsc: boolean) {
let first: any = a.data.row;
let second: any = b.data.row;
return this.sortAlphaAsNumeric(first, second, isAsc);
}

sortExpBlock(a: any, b: any, isAsc: boolean) {
let first: any = a.data.expBlock;
let second: any = b.data.expBlock;
return this.sortAlphaAsNumeric(first, second, isAsc);
}
sortExpReplicate(a: any, b: any, isAsc: boolean){
let first :any = a.data.expReplicate;
let second :any = b.data.expReplicate;
return this.sortAlphaAsNumeric( first, second, isAsc);
}

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

// This sorts the Sub Unit ID's in Alphanumeric order (ie. B300,BO2, B1 would sort to B1, B02, B300)
// 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);
let first: any = a.data.subExpUnitId;
let second: any = b.data.subExpUnitId;
return this.sortAlphaAsNumeric( first, second, isAsc);
}

private sortAlphaAsNumeric( first: number, second: number, isAsc: boolean) {
if (isAsc) {
return first.toString().localeCompare(second.toString(), 'en', {numeric: true});
} else {
return second.toString().localeCompare(first.toString(), 'en', {numeric: true});

}
}

Expand Down