Apply sorting of objective groups to students as well
This commit is contained in:
parent
7fd7728712
commit
4bf3f51644
|
|
@ -33,7 +33,7 @@
|
||||||
import UPDATE_OBJECTIVE_PROGRESS_MUTATION from '@/graphql/gql/mutations/updateObjectiveProgress.gql';
|
import UPDATE_OBJECTIVE_PROGRESS_MUTATION from '@/graphql/gql/mutations/updateObjectiveProgress.gql';
|
||||||
import OBJECTIVE_QUERY from '@/graphql/gql/objectiveQuery.gql';
|
import OBJECTIVE_QUERY from '@/graphql/gql/objectiveQuery.gql';
|
||||||
|
|
||||||
const withoutOwnerFirst = (a, b) => a.owner ? 1 : 0;
|
import {withoutOwnerFirst} from '@/helpers/sorting';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
import ObjectiveGroup from '@/components/objective-groups/ObjectiveGroup';
|
import ObjectiveGroup from '@/components/objective-groups/ObjectiveGroup';
|
||||||
import ObjectiveGroupControl from '@/components/objective-groups/ObjectiveGroupControl';
|
import ObjectiveGroupControl from '@/components/objective-groups/ObjectiveGroupControl';
|
||||||
import {meQuery} from '@/graphql/queries';
|
import {meQuery} from '@/graphql/queries';
|
||||||
|
import {withoutOwnerFirst} from '@/helpers/sorting';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
|
|
@ -55,7 +56,7 @@
|
||||||
return this.groups;
|
return this.groups;
|
||||||
} else {
|
} else {
|
||||||
// todo: maybe this can be done a bit more elegantly
|
// 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 objectives = groups.map(g => g.objectives).flat(); // get all objectives in one array
|
||||||
const firstGroup = Object.assign({}, groups.shift(), {objectives});
|
const firstGroup = Object.assign({}, groups.shift(), {objectives});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
export const withoutOwnerFirst = (a, b) => a.owner ? 1 : -1;
|
||||||
Loading…
Reference in New Issue