Browse Source

qrscanner - WIP

pull/4898/head
Daniel Spaude 2 years ago
parent
commit
6e8b118176
No known key found for this signature in database
GPG Key ID: 654A3D1FA4F35FFE
  1. 2
      packages/nc-gui/components.d.ts
  2. 12
      packages/nc-gui/components/smartsheet/Toolbar.vue
  3. 37
      packages/nc-gui/components/smartsheet/qr-scanner-button/QrScannerButton.vue

2
packages/nc-gui/components.d.ts vendored

@ -151,7 +151,6 @@ declare module '@vue/runtime-core' {
MdiCurrencyUsd: typeof import('~icons/mdi/currency-usd')['default']
MdiDatabaseAlert: typeof import('~icons/mdi/database-alert')['default']
MdiDatabaseLockOutline: typeof import('~icons/mdi/database-lock-outline')['default']
MdiDatabaseOutline: typeof import('~icons/mdi/database-outline')['default']
MdiDatabasePlusOutline: typeof import('~icons/mdi/database-plus-outline')['default']
MdiDatabaseSync: typeof import('~icons/mdi/database-sync')['default']
MdiDelete: typeof import('~icons/mdi/delete')['default']
@ -227,7 +226,6 @@ declare module '@vue/runtime-core' {
MdiStarOutline: typeof import('~icons/mdi/star-outline')['default']
MdiStorefrontOutline: typeof import('~icons/mdi/storefront-outline')['default']
MdiTable: typeof import('~icons/mdi/table')['default']
MdiTableArrowRight: typeof import('~icons/mdi/table-arrow-right')['default']
MdiTableColumnPlusAfter: typeof import('~icons/mdi/table-column-plus-after')['default']
MdiTableColumnPlusBefore: typeof import('~icons/mdi/table-column-plus-before')['default']
MdiTableLarge: typeof import('~icons/mdi/table-large')['default']

12
packages/nc-gui/components/smartsheet/Toolbar.vue

@ -13,15 +13,9 @@ const { allowCSVDownload } = useSharedView()
</script>
<template>
<div
class="nc-table-toolbar w-full py-1 flex gap-2 items-center h-[var(--toolbar-height)] px-2 border-b overflow-x-hidden"
style="z-index: 7"
>
<LazySmartsheetToolbarViewActions
v-if="(isGrid || isGallery || isKanban) && !isPublic && isUIAllowed('dataInsert')"
:show-system-fields="false"
class="ml-1"
/>
<div class="nc-table-toolbar w-full py-1 flex gap-2 items-center px-2 border-b overflow-x-hidden flex-wrap" style="z-index: 7">
<LazySmartsheetToolbarViewActions v-if="(isGrid || isGallery || isKanban) && !isPublic && isUIAllowed('dataInsert')"
:show-system-fields="false" class="ml-1" />
<LazySmartsheetToolbarViewInfo v-if="!isUIAllowed('dataInsert') && !isPublic" />

37
packages/nc-gui/components/smartsheet/qr-scanner-button/QrScannerButton.vue

@ -18,9 +18,9 @@ const view = inject(ActiveViewInj, ref())
const qrCodeFieldOptions = ref<SelectProps['options']>([])
interface Entry {
name: string
}
// interface Entry {
// name: string
// }
onBeforeMount(init)
@ -34,23 +34,38 @@ async function init() {
}
const showQrCodeScanner = ref(false)
const entry = ref<Entry | null>(null)
// const entry = ref<Entry | null>(null)
const selectedCodeColumnIdToScanFor = ref('')
const onDecode = async (qrCodeValue: string) => {
showQrCodeScanner.value = false
try {
showQrCodeScanner.value = false
const nameOfSelectedColumnToScanFor = meta.value?.columns?.find(
(column) => column.id === selectedCodeColumnIdToScanFor.value,
)?.title
const whereClause = `(${nameOfSelectedColumnToScanFor},eq,${qrCodeValue})`
const foundRowForQrCode = await $api.dbViewRow.findOne(NOCO, project.value!.id!, meta.value!.id!, view.value!.title!, {
where: whereClause,
})
// const foundRowsForQrCode = await $api.dbViewRow.findOne(NOCO, project.value!.id!, meta.value!.id!, view.value!.title!, {
const foundRowsForQrCode = (
await $api.dbViewRow.list(NOCO, project.value!.id!, meta.value!.id!, view.value!.title!, {
where: whereClause,
})
).list
if (foundRowsForQrCode.length === 0) {
// extract into localisation file
message.info('No row found for this QR code')
showQrCodeScanner.value = true
return
} else if (foundRowsForQrCode.length > 1) {
// TODO: improve this message and extract into localisation file
message.warn('More than one row found for this QR code. Currently only unique QR codes are supported.')
showQrCodeScanner.value = true
return
}
const primaryKeyValueForFoundRow = extractPkFromRow(foundRowForQrCode, meta!.value!.columns!)
message.info('Found row for this QR code - opening edit mode...')
const primaryKeyValueForFoundRow = extractPkFromRow(foundRowsForQrCode[0], meta!.value!.columns!)
router.push({
query: {
@ -110,6 +125,6 @@ const onLoaded = async () => {
</div>
</a-modal>
<p v-if="entry">Entry found: {{ entry.name }}</p>
<!-- <p v-if="entry">Entry found: {{ entry.name }}</p> -->
</div>
</template>

Loading…
Cancel
Save