2017-06-02 20:55:02 +00:00
|
|
|
|
<template lang="pug">
|
|
|
|
|
|
div
|
2017-06-08 21:27:22 +00:00
|
|
|
|
b-modal#members-modal(:title="$t('createGuild')", size='lg')
|
2017-06-06 05:21:37 +00:00
|
|
|
|
.header-wrap(slot="modal-header")
|
|
|
|
|
|
.row
|
|
|
|
|
|
.col-6
|
2017-06-08 21:27:22 +00:00
|
|
|
|
h1(v-once) {{$t('members')}}
|
2017-06-06 05:21:37 +00:00
|
|
|
|
.col-6
|
2017-08-03 20:04:03 +00:00
|
|
|
|
button(type="button" aria-label="Close" class="close", @click='close()')
|
2017-06-06 05:21:37 +00:00
|
|
|
|
span(aria-hidden="true") ×
|
|
|
|
|
|
.row
|
|
|
|
|
|
.form-group.col-6
|
|
|
|
|
|
input.form-control.search(type="text", :placeholder="$t('search')", v-model='searchTerm')
|
2017-06-08 21:27:22 +00:00
|
|
|
|
.col-4.offset-2
|
2017-06-06 05:21:37 +00:00
|
|
|
|
span.dropdown-label {{ $t('sortBy') }}
|
|
|
|
|
|
b-dropdown(:text="$t('sort')", right=true)
|
2017-06-08 21:27:22 +00:00
|
|
|
|
b-dropdown-item(v-for='sortOption in sortOptions', @click='sort(sortOption.value)', :key='sortOption.value') {{sortOption.text}}
|
2017-08-09 16:56:48 +00:00
|
|
|
|
.row(v-for='member in sortedMembers')
|
2017-06-08 21:27:22 +00:00
|
|
|
|
.col-8.offset-1
|
2017-06-27 20:02:55 +00:00
|
|
|
|
member-details(:member='member')
|
2017-06-08 21:27:22 +00:00
|
|
|
|
.col-3.actions
|
2017-08-23 03:58:13 +00:00
|
|
|
|
b-dropdown(text="...", right=true)
|
|
|
|
|
|
b-dropdown-item(@click='sort(option.value)', v-if='isLeader')
|
2017-08-09 15:13:40 +00:00
|
|
|
|
span.dropdown-icon-item
|
2017-08-23 03:58:13 +00:00
|
|
|
|
.svg-icon.inline(v-html="icons.removeIcon", v-if='isLeader')
|
2017-08-09 15:13:40 +00:00
|
|
|
|
span.text {{$t('removeMember')}}
|
2017-06-08 21:27:22 +00:00
|
|
|
|
b-dropdown-item(@click='sort(option.value)')
|
2017-08-09 15:13:40 +00:00
|
|
|
|
span.dropdown-icon-item
|
|
|
|
|
|
.svg-icon.inline(v-html="icons.messageIcon")
|
|
|
|
|
|
span.text {{$t('sendMessage')}}
|
2017-08-23 03:58:13 +00:00
|
|
|
|
b-dropdown-item(@click='sort(option.value)', v-if='isLeader')
|
2017-08-09 15:13:40 +00:00
|
|
|
|
span.dropdown-icon-item
|
|
|
|
|
|
.svg-icon.inline(v-html="icons.starIcon")
|
|
|
|
|
|
span.text {{$t('promoteToLeader')}}
|
2017-08-23 03:58:13 +00:00
|
|
|
|
b-dropdown-item(@click='sort(option.value)', v-if='isLeader && groupIsSubscribed')
|
2017-08-09 15:13:40 +00:00
|
|
|
|
span.dropdown-icon-item
|
|
|
|
|
|
.svg-icon.inline(v-html="icons.starIcon")
|
|
|
|
|
|
span.text {{$t('addManager')}}
|
2017-08-23 03:58:13 +00:00
|
|
|
|
b-dropdown-item(@click='sort(option.value)', v-if='isLeader && groupIsSubscribed')
|
2017-08-09 15:13:40 +00:00
|
|
|
|
span.dropdown-icon-item
|
|
|
|
|
|
.svg-icon.inline(v-html="icons.removeIcon")
|
|
|
|
|
|
span.text {{$t('removeManager2')}}
|
2017-07-29 22:08:36 +00:00
|
|
|
|
.row.gradient(v-if='members.length > 3')
|
2017-06-02 20:55:02 +00:00
|
|
|
|
</template>
|
|
|
|
|
|
|
2017-06-27 20:02:55 +00:00
|
|
|
|
<style lang='scss' scoped>
|
2017-06-08 21:27:22 +00:00
|
|
|
|
header {
|
|
|
|
|
|
background-color: #edecee;
|
|
|
|
|
|
border-radius: 4px 4px 0 0;
|
|
|
|
|
|
}
|
2017-06-06 05:21:37 +00:00
|
|
|
|
|
2017-06-08 21:27:22 +00:00
|
|
|
|
.header-wrap {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
}
|
2017-06-06 05:21:37 +00:00
|
|
|
|
|
2017-06-08 21:27:22 +00:00
|
|
|
|
h1 {
|
|
|
|
|
|
color: #4f2a93;
|
|
|
|
|
|
}
|
2017-06-06 05:21:37 +00:00
|
|
|
|
|
2017-06-08 21:27:22 +00:00
|
|
|
|
.actions {
|
|
|
|
|
|
padding-top: 5em;
|
2017-06-06 05:21:37 +00:00
|
|
|
|
|
2017-06-08 21:27:22 +00:00
|
|
|
|
.action-icon {
|
|
|
|
|
|
margin-right: 1em;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-06-27 20:02:55 +00:00
|
|
|
|
|
|
|
|
|
|
#members-modal_modal_body {
|
|
|
|
|
|
padding: 0;
|
2017-07-29 22:08:36 +00:00
|
|
|
|
max-height: 450px;
|
2017-06-27 20:02:55 +00:00
|
|
|
|
|
|
|
|
|
|
.col-8 {
|
|
|
|
|
|
margin-left: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.member-details {
|
|
|
|
|
|
margin: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.member-stats {
|
|
|
|
|
|
width: 382px;
|
|
|
|
|
|
height: 147px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.gradient {
|
|
|
|
|
|
background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0), #ffffff);
|
2017-07-29 22:08:36 +00:00
|
|
|
|
height: 50px;
|
2017-06-27 20:02:55 +00:00
|
|
|
|
width: 100%;
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
bottom: 0px;
|
2017-07-29 22:08:36 +00:00
|
|
|
|
margin-left: -15px;
|
2017-06-27 20:02:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-08-09 15:13:40 +00:00
|
|
|
|
.dropdown-icon-item .svg-icon {
|
2017-07-29 22:08:36 +00:00
|
|
|
|
width: 20px;
|
2017-06-27 20:02:55 +00:00
|
|
|
|
}
|
2017-06-06 05:21:37 +00:00
|
|
|
|
</style>
|
|
|
|
|
|
|
2017-06-02 20:55:02 +00:00
|
|
|
|
<script>
|
2017-08-01 18:52:49 +00:00
|
|
|
|
// @TODO: Move this under members directory
|
2017-08-09 16:56:48 +00:00
|
|
|
|
import sortBy from 'lodash/sortBy';
|
2017-06-02 20:55:02 +00:00
|
|
|
|
import bModal from 'bootstrap-vue/lib/components/modal';
|
2017-06-06 05:21:37 +00:00
|
|
|
|
import bDropdown from 'bootstrap-vue/lib/components/dropdown';
|
|
|
|
|
|
import bDropdownItem from 'bootstrap-vue/lib/components/dropdown-item';
|
2017-08-23 03:58:13 +00:00
|
|
|
|
import { mapState } from 'client/libs/store';
|
2017-06-06 05:21:37 +00:00
|
|
|
|
|
2017-06-08 21:36:56 +00:00
|
|
|
|
import MemberDetails from '../memberDetails';
|
2017-06-27 20:02:55 +00:00
|
|
|
|
import removeIcon from 'assets/members/remove.svg';
|
|
|
|
|
|
import messageIcon from 'assets/members/message.svg';
|
|
|
|
|
|
import starIcon from 'assets/members/star.svg';
|
2017-06-02 20:55:02 +00:00
|
|
|
|
|
|
|
|
|
|
export default {
|
2017-08-23 03:58:13 +00:00
|
|
|
|
props: ['hideBadge'],
|
2017-06-02 20:55:02 +00:00
|
|
|
|
components: {
|
|
|
|
|
|
bModal,
|
2017-06-06 05:21:37 +00:00
|
|
|
|
bDropdown,
|
|
|
|
|
|
bDropdownItem,
|
2017-06-08 21:36:56 +00:00
|
|
|
|
MemberDetails,
|
2017-06-02 20:55:02 +00:00
|
|
|
|
},
|
2017-07-31 19:54:52 +00:00
|
|
|
|
mounted () {
|
|
|
|
|
|
this.$root.$on('shown::modal', () => {
|
|
|
|
|
|
this.getMembers();
|
|
|
|
|
|
});
|
2017-06-08 21:27:22 +00:00
|
|
|
|
},
|
2017-06-02 20:55:02 +00:00
|
|
|
|
data () {
|
|
|
|
|
|
return {
|
2017-08-09 16:56:48 +00:00
|
|
|
|
sortOption: '',
|
2017-06-08 21:27:22 +00:00
|
|
|
|
members: [],
|
2017-06-02 20:55:02 +00:00
|
|
|
|
memberToRemove: '',
|
2017-06-08 21:27:22 +00:00
|
|
|
|
sortOptions: [
|
|
|
|
|
|
{
|
2017-08-09 16:56:48 +00:00
|
|
|
|
value: 'level',
|
2017-06-08 21:27:22 +00:00
|
|
|
|
text: this.$t('tier'),
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
value: 'name',
|
|
|
|
|
|
text: this.$t('name'),
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
2017-08-09 16:56:48 +00:00
|
|
|
|
value: 'lvl',
|
2017-06-08 21:27:22 +00:00
|
|
|
|
text: this.$t('level'),
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
value: 'class',
|
|
|
|
|
|
text: this.$t('class'),
|
|
|
|
|
|
},
|
|
|
|
|
|
],
|
|
|
|
|
|
searchTerm: '',
|
2017-06-27 20:02:55 +00:00
|
|
|
|
icons: Object.freeze({
|
|
|
|
|
|
removeIcon,
|
|
|
|
|
|
messageIcon,
|
|
|
|
|
|
starIcon,
|
|
|
|
|
|
}),
|
2017-06-02 20:55:02 +00:00
|
|
|
|
};
|
|
|
|
|
|
},
|
2017-08-09 16:56:48 +00:00
|
|
|
|
computed: {
|
2017-08-23 03:58:13 +00:00
|
|
|
|
...mapState({user: 'user.data'}),
|
|
|
|
|
|
isLeader () {
|
|
|
|
|
|
return this.user._id === this.group.leader || this.user._id === this.group.leader._id;
|
|
|
|
|
|
},
|
|
|
|
|
|
groupIsSubscribed () {
|
|
|
|
|
|
return this.group.purchased.active;
|
|
|
|
|
|
},
|
|
|
|
|
|
group () {
|
|
|
|
|
|
return this.$store.state.memberModalOptions.group;
|
|
|
|
|
|
},
|
2017-08-09 16:56:48 +00:00
|
|
|
|
sortedMembers () {
|
|
|
|
|
|
let sortedMembers = this.members;
|
|
|
|
|
|
if (!this.sortOption) return sortedMembers;
|
|
|
|
|
|
|
|
|
|
|
|
sortedMembers = sortBy(this.members, [(member) => {
|
|
|
|
|
|
if (this.sortOption === 'tier') {
|
|
|
|
|
|
if (!member.contributor) return;
|
|
|
|
|
|
return member.contributor.level;
|
|
|
|
|
|
} else if (this.sortOption === 'name') {
|
|
|
|
|
|
return member.profile.name;
|
|
|
|
|
|
} else if (this.sortOption === 'lvl') {
|
|
|
|
|
|
return member.stats.lvl;
|
|
|
|
|
|
} else if (this.sortOption === 'class') {
|
|
|
|
|
|
return member.stats.class;
|
|
|
|
|
|
}
|
|
|
|
|
|
}]);
|
|
|
|
|
|
|
|
|
|
|
|
return this.members;
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
2017-06-02 20:55:02 +00:00
|
|
|
|
methods: {
|
2017-06-08 21:27:22 +00:00
|
|
|
|
async getMembers () {
|
2017-08-23 03:58:13 +00:00
|
|
|
|
let groupId = this.$store.state.memberModalOptions.groupId || this.group._id;
|
2017-08-07 20:26:17 +00:00
|
|
|
|
if (groupId && groupId !== 'challenge') {
|
2017-07-31 19:54:52 +00:00
|
|
|
|
let members = await this.$store.dispatch('members:getGroupMembers', {
|
2017-08-01 18:52:49 +00:00
|
|
|
|
groupId,
|
2017-07-31 19:54:52 +00:00
|
|
|
|
includeAllPublicFields: true,
|
|
|
|
|
|
});
|
|
|
|
|
|
this.members = members;
|
2017-08-07 20:26:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-08-23 03:58:13 +00:00
|
|
|
|
if (this.$store.state.memberModalOptions.viewingMembers.length > 0) {
|
2017-08-03 20:04:03 +00:00
|
|
|
|
this.members = this.$store.state.viewingMembers;
|
2017-07-31 19:54:52 +00:00
|
|
|
|
}
|
2017-06-02 20:55:02 +00:00
|
|
|
|
},
|
2017-06-08 21:27:22 +00:00
|
|
|
|
async clickMember (uid, forceShow) {
|
2017-06-02 20:55:02 +00:00
|
|
|
|
let user = this.$store.state.user.data;
|
|
|
|
|
|
|
|
|
|
|
|
if (user._id === uid && !forceShow) {
|
|
|
|
|
|
if (this.$route.name === 'tasks') {
|
|
|
|
|
|
this.$route.router.go('options.profile.avatar');
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.$route.router.go('tasks');
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-06-08 21:27:22 +00:00
|
|
|
|
await this.$store.dispatch('members:selectMember', {
|
|
|
|
|
|
memberId: uid,
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
this.$root.$emit('show::modal', 'members-modal');
|
2017-06-02 20:55:02 +00:00
|
|
|
|
},
|
2017-06-08 21:27:22 +00:00
|
|
|
|
async removeMember (member) {
|
2017-06-02 20:55:02 +00:00
|
|
|
|
this.memberToRemove = member;
|
|
|
|
|
|
this.$root.$emit('show::modal', 'remove-member');
|
|
|
|
|
|
},
|
2017-06-08 21:27:22 +00:00
|
|
|
|
async confirmRemoveMember (confirmation) {
|
2017-06-02 20:55:02 +00:00
|
|
|
|
if (!confirmation) {
|
|
|
|
|
|
this.memberToRemove = '';
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2017-06-08 21:27:22 +00:00
|
|
|
|
|
|
|
|
|
|
await this.$store.dispatch('members:removeMember', {
|
|
|
|
|
|
memberId: this.memberToRemove._id,
|
|
|
|
|
|
groupId: this.group._id,
|
|
|
|
|
|
message: this.removeMessage,
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
this.memberToRemove = '';
|
|
|
|
|
|
this.removeMessage = '';
|
2017-06-02 20:55:02 +00:00
|
|
|
|
},
|
2017-06-08 21:27:22 +00:00
|
|
|
|
async quickReply (uid) {
|
2017-06-02 20:55:02 +00:00
|
|
|
|
this.memberToReply = uid;
|
2017-06-08 21:27:22 +00:00
|
|
|
|
await this.$store.dispatch('members:selectMember', {
|
|
|
|
|
|
memberId: uid,
|
|
|
|
|
|
});
|
|
|
|
|
|
this.$root.$emit('show::modal', 'private-message'); // MemberModalCtrl
|
2017-06-02 20:55:02 +00:00
|
|
|
|
},
|
2017-06-08 21:27:22 +00:00
|
|
|
|
async addManager (memberId) {
|
|
|
|
|
|
await this.$store.dispatch('group:addManager', {
|
|
|
|
|
|
memberId,
|
|
|
|
|
|
});
|
2017-06-02 20:55:02 +00:00
|
|
|
|
},
|
2017-06-08 21:27:22 +00:00
|
|
|
|
async removeManager (memberId) {
|
|
|
|
|
|
await this.$store.dispatch('group:removeManager', {
|
|
|
|
|
|
memberId,
|
|
|
|
|
|
});
|
2017-06-02 20:55:02 +00:00
|
|
|
|
},
|
2017-08-03 20:04:03 +00:00
|
|
|
|
close () {
|
|
|
|
|
|
this.$root.$emit('hide::modal', 'members-modal');
|
|
|
|
|
|
},
|
2017-08-09 16:56:48 +00:00
|
|
|
|
sort (option) {
|
|
|
|
|
|
this.sortOption = option;
|
|
|
|
|
|
},
|
2017-06-02 20:55:02 +00:00
|
|
|
|
},
|
|
|
|
|
|
};
|
|
|
|
|
|
</script>
|