Skip to content

Commit

Permalink
fix bwip error
Browse files Browse the repository at this point in the history
  • Loading branch information
oblomov-dev committed Feb 14, 2025
1 parent b4d1487 commit be8211a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/package.devc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<DEVC>
<CTEXT>abap2UI5 - custom controls</CTEXT>
<CTEXT>abap2UI5 - js libraries</CTEXT>
</DEVC>
</asx:values>
</asx:abap>
Expand Down
36 changes: 23 additions & 13 deletions src/z2ui5_cl_cc_bwipjs.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ CLASS Z2UI5_CL_CC_BWIPJS IMPLEMENTATION.
|\n| &&
` },` &&
` onAfterRendering() { ` &&
` if(window.bwipjs == undefined) { const loadScript = (FILE_URL, async = true, type = "text/javascript") => {` && |\n| &&
` debugger; if(window.bwipjs == undefined) { const loadScript = (FILE_URL, async = true, type = "text/javascript") => {` && |\n| &&
` return new Promise((resolve, reject) => {` && |\n| &&
` try {` && |\n| &&
` const scriptEle = document.createElement("script");` && |\n| &&
Expand Down Expand Up @@ -118,18 +118,28 @@ CLASS Z2UI5_CL_CC_BWIPJS IMPLEMENTATION.
` loadScript("https://cdnjs.cloudflare.com/ajax/libs/bwip-js/4.1.1/bwip-js-min.js")` && |\n| &&
` .then( data => {` && |\n| &&
` this.BusyDialog.close();` && |\n| &&
` let canvas = bwipjs.toCanvas('mycanvas', {` && |\n| &&
` bcid: this.getProperty("bcid"), // Barcode type` && |\n| &&
` text: this.getProperty("text"), // Text to encode` && |\n| &&
` scale: this.getProperty("scale"), // 3x scaling factor` && |\n| &&
` height: this.getProperty("height"), // Bar height, in millimeters` && |\n| &&
` includetext: true, // Show human-readable text` && |\n| &&
` textxalign: 'center', // Always good to set this` && |\n| &&
` })` && |\n| &&
` .catch( err => {` && |\n| &&
` new sap.m.MessageBox.error('Error on load bwip-js library: ' + err);` && |\n| &&
` this.BusyDialog.close();` && |\n| &&
` }); } ) } else {` && |\n| &&
` let canvas = bwipjs.toCanvas('mycanvas', {` && |\n| &&
` bcid: this.getProperty("bcid"),` && |\n| &&
` // Barcode type` && |\n| &&
` text: this.getProperty("text"),` && |\n| &&
` // Text to encode` && |\n| &&
` scale: this.getProperty("scale"),` && |\n| &&
` // 3x scaling factor` && |\n| &&
` height: this.getProperty("height"),` && |\n| &&
` // Bar height, in millimeters` && |\n| &&
` includetext: true,` && |\n| &&
` // Show human-readable text` && |\n| &&
` textxalign: 'center',` && |\n| &&
` // Always good to set this` && |\n| &&
` })` && |\n| &&
* ` .catch(err => {` && |\n| &&
* ` new sap.m.MessageBox.error('Error on load bwip-js library: ' + err);` && |\n| &&
* ` this.BusyDialog.close();` && |\n| &&
* ` }` && |\n| &&
* ` );` && |\n| &&
` }` && |\n| &&
` ) ` && |\n| &&
` } else {` && |\n| &&
` let canvas = bwipjs.toCanvas('mycanvas', {` && |\n| &&
` bcid: this.getProperty("bcid"), // Barcode type` && |\n| &&
` text: this.getProperty("text"), // Text to encode` && |\n| &&
Expand Down

0 comments on commit be8211a

Please sign in to comment.