From 57c8f9c14dba1f72b6370df521f3784196c4c227 Mon Sep 17 00:00:00 2001 From: Aaron Louie Date: Fri, 13 Nov 2020 22:06:53 -0500 Subject: [PATCH] WIP: Uncouples barcode dimensions from label dimensions --- src/app/_util/qrCode.ts | 2 +- .../barcode-data-matrix.component.html | 2 +- .../barcode-data-matrix.component.scss | 4 +- .../barcode-data-matrix.component.spec.ts | 2 +- .../barcode-data-matrix.component.ts | 16 ++--- src/app/config/defaults.ts | 60 ++++++++++--------- .../label-layout/label-layout.component.html | 4 +- .../label-layout/label-layout.component.scss | 2 +- .../label-layout/label-layout.component.ts | 18 +++--- src/app/models/labelLayout.interface.ts | 34 ++++++----- src/app/print/print.component.ts | 2 +- 11 files changed, 77 insertions(+), 69 deletions(-) diff --git a/src/app/_util/qrCode.ts b/src/app/_util/qrCode.ts index 78b6c0d..940de94 100644 --- a/src/app/_util/qrCode.ts +++ b/src/app/_util/qrCode.ts @@ -3,7 +3,7 @@ import {formatDate} from '@angular/common'; export const createQrCodeValue = (barCode: string, initials: string, dateCreated: Date, locationId: string): string => { const valArray = [ barCode, - initials, + initials.toUpperCase(), formatDate(dateCreated, 'yyyyMMddHHmm', 'en-us'), locationId, ]; diff --git a/src/app/barcode-data-matrix/barcode-data-matrix.component.html b/src/app/barcode-data-matrix/barcode-data-matrix.component.html index ea3b8af..3f5b639 100644 --- a/src/app/barcode-data-matrix/barcode-data-matrix.component.html +++ b/src/app/barcode-data-matrix/barcode-data-matrix.component.html @@ -1,2 +1,2 @@ - +
diff --git a/src/app/barcode-data-matrix/barcode-data-matrix.component.scss b/src/app/barcode-data-matrix/barcode-data-matrix.component.scss index 50c653f..e8a5a29 100644 --- a/src/app/barcode-data-matrix/barcode-data-matrix.component.scss +++ b/src/app/barcode-data-matrix/barcode-data-matrix.component.scss @@ -1,4 +1,4 @@ #barcodeCanvas { - width: 100%; - height: 100%; + //width: 100%; + //height: 100%; } diff --git a/src/app/barcode-data-matrix/barcode-data-matrix.component.spec.ts b/src/app/barcode-data-matrix/barcode-data-matrix.component.spec.ts index 9085ec7..87f6d98 100644 --- a/src/app/barcode-data-matrix/barcode-data-matrix.component.spec.ts +++ b/src/app/barcode-data-matrix/barcode-data-matrix.component.spec.ts @@ -20,7 +20,7 @@ describe('BarcodeDataMatrixComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(BarcodeDataMatrixComponent); component = fixture.componentInstance; - // settings.labelLayout = labelLayouts.rectangular_lg; + settings.labelLayout = labelLayouts.rectangular_54x32; component.settings = settings; component.format = settings.labelLayout.barcodeType; component.value = '987654321-202101231122-ABCDE-0123'; diff --git a/src/app/barcode-data-matrix/barcode-data-matrix.component.ts b/src/app/barcode-data-matrix/barcode-data-matrix.component.ts index 9f2385f..929e004 100644 --- a/src/app/barcode-data-matrix/barcode-data-matrix.component.ts +++ b/src/app/barcode-data-matrix/barcode-data-matrix.component.ts @@ -1,4 +1,4 @@ -import {Component, Input, OnInit} from '@angular/core'; +import {AfterViewInit, Component, Input, OnInit} from '@angular/core'; import bwipjs from 'bwip-js'; import {AppDefaults} from '../models/appDefaults.interface'; @@ -20,17 +20,17 @@ export class BarcodeDataMatrixComponent implements OnInit { } renderBarcode(): void { - if (bwipjs && bwipjs.toCanvas && this.settings && this.format) { + if (!!(bwipjs && bwipjs.toCanvas && this.settings && this.format)) { bwipjs.toCanvas('barcodeCanvas', { bcid: this.format, text: this.value, - scale: 2, - width: this.settings.labelLayout.labelWidth, - height: this.settings.labelLayout.labelHeight, - includetext: false, - textalign: 'center', + scale: 1, + width: this.settings.labelLayout.barcodeWidth, + height: this.settings.labelLayout.barcodeHeight, + // includetext: false, + // textalign: 'center', // version: '12x64', - padding: this.settings.labelLayout.marginSize, + // padding: this.settings.labelLayout.marginSize, }); } } diff --git a/src/app/config/defaults.ts b/src/app/config/defaults.ts index abf779e..65a03b5 100644 --- a/src/app/config/defaults.ts +++ b/src/app/config/defaults.ts @@ -8,8 +8,8 @@ export const labelLayouts = { type: 'round_32mm_1up', numCols: 1, columnGap: 0, - labelWidth: 28.6, - labelHeight: 28.6, + barcodeWidth: 28.6, + barcodeHeight: 28.6, sideTextMargin: 0, topTextMargin: 0, bottomTextMargin: 0, @@ -20,37 +20,39 @@ export const labelLayouts = { type: 'round_32mm_2up', numCols: 2, columnGap: 3.4, - labelWidth: 28.6, - labelHeight: 28.6, + barcodeWidth: 28.6, + barcodeHeight: 28.6, sideTextMargin: 0, topTextMargin: 0, bottomTextMargin: 0, }), - // rectangular_lg: new LabelLayout({ - // name: '2in x 1.25in Rectangular Label', - // barcodeType: 'qrcode', - // type: 'rectangular_lg', - // numCols: 1, - // columnGap: 0, - // labelWidth: 28.6, - // labelHeight: 28.6, - // sideTextMargin: 10, - // topTextMargin: 1, - // bottomTextMargin: 1, - // }), - // rectangular_sm: new LabelLayout({ - // name: '96mm x 15mm Rectangular Label', - // barcodeType: 'datamatrix', - // type: 'rectangular_sm', - // numCols: 1, - // columnGap: 0, - // labelWidth: 32, - // labelHeight: 16, - // marginSize: 6, - // sideTextMargin: 2, - // topTextMargin: 3, - // bottomTextMargin: 3, - // }), + rectangular_54x32: new LabelLayout({ + name: '2in x 1.25in Rectangular Label', + barcodeType: 'datamatrix', + type: 'rectangular_54x32', + numCols: 1, + columnGap: 0, + columnWidth: 54, + columnHeight: 34, + barcodeWidth: 10, + barcodeHeight: 10, + sideTextMargin: 0, + topTextMargin: 0, + bottomTextMargin: 0, + }), + rectangular_sm: new LabelLayout({ + name: '96mm x 15mm Rectangular Label', + barcodeType: 'datamatrix', + type: 'rectangular_sm', + numCols: 1, + columnGap: 0, + barcodeWidth: 32, + barcodeHeight: 16, + marginSize: 6, + sideTextMargin: 2, + topTextMargin: 3, + bottomTextMargin: 3, + }), }; export const defaultOptions: AppDefaultsOptions = { diff --git a/src/app/label-layout/label-layout.component.html b/src/app/label-layout/label-layout.component.html index 240c86c..f6fec92 100644 --- a/src/app/label-layout/label-layout.component.html +++ b/src/app/label-layout/label-layout.component.html @@ -18,13 +18,13 @@ *ngIf="settings.labelLayout.barcodeType === 'qrcode'" [value]="qrCodeValue" errorCorrectionLevel="H" - [ngStyle]="labelStyle" + [ngStyle]="barcodeStyle" >
void) { const id = createQrCodeValue( this.barCode, - this.initials.toUpperCase(), + this.initials, this.dateCreated, this.settings.locationId );