Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/qr barcode reader #8153

Merged
merged 12 commits into from
Oct 13, 2022
Merged

Feature/qr barcode reader #8153

merged 12 commits into from
Oct 13, 2022

Conversation

deanhannigan
Copy link
Contributor

@deanhannigan deanhannigan commented Oct 6, 2022

Description

Adding a Code Scanner form component for scanning QR codes and a variety of barcodes.

  • Barcode/QR has been added to datasources as a new column type.
  • The Barcode/QR Scanner component is available under the 'Form' sections in the component list.
  • Any field configured as a Barcode/QR will display as a Barcode/QR Scanner in the builder and be persisted as a string.
  • Datasource fields currently configured as Text or Long Form Text or Options can safely switch to Barcode/QR if required

The full list of supported barcodes is available here : https://github.com/mebjas/html5-qrcode

Addresses:

Screenshots

Scanning a QR Code on mobile.

QR_reader_AdobeExpress

Scanning a Code123 Barcode on mobile.

barcode_clip_AdobeExpress

You can also allow manual entry on the field. This feature can be toggled in the builder

Screen_Recording_2022-10-06_at_10_11_54_AdobeExpress

'Barcode/QR' column type db configuration. You can safely switch between all text types.

Screenshot 2022-10-07 at 10 39 49

If the user hasn't granted camera permissions on their device.

Screenshot 2022-10-06 at 09 32 49

@Rory-Powell
Copy link
Contributor

Nice one dean! One suggestion around the name of the column type, code might be confused with a code field as in entering html, js etc. Maybe could use something more distinctive like Scanner Code or Barcode

@deanhannigan
Copy link
Contributor Author

@Rory-Powell Yep, that's fair enough. I'll switch it out for Scanner Code

@codecov-commenter
Copy link

codecov-commenter commented Oct 6, 2022

Codecov Report

Merging #8153 (a39f6af) into develop (34bd4b1) will decrease coverage by 0.00%.
The diff coverage is 31.03%.

❗ Current head a39f6af differs from pull request most recent head c162ad4. Consider uploading reports for the commit c162ad4 to get more accurate results

@@             Coverage Diff             @@
##           develop    #8153      +/-   ##
===========================================
- Coverage    67.08%   67.08%   -0.01%     
===========================================
  Files          122      122              
  Lines         4123     4129       +6     
  Branches       658      659       +1     
===========================================
+ Hits          2766     2770       +4     
- Misses         950      952       +2     
  Partials       407      407              
Impacted Files Coverage Δ
packages/server/src/constants/index.js 100.00% <ø> (ø)
packages/server/src/utilities/csvParser.js 71.23% <0.00%> (-0.99%) ⬇️
...ackages/server/src/utilities/rowProcessor/index.js 49.23% <ø> (ø)
packages/server/src/api/controllers/datasource.js 56.94% <10.00%> (ø)
...s/server/src/api/controllers/row/internalSearch.js 69.71% <33.33%> (ø)
packages/server/src/utilities/plugins.js 42.85% <42.85%> (ø)
packages/server/src/api/controllers/dev.js 60.00% <100.00%> (ø)
packages/server/src/api/controllers/integration.js 92.85% <0.00%> (-7.15%) ⬇️
packages/server/src/utilities/users.js 77.77% <0.00%> (ø)
... and 1 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@deanhannigan deanhannigan marked this pull request as ready for review October 6, 2022 14:01
Copy link
Member

@shogunpurple shogunpurple left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a really nice little component, love the UX. Great job 🚀

@joebudi
Copy link
Contributor

joebudi commented Oct 6, 2022

Nice work @deanhannigan . The UX is great and the write-up was brilliant - loved the videos. I'm with Rory on this. Scanner code is fine, but I'd prefer 'Barcode / QR code' - it is probably the most informative... but a tad long.

@shogunpurple
Copy link
Member

shogunpurple commented Oct 6, 2022

@deanhannigan We should be able to use slashes in the type names anyway for the friendly names - we could go with Barcode/QR as Joe says for a bit more brevity. Having that in there makes things much more explicit

…is also now listed as 'Barcode/QR Scanner'. Minor fix to include longform text columns in the table csv import list
@deanhannigan
Copy link
Contributor Author

@joebudi @shogunpurple I've updated the column type to display as Barcode/QR and the component itself is now labelled as Barcode/QR Scanner in the component list.

When binding, the field type was previously Scannedcode but will now display as the following to fit in with the column name better:

Screenshot 2022-10-07 at 10 43 10

Let me know what you think.

@shogunpurple
Copy link
Member

@deanhannigan thanks for making the updates. Just one change - if it's not possible to have the Barcode/QR in the type list, I'd just make that one Barcode. Right now it's not clear that it's Barcode/QR in the type list, it just looks like one word.

Copy link
Member

@aptkingston aptkingston left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work @deanhannigan! It works perfectly and well done for getting it to work nicely with other text type fields too 👌.

Left a few comments but it's mostly minor stuff.

One other suggestion is that I'd like to move the CodeScanner component inside the forms directory too (beside the field), since it is not exported to use as a standalone component, and the rest of the component inside the app directory are for usage inside apps rather than just parts of other components.

One thing which is a bit unique with this implemenation is that none of it is inside BBUI, where all our other fields are. That's fine, but it just means we can't use the code scanner field inside the builder (which is probably grand since the builder isn't mobile friendly so you'd be entering it manually anyway).

export let value
export let disabled = false
export let allowManualEntry = false
export let scanButtonText = "Scan Code"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NAB: Change casing to "Scan code" for consistency with other buttons

<div class="modal-wrap">
<Modal bind:this={camModal} on:hide={hideReaderModal}>
<ModalContent
title={scanButtonText}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scanButtonText will default to "Scan code" if the value is undefined, but if the user has entered a value in the setting field and then cleared it, the text will always be undefined as it does not account for empty strings.

2 ways to solve this would be:
$: scanButtonText = scanButtonText || "Scan code"
or every time you use scanButtonText, do
scanButtonText || "Scan code

secondary
newStyles
on:click={() => {
manualMode = !manualMode
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NAB: since this is just a toggle, if you've enabled manual mode already and then press this again, it will unset it which feels a bit strange. I reckon we should probably just hide the button if we're already in manual mode, so {#if allowManualEntry && !manualMode}, and then the onclick handler here can just set it explicitly to true.

camModal.hide()
}}
>
Enter Manually
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NAB: change casing to "Enter manually" to be consistent with other buttons.

<style>
#reader :global(video) {
border-radius: 4px;
border: var(--border-light-2);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a hardcoded light border so it looks off in dark themes. Let's use

border: 2px solid var(--spectrum-global-color-gray-300);

instead so that it looks better in any theme.

align-items: center;
justify-content: center;
border-radius: 4px;
border: var(--border-light-2);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a hardcoded light border so it looks off in dark themes. Let's use

border: 2px solid var(--spectrum-global-color-gray-300);

instead so that it looks better in any theme.

},
{
"type": "text",
"label": "Button",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NAB: let's rename this to "Button text" to make it more obvious that's what it is

"styles": [
"size"
],
"draggable": true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NAB: setting draggable to true here is redundant as it's only a flag used to disable DND if set to false. Setting illegal children is also redundant since this component doesn't take child components anyway.

@deanhannigan deanhannigan merged commit c042b36 into develop Oct 13, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Oct 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants