Redirect if disabled list is empty

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
John Molakvoæ (skjnldsv) 2018-04-06 21:36:22 +02:00
parent a2d96128be
commit 85f5ae9264
No known key found for this signature in database
GPG Key ID: 60C25B8C072916CF
4 changed files with 579 additions and 38 deletions

File diff suppressed because one or more lines are too long

View File

@ -139,8 +139,14 @@ export default {
return this.$store.getters.getServerData; return this.$store.getters.getServerData;
}, },
filteredUsers() { filteredUsers() {
if (this.route.hash === '#group_disabled') { if (this.$route.hash === '#group_disabled') {
return this.users.filter(user => user.enabled !== true); let disabledUsers = this.users.filter(user => user.enabled !== true);
if (disabledUsers.length===0 && this.$refs.infiniteLoading && this.$refs.infiniteLoading.isComplete) {
// disabled group is empty, redirection to all users
window.location.hash = '#group_everyone';
this.$refs.infiniteLoading.$emit('$InfiniteLoading:reset');
}
return disabledUsers;
} }
return this.users.filter(user => user.enabled === true); return this.users.filter(user => user.enabled === true);
}, },
@ -169,12 +175,9 @@ export default {
usersLimit() { usersLimit() {
return this.$store.getters.getUsersLimit; return this.$store.getters.getUsersLimit;
}, },
route() {
return this.$store.getters.getRoute;
},
// get selected hash // get selected hash
selectedGroup() { selectedGroup() {
let hash = this.route.hash; let hash = this.$route.hash;
if (typeof hash === 'string' && hash.length > 0) { if (typeof hash === 'string' && hash.length > 0) {
// we have a valid hash: groupXXXX // we have a valid hash: groupXXXX
// group_XXXX are reserved groups // group_XXXX are reserved groups

View File

@ -13,12 +13,6 @@ const mutations = {
} }
}; };
const getters = {
getRoute(state) {
return state.route;
}
};
export default new Vuex.Store({ export default new Vuex.Store({
modules: { modules: {
users, users,
@ -26,6 +20,5 @@ export default new Vuex.Store({
}, },
strict: debug, strict: debug,
mutations, mutations
getters
}); });

View File

@ -142,7 +142,7 @@ export default {
}); });
// Set current group as active // Set current group as active
let activeGroup = groups.findIndex(group => group.href === this.route.hash); let activeGroup = groups.findIndex(group => group.href === this.$route.hash);
if (activeGroup >= 0) { if (activeGroup >= 0) {
groups[activeGroup].classes.push('active'); groups[activeGroup].classes.push('active');
} else { } else {