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
22 changes: 8 additions & 14 deletions src/components/germplasm/GermplasmTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ import {
GermplasmSortField,
Sort
} from "@/breeding-insight/model/Sort";
import {UPDATE_GERMPLASM_SORT} from "@/store/sorting/mutation-types";
import { PaginationQuery } from '@/breeding-insight/model/PaginationQuery';
import {GermplasmFilter} from "@/breeding-insight/model/ListFilter";

Expand All @@ -103,15 +102,6 @@ import {GermplasmFilter} from "@/breeding-insight/model/ListFilter";
...mapGetters([
'activeProgram'
]),
...mapGetters('sorting',
[
'germplasmSort'
])
},
methods: {
...mapMutations('sorting', {
updateSort: UPDATE_GERMPLASM_SORT
})
},
data: () => ({Trait, StringFormatters, TraitStringFormatters, Pedigree, GermplasmUtils, BrAPIUtils, Sort})
})
Expand All @@ -123,6 +113,10 @@ export default class GermplasmTable extends Vue {
entryNumberVisible?: Boolean;
@Prop()
referenceId?: string;
@Prop()
germplasmSort!: GermplasmSort;
@Prop()
updateGermplasmSort!: (sort: GermplasmSort) => void;

private activeProgram?: Program;
private paginationController: PaginationController = new PaginationController();
Expand All @@ -132,8 +126,6 @@ export default class GermplasmTable extends Vue {

private germplasmCallStack?: CallStack;

private germplasmSort!: GermplasmSort;
private updateSort!: (sort: GermplasmSort) => void;
private fieldMap: any = {
'importEntryNumber': GermplasmSortField.ImportEntryNumber,
'accessionNumber': GermplasmSortField.AccessionNumber,
Expand All @@ -149,7 +141,8 @@ export default class GermplasmTable extends Vue {
.reduce((obj, key) => Object.assign({}, obj, { [this.fieldMap[key]]: key }), {});

mounted() {
this.paginationController.pageSize = 200
// Set default page size to 200.
this.paginationController.pageSize = 200;
this.germplasmCallStack = new CallStack(this.germplasmFetch(
this.activeProgram!.id!,
this.germplasmSort,
Expand Down Expand Up @@ -201,7 +194,8 @@ export default class GermplasmTable extends Vue {

setSort(field: string, order: string) {
if (field in this.fieldMap) {
this.updateSort(new GermplasmSort(this.fieldMap[field], Sort.orderAsBI(order)));
// Update the sort.
this.updateGermplasmSort(new GermplasmSort(this.fieldMap[field], Sort.orderAsBI(order)));
this.getGermplasm();
}
}
Expand Down
16 changes: 11 additions & 5 deletions src/store/sorting/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
* limitations under the License.
*/

import {GetterTree} from 'vuex';
import {RootState} from "@/store/types";
import {SortState} from "@/store/sorting/types";
import { GetterTree } from 'vuex';
import { RootState } from "@/store/types";
import { SortState } from "@/store/sorting/types";
import {
ExperimentSort,
GermplasmSort,
Expand All @@ -31,7 +31,7 @@ import {
UserSortField
} from "@/breeding-insight/model/Sort";

const orderMap: any = {[SortOrder.Ascending]: 'asc', [SortOrder.Descending]: 'desc'};
const orderMap: any = { [SortOrder.Ascending]: 'asc', [SortOrder.Descending]: 'desc' };

export const getters: GetterTree<SortState, RootState> = {

Expand All @@ -40,7 +40,7 @@ export const getters: GetterTree<SortState, RootState> = {
return state.activeOntologySort;
},
activeOntologySortOrder(state: SortState): SortOrder {
return state.activeOntologySort.order;
return state.activeOntologySort.order;
},

// archived ontology table
Expand Down Expand Up @@ -123,6 +123,12 @@ export const getters: GetterTree<SortState, RootState> = {
return state.germplasmSort;
},

// germplasm (by list)
germplasmByListSort(state: SortState): GermplasmSort {
return state.germplasmByListSort;
},

// germplmas list
germplasmListSort(state: SortState): GermplasmListSort {
return state.germplasmListSort;
},
Expand Down
3 changes: 3 additions & 0 deletions src/store/sorting/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ state = {
// germplasm table
germplasmSort: new GermplasmSort(GermplasmSortField.AccessionNumber, SortOrder.Descending),

// germplasm (by list) table
germplasmByListSort: new GermplasmSort(GermplasmSortField.ImportEntryNumber, SortOrder.Ascending),

// germplasm list table
germplasmListSort: new GermplasmListSort(GermplasmListSortField.Name, SortOrder.Ascending),

Expand Down
3 changes: 3 additions & 0 deletions src/store/sorting/mutation-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ export const UPDATE_PROGRAM_SORT = 'updateProgramSort';
// germplasm table
export const UPDATE_GERMPLASM_SORT = 'updateGermplasmSort';

// germplasm (by list) table
export const UPDATE_GERMPLASM_BY_LIST_SORT = 'updateGermplasmByListSort';

// germplasm list table
export const UPDATE_GERMPLASM_LIST_SORT = 'updateGermplasmListSort';

Expand Down
7 changes: 7 additions & 0 deletions src/store/sorting/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
IMPORT_PREVIEW_ONT_TOGGLE_SORT_ORDER,
IMPORT_PREVIEW_ONT_NEW_SORT_COLUMN,
UPDATE_GERMPLASM_SORT,
UPDATE_GERMPLASM_BY_LIST_SORT,
UPDATE_GERMPLASM_LIST_SORT,
UPDATE_EXPERIMENT_SORT, UPDATE_ACTIVE_ONT_SORT, UPDATE_ARCHIVED_ONT_SORT
} from "@/store/sorting/mutation-types";
Expand Down Expand Up @@ -89,6 +90,12 @@ export const mutations: MutationTree<SortState> = {
state.germplasmSort.order = sort.order;
},

//germplasm (by list) table
[UPDATE_GERMPLASM_BY_LIST_SORT](state: SortState, sort: GermplasmSort) {
state.germplasmByListSort.field = sort.field;
state.germplasmByListSort.order = sort.order;
},

//germplasm list table
[UPDATE_GERMPLASM_LIST_SORT](state: SortState, sort: GermplasmListSort) {
state.germplasmListSort.field = sort.field;
Expand Down
7 changes: 5 additions & 2 deletions src/store/sorting/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,13 @@ export interface SortState {
programSort: ProgramSort,

// germplasm table
germplasmSort: GermplasmSort
germplasmSort: GermplasmSort,

// germplasm (by list) table
germplasmByListSort: GermplasmSort,

// germplasm list table
germplasmListSort: GermplasmListSort
germplasmListSort: GermplasmListSort,

// experiment and observation table
experimentSort: ExperimentSort
Expand Down
16 changes: 15 additions & 1 deletion src/views/germplasm/AllGermplasm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<section id="germplasmTable">
<GermplasmTable
v-bind:germplasmFetch="germplasmFetch"
v-bind:germplasm-sort="germplasmSort"
v-bind:update-germplasm-sort="updateGermplasmSort"
>
</GermplasmTable>
</section>
Expand All @@ -10,7 +12,7 @@
<script lang="ts">
import {Component, Vue} from "vue-property-decorator";
import {validationMixin} from "vuelidate";
import {mapGetters} from "vuex";
import {mapGetters, mapMutations} from "vuex";
import {Trait} from "@/breeding-insight/model/Trait";
import {StringFormatters} from "@/breeding-insight/utils/StringFormatters";
import {TraitStringFormatters} from "@/breeding-insight/utils/TraitStringFormatters";
Expand All @@ -29,6 +31,7 @@ import {
} from "@/breeding-insight/model/Sort";
import GermplasmTable from "@/components/germplasm/GermplasmTable.vue";
import {PaginationController} from "@/breeding-insight/model/view_models/PaginationController";
import {UPDATE_GERMPLASM_SORT} from "@/store/sorting/mutation-types";

@Component({
mixins: [validationMixin],
Expand All @@ -37,12 +40,23 @@ import {PaginationController} from "@/breeding-insight/model/view_models/Paginat
...mapGetters([
'activeProgram'
]),
...mapGetters('sorting',
[
'germplasmSort',
])
},
methods: {
...mapMutations('sorting', {
updateGermplasmSort: UPDATE_GERMPLASM_SORT,
})
},
data: () => ({Trait, StringFormatters, TraitStringFormatters, Pedigree, GermplasmUtils, Sort})
})
export default class AllGermplasm extends Vue {

private activeProgram?: Program;
private germplasmSort!: GermplasmSort;
private updateGermplasmSort!: (sort: GermplasmSort) => void;

// Set the method used to populate the germplasm table
private germplasmFetch: (programId: string, sort: GermplasmSort, paginationController: PaginationController) => ((filters: any) => Promise<BiResponse>) =
Expand Down
19 changes: 17 additions & 2 deletions src/views/germplasm/GermplasmByList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@
v-bind:germplasmFetch="germplasmFetch"
entryNumberVisible="true"
v-bind:reference-id="referenceId"
v-bind:germplasm-sort="germplasmByListSort"
v-bind:update-germplasm-sort="updateGermplasmByListSort"
>
</GermplasmTable>
</div>
Expand All @@ -128,7 +130,7 @@ import GermplasmTable from '@/components/germplasm/GermplasmTable.vue';
import {GermplasmListSortField, GermplasmSort, SortOrder, GermplasmSortField} from '@/breeding-insight/model/Sort';
import {BiResponse} from '@/breeding-insight/model/BiResponse';
import {PaginationQuery} from '@/breeding-insight/model/PaginationQuery';
import {mapGetters} from 'vuex';
import {mapGetters, mapMutations} from 'vuex';
import {Program} from '@/breeding-insight/model/Program';
import {StringFormatters} from "@/breeding-insight/utils/StringFormatters";
import GermplasmDownloadButton from '@/components/germplasm/GermplasmDownloadButton.vue';
Expand All @@ -142,13 +144,23 @@ import {ListService} from '@/breeding-insight/service/ListService';
import {ListType} from "@/util/ListType";
import {GermplasmFilter} from "@/breeding-insight/model/ListFilter";
import {GermplasmService} from "@/breeding-insight/service/GermplasmService";
import {UPDATE_GERMPLASM_BY_LIST_SORT} from "@/store/sorting/mutation-types";

@Component({
components: { FormModal, GermplasmTable, GermplasmDownloadButton, GermplasmListDeletionModal, ActionMenu },
computed: {
...mapGetters([
'activeProgram'
])
]),
...mapGetters('sorting',
[
'germplasmByListSort',
])
},
methods: {
...mapMutations('sorting', {
updateGermplasmByListSort: UPDATE_GERMPLASM_BY_LIST_SORT,
})
}
})
export default class GermplasmByList extends GermplasmBase {
Expand All @@ -165,6 +177,9 @@ export default class GermplasmByList extends GermplasmBase {
new ActionMenuItem('germplasm-list-download-file', 'download-file', 'Download', true)
];

private germplasmByListSort: GermplasmSort;
private updateGermplasmByListSort: (sort: GermplasmSort) => void;

// Formatting filters
private toYMD(date: string | null | undefined): string {
if (!date) return ''; // Return an empty string if date is null, undefined, or empty
Expand Down