diff --git a/src/App.ts b/src/App.ts index 688ebf97..09a1359f 100755 --- a/src/App.ts +++ b/src/App.ts @@ -58,7 +58,7 @@ export default { } } - function isScrolledIntoView (el: any) { + function isScrolledIntoView(el: any) { let rect = el.getBoundingClientRect() let elemTop = rect.top let elemBottom = rect.bottom @@ -75,6 +75,16 @@ export default { console.log('scrolled') } } + + let displayMode = 'browser'; + const mqStandAlone = '(display-mode: standalone)'; + // @ts-ignore + if (((navigator && (navigator.standalone))) || + (window.matchMedia(mqStandAlone).matches)) { + displayMode = 'standalone' + } + + globalStore.isAppRunning = displayMode === 'standalone'; } function mounted() { diff --git a/src/common/shared_vuejs.ts b/src/common/shared_vuejs.ts index cd4a315f..f4ca32b2 100755 --- a/src/common/shared_vuejs.ts +++ b/src/common/shared_vuejs.ts @@ -37,6 +37,7 @@ export const shared_consts = { CAROUSEL_IMGS: 110, OPENSTREETMAP: 120, MAINVIEW: 130, + CHECKAPPRUNNING: 135, DASHBOARD: 140, STATUSREG: 160, CHECKIFISLOGGED: 170, @@ -1353,6 +1354,10 @@ export const shared_consts = { value: 210, label: 'Notifiche in Top', }, + { + value: 135, + label: 'Check App Running', + }, { value: 220, label: 'CHART', diff --git a/src/components/CCheckAppRunning/CCheckAppRunning.scss b/src/components/CCheckAppRunning/CCheckAppRunning.scss new file mode 100755 index 00000000..e69de29b diff --git a/src/components/CCheckAppRunning/CCheckAppRunning.ts b/src/components/CCheckAppRunning/CCheckAppRunning.ts new file mode 100755 index 00000000..40b011f8 --- /dev/null +++ b/src/components/CCheckAppRunning/CCheckAppRunning.ts @@ -0,0 +1,54 @@ +import { defineComponent, ref, computed, PropType, toRef } from 'vue' +import { useUserStore } from '@store/UserStore' +import { useRouter } from 'vue-router' +import { useGlobalStore } from '@store/globalStore' +import { useI18n } from '@/boot/i18n' +import { tools } from '@store/Modules/tools' +import { costanti, IMainCard } from '@store/Modules/costanti' +import { CBigBtn } from '@/components/CBigBtn' + + +export default defineComponent({ + name: 'CCheckAppRunning', + components: { CBigBtn }, + props: {}, + setup(props, { emit }) { + + const userStore = useUserStore() + const $router = useRouter() + const globalStore = useGlobalStore() + const { t } = useI18n() + + const deferredPrompt = ref(null) + + const isAppRunning = computed(() => globalStore.isAppRunning ) + + const finishLoading = computed(() => globalStore.finishLoading) + + function initprompt() { + window.addEventListener('beforeinstallprompt', (event) => { + event.preventDefault() + console.log('beforeinstallprompt !') + // Stash the event so it can be triggered later. + deferredPrompt.value = event + }) + } + + function installApp() { + if (deferredPrompt.value) + deferredPrompt.value.prompt() + } + + initprompt() + + return { + userStore, + tools, + costanti, + finishLoading, + deferredPrompt, + installApp, + isAppRunning, + } + } +}) diff --git a/src/components/CCheckAppRunning/CCheckAppRunning.vue b/src/components/CCheckAppRunning/CCheckAppRunning.vue new file mode 100755 index 00000000..02f94f31 --- /dev/null +++ b/src/components/CCheckAppRunning/CCheckAppRunning.vue @@ -0,0 +1,31 @@ + + + + + diff --git a/src/components/CCheckAppRunning/index.ts b/src/components/CCheckAppRunning/index.ts new file mode 100755 index 00000000..d042cfd4 --- /dev/null +++ b/src/components/CCheckAppRunning/index.ts @@ -0,0 +1 @@ +export {default as CCheckAppRunning} from './CCheckAppRunning.vue' diff --git a/src/components/CGridTableRec/CGridTableRec.ts b/src/components/CGridTableRec/CGridTableRec.ts index 36b993c3..d479b16e 100755 --- a/src/components/CGridTableRec/CGridTableRec.ts +++ b/src/components/CGridTableRec/CGridTableRec.ts @@ -264,6 +264,7 @@ export default defineComponent({ const addRow = ref('Aggiungi') const newRecordBool = ref(false) + const newRecordBoolOld = ref(false) const editRecordBool = ref(false) const newRecord: any = ref({}) const recSaved: any = ref({}) @@ -278,6 +279,7 @@ export default defineComponent({ const tablesel = ref('') const loading = ref(false) + const editOn = ref(false) const visupagedialog = ref(false) const myrecdialog = ref(null) @@ -1818,6 +1820,15 @@ export default defineComponent({ ris.username = userStore.my.username } + if (userStore.my.profile) { + if (fieldsTable.tableforEnableCircuits.includes(props.prop_mytable)) { + if (!userStore.my.profile.calc.numGoodsAndServices) + userStore.my.profile.calc.numGoodsAndServices = 1 + else + userStore.my.profile.calc.numGoodsAndServices += 1 + } + } + // console.table(serverData.value) if (indrec >= 0) serverData.value[indrec] = ris @@ -2153,6 +2164,8 @@ export default defineComponent({ t, exportTable, showNotification, + editOn, + newRecordBoolOld, } } }) diff --git a/src/components/CGridTableRec/CGridTableRec.vue b/src/components/CGridTableRec/CGridTableRec.vue index 2e99eb2b..99c0b74e 100755 --- a/src/components/CGridTableRec/CGridTableRec.vue +++ b/src/components/CGridTableRec/CGridTableRec.vue @@ -1,5 +1,12 @@