Tab 4 is a viewer.

Fri, 05 Aug 2022 14:54:22 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Fri, 05 Aug 2022 14:54:22 +0200
changeset 821
293ec25995db
parent 820
16ae12aa872e
child 822
bd20a8329b1b

Tab 4 is a viewer.

www/js/prod_edit.js file | annotate | diff | comparison | revisions
--- a/www/js/prod_edit.js	Fri Aug 05 14:41:17 2022 +0200
+++ b/www/js/prod_edit.js	Fri Aug 05 14:54:22 2022 +0200
@@ -843,11 +843,10 @@
     { name: 'h_myrcene', type: 'float' },
     { name: 'h_total_oil', type: 'float' },
     { name: 'h_inventory', type: 'float' },
-    { name: 'h_avail', type: 'int' }
+    { name: 'h_avail', type: 'int' },
+    { name: 'h_utilisation', type: 'float' },
+    { name: 'h_bu_factor', type: 'float' }
    ],
-   addrow: function(rowid, rowdata, position, commit) { commit(true); },
-   deleterow: function(rowid, commit) { commit(true); },
-   updaterow: function(rowid, rowdata, commit) { commit(true); }
   },
   hopAdapter = new $.jqx.dataAdapter(hopSource);
 
@@ -856,97 +855,17 @@
    height: 560,
    source: hopAdapter,
    theme: theme,
-   selectionmode: 'singlerow',
-   showtoolbar: true,
-   rendertoolbar: function(toolbar) {
-    var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>");
-    toolbar.append(container);
-    container.append('<div style="float: left; margin-left: 165px;" id="haddrowbutton"></div>');
-    container.append('<div style="float: left; margin-left: 10px; margin-top: 5px;">In voorraad:</div>');
-    container.append('<div style="float: left; margin-left: 10px;" id="hinstockbutton"></div>');
-    container.append('<input style="float: left; margin-left: 400px;" id="hdeleterowbutton" type="button" value="Verwijder hop" />');
-    // add hop from dropdownlist.
-    $('#haddrowbutton').jqxDropDownList({
-     placeHolder: 'Kies hop:',
-     theme: theme,
-     template: 'primary',
-     source: hoplist,
-     disabled: (dataRecord.stage > 5),
-     displayMember: 'name',
-     width: 150,
-     height: 27,
-     dropDownWidth: 500,
-     dropDownHeight: 500,
-     renderer: function(index, label, value) {
-      var datarecord = hoplist.records[index];
-      return datarecord.origin + ' - ' + datarecord.name + ' / ' + HopFormData[datarecord.form].nl + ' (' + datarecord.alpha + '% &alpha;) (' +
-       Round(datarecord.inventory * 1000.0, 1) + ' gr)';
-     }
-    });
-    $('#haddrowbutton').on('select', function(event) {
-     if (event.args) {
-      var datarecord, row = {}, index = event.args.index;
-      datarecord = hoplist.records[index];
-      row['h_name'] = datarecord.name;
-      row['h_origin'] = datarecord.origin;
-      row['h_amount'] = 0;
-      row['h_cost'] = datarecord.cost;
-      row['h_type'] = datarecord.type;
-      row['h_form'] = datarecord.form;
-      row['h_useat'] = 2; // Boil
-      row['h_time'] = 0;
-      row['h_alpha'] = datarecord.alpha;
-      row['h_beta'] = datarecord.beta;
-      row['h_hsi'] = datarecord.hsi;
-      row['h_humulene'] = datarecord.humulene;
-      row['h_caryophyllene'] = datarecord.caryophyllene;
-      row['h_cohumulone'] = datarecord.cohumulone;
-      row['h_myrcene'] = datarecord.myrcene;
-      row['h_total_oil'] = datarecord.total_oil;
-      row['h_inventory'] = datarecord.inventory;
-      /* If stage > useat moment, adjust the moment */
-      row['h_useat'] = minimum_hop(dataRecord.stage, row['h_useat']);
-      $('#hopGrid').jqxGrid('addrow', null, row);
-     }
-     $('#haddrowbutton').jqxDropDownList('clearSelection');
-    });
-
-    $('#hinstockbutton').jqxCheckBox({ theme: theme, height: 27, disabled: (dataRecord.stage > 5) });
-    $('#hinstockbutton').on('change', function(event) {
-     hopinstock = event.args.checked;
-     hoplist.dataBind();
-    });
-
-    // delete selected hop.
-    $('#hdeleterowbutton').jqxButton({ template: 'danger', theme: theme, height: 27, width: 150, disabled: (dataRecord.stage > 5) });
-    $('#hdeleterowbutton').on('click', function() {
-     var rowscount, id, selectedrowindex = $('#hopGrid').jqxGrid('getselectedrowindex');
-     rowscount = $('#hopGrid').jqxGrid('getdatainformation').rowscount;
-     if (selectedrowindex >= 0 && selectedrowindex < rowscount) {
-      useat = $('#hopGrid').jqxGrid('getcellvalue', selectedrowindex, 'h_useat');
-      if (block_hop(dataRecord.stage, useat)) {
-       alert('Ingredieënt is al verwerkt.');
-      } else {
-       id = $('#hopGrid').jqxGrid('getrowid', selectedrowindex);
-       $('#hopGrid').jqxGrid('deleterow', id);
-      }
-     }
-     calcIBUs();
-    });
-   },
+   editable: false,
    ready: function() { $('#jqxTabs').jqxTabs('next'); },
    columns: [
-    { text: 'Hop', datafield: 'h_name',
-     cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) {
-      return '<span style="margin: 3px; margin-top: 6px; float: left;">' + rowdata.h_origin + ' / ' + rowdata.h_name + '</span>';
-     },
-    },
+    { text: 'Hop', datafield: 'h_name' },
+    { text: 'Origin', width: 180, datafield: 'h_origin' },
     { text: 'Type', width: 90, datafield: 'h_type',
      cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) {
       return '<span style="margin: 4px; margin-top: 6px; float: left;">' + HopTypeData[value].nl + '</span>';
      }
     },
-    { text: 'Vorm', width: 90, datafield: 'h_form',
+    { text: 'Vorm', width: 110, datafield: 'h_form',
      cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) {
       return '<span style="margin: 4px; margin-top: 6px; float: left;">' + HopFormData[value].nl + '</span>';
      }
@@ -970,7 +889,7 @@
     { text: 'IBU', datafield: 'ibu', width: 80, align: 'right',
      cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) {
       var ibu = toIBU(rowdata.h_useat, rowdata.h_form, preboil_sg, parseFloat(dataRecord.batch_size),
-                parseFloat(rowdata.h_amount), parseFloat(rowdata.h_time), parseFloat(rowdata.h_alpha), $('#ibu_method').val(),
+                parseFloat(rowdata.h_amount), parseFloat(rowdata.h_time), parseFloat(rowdata.h_alpha), dataRecord.ibu_method,
                 dataRecord.brew_whirlpool9, dataRecord.brew_whirlpool7, dataRecord.brew_whirlpool6);
       return '<span style="margin: 4px; margin-top: 6px; float: right;">' + dataAdapter.formatNumber(ibu, 'f1') + '</span>';
      }
@@ -995,35 +914,6 @@
        return '<span></span>';
       }
      }
-    },
-    { text: '', datafield: 'Edit', columntype: 'button', width: 100, align: 'center',
-     cellsrenderer: function() {
-      return 'Wijzig';
-     }, buttonclick: function(row) {
-      hopRow = row;
-      hopData = $('#hopGrid').jqxGrid('getrowdata', hopRow);
-      if (block_hop(dataRecord.stage, hopData.h_useat)) {
-       alert('Ingredieënt is al verwerkt.');
-      } else {
-       console.log('edit button row ' + row);
-       $('#wh_name').val(hopData.h_name);
-       $('#wh_amount').val(hopData.h_amount * 1000);
-       var ibu = toIBU(hopData.h_useat, hopData.h_form, preboil_sg, parseFloat($('#batch_size').jqxNumberInput('decimal')),
-                 parseFloat(hopData.h_amount), parseFloat(hopData.h_time), parseFloat(hopData.h_alpha), $('#ibu_method').val(),
-                 dataRecord.brew_whirlpool9, dataRecord.brew_whirlpool7, dataRecord.brew_whirlpool6);
-       $('#wh_ibu').val(ibu);
-       if (hopData.h_useat == 5) // Dry hop
-        $('#wh_time').val(hopData.h_time / 1440);
-       else
-        $('#wh_time').val(hopData.h_time);
-       $('#wh_useat').val(hopData.h_useat);
-       for (i = 0; i < 5; i++) {
-	drop_endis(dataRecord.stage > 2, '#wh_useat', i);
-       }
-       // show the popup window.
-       $('#popupHop').jqxWindow('open');
-      }
-     }
     }
    ]
   });

mercurial