Move disclaimer to app (#68)

The pre app disclaimer makes more sense initialized by the app and not the home page.  This PR moves the popup to the app and adds basic store functionality to give global access to the state of the apps agreement.

Signed-off-by: Justin Georgi <justin.georgi@gmail.com>

Reviewed-on: Georgi_Lab/ALVINN_f7#68
This commit is contained in:
2024-01-10 09:32:41 -07:00
parent 671813958b
commit 23a2772468
3 changed files with 99 additions and 102 deletions

View File

@@ -17,7 +17,29 @@
</f7-panel>
<!-- Your main view, should have "view-main" class -->
<f7-view main class="safe-areas" url="/"></f7-view>
<f7-view main class="safe-areas" url="/">
<f7-popup :opened="showDisclaimer"
style="height: auto; text-align: center;"
:close-by-backdrop-click="false"
:close-on-escape="false"
:swipe-to-close="false"
>
<f7-block-title large>
IMPORTANT
</f7-block-title>
<f7-block>
<h3>
ALVINN is for educational purposes only. It may not be used for medical diagnosis, intervention, or treatment.
</h3>
<div style="display: flex; justify-content: space-around; flex-direction: row; align-items: center;">
<span style="height: min-content;">
<f7-checkbox v-model:checked="rememberAgreement"/> Don't show again
</span>
<f7-button text="I agree" fill @click="setAgreement" />
</div>
</f7-block>
</f7-popup>
</f7-view>
</f7-app>
</template>
@@ -38,6 +60,57 @@
import store from '../js/store';
export default {
data () {
return {
rememberAgreement: false,
siteAgreement: false,
showDisclaimer: true
}
},
created () {
var loadSiteSettings = localStorage.getItem('siteSettings')
if (loadSiteSettings) {
var loadedSettings = JSON.parse(loadSiteSettings)
this.siteAgreement = loadedSettings.siteAgreement
this.rememberAgreement = loadedSettings.rememberAgreement
}
if (this.siteAgreement && this.rememberAgreement) {
this.showDisclaimer = false
store().agree()
}
},
methods: {
setAgreement () {
this.siteAgreement = true
store().agree()
let newSettings = {
siteAgreement: this.siteAgreement,
rememberAgreement: this.rememberAgreement
}
let saveSiteSettings = new Promise(
(saved,failed) => {
try {
localStorage.setItem('siteSettings',JSON.stringify(newSettings))
saved()
} catch {
failed()
}
}
)
saveSiteSettings.then(
() => {
this.showDisclaimer = false
},
() => {
var toast = f7.toast.create({
text: 'ERROR: No settings saved',
closeTimeout: 2000
})
toast.open()
}
)
}
},
setup() {
const device = getDevice();
// Framework7 Parameters
@@ -48,6 +121,7 @@
} catch {
var darkTheme = 'auto'
}
//provide('isAgreed',siteAgreement)
const f7params = {
name: 'ALVINN', // App name
theme: 'auto', // Automatic theme detection
@@ -56,8 +130,6 @@
primary: '#002f65',
},
// App store
store: store,
// App routes
routes: routes,
@@ -98,7 +170,7 @@
});
return {
f7params
f7params,
}
}
}