Apply sorting of objective groups to students as well

This commit is contained in:
Ramon Wenger 2018-11-21 15:18:54 +01:00
parent 7fd7728712
commit 4bf3f51644
3 changed files with 4 additions and 2 deletions

View File

@ -33,7 +33,7 @@
import UPDATE_OBJECTIVE_PROGRESS_MUTATION from '@/graphql/gql/mutations/updateObjectiveProgress.gql';
import OBJECTIVE_QUERY from '@/graphql/gql/objectiveQuery.gql';
const withoutOwnerFirst = (a, b) => a.owner ? 1 : 0;
import {withoutOwnerFirst} from '@/helpers/sorting';
export default {
components: {

View File

@ -18,6 +18,7 @@
import ObjectiveGroup from '@/components/objective-groups/ObjectiveGroup';
import ObjectiveGroupControl from '@/components/objective-groups/ObjectiveGroupControl';
import {meQuery} from '@/graphql/queries';
import {withoutOwnerFirst} from '@/helpers/sorting';
export default {
props: {
@ -55,7 +56,7 @@
return this.groups;
} else {
// todo: maybe this can be done a bit more elegantly
const groups = [...this.groups];
const groups = [...this.groups].sort(withoutOwnerFirst);
const objectives = groups.map(g => g.objectives).flat(); // get all objectives in one array
const firstGroup = Object.assign({}, groups.shift(), {objectives});

View File

@ -0,0 +1 @@
export const withoutOwnerFirst = (a, b) => a.owner ? 1 : -1;