Skip to content

Commit

Permalink
#1035 new error descriptions for LWA (fix for scan parse) + font adju…
Browse files Browse the repository at this point in the history
…stment
  • Loading branch information
adiganga2002 committed Nov 15, 2022
1 parent 29e1039 commit d46717d
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 36 deletions.
46 changes: 27 additions & 19 deletions apihub-root/lightweight-pwa/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ body {
#leaflet-content,
#leaflet-content .select-lang-text,
#leaflet-content .languages-list {
font-size: calc(100% + 0.8vmin);
font-size: calc(100% + 0.3vmin);
}

#leaflet-content .select-lang-text {
Expand All @@ -413,16 +413,17 @@ body {
}

#leaflet-content h5 {
font-family: 'DM Sans';
font-size: 110%;
font-family: 'DM Sans bold';
font-size: 100%;
margin-right: 1rem;
}

.leaflet-content-wrapper{
.leaflet-content-wrapper {
position: relative;
width: 100%;
height: 100%;
}

#leaflet-content {
text-align: start;
overflow-y: auto;
Expand Down Expand Up @@ -484,7 +485,7 @@ body {
background-position: top;
background-size: contain;
background-repeat: no-repeat;
top: 7px;
top: 2px;
}

.leaflet-accordion-item.active:before {
Expand Down Expand Up @@ -548,8 +549,11 @@ body {
.leaflet-page .product-name,
.modal-header .modal-title,
.error-page .header-title {
font-size: 2.5vh;
font-size: 3vh;
font-family: 'DM Sans bold';
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}

.modal-header.centred-header .modal-title {
Expand Down Expand Up @@ -840,18 +844,24 @@ body {
left: 0%;
transform: translate(-30%, 10%);
}
.modal-header.left-aligned-header{

.modal-header.left-aligned-header {
border-radius: 0;
}

.page-container.error-page .page-header .header-title:after {
margin-left: 1.5rem;
}


.leaflet-page .product-name,
.modal-header .modal-title,
.error-page .header-title {
font-size: 4vh;
font-family: 'DM Sans bold';
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}

.leaflet-page .product-description, .error-page .header-subtitle, .error-page .page-content {
Expand All @@ -864,20 +874,23 @@ body {
}


#leaflet-content{
#leaflet-content {
width: 100vw;
}

#leaflet-content,
#leaflet-content .select-lang-text,
#leaflet-content .languages-list {
font-size: calc(100% + 2.5vmin);
}

/* #leaflet-content,
#leaflet-content .select-lang-text,
#leaflet-content .languages-list {
font-size: calc(100% + 2.5vmin);
}*/
#leaflet-content h5 {
margin-right: 4rem;
}

.leaflet-accordion-item:before {
top: 7px;
}

.leaflet-accordion-item table,
.leaflet-accordion-item table td,
.leaflet-accordion-item table th {
Expand Down Expand Up @@ -918,11 +931,6 @@ body {
border-radius: unset;
}

.modal-header .modal-title {
font-size: 3vh;
font-family: 'DM Sans bold';
}

.modal-header .modal-subtitle {
position: relative;
font-size: 2vh;
Expand Down
Binary file removed apihub-root/lightweight-pwa/images/menu-icon.png
Binary file not shown.
4 changes: 2 additions & 2 deletions apihub-root/lightweight-pwa/images/new-menu-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion apihub-root/lightweight-pwa/js/constants.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const constants = {
const constants = {
/*error code value matches with a key in translations. Adding a new code should sync with translations*/
errorCodes: {
"gtin_not_created": "001",
Expand All @@ -14,3 +14,4 @@ export const constants = {
"no_uploaded_epi": "011"
}
}
export default constants;
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {goToPage} from "../utils/utils.js"
import {constants} from "../constants.js"
import {getTranslation} from "../translations.js";

function ErrorController() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import XMLDisplayService from "../services/XMLDisplayService/XMLDisplayService.js"
import {goToPage, goToErrorPage} from "../utils/utils.js";
import {constants} from "../constants.js"
import constants from "../constants.js"
import LeafletService from "../services/LeafletService.js";

function LeafletController() {
Expand Down
22 changes: 16 additions & 6 deletions apihub-root/lightweight-pwa/js/controllers/ScanController.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {convertFromISOtoYYYY_HM, goToErrorPage, goToPage, validateGTIN} from "..
import interpretGS1scan from "../utils/interpretGS1scan/interpretGS1scan.js";
import ScanService, {switchFacingMode} from "../services/ScanService.js";
import {getTranslation} from "../translations.js";
import constants from "../constants.js";

function ScanController() {
this.init = async function (facingMode) {
Expand Down Expand Up @@ -45,7 +46,7 @@ function ScanController() {
this.scanService.stop();
clearInterval(this.scanInterval);
scanResult = result.text;
this.processGS1Fields(this.parseGS1Code(result.text));
this.processGS1Fields(scanResult)
}).catch(err => {
err.scanResult = scanResult;
this.redirectToError(err);
Expand Down Expand Up @@ -92,12 +93,21 @@ function ScanController() {
return gs1Fields;
}

this.processGS1Fields = function (gs1Fields) {
let gtinValidationResult = validateGTIN(gs1Fields.gtin);
if (gtinValidationResult.isValid) {
this.processGS1Fields = function (scanResultText) {
let gs1Fields = null;
try {
gs1Fields = this.parseGS1Code(scanResultText);
goToPage(`/leaflet.html?gtin=${gs1Fields.gtin}&batch=${gs1Fields.batchNumber}&expiry=${gs1Fields.expiry}`)
} else {
goToErrorPage(gtinValidationResult.errorCode);
} catch (err) {
if (err.message) {
if (err.message.includes("INVALID CHECK DIGIT:")) {
goToErrorPage(constants.errorCodes.gtin_wrong_digit);
}
if (err.message.includes("SYNTAX ERROR:")) {
goToErrorPage(constants.errorCodes.gtin_wrong_chars);
}
}
goToErrorPage(constants.errorCodes.unknown_error);
}
}

Expand Down
2 changes: 1 addition & 1 deletion apihub-root/lightweight-pwa/js/services/LeafletService.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import RandomRoundRobinService from "./RandomRoundRobinService.js";
import environment from "../../environment.js";
import {constants} from "../constants.js"
import constants from "../constants.js"
import CustomError from "../utils/CustomError.js";
import {goToErrorPage, goToPage, validateGTIN} from "../utils/utils.js";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {defualtXslContent, acordisXslContent} from "./leafletXSL.js"
import CustomError from "../../utils/CustomError.js";
import {constants} from "../../constants.js";
import constants from "../../constants.js";

class XMLDisplayService {
constructor(containerIdSelector) {
Expand Down
3 changes: 2 additions & 1 deletion apihub-root/lightweight-pwa/js/utils/CustomError.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
class CustomError extends Error {
constructor(code, message) {
constructor(code, message, errData) {
super(message)
this.code = code;
this.errData = errData
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4399,7 +4399,7 @@ export default class GS1DigitalLinkToolkit {
let queryStringArray=[];
let queryString="";
let webURI="";
let canonicalStem="https://id.gs1.org";
let canonicalStem="https://id.gs1.orgx";
let rv={};

// Need to remove unwanted trailing slash
Expand Down Expand Up @@ -5623,7 +5623,7 @@ export default class GS1DigitalLinkToolkit {
let queryStringArray=[];
let queryString="";
let webURI="";
let canonicalStem="https://id.gs1.org";
let canonicalStem="https://id.gs1.orgx";
let rv={};

if (!(compressOtherKeyValuePairs)) {
Expand Down
2 changes: 1 addition & 1 deletion apihub-root/lightweight-pwa/js/utils/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {constants} from "../constants.js"
import constants from "../constants.js"

const monthNames = ["January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"
Expand Down

0 comments on commit d46717d

Please # to comment.