]> _ Git - fluidbook-html5.git/commitdiff
wait #4740 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 24 Nov 2021 10:13:36 +0000 (11:13 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 24 Nov 2021 10:13:36 +0000 (11:13 +0100)
js/libs/fluidbook/special/wescosales.js

index 8ebf5f5ff9d621ae746f74791fc44c33ad6094c6..7b557f391ca520cdd1c968c904497f570c6c9315 100644 (file)
@@ -103,7 +103,7 @@ function setWescoSalesPanel(ref, e, updateOnly) {
             var groupId = groupsByRef[ref][j];
             var group = groups[groupId];
             tabs.push('<a nohref data-tab="group_' + groupId + '" title="' + escapeHtml(group.label) + '">' + group.label + '</a>');
-            w += wescoSalesTab('group_' + groupId, group.references.join(','));
+            w += wescoSalesTab('group_' + groupId, group.references.join(','), undefined, group.longlabel);
         }
     }
 
@@ -123,7 +123,6 @@ function setWescoSalesPanel(ref, e, updateOnly) {
     }
 
     // Close tab
-
     var nbtabs = tabs.length;
     tabs.push('<a href="#" class="close"></a>');
     w = '<div class="tabs">' + tabs.join('') + '</div>' + w;
@@ -162,7 +161,6 @@ function wescoSalesTab(id, ref, refquantities, titleref, hideca) {
 
 
     var activeCountry = $("#wescosalesselect").val();
-    var first = true;
     var wtitle = '';
     var wrefs = [];
     var unique = refs.length === 1;
@@ -173,10 +171,6 @@ function wescoSalesTab(id, ref, refquantities, titleref, hideca) {
         if (r.ref === undefined) {
             return;
         }
-        if (first) {
-            first = false;
-            wtitle = r.title;
-        }
 
         var rref = r.ref;
         if (rref.length === 9) {
@@ -217,9 +211,11 @@ function wescoSalesTab(id, ref, refquantities, titleref, hideca) {
         }
     });
 
-    if (titleref !== undefined) {
+    if (isRef(titleref)) {
         var r = getWescoRef(titleref);
         wtitle = r.title;
+    } else {
+        wtitle = titleref;
     }
 
     var w = '<div data-tab="' + id + '">';
@@ -227,7 +223,6 @@ function wescoSalesTab(id, ref, refquantities, titleref, hideca) {
     w += '<h3>' + wrefs.join(', ') + '</h3>';
     w += '<hr />';
 
-
     w += '<table>';
     w += '<tr><th></th><th>Qté</th>';
     var colspan = 2;
@@ -240,7 +235,6 @@ function wescoSalesTab(id, ref, refquantities, titleref, hideca) {
     var format = new Intl.NumberFormat('fr-FR');
 
     $.each(wlines, function (date, line) {
-        console.log(line.ca);
         var ca = unique && line.ca.toString().match(/[^0-9, .]/) ? line.ca : format.format(wescoParseNumber(line.ca));
         var qte = unique && line.qte.toString().match(/[^0-9, .]/) ? line.qte : format.format(wescoParseNumber(line.qte));
         w += '<tr>';
@@ -313,7 +307,7 @@ function getAllRefs() {
                     }
                     var groupId = linenum;
                     var label = (line[1] === null || line[1] === '' || line[1] === undefined) ? line[0] : line[1];
-                    var group = {label: label};
+                    var group = {label: label, longlabel: line[0]};
                     var references = [];
                     for (var gi = 2; gi <= line.length; gi++) {
                         var v = line[gi];
@@ -459,6 +453,11 @@ function wescoLinksReady() {
     });
 }
 
+function isRef(ref) {
+    var ref = ref.toString().replace(/\s*/g, '');
+    return ref.match(/^\d{1,5}$/);
+}
+
 function normalizeRef(oref) {
     if (normalizeRefCache[oref] == null) {
         ref = oref.toString().replace(/\s*/g, '');