diff --git a/client/src/components/modules/Module.vue b/client/src/components/modules/Module.vue index 35537639..1c963084 100644 --- a/client/src/components/modules/Module.vue +++ b/client/src/components/modules/Module.vue @@ -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: { diff --git a/client/src/components/objective-groups/ObjectiveGroups.vue b/client/src/components/objective-groups/ObjectiveGroups.vue index 56366d28..98c53d37 100644 --- a/client/src/components/objective-groups/ObjectiveGroups.vue +++ b/client/src/components/objective-groups/ObjectiveGroups.vue @@ -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}); diff --git a/client/src/helpers/sorting.js b/client/src/helpers/sorting.js new file mode 100644 index 00000000..9e3db38e --- /dev/null +++ b/client/src/helpers/sorting.js @@ -0,0 +1 @@ +export const withoutOwnerFirst = (a, b) => a.owner ? 1 : -1;