import { defineComponent, onMounted, PropType, ref, watch, computed } 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 { fieldsTable } from '@store/Modules/fieldsTable' import { tools } from '@store/Modules/tools' import { toolsext } from '@store/Modules/toolsext' import { useQuasar } from 'quasar' import { useI18n } from '@/boot/i18n' import { CMyCardPopup } from '@/components/CMyCardPopup' import { useRouter } from 'vue-router' import { useCalendarStore } from '@src/store/CalendarStore' import { useGlobalStore } from '@src/store/globalStore' export default defineComponent({ name: 'CMyRecCard', components: { CMyCardPopup }, emits: ['setCmd', 'cmdext'], props: { table: { type: String, required: true, }, prop_myrec: { type: Object as PropType, required: false, default: null, }, editOn: { type: Boolean, required: false, default: false, }, margin_right: { type: Number, required: false, default: 0, } }, setup(props, { emit }) { const userStore = useUserStore() const calendarStore = useCalendarStore() const globalStore = useGlobalStore() // const $q = useQuasar() const { t } = useI18n() const $router = useRouter() const myrec = ref(null) const visupage = ref(false) const disabilita = computed(() => { return props.table === shared_consts.TABLES_MYBACHECAS }) watch(() => props.prop_myrec, (newval, oldval) => { mounted() }) function mounted() { if (props.prop_myrec) { myrec.value = props.prop_myrec } } function showBadge() { if (shared_consts.TABLES_SHOW_ADTYPE.includes(props.table)) { return true } return false } function getImgUser(profile: IUserFields) { return userStore.getImgByProfile(profile) } function naviga(path: string) { $router.push(path) } function setCmd($q: any, cmd: number, myusername: string, value: any, groupname: string) { emit('setCmd', $q, cmd, myusername, value, groupname) } function cmdExt(cmd: any, val1: any, val2: any) { emit('cmdext', cmd, val1, val2) } function navigaExt(obj: any) { cmdExt(costanti.CMD_SHOW_PAGE, null, obj) //let link = shared_consts.getDirectoryByTable(props.table) + '/' + obj._id //console.log('link', link) //$router.push(link) } function getNameToShow(user: IUserFields, col = null) { if (props.table === shared_consts.TABLES_MYBACHECAS && myrec.value.groupname) return myrec.value.groupname else return userStore.getNameToShow(user, col) } function isPartecipero() { return (props.table === shared_consts.TABLES_MYBACHECAS && calendarStore.isPartecipero(myrec.value._id, props.table)) } onMounted(mounted) return { t, myrec, costanti, getImgUser, naviga, navigaExt, setCmd, shared_consts, userStore, tools, toolsext, fieldsTable, cmdExt, visupage, showBadge, getNameToShow, isPartecipero, calendarStore, disabilita, globalStore, } }, })