Friends, search

This commit is contained in:
paoloar77
2022-01-12 00:38:31 +01:00
parent 3de9967571
commit 45993d05c5
27 changed files with 464 additions and 152 deletions

View File

@@ -0,0 +1,4 @@
.myflex{
display: flex;
flex: 1;
}

View File

@@ -0,0 +1,86 @@
import { defineComponent, onMounted, PropType, ref, watch } from 'vue'
import { useUserStore } from '@store/UserStore'
import { IImgGallery, IUserFields, IUserProfile } from 'model'
import { costanti } from '@costanti'
import { shared_consts } from '@/common/shared_vuejs'
import { tools } from '@store/Modules/tools'
import { useQuasar } from 'quasar'
import { useI18n } from '@/boot/i18n'
import { useRoute, useRouter } from 'vue-router'
export default defineComponent({
name: 'CMyUser',
emits: ['setCmd'],
props: {
mycontact: {
type: Object as PropType<IUserFields | null>,
required: false,
default: null,
},
myusername: {
type: String,
required: false,
default: null,
},
visu: {
type: Number,
required: true,
}
},
setup(props, { emit }) {
const userStore = useUserStore()
const $q = useQuasar()
const { t } = useI18n()
const $router = useRouter()
const $route = useRoute()
const username = ref('')
const contact = ref(<IUserFields | null>null)
watch(() => props.mycontact, (newval, oldval) => {
console.log('watch: mycontact')
mounted()
})
function mounted() {
if (!props.mycontact) {
if (props.myusername) {
username.value = props.myusername
//++Todo: carica contact
contact.value = null
}
} else {
if (props.mycontact) {
contact.value = props.mycontact
username.value = props.mycontact.username
}
}
}
function getImgUser(profile: IUserFields) {
return userStore.getImgByProfile(profile)
}
function naviga(path: string) {
$router.push(path)
}
function setCmd(cmd: number, myusername: string, value: any = '') {
emit('setCmd', cmd, myusername, value)
}
onMounted(mounted)
return {
contact,
costanti,
getImgUser,
naviga,
setCmd,
shared_consts,
}
},
})

View File

@@ -0,0 +1,84 @@
<template>
<div v-if="contact">
<q-item 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 @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 v-if="visu === 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="setCmd(shared_consts.FRIENDSCMD.REMOVE_FROM_MYFRIENDS, 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="setCmd(shared_consts.FRIENDSCMD.BLOCK_USER, 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="visu === costanti.ASK_TRUST">
<q-item-label>
<q-btn color="positive" :label="$t('friends.accept_trust')" @click="setCmd(shared_consts.FRIENDSCMD.SETTRUST, contact.username, true)"/>
</q-item-label>
<q-item-label>
<q-btn color="negative" :label="$t('friends.reject_trust')" @click="setCmd(shared_consts.FRIENDSCMD.SETTRUST, contact.username, false)"/>
</q-item-label>
</q-item-section>
<q-item-section side v-if="visu === costanti.TRUSTED">
<q-item-label>
<q-btn rounded icon="fas fa-ellipsis-h">
<q-menu>
<q-list v-if="true" style="min-width: 200px">
<q-item clickable v-close-popup @click="setCmd(shared_consts.FRIENDSCMD.SETFRIEND, contact.username)">
<q-item-section>{{ $t('friends.accept_friend') }}</q-item-section>
</q-item>
</q-list>
<q-list style="min-width: 200px">
<q-item clickable v-close-popup @click="setCmd(shared_consts.FRIENDSCMD.SETTRUST, contact.username, false)">
<q-item-section>{{ $t('friends.reject_friend') }}</q-item-section>
</q-item>
</q-list>
</q-menu>
</q-btn>
</q-item-label>
</q-item-section>
<q-item-section side v-if="visu === 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="setCmd(shared_consts.FRIENDSCMD.SETTRUST, contact.username, true)">
<q-item-section>{{ $t('friends.accept_trust') }}</q-item-section>
</q-item>
</q-list>
</q-menu>
</q-btn>
</q-item-label>
</q-item-section>
</q-item>
</div>
</template>
<script lang="ts" src="./CMyUser.ts">
</script>
<style lang="scss" scoped>
@import './CMyUser.scss';
</style>

View File

@@ -0,0 +1 @@
export { default as CMyUser } from './CMyUser.vue'