- tutorial Circuito Ris Italia
- Invia RIS (visibile per tutti)
This commit is contained in:
@@ -20,9 +20,12 @@ import { useI18n } from '@/boot/i18n'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { useCircuitStore } from '@store/CircuitStore'
|
||||
|
||||
const STEP_CIRCUIT = 2
|
||||
const STEP_NAME_SURNAME = 20
|
||||
const STEP_FOTO = 50
|
||||
const STEP_CITY = 100
|
||||
const STEP_CIRCUIT = 200
|
||||
const STEP_CIRCUIT_ITALIA = 210
|
||||
const STEP_FINE = 400
|
||||
const STEP_NAME_SURNAME = 401
|
||||
const STEP_FOTO = 402
|
||||
|
||||
export default defineComponent({
|
||||
name: 'CMyProfileTutorial',
|
||||
@@ -54,12 +57,16 @@ export default defineComponent({
|
||||
const $route = useRoute()
|
||||
|
||||
const showAccountInfo = ref(false)
|
||||
const indstep = ref(0)
|
||||
const step = ref(1)
|
||||
const nascondiavviso = ref(false)
|
||||
|
||||
const username = ref('')
|
||||
const showsendCoinTo = ref(false)
|
||||
const circuitsel = ref('')
|
||||
const mycircuit = ref(<ICircuit | undefined | null>null)
|
||||
const circuititalia = ref(<ICircuit | undefined | null>null)
|
||||
const mylistcircuits = ref(<ICircuit[] | undefined>[])
|
||||
|
||||
const contact = ref(<IUserFields | null>null)
|
||||
|
||||
@@ -81,57 +88,38 @@ export default defineComponent({
|
||||
}
|
||||
})
|
||||
|
||||
const card = computed(() => {
|
||||
|
||||
if (contact.value && contact.value.profile.resid_card) {
|
||||
return contact.value.profile.resid_card
|
||||
} else {
|
||||
return ''
|
||||
}
|
||||
})
|
||||
|
||||
watch(() => strProv.value, (newval: string, oldval: string) => {
|
||||
mycircuit.value = circuitStore.getCircuitByProvince(strProv.value)
|
||||
mycircuit.value = circuitStore.getCircuitByProvinceAndCard(strProv.value, card.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_CIRCUIT )) {
|
||||
mycircuit.value = circuitStore.getCircuitByProvince(strProv.value)
|
||||
console.log('isAskedToCircuit()', isAskedToCircuit())
|
||||
// userStore.savenoCircuit(isAskedToCircuit())
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
if (step.value === STEP_FOTO + 1) {
|
||||
let index = step.value
|
||||
if (userStore.my.profile.img) {
|
||||
// foto esistente
|
||||
userStore.savenoFoto(false)
|
||||
} else {
|
||||
userStore.savenoFoto(true)
|
||||
}
|
||||
}
|
||||
watch(() => card.value, (newval: string, oldval: string) => {
|
||||
mycircuit.value = circuitStore.getCircuitByProvinceAndCard(strProv.value, card.value)
|
||||
})
|
||||
|
||||
watch(() => circuitsel.value, (newval: string, oldval: string) => {
|
||||
if (circuitsel.value)
|
||||
mycircuit.value = circuitStore.getCircuitByName(circuitsel.value)
|
||||
})
|
||||
|
||||
|
||||
const arrStep = [
|
||||
let arrStep = ref([
|
||||
{
|
||||
step: 1,
|
||||
indstep: 0,
|
||||
step: STEP_CITY,
|
||||
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 },
|
||||
checkOkReal: function () { return this.checkOk() },
|
||||
checkOk: function (): boolean { return contact.value ? !!contact.value.profile.resid_province : false },
|
||||
checkOkReal: function (): boolean { return this.checkOk() },
|
||||
icon: 'house',
|
||||
required: true,
|
||||
},
|
||||
@@ -146,6 +134,7 @@ export default defineComponent({
|
||||
required: false,
|
||||
},*/
|
||||
{
|
||||
indstep: 1,
|
||||
step: STEP_CIRCUIT,
|
||||
title: t('tutorial.step_circuito_title'),
|
||||
extratitle: function () { return mycircuit.value ? ': ' + mycircuit.value.name : '' },
|
||||
@@ -192,26 +181,105 @@ export default defineComponent({
|
||||
icon: 'fas fa-tshirt',
|
||||
required: false,
|
||||
},*/
|
||||
{
|
||||
step: 3,
|
||||
title: t('tutorial.step_fine_title'),
|
||||
extratitle: function () { return '' },
|
||||
label: t('tutorial.step_fine'),
|
||||
checkOk: function () {
|
||||
return true
|
||||
},
|
||||
checkOkReal: function () { return this.checkOk() },
|
||||
icon: 'fas fa-tshirt',
|
||||
required: false,
|
||||
},
|
||||
]
|
||||
])
|
||||
|
||||
const numindstep = computed(() => arrStep.value.length)
|
||||
|
||||
watch(() => indstep.value, (newval: number, oldval: number) => {
|
||||
if (indstep.value >= 0)
|
||||
step.value = arrStep.value[indstep.value].step
|
||||
else
|
||||
step.value = 0
|
||||
|
||||
if (indstep.value > userStore.my.profile.stepTutorial)
|
||||
userStore.my.profile.stepTutorial = indstep.value
|
||||
|
||||
userStore.saveStepTutorial(indstep.value)
|
||||
if (indstep.value >= numindstep.value) {
|
||||
tools.scrollToTop()
|
||||
}
|
||||
|
||||
if ((step.value === STEP_CIRCUIT)) {
|
||||
mycircuit.value = circuitStore.getCircuitByProvinceAndCard(strProv.value, card.value)
|
||||
|
||||
mylistcircuits.value = circuitStore.getCircuitsNameByProvince(strProv.value)
|
||||
console.log('isAskedToCircuit()', isAskedToCircuit())
|
||||
// userStore.savenoCircuit(isAskedToCircuit())
|
||||
}
|
||||
|
||||
if ((step.value === STEP_CIRCUIT_ITALIA)) {
|
||||
mylistcircuits.value = []
|
||||
circuititalia.value = circuitStore.getCircuitByPath('ris_italia')
|
||||
}
|
||||
|
||||
if (step.value === STEP_NAME_SURNAME + 1) {
|
||||
let index = indstep.value
|
||||
console.log('Salva ', arrStep.value[index])
|
||||
if ((contact.value ? !!contact.value.name : false) && contact.value!.name) {
|
||||
// nome esistente
|
||||
userStore.savenoNameSurname(false)
|
||||
} else {
|
||||
userStore.savenoNameSurname(true)
|
||||
}
|
||||
}
|
||||
|
||||
/*if (step.value === STEP_FOTO + 1) {
|
||||
let index = indstep.value
|
||||
if (userStore.my.profile.img) {
|
||||
// foto esistente
|
||||
userStore.savenoFoto(false)
|
||||
} else {
|
||||
userStore.savenoFoto(true)
|
||||
}
|
||||
} */
|
||||
|
||||
})
|
||||
|
||||
|
||||
const stepFine = {
|
||||
step: STEP_FINE,
|
||||
title: t('tutorial.step_fine_title'),
|
||||
extratitle: function () { return '' },
|
||||
label: t('tutorial.step_fine'),
|
||||
checkOk: function () {
|
||||
return true
|
||||
},
|
||||
checkOkReal: function () { return this.checkOk() },
|
||||
icon: 'fas fa-tshirt',
|
||||
required: false,
|
||||
}
|
||||
|
||||
|
||||
const stepCircItalia =
|
||||
{
|
||||
step: STEP_CIRCUIT_ITALIA,
|
||||
title: t('tutorial.step_circuito_italia_title'),
|
||||
extratitle: function () { return circuititalia.value ? ': ' + circuititalia.value.name : '' },
|
||||
label: circuitStore.SonoDentroAdAlmeno1CircuitoConFido() ? t('tutorial.step_circuito_italia') : t('tutorial.non_sono_dentro_al_mio_circuito'),
|
||||
label_ok: t('tutorial.step_circuito_italia_ok'),
|
||||
checkOk: function () {
|
||||
if (circuititalia.value) {
|
||||
return ((userStore.IsMyCircuitByName(circuititalia.value.name) ||
|
||||
userStore.IsAskedCircuitByName(circuititalia.value.name))) || userStore.my.profile.noCircIta
|
||||
}
|
||||
return false
|
||||
},
|
||||
checkOkReal: function () {
|
||||
if (circuititalia.value) {
|
||||
return ((userStore.IsMyCircuitByName(circuititalia.value.name) ||
|
||||
userStore.IsAskedCircuitByName(circuititalia.value.name)))
|
||||
}
|
||||
return false
|
||||
},
|
||||
icon: 'img: images/1ris_rosso_100.png',
|
||||
required: false,
|
||||
}
|
||||
|
||||
const numstep = computed(() => arrStep.length)
|
||||
|
||||
const prStep = computed(() => {
|
||||
|
||||
let num = 0
|
||||
for (const mystep of arrStep) {
|
||||
for (const mystep of arrStep.value) {
|
||||
if (mystep.checkOk())
|
||||
num++
|
||||
}
|
||||
@@ -220,8 +288,8 @@ export default defineComponent({
|
||||
|
||||
const progressStep = computed(() => {
|
||||
|
||||
if (numstep.value > 0)
|
||||
return prStep.value / numstep.value
|
||||
if (numindstep.value > 0)
|
||||
return prStep.value / numindstep.value
|
||||
else
|
||||
return 0
|
||||
})
|
||||
@@ -253,22 +321,24 @@ export default defineComponent({
|
||||
username.value = props.mycontact.username
|
||||
}
|
||||
}
|
||||
mylistcircuits.value = circuitStore.getCircuitsNameByProvince(strProv.value)
|
||||
|
||||
mycircuit.value = circuitStore.getCircuitByProvince(strProv.value)
|
||||
mycircuit.value = circuitStore.getCircuitByProvinceAndCard(strProv.value, card.value)
|
||||
|
||||
if (contact.value)
|
||||
filtroutente.value = [{ userId: contact.value._id }]
|
||||
if (contact.value)
|
||||
filtroutente.value = [{ userId: contact.value._id }]
|
||||
|
||||
userStore.my.profile.stepTutorial = getFirstStepToFill()
|
||||
|
||||
step.value = userStore.my.profile.stepTutorial ? userStore.my.profile.stepTutorial : 1
|
||||
if (step.value > numstep.value)
|
||||
step.value = numstep.value
|
||||
indstep.value = userStore.my.profile.stepTutorial ? userStore.my.profile.stepTutorial : 1
|
||||
if (indstep.value > numindstep.value)
|
||||
indstep.value = numindstep.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 = 0
|
||||
}
|
||||
|
||||
|
||||
@@ -276,8 +346,8 @@ export default defineComponent({
|
||||
|
||||
|
||||
function getFirstStepToFill() {
|
||||
let num = 1
|
||||
for (const mystep of arrStep) {
|
||||
let num = 0
|
||||
for (const mystep of arrStep.value) {
|
||||
if (mystep.checkOk())
|
||||
num++
|
||||
else
|
||||
@@ -308,23 +378,23 @@ export default defineComponent({
|
||||
|
||||
const checkifDisabled = computed(() => {
|
||||
let ret = true
|
||||
let mystep = step.value
|
||||
let mystep = indstep.value
|
||||
if (mystep > 0) {
|
||||
return !arrStep[mystep - 1].checkOk()
|
||||
return !arrStep.value[mystep].checkOk()
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
})
|
||||
|
||||
function clickFinish() {
|
||||
userStore.my.profile.stepTutorial = numstep.value + 1
|
||||
step.value = numstep.value + 1
|
||||
userStore.my.profile.stepTutorial = numindstep.value + 1
|
||||
indstep.value = numindstep.value + 1
|
||||
|
||||
}
|
||||
|
||||
function isNextDisable() {
|
||||
try {
|
||||
return arrStep[step.value - 1].required && !arrStep[step.value - 1].checkOk()
|
||||
return arrStep.value[indstep.value - 1].required && !arrStep.value[indstep.value - 1].checkOk()
|
||||
} catch (e) {
|
||||
return false
|
||||
}
|
||||
@@ -334,7 +404,7 @@ export default defineComponent({
|
||||
return prStep.value
|
||||
}
|
||||
function completed() {
|
||||
return prStep.value === numstep.value
|
||||
return prStep.value === numindstep.value
|
||||
}
|
||||
|
||||
function getColorTutorial() {
|
||||
@@ -348,7 +418,14 @@ export default defineComponent({
|
||||
return 'primary'
|
||||
}
|
||||
}
|
||||
|
||||
function mounted() {
|
||||
|
||||
if (circuitStore.SonoDentroAdAlmeno1CircuitoConFido())
|
||||
arrStep.value.push({ ...stepCircItalia, indstep: numindstep.value })
|
||||
|
||||
arrStep.value.push({ ...stepFine, indstep: numindstep.value })
|
||||
|
||||
if (userStore.isUserOk()) {
|
||||
updatestart()
|
||||
}
|
||||
@@ -359,13 +436,44 @@ export default defineComponent({
|
||||
return !!(mycircuit.value && ((!userStore.IsMyCircuitByName(mycircuit.value.name) && !userStore.IsAskedCircuitByName(mycircuit.value.name))))
|
||||
}
|
||||
|
||||
function isSalta() {
|
||||
return step.value === STEP_CIRCUIT && (mycircuit.value && isAskedToCircuit())
|
||||
function isAskedToCircuitItalia(): boolean {
|
||||
return !!(circuititalia.value && ((!userStore.IsMyCircuitByName(circuititalia.value.name) && !userStore.IsAskedCircuitByName(circuititalia.value.name))))
|
||||
}
|
||||
|
||||
function askToConfirmSkip() {
|
||||
function isSalta(step: number) {
|
||||
return (step === STEP_CIRCUIT && (mycircuit.value && isAskedToCircuit())) ||
|
||||
(step === STEP_CIRCUIT_ITALIA && (circuititalia.value && isAskedToCircuitItalia()))
|
||||
}
|
||||
|
||||
function askToConfirmSkip(mystep: number) {
|
||||
if (mystep === STEP_CIRCUIT) {
|
||||
return $q.dialog({
|
||||
message: t('circuit.skipentercircuit'),
|
||||
html: true,
|
||||
ok: {
|
||||
label: t('dialog.yes'),
|
||||
push: false,
|
||||
},
|
||||
title: '',
|
||||
cancel: true,
|
||||
persistent: false,
|
||||
}).onOk(() => {
|
||||
if ((step.value === STEP_CIRCUIT)) {
|
||||
userStore.savenoCircuit(isAskedToCircuit())
|
||||
}
|
||||
indstep.value++
|
||||
return true
|
||||
}).onCancel(() => {
|
||||
return false
|
||||
})
|
||||
} else if (mystep === STEP_CIRCUIT_ITALIA) {
|
||||
askToConfirmSkipItalia(mystep)
|
||||
}
|
||||
}
|
||||
|
||||
function askToConfirmSkipItalia(mystep: number) {
|
||||
return $q.dialog({
|
||||
message: t('circuit.skipentercircuit'),
|
||||
message: t('circuit.skipentercircuit_italia'),
|
||||
html: true,
|
||||
ok: {
|
||||
label: t('dialog.yes'),
|
||||
@@ -375,15 +483,18 @@ export default defineComponent({
|
||||
cancel: true,
|
||||
persistent: false,
|
||||
}).onOk(() => {
|
||||
step.value++
|
||||
if ((mystep === STEP_CIRCUIT_ITALIA)) {
|
||||
userStore.savenoCircIta(isAskedToCircuitItalia())
|
||||
}
|
||||
indstep.value++
|
||||
return true
|
||||
}).onCancel(() => {
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
||||
function getColorDone(step: number) {
|
||||
return arrStep[step].checkOkReal() ? 'positive' : 'negative'
|
||||
function getColorDone(indstep: number) {
|
||||
return arrStep.value[indstep].checkOkReal() ? 'positive' : 'negative'
|
||||
}
|
||||
|
||||
onMounted(mounted)
|
||||
@@ -399,13 +510,15 @@ export default defineComponent({
|
||||
tools,
|
||||
showsendCoinTo,
|
||||
showAccountInfo,
|
||||
indstep,
|
||||
step,
|
||||
numstep,
|
||||
numindstep,
|
||||
progressLabel,
|
||||
progressStep,
|
||||
arrStep,
|
||||
strProv,
|
||||
mycircuit,
|
||||
mylistcircuits,
|
||||
userStore,
|
||||
clickFinish,
|
||||
isNextDisable,
|
||||
@@ -417,10 +530,18 @@ export default defineComponent({
|
||||
getColorTutorial,
|
||||
getFirstStepToFill,
|
||||
STEP_CIRCUIT,
|
||||
STEP_CIRCUIT_ITALIA,
|
||||
STEP_CITY,
|
||||
STEP_FOTO,
|
||||
STEP_NAME_SURNAME,
|
||||
isSalta,
|
||||
askToConfirmSkip,
|
||||
getColorDone,
|
||||
nascondiavviso,
|
||||
circuitsel,
|
||||
card,
|
||||
askToConfirmSkipItalia,
|
||||
circuititalia,
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user