Switches DMRE version to 12x64. Fixes failing unit test.

This commit is contained in:
Aaron Louie 2020-11-09 17:21:22 -05:00
parent fa86d296f6
commit 7934fff316
3 changed files with 28 additions and 17 deletions

View File

@ -1,10 +1,14 @@
import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import {defaultOptions, labelLayouts} from '../config/defaults';
import {AppDefaults} from '../models/appDefaults.interface';
import {LabelLayout} from '../models/labelLayout.interface';
import { BarcodeDataMatrixComponent } from './barcode-data-matrix.component'; import { BarcodeDataMatrixComponent } from './barcode-data-matrix.component';
describe('BarcodeDataMatrixComponent', () => { describe('BarcodeDataMatrixComponent', () => {
let component: BarcodeDataMatrixComponent; let component: BarcodeDataMatrixComponent;
let fixture: ComponentFixture<BarcodeDataMatrixComponent>; let fixture: ComponentFixture<BarcodeDataMatrixComponent>;
const settings = new AppDefaults(defaultOptions);
beforeEach(async () => { beforeEach(async () => {
await TestBed.configureTestingModule({ await TestBed.configureTestingModule({
@ -16,6 +20,10 @@ describe('BarcodeDataMatrixComponent', () => {
beforeEach(() => { beforeEach(() => {
fixture = TestBed.createComponent(BarcodeDataMatrixComponent); fixture = TestBed.createComponent(BarcodeDataMatrixComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
settings.labelLayout = labelLayouts.rectangular_lg;
component.settings = settings;
component.format = settings.labelLayout.barcodeType;
component.value = '987654321-202101231122-ABCDE-0123';
fixture.detectChanges(); fixture.detectChanges();
}); });

View File

@ -20,6 +20,7 @@ export class BarcodeDataMatrixComponent implements OnInit {
} }
renderBarcode(): void { renderBarcode(): void {
if (bwipjs && bwipjs.toCanvas && this.settings && this.format) {
bwipjs.toCanvas('barcodeCanvas', { bwipjs.toCanvas('barcodeCanvas', {
bcid: this.format, bcid: this.format,
text: this.value, text: this.value,
@ -28,8 +29,9 @@ export class BarcodeDataMatrixComponent implements OnInit {
height: this.settings.labelLayout.labelHeight, height: this.settings.labelLayout.labelHeight,
includetext: false, includetext: false,
textalign: 'center', textalign: 'center',
version: '8x96', version: '12x64',
padding: this.settings.labelLayout.marginSize, padding: this.settings.labelLayout.marginSize,
}); });
} }
} }
}

View File

@ -18,12 +18,13 @@ export const labelLayouts = {
}), }),
rectangular_lg: new LabelLayout({ rectangular_lg: new LabelLayout({
name: '2in x 1.25in Rectangular Label', name: '2in x 1.25in Rectangular Label',
barcodeType: 'qrcode', barcodeType: 'datamatrixrectangularextension',
type: 'rectangular_lg', type: 'rectangular_lg',
numCols: 1, numCols: 1,
columnGap: 0, columnGap: 0,
labelWidth: 38, labelWidth: 47,
labelHeight: 38, labelHeight: 8,
marginSize: 3,
}), }),
rectangular_sm: new LabelLayout({ rectangular_sm: new LabelLayout({
name: '96mm x 15mm Rectangular Label', name: '96mm x 15mm Rectangular Label',
@ -31,9 +32,9 @@ export const labelLayouts = {
type: 'rectangular_sm', type: 'rectangular_sm',
numCols: 1, numCols: 1,
columnGap: 0, columnGap: 0,
labelWidth: 96, labelWidth: 32,
labelHeight: 8, labelHeight: 6,
marginSize: 4, marginSize: 3,
}), }),
}; };