Lista Amici
Richieste di Fiducia Accettati Rifiutati
This commit is contained in:
@@ -13,6 +13,7 @@ import { toolsext } from '@store/Modules/toolsext'
|
||||
import { useQuasar } from 'quasar'
|
||||
import { costanti } from '@costanti'
|
||||
import { IUserFields, IUserProfile } from 'model'
|
||||
import { shared_consts } from '@/common/shared_vuejs'
|
||||
|
||||
|
||||
export default defineComponent({
|
||||
@@ -21,7 +22,9 @@ export default defineComponent({
|
||||
props: {},
|
||||
setup() {
|
||||
const userStore = useUserStore()
|
||||
const $router = useRouter()
|
||||
const $route = useRoute()
|
||||
const $q = useQuasar()
|
||||
const { t } = useI18n()
|
||||
|
||||
const username = ref('')
|
||||
@@ -36,9 +39,11 @@ export default defineComponent({
|
||||
if (filter.value === costanti.FRIENDS) {
|
||||
arr = listFriends.value
|
||||
}else if (filter.value === costanti.ASK_TRUST) {
|
||||
arr = listTrusted.value.filter((user: IUserFields) => !user.verified_by_aportador)
|
||||
arr = listTrusted.value.filter((user: IUserFields) => user.verified_by_aportador === undefined)
|
||||
}else if (filter.value === costanti.TRUSTED) {
|
||||
arr = listTrusted.value.filter((user: IUserFields) => !user.verified_by_aportador)
|
||||
arr = listTrusted.value.filter((user: IUserFields) => user.verified_by_aportador)
|
||||
}else if (filter.value === costanti.REEJECTED) {
|
||||
arr = listTrusted.value.filter((user: IUserFields) => user.verified_by_aportador === false)
|
||||
}
|
||||
|
||||
return arr
|
||||
@@ -50,15 +55,20 @@ export default defineComponent({
|
||||
})
|
||||
|
||||
const numAskTrust = computed(() => {
|
||||
const arr = listTrusted.value.filter((user: IUserFields) => !user.verified_by_aportador)
|
||||
const arr = listTrusted.value.filter((user: IUserFields) => user.verified_by_aportador === undefined)
|
||||
return (arr) ? arr.length : 0
|
||||
})
|
||||
|
||||
const numAskTrusted = computed(() => {
|
||||
const numTrusted = computed(() => {
|
||||
const arr = listTrusted.value.filter((user: IUserFields) => user.verified_by_aportador)
|
||||
return (arr) ? arr.length : 0
|
||||
})
|
||||
|
||||
const numRejected = computed(() => {
|
||||
const arr = listTrusted.value.filter((user: IUserFields) => user.verified_by_aportador === false)
|
||||
return (arr) ? arr.length : 0
|
||||
})
|
||||
|
||||
function loadFriends() {
|
||||
// Carica il profilo di quest'utente
|
||||
if (username.value) {
|
||||
@@ -83,6 +93,44 @@ export default defineComponent({
|
||||
return userStore.getImgByProfile(profile)
|
||||
}
|
||||
|
||||
function setRequestTrust(usernameDest: string, value: any) {
|
||||
userStore.setFriendsCmd($q, t, username.value, usernameDest, shared_consts.FRIENDSCMD.SETTRUST, value).then((res) => {
|
||||
if (res) {
|
||||
const myuser: IUserFields|undefined = listTrusted.value.find((rec: IUserFields) => rec.username === usernameDest )
|
||||
if (myuser) {
|
||||
listFriends.value.push(myuser)
|
||||
listTrusted.value = listTrusted.value.filter((rec: IUserFields) => rec.username !== usernameDest)
|
||||
}
|
||||
tools.showPositiveNotif($q, t('db.trusted'))
|
||||
|
||||
} else {
|
||||
tools.showNegativeNotif($q, t('db.recfailed'))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function removeFromMyFriends(usernameDest: string) {
|
||||
userStore.setFriendsCmd($q, t, username.value, usernameDest, shared_consts.FRIENDSCMD.REMOVE_FROM_MYFRIENDS, null).then((res) => {
|
||||
if (res) {
|
||||
listFriends.value = listFriends.value.filter((rec: IUserFields) => rec.username !== usernameDest)
|
||||
tools.showPositiveNotif($q, t('db.removedfriend'))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function blockUser(usernameDest: string) {
|
||||
userStore.setFriendsCmd($q, t, username.value, usernameDest, shared_consts.FRIENDSCMD.REMOVE_FROM_MYFRIENDS, null).then((res) => {
|
||||
if (res) {
|
||||
listFriends.value = listFriends.value.filter((rec: IUserFields) => rec.username !== usernameDest)
|
||||
tools.showPositiveNotif($q, t('db.blockedfriend'))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function naviga(path: string) {
|
||||
$router.push(path)
|
||||
}
|
||||
|
||||
onMounted(mounted)
|
||||
|
||||
return {
|
||||
@@ -95,7 +143,12 @@ export default defineComponent({
|
||||
listfriendsfiltered,
|
||||
numFriends,
|
||||
numAskTrust,
|
||||
numAskTrusted,
|
||||
numTrusted,
|
||||
numRejected,
|
||||
setRequestTrust,
|
||||
removeFromMyFriends,
|
||||
blockUser,
|
||||
naviga,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -7,32 +7,85 @@
|
||||
no-caps
|
||||
rounded
|
||||
unelevated
|
||||
push
|
||||
toggle-color="primary"
|
||||
color="white"
|
||||
text-color="primary"
|
||||
:options="[
|
||||
{label: $t('mypages.friends') + ' (' + numFriends + ')', value: costanti.FRIENDS},
|
||||
{label: $t('mypages.request_trust') + ' (' + numAskTrust + ')', value: costanti.ASK_TRUST},
|
||||
{label: $t('mypages.trusted') + ' (' + numAskTrusted + ')', value: costanti.TRUSTED}
|
||||
{label: $t('mypages.trusted') + ' (' + numTrusted + ')', value: costanti.TRUSTED},
|
||||
{label: $t('mypages.rejected') + ' (' + numRejected + ')', value: costanti.REEJECTED}
|
||||
]"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<q-list bordered>
|
||||
<q-item v-for="(contact, index) in listfriendsfiltered" :key="index" class="q-my-sm" clickable v-ripple>
|
||||
<q-item-section avatar>
|
||||
<q-avatar>
|
||||
<img :src="getImgUser(contact)" :alt="contact.username">
|
||||
<q-list>
|
||||
<q-item v-for="(contact, index) in listfriendsfiltered" :key="index" class="q-my-sm" clickable>
|
||||
<q-item-section avatar @click="naviga(`/my/` + contact.username)">
|
||||
<q-avatar size="60px">
|
||||
<q-img :src="getImgUser(contact)" :alt="contact.username" img-class="imgprofile" height="60px" />
|
||||
</q-avatar>
|
||||
</q-item-section>
|
||||
|
||||
<q-item-section>
|
||||
<q-item-label>{{ contact.name }} {{ contact.surname }}</q-item-label>
|
||||
<q-item-section @click="naviga(`/my/` + contact.username)">
|
||||
<q-item-label><strong>{{ contact.name }} {{ contact.surname }}</strong> ({{ contact.username }})
|
||||
</q-item-label>
|
||||
<q-item-label caption lines="1">{{ contact.email }}</q-item-label>
|
||||
</q-item-section>
|
||||
|
||||
<q-item-section side>
|
||||
<q-icon name="chat_bubble" color="green" />
|
||||
|
||||
<q-item-section side v-if="filter === costanti.FRIENDS">
|
||||
<q-item-label>
|
||||
<q-btn rounded icon="fas fa-ellipsis-h">
|
||||
<q-menu>
|
||||
<q-list style="min-width: 150px">
|
||||
<q-item clickable icon="fas fa-user-minus" v-close-popup @click="removeFromMyFriends(contact.username)">
|
||||
<q-item-section>{{$t('friends.remove_from_myfriends')}}</q-item-section>
|
||||
</q-item>
|
||||
</q-list>
|
||||
<q-list style="min-width: 150px">
|
||||
<q-item clickable icon="fas fa-ban" v-close-popup @click="blockUser(contact.username)">
|
||||
<q-item-section>{{$t('friends.block_user')}}</q-item-section>
|
||||
</q-item>
|
||||
</q-list>
|
||||
</q-menu>
|
||||
</q-btn>
|
||||
</q-item-label>
|
||||
</q-item-section>
|
||||
<q-item-section side v-if="filter === costanti.ASK_TRUST">
|
||||
<q-item-label>
|
||||
<q-btn color="positive" :label="$t('friends.accept')" @click="setRequestTrust(contact.username, true)"/>
|
||||
</q-item-label>
|
||||
<q-item-label>
|
||||
<q-btn color="negative" :label="$t('friends.reject')" @click="setRequestTrust(contact.username, false)"/>
|
||||
</q-item-label>
|
||||
</q-item-section>
|
||||
<q-item-section side v-if="filter === costanti.TRUSTED">
|
||||
<q-item-label>
|
||||
<q-btn rounded icon="fas fa-ellipsis-h">
|
||||
<q-menu>
|
||||
<q-list style="min-width: 200px">
|
||||
<q-item clickable v-close-popup @click="removeFromMyFriends(contact.username)">
|
||||
<q-item-section>{{$t('friends.reject')}}</q-item-section>
|
||||
</q-item>
|
||||
</q-list>
|
||||
</q-menu>
|
||||
</q-btn>
|
||||
</q-item-label>
|
||||
</q-item-section>
|
||||
<q-item-section side v-if="filter === costanti.REEJECTED">
|
||||
<q-item-label>
|
||||
<q-btn rounded icon="fas fa-ellipsis-h">
|
||||
<q-menu>
|
||||
<q-list style="min-width: 200px">
|
||||
<q-item clickable icon="fas fa-user-minus" v-close-popup @click="setRequestTrust(contact.username, false)">
|
||||
<q-item-section>{{$t('friends.accept')}}</q-item-section>
|
||||
</q-item>
|
||||
</q-list>
|
||||
</q-menu>
|
||||
</q-btn>
|
||||
</q-item-label>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</q-list>
|
||||
|
||||
Reference in New Issue
Block a user