Skip to content
Snippets Groups Projects
Commit 52166ec7 authored by Timothee P's avatar Timothee P :sunflower:
Browse files

add sorting function

parent c8537f08
No related branches found
No related tags found
No related merge requests found
...@@ -123,6 +123,8 @@ export default { ...@@ -123,6 +123,8 @@ export default {
value: "contributor", value: "contributor",
}, },
}, },
isSortedByName: false,
isSortedByStatus: false,
}; };
}, },
...@@ -147,9 +149,21 @@ export default { ...@@ -147,9 +149,21 @@ export default {
}, },
projectMembers() { projectMembers() {
return this.projectUsers.filter( return this.projectUsers
(el) => el.userLevel.value !== "logged_user" .filter((el) => el.userLevel.value !== "logged_user")
); .sort((a, b) => {
if (this.isSortedByName) {
const textA = a.user.username.toUpperCase();
const textB = b.user.username.toUpperCase();
return textA < textB ? -1 : textA > textB ? 1 : 0;
} else if (this.isSortedByStatus) {
const textA = a.userLevel.name.toUpperCase();
const textB = b.userLevel.name.toUpperCase();
return textA < textB ? -1 : textA > textB ? 1 : 0;
} else {
return 0;
}
});
}, },
}, },
...@@ -195,7 +209,8 @@ export default { ...@@ -195,7 +209,8 @@ export default {
}); });
}, },
fetchMembers() { // todo: move function to a service fetchMembers() {
// todo: move function to a service
return axios return axios
.get( .get(
`${this.$store.state.configuration.VUE_APP_DJANGO_API_BASE}projects/${this.$route.params.slug}/utilisateurs` `${this.$store.state.configuration.VUE_APP_DJANGO_API_BASE}projects/${this.$route.params.slug}/utilisateurs`
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment