- Invia Ris a e Ricevi Ris
- Tutorial Guidato Passi da Compiere - Provincia in cui vivi - Policy aggiornata
This commit is contained in:
@@ -5,21 +5,28 @@ import { costanti } from '@costanti'
|
||||
import { shared_consts } from '@/common/shared_vuejs'
|
||||
import { tools } from '@store/Modules/tools'
|
||||
import { useQuasar } from 'quasar'
|
||||
import { CTitleBanner } from '@/components/CTitleBanner'
|
||||
import { CSendCoins } from '@/components/CSendCoins'
|
||||
import { CSkill } from '@/components/CSkill'
|
||||
import { CMyFieldRec } from '@/components/CMyFieldRec'
|
||||
import { CSaldo } from '@/components/CSaldo'
|
||||
import { CMySelectCity } from '@/components/CMySelectCity'
|
||||
import { CMyFieldDb } from '@/components/CMyFieldDb'
|
||||
import { CMyCircuit } from '@/components/CMyCircuit'
|
||||
import { CMySelect } from '@/components/CMySelect'
|
||||
import { CMyUserOnlyView } from '@/components/CMyUserOnlyView'
|
||||
import { CUserInfoAccount } from '@/components/CUserInfoAccount'
|
||||
import { useI18n } from '@/boot/i18n'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { useCircuitStore } from '@store/CircuitStore'
|
||||
|
||||
const STEP_NAME_SURNAME = 2
|
||||
|
||||
export default defineComponent({
|
||||
name: 'CMyProfileTutorial',
|
||||
components: {
|
||||
CSendCoins, CSaldo, CUserInfoAccount,
|
||||
CMySelectCity, CMyFieldRec, CMySelect
|
||||
CMySelectCity, CMyFieldRec, CSkill, CMyUserOnlyView, CTitleBanner, CMySelect, CMyFieldDb, CMyCircuit
|
||||
},
|
||||
emits: ['setCmd'],
|
||||
props: {
|
||||
@@ -45,39 +52,158 @@ export default defineComponent({
|
||||
const $route = useRoute()
|
||||
|
||||
const showAccountInfo = ref(false)
|
||||
const slidestep = ref('1')
|
||||
const step = ref(1)
|
||||
|
||||
const username = ref('')
|
||||
const showsendCoinTo = ref(false)
|
||||
const mycircuit = ref(<ICircuit | undefined | null>null)
|
||||
|
||||
const contact = ref(<IUserFields | null>null)
|
||||
const circuit = ref(<ICircuit | null | undefined>null)
|
||||
|
||||
|
||||
const filtroutente = ref(<any[]>[])
|
||||
|
||||
const stepTut = computed(() => userStore.my.profile.stepTutorial)
|
||||
const noNameSurname = computed(() => userStore.my.profile.noNameSurname)
|
||||
|
||||
const mycards = computed(() => {
|
||||
return costanti.MAINCARDS.filter((rec: any) => shared_consts.TABLES_INSERT_ALMOST_ONE_TO_ENABLE_CIRCUIT.includes(rec.table))
|
||||
})
|
||||
|
||||
const strProv = computed(() => {
|
||||
|
||||
if (contact.value && contact.value.profile.resid_province) {
|
||||
return contact.value.profile.resid_province
|
||||
} else {
|
||||
return ''
|
||||
}
|
||||
})
|
||||
|
||||
watch(() => strProv.value, (newval: string, oldval: string) => {
|
||||
mycircuit.value = circuitStore.getCircuitByProvince(strProv.value)
|
||||
})
|
||||
|
||||
watch(() => step.value, (newval: number, oldval: number) => {
|
||||
|
||||
if (step.value > userStore.my.profile.stepTutorial)
|
||||
userStore.my.profile.stepTutorial = step.value
|
||||
|
||||
userStore.saveStepTutorial(step.value)
|
||||
if (step.value >= numstep.value) {
|
||||
tools.scrollToTop()
|
||||
}
|
||||
|
||||
if (step.value === STEP_NAME_SURNAME + 1) {
|
||||
let index = step.value
|
||||
console.log('Salva ', arrStep[index])
|
||||
if ((contact.value ? !!contact.value.name : false) && contact.value!.name) {
|
||||
// nome esistente
|
||||
userStore.savenoNameSurname(false)
|
||||
} else {
|
||||
userStore.savenoNameSurname(true)
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
|
||||
const arrStep = [
|
||||
{
|
||||
label: t('tutorial.step_residence_title'),
|
||||
step: 1,
|
||||
title: t('tutorial.step_residence_title'),
|
||||
extratitle: function () { return ': ' + contact.value!.profile.resid_province },
|
||||
label: t('tutorial.step_residence'),
|
||||
checkOk: function () { return contact.value ? !!contact.value.profile.resid_province : false },
|
||||
step: '1',
|
||||
icon: 'house'
|
||||
}
|
||||
},
|
||||
{
|
||||
step: STEP_NAME_SURNAME, // 2
|
||||
title: t('tutorial.step_nomecognome_title'),
|
||||
extratitle: function () { return ': ' + (contact.value ? tools.getNomeUtenteEUsernameByRecUser(contact.value) : '') },
|
||||
label: t('tutorial.step_nomecognome'),
|
||||
checkOk: function () { return ((contact.value ? !!contact.value.name : false) || userStore.my.profile.noNameSurname) },
|
||||
icon: 'user'
|
||||
},
|
||||
{
|
||||
step: 3,
|
||||
title: t('tutorial.step_circuito_title'),
|
||||
extratitle: function () { return mycircuit.value ? ': ' + mycircuit.value.name : '' },
|
||||
label: t('tutorial.step_circuito'),
|
||||
label_ok: t('tutorial.step_circuito_ok'),
|
||||
checkOk: function () {
|
||||
if (mycircuit.value) {
|
||||
return (userStore.IsMyCircuitByName(mycircuit.value.name) ||
|
||||
userStore.IsAskedCircuitByName(mycircuit.value.name))
|
||||
}
|
||||
return false
|
||||
},
|
||||
icon: 'img: images/1ris_rosso_100.png',
|
||||
},
|
||||
{
|
||||
step: 4,
|
||||
title: t('tutorial.step_beniservizi_title'),
|
||||
extratitle: function () { return ': (' + userStore.my.profile.calc.numGoodsAndServices + ')' },
|
||||
label: t('tutorial.step_beniservizi'),
|
||||
checkOk: function () {
|
||||
return userStore.my.profile.calc.numGoodsAndServices! > 0
|
||||
},
|
||||
icon: 'fas fa-tshirt',
|
||||
},
|
||||
{
|
||||
step: 5,
|
||||
title: t('tutorial.step_foto_title'),
|
||||
extratitle: function () { return ': (' + (userStore.my.profile.img ? t('dialog.yes') : t('dialog.no')) + ')' },
|
||||
label: t('tutorial.step_foto'),
|
||||
checkOk: function () {
|
||||
return !!userStore.my.profile.img
|
||||
},
|
||||
icon: 'fas fa-tshirt',
|
||||
},
|
||||
{
|
||||
step: 6,
|
||||
title: t('tutorial.step_fine_title'),
|
||||
extratitle: function () { return '' },
|
||||
label: t('tutorial.step_fine'),
|
||||
checkOk: function () {
|
||||
return true
|
||||
},
|
||||
icon: 'fas fa-tshirt',
|
||||
},
|
||||
]
|
||||
|
||||
const numstep = computed(() => arrStep.length)
|
||||
|
||||
const progressStep = computed(() => {
|
||||
let prStep = 0
|
||||
const prStep = computed(() => {
|
||||
|
||||
return prStep / numstep.value
|
||||
let num = 0
|
||||
for (const mystep of arrStep) {
|
||||
if (mystep.checkOk())
|
||||
num++
|
||||
}
|
||||
return num
|
||||
})
|
||||
|
||||
const progressLabel = computed(() => (progressStep.value * 100).toFixed(2) + '%')
|
||||
const progressStep = computed(() => {
|
||||
|
||||
if (numstep.value > 0)
|
||||
return prStep.value / numstep.value
|
||||
else
|
||||
return 0
|
||||
})
|
||||
|
||||
const progressLabel = computed(() => (progressStep.value * 100).toFixed(0) + '%')
|
||||
|
||||
watch(() => props.mycontact, (newval, oldval) => {
|
||||
console.log('watch: mycontact')
|
||||
mounted()
|
||||
updatestart()
|
||||
})
|
||||
|
||||
function mounted() {
|
||||
watch(() => tools.isUserOk(), (newval, oldval) => {
|
||||
if (userStore.isUserOk()) {
|
||||
updatestart()
|
||||
}
|
||||
})
|
||||
|
||||
function updatestart() {
|
||||
if (!props.mycontact) {
|
||||
if (props.myusername) {
|
||||
username.value = props.myusername
|
||||
@@ -93,7 +219,36 @@ export default defineComponent({
|
||||
}
|
||||
}
|
||||
|
||||
mycircuit.value = circuitStore.getCircuitByProvince(strProv.value)
|
||||
|
||||
if (contact.value)
|
||||
filtroutente.value = [{ userId: contact.value._id }]
|
||||
|
||||
step.value = userStore.my.profile.stepTutorial ? userStore.my.profile.stepTutorial : 1
|
||||
if (step.value > numstep.value)
|
||||
step.value = numstep.value
|
||||
|
||||
// circuit.value = circuitStore.getCircuitByName(props.circuitname)
|
||||
|
||||
if (!userStore.my.profile.stepTutorial || userStore.my.profile.stepTutorial === 0) {
|
||||
userStore.my.profile.stepTutorial = 1
|
||||
}
|
||||
|
||||
userStore.my.profile.stepTutorial = getFirstStepToFill()
|
||||
|
||||
}
|
||||
|
||||
|
||||
function getFirstStepToFill() {
|
||||
let num = 1
|
||||
for (const mystep of arrStep) {
|
||||
if (mystep.checkOk())
|
||||
num++
|
||||
else
|
||||
break
|
||||
}
|
||||
|
||||
return num
|
||||
}
|
||||
|
||||
function getImgUser(profile: IUserFields) {
|
||||
@@ -117,7 +272,7 @@ export default defineComponent({
|
||||
|
||||
const checkifDisabled = computed(() => {
|
||||
let ret = true
|
||||
let mystep = parseInt(slidestep.value)
|
||||
let mystep = step.value
|
||||
if (mystep > 0) {
|
||||
return !arrStep[mystep - 1].checkOk()
|
||||
} else {
|
||||
@@ -125,6 +280,37 @@ export default defineComponent({
|
||||
}
|
||||
})
|
||||
|
||||
function clickFinish() {
|
||||
userStore.my.profile.stepTutorial = numstep.value + 1
|
||||
step.value = numstep.value + 1
|
||||
|
||||
}
|
||||
|
||||
function numStepCompleted() {
|
||||
return prStep.value
|
||||
}
|
||||
function completed() {
|
||||
return prStep.value === numstep.value
|
||||
}
|
||||
|
||||
function getColorTutorial() {
|
||||
return completed() ? 'bg-green-5' : 'bg-primary'
|
||||
}
|
||||
|
||||
function getColor() {
|
||||
if (numStepCompleted()) {
|
||||
return 'positive'
|
||||
} else {
|
||||
return 'primary'
|
||||
}
|
||||
}
|
||||
function mounted() {
|
||||
if (userStore.isUserOk()) {
|
||||
updatestart()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
onMounted(mounted)
|
||||
|
||||
return {
|
||||
@@ -137,12 +323,23 @@ export default defineComponent({
|
||||
shared_consts,
|
||||
tools,
|
||||
showsendCoinTo,
|
||||
circuit,
|
||||
showAccountInfo,
|
||||
slidestep,
|
||||
step,
|
||||
numstep,
|
||||
progressLabel,
|
||||
progressStep,
|
||||
arrStep,
|
||||
strProv,
|
||||
mycircuit,
|
||||
userStore,
|
||||
clickFinish,
|
||||
mycards,
|
||||
filtroutente,
|
||||
getColor,
|
||||
stepTut,
|
||||
completed,
|
||||
getColorTutorial,
|
||||
getFirstStepToFill,
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user