www/js/rec_edit.js

changeset 145
2662720e1949
parent 144
ae15cfe5f008
child 146
2a6c00d325b2
--- a/www/js/rec_edit.js	Sun Dec 16 12:40:04 2018 +0100
+++ b/www/js/rec_edit.js	Sun Dec 16 13:53:48 2018 +0100
@@ -261,39 +261,6 @@
 		});
 	};
 
-	// Styles dropdown list
-	var stylesUrl = "includes/db_profile_styles.php";
-	var stylesSource = {
-		datatype: "json",
-		datafields: [
-			{ name: 'record', type: 'number' },
-		        { name: 'name', type: 'string' },
-			{ name: 'category', type: 'string' },
-			{ name: 'category_number', type: 'number' },
-			{ name: 'style_letter', type: 'string' },
-			{ name: 'style_guide', type: 'string' },
-			{ name: 'type', type: 'string' },
-			{ name: 'og_min', type: 'float' },
-			{ name: 'og_max', type: 'float' },
-			{ name: 'fg_min', type: 'float' },
-			{ name: 'fg_max', type: 'float' },
-			{ name: 'ibu_min', type: 'float' },
-			{ name: 'ibu_max', type: 'float' },
-			{ name: 'color_min', type: 'float' },
-			{ name: 'color_max', type: 'float' },
-			{ name: 'carb_min', type: 'float' },
-			{ name: 'carb_max', type: 'float' },
-			{ name: 'abv_min', type: 'float' },
-			{ name: 'abv_max', type: 'float' },
-			{ name: 'notes', type: 'string' },
-			{ name: 'profile', type: 'string' },
-			{ name: 'ingredients', type: 'string' },
-			{ name: 'examples', type: 'string' }
-		],
-		url: stylesUrl,
-		async: true
-	};
-	var styleslist = new $.jqx.dataAdapter(stylesSource);
 	$("#styleSelect").jqxDropDownList({
 		placeHolder: "Kies bierstijl:",
 		theme: theme,
@@ -1073,7 +1040,8 @@
                                 $("#mdeleterowbutton").on('click', function () {
                                         var selectedrowindex = $("#miscGrid").jqxGrid('getselectedrowindex');
                                         var rowscount = $("#miscGrid").jqxGrid('getdatainformation').rowscount;
-                                        if (selectedrowindex >= 0 && selectedrowindex < rowscount) {
+					var type = $("#miscGrid").jqxGrid('getcellvalue', selectedrowindex, "m_type");
+                                        if (selectedrowindex >= 0 && selectedrowindex < rowscount && type != "Water agent")  {
                                                 var id = $("#miscGrid").jqxGrid('getrowid', selectedrowindex);
                                                 var commit = $("#miscGrid").jqxGrid('deleterow', id);
                                         }
@@ -1089,6 +1057,11 @@
 				  createeditor: function (row, column, editor) {
 					var srcUseUse = [ "Mash", "Boil", "Primary", "Secondary", "Bottling" ];
 					editor.jqxDropDownList({ autoDropDownHeight: true, source: srcUseUse });
+				  },
+				  cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) {
+					var type = $("#miscGrid").jqxGrid('getcellvalue', row, "m_type");
+					if (type == "Water agent")
+						return oldvalue;
 				  }
 			       	},
 				{ datafield: 'm_amount_is_weight', hidden: true },	// We need to declare this column
@@ -1111,6 +1084,11 @@
 						inputMode: 'simple', min: 0, max: parseFloat(dataRecord.boil_size) * 1000,
 						decimalDigits: 2, spinButtons: false
 					});
+				  },
+				  cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) {
+					var type = $("#miscGrid").jqxGrid('getcellvalue', row, "m_type");
+					if (type == "Water agent")
+						return oldvalue;
 				  }
                                 },
                                 { text: 'Tijd', datafield: 'm_time', width: 70, align: 'right', cellsalign: 'right', cellsformat: 'f0',

mercurial