Fixes and updates.

This commit is contained in:
Wynne Crisman
2020-01-16 09:31:12 -08:00
parent 2e57558ef4
commit a20e42e360
25 changed files with 346 additions and 820 deletions

View File

@@ -1,11 +1,11 @@
import './PrintLabel.html';
import JsBarcode from 'JsBarcode';
//import QRCode from "../util/qrcode/qrcode";
import QRCode from '/imports/util/qrcode/qrcode';
//let {qrcode, svg2url} = require('pure-svg-code');
import LabelFormats from '/imports/LabelFormats.js';
Template.PrintLabel.onCreated(function() {
});
Template.PrintLabel.onRendered(function() {
function getUrlVars() {
let vars = {};
let parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
@@ -13,20 +13,30 @@ Template.PrintLabel.onCreated(function() {
});
return vars;
}
function setupDisplay(vars) {
$('.label').removeClass().addClass("label " + vars.format);
$('.title1').html(vars['title1']);
$('.title2').html(vars['title2'] === undefined ? "" : vars['title2']);
$('.ingredientsList').html(vars['ingredients']);
$('.date').html(vars['date']);
$('.size').html(vars['size']);
}
this.vars = getUrlVars();
});
Template.PrintLabel.onRendered(function() {
let vars = this.vars;
$('.title1').html(vars['title1']);
$('.title2').html(vars['title2'] === undefined ? "" : vars['title2']);
$('.ingredients').append(vars['ingredients']);
$('.date').html(vars['date']);
$('.size').html(vars['size']);
//JsBarcode(".barcode").init();
let _this = this;
//Use the reactive variables if this is being rendered as part of the client's view (a preview of what will be printed). Otherwise take the URL parameters as the vars for rendering.
if(Blaze.getData(_this.view).vars) {
Tracker.autorun(function() {
let vars = Blaze.getData(_this.view).vars;
setupDisplay(vars);
});
}
else {
let vars = getUrlVars();
setupDisplay(vars);
}
//const svgString = qrcode({content: "1234567890", padding: 0, width: 50, height: 50, color: "#000000", background: "#FFFFFF", ecl: "L"});
//this.$('.qrcode').attr('src', svg2url(svgString));
new QRCode(document.getElementById("qrcode"), {text: "1234567890", width: 60, height: 60});
});