Browse Source

code scanner for forms - WIP

pull/5114/head
Daniel Spaude 2 years ago
parent
commit
f3817f1858
No known key found for this signature in database
GPG Key ID: 654A3D1FA4F35FFE
  1. 35
      packages/nc-gui/pages/[projectType]/form/[viewId]/index/index.vue

35
packages/nc-gui/pages/[projectType]/form/[viewId]/index/index.vue

@ -1,5 +1,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { RelationTypes, UITypes, isVirtualCol } from 'nocodb-sdk' import { RelationTypes, UITypes, isVirtualCol } from 'nocodb-sdk'
import { ref } from 'vue'
import { StreamBarcodeReader } from 'vue-barcode-reader'
import { useSharedFormStoreOrThrow } from '#imports' import { useSharedFormStoreOrThrow } from '#imports'
const { sharedFormView, submitForm, v$, formState, notFound, formColumns, submitted, secondsRemain, isLoading } = const { sharedFormView, submitForm, v$, formState, notFound, formColumns, submitted, secondsRemain, isLoading } =
@ -17,6 +19,28 @@ function isRequired(_columnObj: Record<string, any>, required = false) {
return !!(required || (columnObj && columnObj.rqd && !columnObj.cdf)) return !!(required || (columnObj && columnObj.rqd && !columnObj.cdf))
} }
const showCodeScannerOverlay = ref(false)
const scannerIsReady = ref(false)
const onLoaded = async () => {
scannerIsReady.value = true
}
const showScannerIsLoadingMessage = computed(() => !scannerIsReady.value)
const onDecode = async (codeValue: string) => {
if (!showScannerField.value) {
return
}
try {
showCodeScannerOverlay.value = false
alert(`you scanned "${codeValue}"`)
} catch (error) {
console.error(error)
}
}
</script> </script>
<template> <template>
@ -109,16 +133,12 @@ function isRequired(_columnObj: Record<string, any>, required = false) {
{{ field.description }} {{ field.description }}
</div> </div>
<div> <div>
SCANNER PLACEHOLDER SCANNER PLACEHOLDER
<a-button class="nc-btn-find-row-by-scan nc-toolbar-btn" @click="showCodeScannerOverlay = true"> <a-button class="nc-btn-find-row-by-scan nc-toolbar-btn" @click="showCodeScannerOverlay = true">
<div class="flex items-center gap-1"> <div class="flex items-center gap-1">
<QrCodeScan /> <QrCodeScan />
<span class="!text-xs font-weight-normal"> <span class="!text-xs font-weight-normal"> {{ $t('activity.findRowByCodeScan') }}</span>
{{ $t('activity.findRowByCodeScan') }}</span
>
</div> </div>
</a-button> </a-button>
<a-modal <a-modal
@ -134,7 +154,7 @@ function isRequired(_columnObj: Record<string, any>, required = false) {
<div class="relative flex flex-col h-full"> <div class="relative flex flex-col h-full">
<div> <div>
<StreamBarcodeReader <StreamBarcodeReader
v-show="showScannerField" v-show="scannerIsReady"
@decode="onDecode" @decode="onDecode"
@loaded="onLoaded" @loaded="onLoaded"
></StreamBarcodeReader> ></StreamBarcodeReader>
@ -145,9 +165,6 @@ function isRequired(_columnObj: Record<string, any>, required = false) {
</div> </div>
</a-modal> </a-modal>
</div> </div>
</div> </div>
</div> </div>
</div> </div>

Loading…
Cancel
Save