I'm fairly new to Vue.js and Vuetify (used AngularJS for several years but our company is switching to Vue.js). What I'm trying to accomplish is when the user clicks on a 'sign in' button it does some checks (i.e. username cannot be blank) and launches a Vuetify Dialog to alert the user. I know Vuetify has some built in validation but looking for something a little more robust where I can wait for a reponse (i.e. when I need to wait for something like can I use your history / location).
Basically looking to do:
if (!userName){
userName = await mbox('You must Enter your Username');
return
}
OR
var mProceed = await mbox('Can we use your location for awesome stuff?');
where mbox (a simple messagebox popup box) is a function that returns a promise, programmatically loads a vue component, adds it to the dom, and waits for the response.
i.e.
async function mbox (mText) {
// load dialog component here and set message passed in
// How Do I load the template / wait for it?
return dialogResult
}
Vue Component would look something like (With button captions and text being variables I pass in to my mbox function):
<template>
<v-layout row justify-center>
<v-dialog
v-model=dialog
max-width=290
>
<v-card>
<v-card-title class=headline>Use Google's location service?</v-card-title>
<v-card-text>
Let Google help apps determine location. This means sending anonymous location data to Google, even when no apps are running.
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn
color=green darken-1
flat=flat
@click=dialog = false
>
Disagree
</v-btn>
<v-btn
color=green darken-1
flat=flat
@click=dialog = false
>
Agree
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</v-layout>
</template>
I'm fine editing the template / adding the script for the vue component I'm just not sure how to have it called via a method that returns a promise and waits for the response?