2018-02-15 22:08:06 -06:00
|
|
|
<template>
|
|
|
|
<div class="mk-users-list">
|
|
|
|
<nav>
|
|
|
|
<div>
|
2018-05-17 13:07:11 -05:00
|
|
|
<span :data-active="mode == 'all'" @click="mode = 'all'">%i18n:@all%<span>{{ count }}</span></span>
|
2018-05-26 23:49:09 -05:00
|
|
|
<span v-if="$store.getters.isSignedIn && youKnowCount" :data-active="mode == 'iknow'" @click="mode = 'iknow'">%i18n:@iknow%<span>{{ youKnowCount }}</span></span>
|
2018-02-15 22:08:06 -06:00
|
|
|
</div>
|
|
|
|
</nav>
|
|
|
|
<div class="users" v-if="!fetching && users.length != 0">
|
|
|
|
<div v-for="u in users" :key="u.id">
|
2018-02-22 08:05:05 -06:00
|
|
|
<x-item :user="u"/>
|
2018-02-15 22:08:06 -06:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<button class="more" v-if="!fetching && next != null" @click="more" :disabled="moreFetching">
|
2018-05-17 13:07:11 -05:00
|
|
|
<span v-if="!moreFetching">%i18n:@load-more%</span>
|
|
|
|
<span v-if="moreFetching">%i18n:common.loading%<mk-ellipsis/></span>
|
2018-02-15 22:08:06 -06:00
|
|
|
</button>
|
|
|
|
<p class="no" v-if="!fetching && users.length == 0">
|
|
|
|
<slot></slot>
|
|
|
|
</p>
|
2018-05-17 13:07:11 -05:00
|
|
|
<p class="fetching" v-if="fetching">%fa:spinner .pulse .fw%%i18n:@fetching%<mk-ellipsis/></p>
|
2018-02-15 22:08:06 -06:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
2018-02-22 08:05:05 -06:00
|
|
|
import XItem from './users-list.item.vue';
|
|
|
|
|
2018-02-15 22:08:06 -06:00
|
|
|
export default Vue.extend({
|
2018-02-22 08:05:05 -06:00
|
|
|
components: {
|
|
|
|
XItem
|
|
|
|
},
|
2018-02-15 22:08:06 -06:00
|
|
|
props: ['fetch', 'count', 'youKnowCount'],
|
|
|
|
data() {
|
|
|
|
return {
|
2018-09-12 12:08:17 -05:00
|
|
|
limit: 20,
|
2018-02-15 22:08:06 -06:00
|
|
|
mode: 'all',
|
|
|
|
fetching: true,
|
|
|
|
moreFetching: false,
|
|
|
|
users: [],
|
|
|
|
next: null
|
|
|
|
};
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this._fetch(() => {
|
|
|
|
this.$emit('loaded');
|
|
|
|
});
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
_fetch(cb) {
|
|
|
|
this.fetching = true;
|
|
|
|
this.fetch(this.mode == 'iknow', this.limit, null, obj => {
|
|
|
|
this.users = obj.users;
|
|
|
|
this.next = obj.next;
|
2018-02-19 08:37:09 -06:00
|
|
|
this.fetching = false;
|
2018-02-15 22:08:06 -06:00
|
|
|
if (cb) cb();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
more() {
|
|
|
|
this.moreFetching = true;
|
|
|
|
this.fetch(this.mode == 'iknow', this.limit, this.next, obj => {
|
|
|
|
this.moreFetching = false;
|
|
|
|
this.users = this.users.concat(obj.users);
|
|
|
|
this.next = obj.next;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="stylus" scoped>
|
2018-09-26 06:19:35 -05:00
|
|
|
|
2018-03-02 22:47:55 -06:00
|
|
|
|
2018-02-15 22:08:06 -06:00
|
|
|
.mk-users-list
|
|
|
|
height 100%
|
2018-09-12 12:08:17 -05:00
|
|
|
overflow auto
|
|
|
|
background #eee
|
2018-02-15 22:08:06 -06:00
|
|
|
|
|
|
|
> nav
|
2018-09-12 12:08:17 -05:00
|
|
|
z-index 10
|
|
|
|
position sticky
|
|
|
|
top 0
|
|
|
|
background #fff
|
2018-02-15 22:08:06 -06:00
|
|
|
box-shadow 0 1px 0 rgba(#000, 0.1)
|
|
|
|
|
|
|
|
> div
|
|
|
|
display flex
|
|
|
|
justify-content center
|
|
|
|
margin 0 auto
|
|
|
|
max-width 600px
|
|
|
|
|
|
|
|
> span
|
|
|
|
display block
|
|
|
|
flex 1 1
|
|
|
|
text-align center
|
|
|
|
line-height 52px
|
|
|
|
font-size 14px
|
|
|
|
color #657786
|
|
|
|
border-bottom solid 2px transparent
|
|
|
|
cursor pointer
|
|
|
|
|
|
|
|
*
|
|
|
|
pointer-events none
|
|
|
|
|
2018-04-26 00:38:37 -05:00
|
|
|
&[data-active]
|
2018-02-15 22:08:06 -06:00
|
|
|
font-weight bold
|
2018-09-26 06:19:35 -05:00
|
|
|
color var(--primary)
|
|
|
|
border-color var(--primary)
|
2018-02-15 22:08:06 -06:00
|
|
|
cursor default
|
|
|
|
|
|
|
|
> span
|
|
|
|
display inline-block
|
|
|
|
margin-left 4px
|
|
|
|
padding 2px 5px
|
|
|
|
font-size 12px
|
|
|
|
line-height 1
|
|
|
|
color #888
|
|
|
|
background #eee
|
|
|
|
border-radius 20px
|
|
|
|
|
2018-09-12 12:08:17 -05:00
|
|
|
> button
|
|
|
|
display block
|
|
|
|
width calc(100% - 32px)
|
|
|
|
margin 16px
|
|
|
|
padding 16px
|
2018-02-15 22:08:06 -06:00
|
|
|
|
2018-09-12 12:08:17 -05:00
|
|
|
&:hover
|
|
|
|
background rgba(#000, 0.1)
|
2018-02-15 22:08:06 -06:00
|
|
|
|
|
|
|
> .no
|
|
|
|
margin 0
|
|
|
|
padding 16px
|
|
|
|
text-align center
|
|
|
|
color #aaa
|
|
|
|
|
|
|
|
> .fetching
|
|
|
|
margin 0
|
|
|
|
padding 16px
|
|
|
|
text-align center
|
|
|
|
color #aaa
|
|
|
|
|
|
|
|
> [data-fa]
|
|
|
|
margin-right 4px
|
|
|
|
|
|
|
|
</style>
|