jqgrid_utils 1.1.4 → 1.1.5

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.
package/README.md CHANGED
@@ -1,10 +1,9 @@
1
- # Vanilla - website - utils
1
+ # Jqgrid_utils
2
2
  Convenient Functions for free jqGrid
3
3
 
4
4
  Demo:
5
5
  https://jqgrid_utils.calantas.org
6
6
 
7
-
8
7
  # Example Usage:
9
8
 
10
9
  Add a the library to your website
@@ -43,6 +43,7 @@ module.exports = class Vanilla_website_utils
43
43
  {
44
44
  this.grid_set_captain(_grid, data=[]);
45
45
  }
46
+
46
47
  async grid_set_captain(_grid, data=[])
47
48
  {
48
49
  const grid = jQuery(_grid);
@@ -226,6 +227,153 @@ async hide_del_icon()
226
227
  jQuery('.ui-inline-del').each(function(index) {jQuery(this).html('');});
227
228
  }
228
229
 
230
+
231
+
232
+
233
+
234
+
235
+ async add_link_details(col_model, url, edit_field, attr = '', keys, format)
236
+ {
237
+
238
+ if (url.indexOf('?') > -1)
239
+ {
240
+ url = url + '&';
241
+ }
242
+ else
243
+ {
244
+ url = url + '?';
245
+ }
246
+
247
+ for (let i = 0; i < col_model.length; i++)
248
+ {
249
+ if (col_model[i]['name'] === edit_field)
250
+ {
251
+ col_model[i]['formatter'] = function(cell_val, obj)
252
+ {
253
+ let key_val = cell_val;
254
+
255
+ if (typeof keys === 'object')
256
+ {
257
+ let pref = '';
258
+ for (i in keys)
259
+ {
260
+ let key = i;
261
+ let v = keys[i];
262
+ key_val = obj.rowData[v];
263
+ if (key_val)
264
+ {
265
+ if (key_val)
266
+ {
267
+ if (key.indexOf('=') !== -1)
268
+ {
269
+ pref = pref + '' + key + '' + encodeURIComponent(key_val) + '&';
270
+ }
271
+ else
272
+ {
273
+ pref = pref + '' + key + '=' + encodeURIComponent(key_val) + '&';
274
+ }
275
+ }
276
+ }
277
+ }
278
+ if (pref)
279
+ {
280
+ if (pref.slice(-1) === '&')
281
+ {
282
+ pref = pref.slice(0, -1);
283
+ }
284
+ if (format == 'format_ok')
285
+ {
286
+
287
+ if (cell_val == 0 || cell_val === 'fail')
288
+ {
289
+ cell_val = '<i class="fa fa-times-circle" aria-hidden="true" style="color:#ff0000;"></i>';
290
+ }
291
+ else
292
+ {
293
+ cell_val = '<i class="fa fa-check-circle" aria-hidden="true" style="color:#008000;"></i>';
294
+ }
295
+ }
296
+
297
+
298
+ cell_val = '<a ' + attr + 'href="' + url + pref + '"> ' + cell_val + '</a>';
299
+ }
300
+
301
+ }
302
+
303
+ return cell_val;
304
+ };
305
+ }
306
+
307
+ }
308
+
309
+ return col_model;
310
+ }
311
+
312
+
313
+
314
+ async add_link_details_separator(col_model, url, edit_field, attr = '', keys)
315
+ {
316
+
317
+ url = url + '/';
318
+
319
+
320
+ for (let i = 0; i < col_model.length; i++)
321
+ {
322
+ if (col_model[i]['name'] === edit_field)
323
+ {
324
+ col_model[i]['formatter'] = function(cell_val, obj)
325
+ {
326
+ let key_val = cell_val;
327
+
328
+ if (typeof keys === 'object')
329
+ {
330
+ let pref = '';
331
+ for (i in keys)
332
+ {
333
+ let key = i;
334
+ let v = keys[i];
335
+ key_val = obj.rowData[v];
336
+ if (key_val)
337
+ {
338
+ if (key_val)
339
+ {
340
+ pref = pref + '' + '/' + encodeURIComponent(key_val) + '&';
341
+ }
342
+ }
343
+ }
344
+ if (pref)
345
+ {
346
+ if (pref.slice(-1) === '&')
347
+ {
348
+ pref = pref.slice(0, -1);
349
+ }
350
+
351
+ cell_val = '<a ' + attr + 'href="' + url + pref + '"> ' + cell_val + '</a>';
352
+ }
353
+
354
+ }
355
+
356
+ return cell_val;
357
+ };
358
+ }
359
+
360
+ }
361
+
362
+ return col_model;
363
+ }
364
+
365
+
366
+
367
+
368
+
369
+
370
+
371
+
372
+
373
+
374
+
375
+
376
+
229
377
  };
230
378
 
231
379
 
package/jqgrid_utils.js CHANGED
@@ -42,6 +42,7 @@ module.exports = class Vanilla_website_utils
42
42
  {
43
43
  this.grid_set_captain(_grid, data=[]);
44
44
  }
45
+
45
46
  async grid_set_captain(_grid, data=[])
46
47
  {
47
48
  const grid = jQuery(_grid);
@@ -225,6 +226,153 @@ async hide_del_icon()
225
226
  jQuery('.ui-inline-del').each(function(index) {jQuery(this).html('');});
226
227
  }
227
228
 
229
+
230
+
231
+
232
+
233
+
234
+ async add_link_details(col_model, url, edit_field, attr = '', keys, format)
235
+ {
236
+
237
+ if (url.indexOf('?') > -1)
238
+ {
239
+ url = url + '&';
240
+ }
241
+ else
242
+ {
243
+ url = url + '?';
244
+ }
245
+
246
+ for (let i = 0; i < col_model.length; i++)
247
+ {
248
+ if (col_model[i]['name'] === edit_field)
249
+ {
250
+ col_model[i]['formatter'] = function(cell_val, obj)
251
+ {
252
+ let key_val = cell_val;
253
+
254
+ if (typeof keys === 'object')
255
+ {
256
+ let pref = '';
257
+ for (i in keys)
258
+ {
259
+ let key = i;
260
+ let v = keys[i];
261
+ key_val = obj.rowData[v];
262
+ if (key_val)
263
+ {
264
+ if (key_val)
265
+ {
266
+ if (key.indexOf('=') !== -1)
267
+ {
268
+ pref = pref + '' + key + '' + encodeURIComponent(key_val) + '&';
269
+ }
270
+ else
271
+ {
272
+ pref = pref + '' + key + '=' + encodeURIComponent(key_val) + '&';
273
+ }
274
+ }
275
+ }
276
+ }
277
+ if (pref)
278
+ {
279
+ if (pref.slice(-1) === '&')
280
+ {
281
+ pref = pref.slice(0, -1);
282
+ }
283
+ if (format == 'format_ok')
284
+ {
285
+
286
+ if (cell_val == 0 || cell_val === 'fail')
287
+ {
288
+ cell_val = '<i class="fa fa-times-circle" aria-hidden="true" style="color:#ff0000;"></i>';
289
+ }
290
+ else
291
+ {
292
+ cell_val = '<i class="fa fa-check-circle" aria-hidden="true" style="color:#008000;"></i>';
293
+ }
294
+ }
295
+
296
+
297
+ cell_val = '<a ' + attr + 'href="' + url + pref + '"> ' + cell_val + '</a>';
298
+ }
299
+
300
+ }
301
+
302
+ return cell_val;
303
+ };
304
+ }
305
+
306
+ }
307
+
308
+ return col_model;
309
+ }
310
+
311
+
312
+
313
+ async add_link_details_separator(col_model, url, edit_field, attr = '', keys)
314
+ {
315
+
316
+ url = url + '/';
317
+
318
+
319
+ for (let i = 0; i < col_model.length; i++)
320
+ {
321
+ if (col_model[i]['name'] === edit_field)
322
+ {
323
+ col_model[i]['formatter'] = function(cell_val, obj)
324
+ {
325
+ let key_val = cell_val;
326
+
327
+ if (typeof keys === 'object')
328
+ {
329
+ let pref = '';
330
+ for (i in keys)
331
+ {
332
+ let key = i;
333
+ let v = keys[i];
334
+ key_val = obj.rowData[v];
335
+ if (key_val)
336
+ {
337
+ if (key_val)
338
+ {
339
+ pref = pref + '' + '/' + encodeURIComponent(key_val) + '&';
340
+ }
341
+ }
342
+ }
343
+ if (pref)
344
+ {
345
+ if (pref.slice(-1) === '&')
346
+ {
347
+ pref = pref.slice(0, -1);
348
+ }
349
+
350
+ cell_val = '<a ' + attr + 'href="' + url + pref + '"> ' + cell_val + '</a>';
351
+ }
352
+
353
+ }
354
+
355
+ return cell_val;
356
+ };
357
+ }
358
+
359
+ }
360
+
361
+ return col_model;
362
+ }
363
+
364
+
365
+
366
+
367
+
368
+
369
+
370
+
371
+
372
+
373
+
374
+
375
+
228
376
  };
229
377
 
230
378
 
package/package.json CHANGED
@@ -28,5 +28,5 @@
28
28
  {
29
29
  "test": "echo \"Error: no test specified\" && exit 1"
30
30
  },
31
- "version": "1.1.4"
31
+ "version": "1.1.5"
32
32
  }