Allow add and delete of fermentables durring valid brew moments. Add and edit a fermantable only to stages that have not yet been done. Block the packaging choices, edited elsewhere.

Fri, 21 May 2021 16:36:06 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Fri, 21 May 2021 16:36:06 +0200
changeset 751
3ba26a83eb93
parent 750
e94e79832e63
child 752
f68e3bbc1ada

Allow add and delete of fermentables durring valid brew moments. Add and edit a fermantable only to stages that have not yet been done. Block the packaging choices, edited elsewhere.

www/js/prod_edit.js file | annotate | diff | comparison | revisions
--- a/www/js/prod_edit.js	Sun May 09 11:54:03 2021 +0200
+++ b/www/js/prod_edit.js	Fri May 21 16:36:06 2021 +0200
@@ -717,7 +717,7 @@
      template: 'primary',
      source: fermentablelist,
      displayMember: 'name',
-     disabled: (dataRecord.stage > 3),
+     disabled: (dataRecord.stage > 6),
      width: 150,
      height: 27,
      dropDownWidth: 500,
@@ -753,6 +753,13 @@
       } else {
        row['f_added'] = 0; // Mash
       }
+      /* If stage > added moment, adjust the moment */
+      if (dataRecord.stage > 5 && row['f_added'] < 4)
+       row['f_added'] = 4;
+      if (dataRecord.stage > 3 && row['f_added'] < 3)
+       row['f_added'] = 3;
+      if (dataRecord.stage > 2 && row['f_added'] < 2)
+       row['f_added'] = 2;
       row['f_dissolved_protein'] = datarecord.dissolved_protein;
       row['f_recommend_mash'] = datarecord.recommend_mash;
       row['f_add_after_boil'] = datarecord.add_after_boil;
@@ -771,14 +778,14 @@
      }
     });
 
-    $('#finstockbutton').jqxCheckBox({ theme: theme, height: 27, disabled: (dataRecord.stage > 3) });
+    $('#finstockbutton').jqxCheckBox({ theme: theme, height: 27, disabled: (dataRecord.stage > 6) });
     $('#finstockbutton').on('change', function(event) {
      fermentableinstock = event.args.checked;
      fermentablelist.dataBind();
     });
 
     // delete selected fermentable.
-    $('#fdeleterowbutton').jqxButton({ template: 'danger', theme: theme, height: 27, width: 150, disabled: (dataRecord.stage > 3) });
+    $('#fdeleterowbutton').jqxButton({ template: 'danger', theme: theme, height: 27, width: 150, disabled: (dataRecord.stage > 6) });
     $('#fdeleterowbutton').on('click', function() {
      var rowscount, id, percent, amount, i, rowdata,
      selectedrowindex = $('#fermentableGrid').jqxGrid('getselectedrowindex');
@@ -871,7 +878,7 @@
       fermentableData = $('#fermentableGrid').jqxGrid('getrowdata', fermentableRow);
       if (fermentableData.f_added >= 4) {
        alert('Wijzig dit in de Verpakken tab');
-      } else if (dataRecord.stage > 3) {
+      } else if ((dataRecord.stage >= 3 && fermentableData.f_added <= 1) || (dataRecord.stage >= 4 && fermentableData.f_added <= 2) || (dataRecord.stage >= 6 && fermentableData.f_added <= 3)) {
        alert('Ingredieënt is al verwerkt.');
       } else {
        $('#wf_name').val(fermentableData.f_name);
@@ -880,6 +887,11 @@
        $('#wf_max_in_batch').val(fermentableData.f_max_in_batch);
        $('#wf_adjust_to_total_100').val(fermentableData.f_adjust_to_total_100);
        $('#wf_added').val(fermentableData.f_added);
+       (dataRecord.stage >= 3) ? $('#wf_added').jqxDropDownList('disableAt', 0) : $('#wf_added').jqxDropDownList('enableAt', 0);
+       (dataRecord.stage >= 3) ? $('#wf_added').jqxDropDownList('disableAt', 1) : $('#wf_added').jqxDropDownList('enableAt', 1);
+       (dataRecord.stage >= 4) ? $('#wf_added').jqxDropDownList('disableAt', 2) : $('#wf_added').jqxDropDownList('enableAt', 2);
+       $('#wf_added').jqxDropDownList('disableAt', 4);
+       $('#wf_added').jqxDropDownList('disableAt', 5);
        // show the popup window.
        $('#popupFermentable').jqxWindow('open');
       }

mercurial