Files
salvato.newfreeplanet/src/components/CMyProfileTutorial/CMyProfileTutorial.ts

149 lines
3.7 KiB
TypeScript
Raw Normal View History

import { defineComponent, onMounted, PropType, ref, watch, computed } from 'vue'
import { useUserStore } from '@store/UserStore'
import { ICircuit, 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 { CSendCoins } from '@/components/CSendCoins'
import { CMyFieldRec } from '@/components/CMyFieldRec'
import { CSaldo } from '@/components/CSaldo'
import { CMySelectCity } from '@/components/CMySelectCity'
import { CMySelect } from '@/components/CMySelect'
import { CUserInfoAccount } from '@/components/CUserInfoAccount'
import { useI18n } from '@/boot/i18n'
import { useRoute, useRouter } from 'vue-router'
import { useCircuitStore } from '@store/CircuitStore'
export default defineComponent({
name: 'CMyProfileTutorial',
components: {
CSendCoins, CSaldo, CUserInfoAccount,
CMySelectCity, CMyFieldRec, CMySelect
},
emits: ['setCmd'],
props: {
mycontact: {
type: Object as PropType<IUserFields | null>,
required: false,
default: null,
},
myusername: {
type: String,
required: false,
default: null,
},
},
setup(props, { emit }) {
const userStore = useUserStore()
const circuitStore = useCircuitStore()
const $q = useQuasar()
const { t } = useI18n()
const $router = useRouter()
const $route = useRoute()
const showAccountInfo = ref(false)
const slidestep = ref('1')
const username = ref('')
const showsendCoinTo = ref(false)
const contact = ref(<IUserFields | null>null)
const circuit = ref(<ICircuit | null | undefined>null)
const arrStep = [
{
label: t('tutorial.step_residence_title'),
checkOk: function () { return contact.value ? !!contact.value.profile.resid_province : false },
step: '1',
icon: 'house'
}
]
const numstep = computed(() => arrStep.length)
const progressStep = computed(() => {
let prStep = 0
return prStep / numstep.value
})
const progressLabel = computed(() => (progressStep.value * 100).toFixed(2) + '%')
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 {
contact.value = userStore.my
}
} else {
if (props.mycontact) {
contact.value = props.mycontact
username.value = props.mycontact.username
}
}
// circuit.value = circuitStore.getCircuitByName(props.circuitname)
}
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, dest: string) {
emit('setCmd', $q, cmd, myusername, value, dest)
}
function getLabelByStatusStep(step: string) {
let mystr = ''
return mystr
}
const checkifDisabled = computed(() => {
let ret = true
let mystep = parseInt(slidestep.value)
if (mystep > 0) {
return !arrStep[mystep - 1].checkOk()
} else {
return false
}
})
onMounted(mounted)
return {
contact,
costanti,
checkifDisabled,
getImgUser,
naviga,
setCmd,
shared_consts,
tools,
showsendCoinTo,
circuit,
showAccountInfo,
slidestep,
numstep,
progressLabel,
arrStep,
}
},
})