jqgrid_utils 1.2.18 → 1.3.1

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
@@ -46,13 +46,14 @@ A module for Jqgrid_utils
46
46
  * [module.exports#insert_row(row, url)](#exp_module_Jqgrid_utils--module.exports+insert_row) ⇒ <code>object</code> ⏏
47
47
  * [module.exports#update_row(row, url, req)](#exp_module_Jqgrid_utils--module.exports+update_row) ⇒ <code>object</code> ⏏
48
48
  * [module.exports#delete_row(_id, url)](#exp_module_Jqgrid_utils--module.exports+delete_row) ⇒ <code>object</code> ⏏
49
- * [module.exports#adelete_api(url)](#exp_module_Jqgrid_utils--module.exports+adelete_api) ⇒ <code>object</code> ⏏
49
+ * [module.exports#adelete_api(url, json)](#exp_module_Jqgrid_utils--module.exports+adelete_api) ⇒ <code>object</code> ⏏
50
50
  * [module.exports#post_json(url, data)](#exp_module_Jqgrid_utils--module.exports+post_json) ⇒ <code>object</code> ⏏
51
51
  * [module.exports#put_json(url, data)](#exp_module_Jqgrid_utils--module.exports+put_json) ⇒ <code>object</code> ⏏
52
52
  * [module.exports#s_hide_del_icon()](#exp_module_Jqgrid_utils--module.exports+s_hide_del_icon) ⏏
53
53
  * [module.exports#hide_del_icon()](#exp_module_Jqgrid_utils--module.exports+hide_del_icon) ⏏
54
54
  * [module.exports#add_link_details(col_model, url, edit_field, attr, keys)](#exp_module_Jqgrid_utils--module.exports+add_link_details) ⏏
55
55
  * [module.exports#add_link_details_separator(col_model, url, edit_field, attr, keys)](#exp_module_Jqgrid_utils--module.exports+add_link_details_separator) ⏏
56
+ * [module.exports#add_link_separator(col_model, url, edit_field, fields)](#exp_module_Jqgrid_utils--module.exports+add_link_separator) ⏏
56
57
  * [module.exports#__cell_format()](#exp_module_Jqgrid_utils--module.exports+__cell_format) ⏏
57
58
  * [module.exports#subgrid(_id, id, data_url, col_model, caption)](#exp_module_Jqgrid_utils--module.exports+subgrid) ⏏
58
59
  * [module.exports#add_image(col_model, edit_field, size, link)](#exp_module_Jqgrid_utils--module.exports+add_image) ⏏
@@ -164,7 +165,7 @@ resizeStop: jqu.resize_cell,
164
165
  Upsert(insert or update) from the grid to an API
165
166
 
166
167
  **Kind**: Exported function
167
- **Returns**: <code>object</code> - {update: 'ok'} or {udpate: 'failed'}
168
+ **Returns**: <code>object</code> - {update: 'ok'} or {update: 'failed'}
168
169
 
169
170
  | Param | Type | Description |
170
171
  | --- | --- | --- |
@@ -177,7 +178,7 @@ Upsert(insert or update) from the grid to an API
177
178
  var jqu = new Jqgrid_utils();
178
179
  afterSetRow: async function(row)
179
180
  {
180
- let r = await jqu.upsert_row(row, url);
181
+ let r = await jqu.upsert_row(row, 'http://api.com',{'key':'value'});
181
182
  console.log(r);
182
183
  },
183
184
  ```
@@ -192,15 +193,14 @@ Insert from the grid to an API used by the upsert_row function
192
193
  | Param | Type | Description |
193
194
  | --- | --- | --- |
194
195
  | row | <code>object</code> | row object |
195
- | url | <code>string</code> | url of the API |
196
- | | <code>string</code> | data oject |
196
+ | url | <code>string</code> | URL of the API |
197
197
 
198
198
  **Example**
199
199
  ```js
200
200
  var jqu = new Jqgrid_utils();
201
201
  afterSetRow: async function(row)
202
202
  {
203
- let r = await jqu.upsert_row(row, url);
203
+ let r = await jqu.insert_row(row, 'http://api.com');
204
204
  console.log(r);
205
205
  },
206
206
  ```
@@ -223,7 +223,7 @@ Update from the grid to an API used by the upsert_row function
223
223
  var jqu = new Jqgrid_utils();
224
224
  afterSetRow: async function(row)
225
225
  {
226
- let r = await jqu.upsert_row(row, url);
226
+ let r = await jqu.update_row(row, 'http://api.com',{'key':value});
227
227
  console.log(r);
228
228
  },
229
229
  ```
@@ -245,21 +245,22 @@ Delete from the grid to an API
245
245
  var jqu = new Jqgrid_utils();
246
246
  afterDelRow: async function(row)
247
247
  {
248
- const r = await jqu.delete_row(row, url);
248
+ const r = await jqu.delete_row('id', 'http://api.com');
249
249
  console.log(r + ' : ' + row + ' - from API');
250
250
  },
251
251
  ```
252
252
  <a name="exp_module_Jqgrid_utils--module.exports+adelete_api"></a>
253
253
 
254
- ### module.exports#adelete\_api(url) ⇒ <code>object</code> ⏏
254
+ ### module.exports#adelete\_api(url, json) ⇒ <code>object</code> ⏏
255
255
  Async Delete request used by function delete_row
256
256
 
257
257
  **Kind**: Exported function
258
258
  **Returns**: <code>object</code> - @returns {object} Object from the the API like {delete: 'ok'} or {delete: 'failed'}
259
259
 
260
- | Param | Type | Description |
261
- | --- | --- | --- |
262
- | url | <code>string</code> | url of the API |
260
+ | Param | Type | Default | Description |
261
+ | --- | --- | --- | --- |
262
+ | url | <code>string</code> | | url of the API |
263
+ | json | <code>boalan</code> | <code>false</code> | header should be json type? default form type |
263
264
 
264
265
  **Example**
265
266
  ```js
@@ -345,7 +346,7 @@ Convert a cell into a link/url with data from another cell
345
346
  **Example**
346
347
  ```js
347
348
  var jqu = new Jqgrid_utils();
348
- col_model = await jqu.add_link_details(col_model,'http://foo.bar'' , 'target_field','target="_blank"',{"key":"field1","key":"field2"});
349
+ col_model = await jqu.add_link_details(col_model,'http://foo.bar' , 'style','target="_blank"',{'key':'style'});
349
350
  ```
350
351
  <a name="exp_module_Jqgrid_utils--module.exports+add_link_details_separator"></a>
351
352
 
@@ -365,7 +366,33 @@ Convert a cell into seperated based link/url like https://foo.bar.com/field/valu
365
366
  **Example**
366
367
  ```js
367
368
  var jqu = new Jqgrid_utils();
368
- col_model = await jqu.add_link_details_separator(col_model, 'https://foo.com' , 'couchdb','target="_blank"',{"mykey":"myval"});
369
+ col_model = await jqu.add_link_details_separator(col_model, url1 , 'style','target="_blank"',{"pricelist":"pricelist","style":"style"});
370
+ col_model = await jqu.add_link_details_separator(col_model, 'https://foo.com' , 'target_column','target="_blank"',{"mykey":"myval"});
371
+ ```
372
+ <a name="exp_module_Jqgrid_utils--module.exports+add_link_separator"></a>
373
+
374
+ ### module.exports#add\_link\_separator(col_model, url, edit_field, fields) ⏏
375
+ Convert a cell into seperated based link/url include parameter based url like https://foo.bar.com/field.html?k=v
376
+
377
+ **Kind**: Exported function
378
+
379
+ | Param | Type | Description |
380
+ | --- | --- | --- |
381
+ | col_model | <code>object</code> | col_model of the grid |
382
+ | url | <code>string</code> | URL string |
383
+ | edit_field | <code>array</code> | array of dict |
384
+ | fields | <code>string</code> | URL Attributes |
385
+
386
+ **Example**
387
+ ```js
388
+ var jqu = new Jqgrid_utils();
389
+ col_model = await jqu.add_link_separator(col_model, host + '/html' , 'style',[
390
+ {
391
+ 'field':'pricelist',
392
+ 'extension':'.html',
393
+ 'fields':{'style':'style'}
394
+ }
395
+ ]);
369
396
  ```
370
397
  <a name="exp_module_Jqgrid_utils--module.exports+__cell_format"></a>
371
398
 
@@ -175,12 +175,12 @@ col_model = await jqu.resize_saved_cell_width(col_model);
175
175
  @param {object} - row object
176
176
  @param {string} - url of the API
177
177
  @param {string} - data oject
178
- @returns {object} {update: 'ok'} or {udpate: 'failed'}
178
+ @returns {object} {update: 'ok'} or {update: 'failed'}
179
179
  @example
180
180
  var jqu = new Jqgrid_utils();
181
181
  afterSetRow: async function(row)
182
182
  {
183
- let r = await jqu.upsert_row(row, url);
183
+ let r = await jqu.upsert_row(row, 'http://api.com',{'key':'value'});
184
184
  console.log(r);
185
185
  },
186
186
  */
@@ -203,14 +203,13 @@ async upsert_row(row, url, req = {})
203
203
  * Insert from the grid to an API used by the upsert_row function
204
204
  @alias module:Jqgrid_utils
205
205
  @param {object} - row object
206
- @param {string} - url of the API
207
- @param {string} - data oject
206
+ @param {string} - URL of the API
208
207
  @returns {object} Object from the the API like {update: 'ok'} or {update: 'failed'}
209
208
  @example
210
209
  var jqu = new Jqgrid_utils();
211
210
  afterSetRow: async function(row)
212
211
  {
213
- let r = await jqu.upsert_row(row, url);
212
+ let r = await jqu.insert_row(row, 'http://api.com');
214
213
  console.log(r);
215
214
  },
216
215
  */
@@ -246,7 +245,7 @@ async insert_row(row, url)
246
245
  var jqu = new Jqgrid_utils();
247
246
  afterSetRow: async function(row)
248
247
  {
249
- let r = await jqu.upsert_row(row, url);
248
+ let r = await jqu.update_row(row, 'http://api.com',{'key':value});
250
249
  console.log(r);
251
250
  },
252
251
  */
@@ -281,7 +280,7 @@ async update_row(row, url, req = {})
281
280
  var jqu = new Jqgrid_utils();
282
281
  afterDelRow: async function(row)
283
282
  {
284
- const r = await jqu.delete_row(row, url);
283
+ const r = await jqu.delete_row('id', 'http://api.com');
285
284
  console.log(r + ' : ' + row + ' - from API');
286
285
  },
287
286
  */
@@ -307,6 +306,7 @@ async delete_row(_id, url)
307
306
  * Async Delete request used by function delete_row
308
307
  @alias module:Jqgrid_utils
309
308
  @param {string} - url of the API
309
+ @param {boalan} - header should be json type? default form type
310
310
  @returns {object} @returns {object} Object from the the API like {delete: 'ok'} or {delete: 'failed'}
311
311
  @example
312
312
  var jqu = new Jqgrid_utils();
@@ -415,7 +415,7 @@ async hide_del_icon()
415
415
  @param {object} - keys and fields value to use
416
416
  @example
417
417
  var jqu = new Jqgrid_utils();
418
- col_model = await jqu.add_link_details(col_model,'http://foo.bar'' , 'target_field','target="_blank"',{"key":"field1","key":"field2"});
418
+ col_model = await jqu.add_link_details(col_model,'http://foo.bar' , 'style','target="_blank"',{'key':'style'});
419
419
  */
420
420
  async add_link_details(col_model, url, edit_field, attr = '', keys, format)
421
421
  {
@@ -494,7 +494,8 @@ async add_link_details(col_model, url, edit_field, attr = '', keys, format)
494
494
  @param {object} - keys and fields value to use
495
495
  @example
496
496
  var jqu = new Jqgrid_utils();
497
- col_model = await jqu.add_link_details_separator(col_model, 'https://foo.com' , 'couchdb','target="_blank"',{"mykey":"myval"});
497
+ col_model = await jqu.add_link_details_separator(col_model, url1 , 'style','target="_blank"',{"pricelist":"pricelist","style":"style"});
498
+ col_model = await jqu.add_link_details_separator(col_model, 'https://foo.com' , 'target_column','target="_blank"',{"mykey":"myval"});
498
499
  */
499
500
  async add_link_details_separator(col_model, url, edit_field, attr = '', keys, format)
500
501
  {
@@ -523,7 +524,7 @@ async add_link_details_separator(col_model, url, edit_field, attr = '', keys, fo
523
524
  {
524
525
  if(key != '')
525
526
  {
526
- pref += key + '' + '/' + encodeURIComponent(key_val);
527
+ pref += key + '' + '/' + encodeURIComponent(key_val) + '/';
527
528
  }
528
529
  else
529
530
  {
@@ -534,7 +535,7 @@ async add_link_details_separator(col_model, url, edit_field, attr = '', keys, fo
534
535
  }
535
536
  if (pref)
536
537
  {
537
- if (pref.slice(-1) === '&')
538
+ if (pref.slice(-1) === '&' || pref.slice(-1) === '/' )
538
539
  {
539
540
  pref = pref.slice(0, -1);
540
541
  }
@@ -555,8 +556,76 @@ async add_link_details_separator(col_model, url, edit_field, attr = '', keys, fo
555
556
 
556
557
 
557
558
 
559
+ /**
560
+ * Convert a cell into seperated based link/url include parameter based url like https://foo.bar.com/field.html?k=v
561
+ @alias module:Jqgrid_utils
562
+ @param {object} - col_model of the grid
563
+ @param {string} - URL string
564
+ @param {array} - array of dict
565
+ @param {string} - URL Attributes
566
+ @example
567
+ var jqu = new Jqgrid_utils();
568
+ col_model = await jqu.add_link_separator(col_model, host + '/html' , 'style',[
569
+ {
570
+ 'field':'pricelist',
571
+ 'extension':'.html',
572
+ 'fields':{'style':'style'}
573
+ }
574
+ ]);
575
+
576
+ */
577
+ async add_link_separator(col_model, url, edit_field, fields, attr='')
578
+ {
579
+ url = url + '/';
580
+ let self = this;
581
+ for (let i = 0; i < col_model.length; i++)
582
+ {
583
+ if (col_model[i]['name'] === edit_field)
584
+ {
585
+ col_model[i]['formatter'] = function(cell_val, obj)
586
+ {
587
+ let key_val = cell_val;
588
+ let pref = '';
589
+ for(let x in fields)
590
+ {
591
+ for(let xx in fields[x])
592
+ {
593
+ if(xx === 'field')
594
+ {
595
+ let field_value = obj.rowData[fields[x][xx]];
596
+ pref += field_value;
597
+ }
598
+ if(xx === 'extension')
599
+ {
600
+ pref += fields[x][xx] ;
601
+ }
602
+ if(xx === 'fields')
603
+ {
604
+ pref += '?';
605
+ for(let key in fields[x][xx])
606
+ {
607
+ let val = obj.rowData[fields[x][xx][key]];
608
+ pref = pref + '' + key + '=' + encodeURIComponent(val) + '&';
609
+ }
610
+ }
558
611
 
612
+ }
613
+ }
614
+ if (pref)
615
+ {
616
+ if (pref.slice(-1) === '&' || pref.slice(-1) === '/' )
617
+ {
618
+ pref = pref.slice(0, -1);
619
+ }
620
+ cell_val = '<a ' + attr + 'href="' + url + pref + '"> ' + cell_val + '</a>';
621
+ }
559
622
 
623
+ return cell_val;
624
+ };
625
+ }
626
+ }
627
+ return col_model;
628
+ }
560
629
 
561
630
  /**
562
631
  * Private Function
package/jqgrid_utils.js CHANGED
@@ -174,12 +174,12 @@ col_model = await jqu.resize_saved_cell_width(col_model);
174
174
  @param {object} - row object
175
175
  @param {string} - url of the API
176
176
  @param {string} - data oject
177
- @returns {object} {update: 'ok'} or {udpate: 'failed'}
177
+ @returns {object} {update: 'ok'} or {update: 'failed'}
178
178
  @example
179
179
  var jqu = new Jqgrid_utils();
180
180
  afterSetRow: async function(row)
181
181
  {
182
- let r = await jqu.upsert_row(row, url);
182
+ let r = await jqu.upsert_row(row, 'http://api.com',{'key':'value'});
183
183
  console.log(r);
184
184
  },
185
185
  */
@@ -202,14 +202,13 @@ async upsert_row(row, url, req = {})
202
202
  * Insert from the grid to an API used by the upsert_row function
203
203
  @alias module:Jqgrid_utils
204
204
  @param {object} - row object
205
- @param {string} - url of the API
206
- @param {string} - data oject
205
+ @param {string} - URL of the API
207
206
  @returns {object} Object from the the API like {update: 'ok'} or {update: 'failed'}
208
207
  @example
209
208
  var jqu = new Jqgrid_utils();
210
209
  afterSetRow: async function(row)
211
210
  {
212
- let r = await jqu.upsert_row(row, url);
211
+ let r = await jqu.insert_row(row, 'http://api.com');
213
212
  console.log(r);
214
213
  },
215
214
  */
@@ -245,7 +244,7 @@ async insert_row(row, url)
245
244
  var jqu = new Jqgrid_utils();
246
245
  afterSetRow: async function(row)
247
246
  {
248
- let r = await jqu.upsert_row(row, url);
247
+ let r = await jqu.update_row(row, 'http://api.com',{'key':value});
249
248
  console.log(r);
250
249
  },
251
250
  */
@@ -280,7 +279,7 @@ async update_row(row, url, req = {})
280
279
  var jqu = new Jqgrid_utils();
281
280
  afterDelRow: async function(row)
282
281
  {
283
- const r = await jqu.delete_row(row, url);
282
+ const r = await jqu.delete_row('id', 'http://api.com');
284
283
  console.log(r + ' : ' + row + ' - from API');
285
284
  },
286
285
  */
@@ -306,6 +305,7 @@ async delete_row(_id, url)
306
305
  * Async Delete request used by function delete_row
307
306
  @alias module:Jqgrid_utils
308
307
  @param {string} - url of the API
308
+ @param {boalan} - header should be json type? default form type
309
309
  @returns {object} @returns {object} Object from the the API like {delete: 'ok'} or {delete: 'failed'}
310
310
  @example
311
311
  var jqu = new Jqgrid_utils();
@@ -414,7 +414,7 @@ async hide_del_icon()
414
414
  @param {object} - keys and fields value to use
415
415
  @example
416
416
  var jqu = new Jqgrid_utils();
417
- col_model = await jqu.add_link_details(col_model,'http://foo.bar'' , 'target_field','target="_blank"',{"key":"field1","key":"field2"});
417
+ col_model = await jqu.add_link_details(col_model,'http://foo.bar' , 'style','target="_blank"',{'key':'style'});
418
418
  */
419
419
  async add_link_details(col_model, url, edit_field, attr = '', keys, format)
420
420
  {
@@ -493,7 +493,8 @@ async add_link_details(col_model, url, edit_field, attr = '', keys, format)
493
493
  @param {object} - keys and fields value to use
494
494
  @example
495
495
  var jqu = new Jqgrid_utils();
496
- col_model = await jqu.add_link_details_separator(col_model, 'https://foo.com' , 'couchdb','target="_blank"',{"mykey":"myval"});
496
+ col_model = await jqu.add_link_details_separator(col_model, url1 , 'style','target="_blank"',{"pricelist":"pricelist","style":"style"});
497
+ col_model = await jqu.add_link_details_separator(col_model, 'https://foo.com' , 'target_column','target="_blank"',{"mykey":"myval"});
497
498
  */
498
499
  async add_link_details_separator(col_model, url, edit_field, attr = '', keys, format)
499
500
  {
@@ -522,7 +523,7 @@ async add_link_details_separator(col_model, url, edit_field, attr = '', keys, fo
522
523
  {
523
524
  if(key != '')
524
525
  {
525
- pref += key + '' + '/' + encodeURIComponent(key_val);
526
+ pref += key + '' + '/' + encodeURIComponent(key_val) + '/';
526
527
  }
527
528
  else
528
529
  {
@@ -533,7 +534,7 @@ async add_link_details_separator(col_model, url, edit_field, attr = '', keys, fo
533
534
  }
534
535
  if (pref)
535
536
  {
536
- if (pref.slice(-1) === '&')
537
+ if (pref.slice(-1) === '&' || pref.slice(-1) === '/' )
537
538
  {
538
539
  pref = pref.slice(0, -1);
539
540
  }
@@ -554,8 +555,76 @@ async add_link_details_separator(col_model, url, edit_field, attr = '', keys, fo
554
555
 
555
556
 
556
557
 
558
+ /**
559
+ * Convert a cell into seperated based link/url include parameter based url like https://foo.bar.com/field.html?k=v
560
+ @alias module:Jqgrid_utils
561
+ @param {object} - col_model of the grid
562
+ @param {string} - URL string
563
+ @param {array} - array of dict
564
+ @param {string} - URL Attributes
565
+ @example
566
+ var jqu = new Jqgrid_utils();
567
+ col_model = await jqu.add_link_separator(col_model, host + '/html' , 'style',[
568
+ {
569
+ 'field':'pricelist',
570
+ 'extension':'.html',
571
+ 'fields':{'style':'style'}
572
+ }
573
+ ]);
574
+
575
+ */
576
+ async add_link_separator(col_model, url, edit_field, fields, attr='')
577
+ {
578
+ url = url + '/';
579
+ let self = this;
580
+ for (let i = 0; i < col_model.length; i++)
581
+ {
582
+ if (col_model[i]['name'] === edit_field)
583
+ {
584
+ col_model[i]['formatter'] = function(cell_val, obj)
585
+ {
586
+ let key_val = cell_val;
587
+ let pref = '';
588
+ for(let x in fields)
589
+ {
590
+ for(let xx in fields[x])
591
+ {
592
+ if(xx === 'field')
593
+ {
594
+ let field_value = obj.rowData[fields[x][xx]];
595
+ pref += field_value;
596
+ }
597
+ if(xx === 'extension')
598
+ {
599
+ pref += fields[x][xx] ;
600
+ }
601
+ if(xx === 'fields')
602
+ {
603
+ pref += '?';
604
+ for(let key in fields[x][xx])
605
+ {
606
+ let val = obj.rowData[fields[x][xx][key]];
607
+ pref = pref + '' + key + '=' + encodeURIComponent(val) + '&';
608
+ }
609
+ }
557
610
 
611
+ }
612
+ }
613
+ if (pref)
614
+ {
615
+ if (pref.slice(-1) === '&' || pref.slice(-1) === '/' )
616
+ {
617
+ pref = pref.slice(0, -1);
618
+ }
619
+ cell_val = '<a ' + attr + 'href="' + url + pref + '"> ' + cell_val + '</a>';
620
+ }
558
621
 
622
+ return cell_val;
623
+ };
624
+ }
625
+ }
626
+ return col_model;
627
+ }
559
628
 
560
629
  /**
561
630
  * Private Function
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.2.18"
32
+ "version": "1.3.1"
33
33
  }