www/js/recipes.js

changeset 65
5d5c67818d11
parent 62
12c5eae75d1e
child 66
674948226777
equal deleted inserted replaced
64:5d5fc6f7cbfe 65:5d5c67818d11
235 theme: theme, 235 theme: theme,
236 source: fermentablelist, 236 source: fermentablelist,
237 displayMember: "name", 237 displayMember: "name",
238 width: 150, 238 width: 150,
239 height: 27, 239 height: 27,
240 dropDownWidth: 300 240 dropDownWidth: 500,
241 dropDownHeight: 500,
242 renderer: function (index, label, value) {
243 var datarecord = fermentablelist.records[index];
244 return datarecord.supplier+ " / " + datarecord.name + " (" + datarecord.color + " EBC)";
245 }
241 }); 246 });
242 $("#faddrowbutton").on('select', function (event) { 247 $("#faddrowbutton").on('select', function (event) {
243 if (event.args) { 248 if (event.args) {
244 var index = event.args.index; 249 var index = event.args.index;
245 var datarecord = fermentablelist.records[index]; 250 var datarecord = fermentablelist.records[index];
286 }); 291 });
287 }, 292 },
288 columns: [ 293 columns: [
289 { text: 'Mout/suiker', editable: false, datafield: 'f_name' }, 294 { text: 'Mout/suiker', editable: false, datafield: 'f_name' },
290 { text: 'Type', editable: false, width: 100, datafield: 'f_type' }, 295 { text: 'Type', editable: false, width: 100, datafield: 'f_type' },
291 { text: 'Opbrengst', datafield: 'f_yield', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, 296 { text: 'Opbrengst', editable: false, datafield: 'f_yield', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'p1' },
292 { text: 'Gewicht', datafield: 'f_amount', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'f3', 297 { text: 'Gewicht', datafield: 'f_amount', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'f3',
293 columntype: 'numberinput', 298 columntype: 'numberinput',
294 validation: function (cell, value) { 299 validation: function (cell, value) {
295 if (value < 0 || value > 100000000000 ) { 300 // Maximum weight is the batch_size, just a simple check.
296 return { result: false, message: "Volume moet 0-~ zijn" }; 301 var maxmout = parseFloat($("#batch_size").jqxNumberInput('decimal'));
302 if (value < 0 || value > maxmout) {
303 return { result: false, message: "Gewicht moet 0-"+maxmout+" zijn" };
297 } 304 }
298 return true; 305 return true;
306 },
307 initeditor: function (row, cellvalue, editor) {
308 editor.jqxNumberInput({ decimalDigits: 3 });
299 } 309 }
300 }, 310 },
301 { text: 'Procent', datafield: 'f_percentage', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'p3', 311 { text: 'Procent', datafield: 'f_percentage', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'p1',
302 columntype: 'numberinput', 312 columntype: 'numberinput',
303 validation: function (cell, value) { 313 validation: function (cell, value) {
304 if (value < 0 || value > 100) { 314 if (value < 0 || value > 100) {
305 return { result: false, message: "Percentage moet 0-100 zijn" }; 315 return { result: false, message: "Percentage moet 0-100 zijn" };
306 } 316 }
307 return true; 317 return true;
318 },
319 initeditor: function (row, cellvalue, editor) {
320 editor.jqxNumberInput({ decimalDigits: 1 });
308 } 321 }
309 }, 322 },
310 { text: '100%', datafield: 'f_adjust_to_total_100', columntype: 'checkbox', width: 80 } 323 { text: '100%', datafield: 'f_adjust_to_total_100', columntype: 'checkbox', width: 80 }
311 ] 324 ]
312 }) 325 });
326 $("#fermentableGrid").on('cellendedit', function (event) {
327 $('#fermentableGrid').jqxGrid('sortby', 'f_amount', 'desc');
328 });
313 }; 329 };
314 330
315 // Inline hops editor 331 // Inline hops editor
316 var editHop = function (data) { 332 var editHop = function (data) {
317 var hopSource = { 333 var hopSource = {
1113 } 1129 }
1114 ], 1130 ],
1115 groups: ['st_guide','st_letter' ] 1131 groups: ['st_guide','st_letter' ]
1116 }); 1132 });
1117 1133
1118
1119 // initialize the popup window and buttons. 1134 // initialize the popup window and buttons.
1120 $("#popupWindow").jqxWindow({ 1135 $("#popupWindow").jqxWindow({
1121 width: 1202, 1136 width: 1202,
1122 height: 622, 1137 height: 622,
1123 resizable: false, 1138 resizable: false,
1125 isModal: true, 1140 isModal: true,
1126 autoOpen: false, 1141 autoOpen: false,
1127 cancelButton: $("#Cancel"), 1142 cancelButton: $("#Cancel"),
1128 modalOpacity: 0.40 1143 modalOpacity: 0.40
1129 }); 1144 });
1130 $("#popupWindow").on('open', function () {
1131 $("#name").jqxInput('selectAll');
1132 });
1133
1134 // Tabs inside the popup window. 1145 // Tabs inside the popup window.
1135 $('#jqxTabs').jqxTabs({ 1146 $('#jqxTabs').jqxTabs({
1136 theme: theme, 1147 theme: theme,
1137 autoHeight: false, 1148 autoHeight: false,
1138 height: 580, 1149 height: 580,
1139 position: 'top' 1150 position: 'top'
1151 });
1152 $("#popupWindow").on('open', function () {
1153 $("#name").jqxInput('selectAll');
1140 }); 1154 });
1141 1155
1142 $("#Delete").jqxButton({ width: '90px', theme: theme }); 1156 $("#Delete").jqxButton({ width: '90px', theme: theme });
1143 $("#Delete").click(function () { 1157 $("#Delete").click(function () {
1144 if (editrow >= 0) { 1158 if (editrow >= 0) {
1149 $("#jqxgrid").jqxGrid('deleterow', rowID); 1163 $("#jqxgrid").jqxGrid('deleterow', rowID);
1150 }); 1164 });
1151 } 1165 }
1152 $("#popupWindow").jqxWindow('hide'); 1166 $("#popupWindow").jqxWindow('hide');
1153 }); 1167 });
1168
1154 $("#Cancel").jqxButton({ width: '90px', theme: theme }); 1169 $("#Cancel").jqxButton({ width: '90px', theme: theme });
1155 $("#Save").jqxButton({ width: '90px', theme: theme }); 1170 $("#Save").jqxButton({ width: '90px', theme: theme });
1156 // update the edited row when the user clicks the 'Save' button. 1171 // update the edited row when the user clicks the 'Save' button.
1157 $("#Save").click(function () { 1172 $("#Save").click(function () {
1158 var fermentablerow = $('#fermentableGrid').jqxGrid('getrows'); 1173 var fermentablerow = $('#fermentableGrid').jqxGrid('getrows');

mercurial