jqgrid_utils 1.4.1 → 1.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23,6 +23,44 @@ module.exports = class Vanilla_website_utils
23
23
  }
24
24
 
25
25
 
26
+
27
+
28
+ /**
29
+ * Add an OK Button
30
+ @alias module:Jqgrid_utils
31
+ @param {array} - grid col_model
32
+ @param {array} - list of columns names what will be converted to ok buttons
33
+ @returns {array} - col_model
34
+ @example
35
+ var jqu = new Jqgrid_utils();
36
+ col_model = await jqu.add_ok_button(col_model, ['checked']);
37
+ */
38
+
39
+ async add_ok_button(col_model, fields)
40
+ {
41
+ let self = this;
42
+ for (let i = 0; i < col_model.length; i++)
43
+ {
44
+ if (fields.indexOf(col_model[i]['name']) > -1)
45
+ {
46
+ col_model[i]['formatter'] = function(cell_val)
47
+ {
48
+ if (cell_val != undefined)
49
+ {
50
+ return self.__cell_format(cell_val, 'format_ok');
51
+ }
52
+ else
53
+ {
54
+ return '';
55
+ }
56
+ };
57
+ }
58
+ }
59
+ return col_model;
60
+ }
61
+
62
+
63
+
26
64
  /**
27
65
  * Get the filled cell data
28
66
  @alias module:Jqgrid_utils
@@ -33,7 +71,6 @@ module.exports = class Vanilla_website_utils
33
71
  var jqu = new Jqgrid_utils();
34
72
  col_model = await jqu.set_link(col_model,'av0_code','url_code','target="blank"');
35
73
  */
36
-
37
74
  async get_filled_cell_table_data(_grid, fields=[])
38
75
  {
39
76
  let d = jQuery(_grid).jqGrid('getGridParam','data');
@@ -192,21 +229,24 @@ loadComplete: function(){
192
229
  */
193
230
  async grid_set_caption(_grid, data=[])
194
231
  {
195
- const grid = jQuery(_grid);
196
- let count = 0;
197
- if(data.length === 0)
232
+ if(_grid)
198
233
  {
199
- count = grid.jqGrid('getGridParam', 'records');
200
- }
201
- else
202
- {
203
- count = data.length;
204
- }
205
- let caption = grid.jqGrid("getGridParam", "caption");
206
- const reg = /\d.*x/;
207
- const new_caption = caption.replace(reg, "");
208
- grid.jqGrid('setCaption', new_caption + " " + count + 'x');
234
+ const grid = jQuery(_grid);
235
+ let count = 0;
236
+ if(data.length === 0)
237
+ {
238
+ count = grid.jqGrid('getGridParam', 'records');
239
+ }
240
+ else
241
+ {
242
+ count = data.length;
243
+ }
244
+ let caption = grid.jqGrid("getGridParam", "caption");
245
+ const reg = /\d.*x/;
246
+ const new_caption = caption.replace(reg, "");
247
+ grid.jqGrid('setCaption', new_caption + " " + count + 'x');
209
248
  }
249
+ }
210
250
 
211
251
  /**
212
252
  @alias module:Jqgrid_utils
@@ -748,11 +788,11 @@ __cell_format(cell_value, format)
748
788
  {
749
789
  if (cell_value == 0 || cell_value === 'fail')
750
790
  {
751
- cell_value = '<i class="fa fa-times-circle" aria-hidden="true" style="color:#ff0000;"></i>';
791
+ cell_value = '<i data-check="failed" class="fa fa-times-circle" aria-hidden="true" style="color:#ff0000;"></i>';
752
792
  }
753
793
  else
754
794
  {
755
- cell_value = '<i class="fa fa-check-circle" aria-hidden="true" style="color:#008000;"></i>';
795
+ cell_value = '<i data-check="ok" class="fa fa-check-circle" aria-hidden="true" style="color:#008000;"></i>';
756
796
  }
757
797
  }
758
798
  return cell_value;
package/jqgrid_utils.js CHANGED
@@ -22,6 +22,44 @@ module.exports = class Vanilla_website_utils
22
22
  }
23
23
 
24
24
 
25
+
26
+
27
+ /**
28
+ * Add an OK Button
29
+ @alias module:Jqgrid_utils
30
+ @param {array} - grid col_model
31
+ @param {array} - list of columns names what will be converted to ok buttons
32
+ @returns {array} - col_model
33
+ @example
34
+ var jqu = new Jqgrid_utils();
35
+ col_model = await jqu.add_ok_button(col_model, ['checked']);
36
+ */
37
+
38
+ async add_ok_button(col_model, fields)
39
+ {
40
+ let self = this;
41
+ for (let i = 0; i < col_model.length; i++)
42
+ {
43
+ if (fields.indexOf(col_model[i]['name']) > -1)
44
+ {
45
+ col_model[i]['formatter'] = function(cell_val)
46
+ {
47
+ if (cell_val != undefined)
48
+ {
49
+ return self.__cell_format(cell_val, 'format_ok');
50
+ }
51
+ else
52
+ {
53
+ return '';
54
+ }
55
+ };
56
+ }
57
+ }
58
+ return col_model;
59
+ }
60
+
61
+
62
+
25
63
  /**
26
64
  * Get the filled cell data
27
65
  @alias module:Jqgrid_utils
@@ -32,7 +70,6 @@ module.exports = class Vanilla_website_utils
32
70
  var jqu = new Jqgrid_utils();
33
71
  col_model = await jqu.set_link(col_model,'av0_code','url_code','target="blank"');
34
72
  */
35
-
36
73
  async get_filled_cell_table_data(_grid, fields=[])
37
74
  {
38
75
  let d = jQuery(_grid).jqGrid('getGridParam','data');
@@ -191,21 +228,24 @@ loadComplete: function(){
191
228
  */
192
229
  async grid_set_caption(_grid, data=[])
193
230
  {
194
- const grid = jQuery(_grid);
195
- let count = 0;
196
- if(data.length === 0)
231
+ if(_grid)
197
232
  {
198
- count = grid.jqGrid('getGridParam', 'records');
199
- }
200
- else
201
- {
202
- count = data.length;
203
- }
204
- let caption = grid.jqGrid("getGridParam", "caption");
205
- const reg = /\d.*x/;
206
- const new_caption = caption.replace(reg, "");
207
- grid.jqGrid('setCaption', new_caption + " " + count + 'x');
233
+ const grid = jQuery(_grid);
234
+ let count = 0;
235
+ if(data.length === 0)
236
+ {
237
+ count = grid.jqGrid('getGridParam', 'records');
238
+ }
239
+ else
240
+ {
241
+ count = data.length;
242
+ }
243
+ let caption = grid.jqGrid("getGridParam", "caption");
244
+ const reg = /\d.*x/;
245
+ const new_caption = caption.replace(reg, "");
246
+ grid.jqGrid('setCaption', new_caption + " " + count + 'x');
208
247
  }
248
+ }
209
249
 
210
250
  /**
211
251
  @alias module:Jqgrid_utils
@@ -747,11 +787,11 @@ __cell_format(cell_value, format)
747
787
  {
748
788
  if (cell_value == 0 || cell_value === 'fail')
749
789
  {
750
- cell_value = '<i class="fa fa-times-circle" aria-hidden="true" style="color:#ff0000;"></i>';
790
+ cell_value = '<i data-check="failed" class="fa fa-times-circle" aria-hidden="true" style="color:#ff0000;"></i>';
751
791
  }
752
792
  else
753
793
  {
754
- cell_value = '<i class="fa fa-check-circle" aria-hidden="true" style="color:#008000;"></i>';
794
+ cell_value = '<i data-check="ok" class="fa fa-check-circle" aria-hidden="true" style="color:#008000;"></i>';
755
795
  }
756
796
  }
757
797
  return cell_value;
package/package.json CHANGED
@@ -29,5 +29,5 @@
29
29
  {
30
30
  "test": "echo \"Error: no test specified\" && exit 1"
31
31
  },
32
- "version": "1.4.1"
32
+ "version": "1.4.4"
33
33
  }