jqgrid_utils 1.22.0 → 1.23.0

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
@@ -27,8 +27,8 @@ A module for Jqgrid_utils
27
27
 
28
28
 
29
29
  * [Jqgrid_utils](#module_Jqgrid_utils)
30
- * [module.exports#update_row_to_api(col_model, api, _ids)](#exp_module_Jqgrid_utils--module.exports+update_row_to_api) ⏏
31
- * [module.exports#delete_row_to_api(col_model, api, ids)](#exp_module_Jqgrid_utils--module.exports+delete_row_to_api) ⏏
30
+ * [module.exports#update_row_to_api(_self, api, _ids, row)](#exp_module_Jqgrid_utils--module.exports+update_row_to_api) ⏏
31
+ * [module.exports#delete_row_to_api(_self, api, rowid, _ids, data)](#exp_module_Jqgrid_utils--module.exports+delete_row_to_api) ⏏
32
32
  * [module.exports#append_seperator_link_column(col_model, url, field_value, base, attr, keys)](#exp_module_Jqgrid_utils--module.exports+append_seperator_link_column) ⏏
33
33
  * [module.exports#add_edit(col_model)](#exp_module_Jqgrid_utils--module.exports+add_edit) ⏏
34
34
  * [module.exports#add_textarea(col_model, edit_field)](#exp_module_Jqgrid_utils--module.exports+add_textarea) ⏏
@@ -69,16 +69,17 @@ A module for Jqgrid_utils
69
69
 
70
70
  <a name="exp_module_Jqgrid_utils--module.exports+update_row_to_api"></a>
71
71
 
72
- ### module.exports#update\_row\_to\_api(col_model, api, _ids) ⏏
72
+ ### module.exports#update\_row\_to\_api(_self, api, _ids, row) ⏏
73
73
  Takes the updated columns data and send it to your API post server
74
74
 
75
75
  **Kind**: Exported function
76
76
 
77
77
  | Param | Type | Description |
78
78
  | --- | --- | --- |
79
- | col_model | <code>string</code> | API URL like https://foo.com (required) |
80
- | api | <code>array</code> | id list, ids from the column header (required) |
81
- | _ids | <code>object</code> | settings - extra key:value to send to your server |
79
+ | _self | <code>object</code> | Grid Object (required) |
80
+ | api | <code>string</code> | API URL like https://foo.com (required) |
81
+ | _ids | <code>array</code> | id list, ids from the column header (required) |
82
+ | row | <code>object</code> | settings - extra key:value to send to your server |
82
83
 
83
84
  **Example**
84
85
  ```js
@@ -89,7 +90,7 @@ Takes the updated columns data and send it to your API post server
89
90
  const api = _api + '/column2';
90
91
  let info = {"msg":"failed"};
91
92
  var jqu = new Jqgrid_utils();
92
- info = await jqu.update_row_to_api(col_model,api,['id'],row,{server : '232',db : 'sl_h',table : 'kpi',});
93
+ info = await jqu.update_row_to_api($grid,,api,['id'],row,{server : '232',db : 'sl_h',table : 'kpi',});
93
94
  log.info(JSON.parse(info).msg);
94
95
  },
95
96
 
@@ -100,32 +101,42 @@ Takes the updated columns data and send it to your API post server
100
101
  ```
101
102
  <a name="exp_module_Jqgrid_utils--module.exports+delete_row_to_api"></a>
102
103
 
103
- ### module.exports#delete\_row\_to\_api(col_model, api, ids) ⏏
104
- Take your row id value and send it to your delete post API server
104
+ ### module.exports#delete\_row\_to\_api(_self, api, rowid, _ids, data) ⏏
105
+ After Delete a Grid Row send to and DELETE REST Request
106
+ You need to define loadComplete and afterDelRow
107
+ The Grid data needs to be saved as record within loadComplete
105
108
 
106
109
  **Kind**: Exported function
107
110
 
108
111
  | Param | Type | Description |
109
112
  | --- | --- | --- |
110
- | col_model | <code>string</code> | API URL like https://foo.com |
111
- | api | <code>array</code> | id list, ids from the column header (required) |
112
- | ids | <code>object</code> | settings - extra key:value to send to your server |
113
-
114
- **Example**
115
- ```js
116
- afterDelRow: async function(rowid){
117
- const _api = await get_api_url('sapir');
118
- const api = _api + '/column2';
119
- let info = {"msg":"failed"};
120
- var jqu = new Jqgrid_utils();
121
- info = await jqu.delete_row_to_api(col_model,api,[rowid],{
122
- server : '232',
123
- db : 'sl_h',
124
- table : 'kpi',
125
- operator: 'delete',
126
- });
127
- log.info(JSON.parse(info).msg);
128
- },
113
+ | _self | <code>object</code> | Grid Object (required) |
114
+ | api | <code>string</code> | API URL like https://foo.com (required) |
115
+ | rowid | <code>string</code> | the row id value from afterDelRow (required) |
116
+ | _ids | <code>array</code> | id list, ids from the column header colmodel (required) |
117
+ | data | <code>object</code> | settings - extra key:value to send to your server |
118
+
119
+ **Example**
120
+ ```js
121
+ loadComplete: async function()
122
+ {
123
+ $grid.jqGrid('setGridParam',{record_data:$grid.jqGrid("getGridParam").data});
124
+ },
125
+ afterDelRow: async function(rowid)
126
+ {
127
+ const _api = await get_api_url('sapir');
128
+ const api = _api + '/column2';
129
+ let info = {"msg":"failed"};
130
+ var jqu = new Jqgrid_utils();
131
+
132
+ info = await jqu.delete_row_to_api($grid,api,rowid,['id'],{
133
+ server : '232',
134
+ db : 'sl_h',
135
+ table : 'kpi',
136
+ operator: 'delete',
137
+ });
138
+ log.info(JSON.parse(info).msg);
139
+ },
129
140
  ```
130
141
  <a name="exp_module_Jqgrid_utils--module.exports+append_seperator_link_column"></a>
131
142
 
@@ -25,6 +25,7 @@ module.exports = class Vanilla_website_utils
25
25
  /**
26
26
  * Takes the updated columns data and send it to your API post server
27
27
  @alias module:Jqgrid_utils
28
+ @param {object} - Grid Object (required)
28
29
  @param {string} - API URL like https://foo.com (required)
29
30
  @param {array} - id list, ids from the column header (required)
30
31
  @param {object} - settings - extra key:value to send to your server
@@ -37,7 +38,7 @@ module.exports = class Vanilla_website_utils
37
38
  const api = _api + '/column2';
38
39
  let info = {"msg":"failed"};
39
40
  var jqu = new Jqgrid_utils();
40
- info = await jqu.update_row_to_api(col_model,api,['id'],row,{server : '232',db : 'sl_h',table : 'kpi',});
41
+ info = await jqu.update_row_to_api($grid,,api,['id'],row,{server : '232',db : 'sl_h',table : 'kpi',});
41
42
  log.info(JSON.parse(info).msg);
42
43
  },
43
44
 
@@ -50,7 +51,7 @@ module.exports = class Vanilla_website_utils
50
51
  */
51
52
 
52
53
 
53
- async update_row_to_api(col_model, api='',_ids=['id'],row={}, data)
54
+ async update_row_to_api(_self, api='',_ids=['id'],row={}, data)
54
55
  {
55
56
  let self = this;
56
57
  let infos = [];
@@ -133,41 +134,76 @@ module.exports = class Vanilla_website_utils
133
134
 
134
135
 
135
136
  /**
136
- * Take your row id value and send it to your delete post API server
137
- @alias module:Jqgrid_utils
138
- @param {string} - API URL like https://foo.com
139
- @param {array} - id list, ids from the column header (required)
137
+ * After Delete a Grid Row send to and DELETE REST Request
138
+ * You need to define loadComplete and afterDelRow
139
+ * The Grid data needs to be saved as record within loadComplete
140
+ @alias module:Jqgrid_utils
141
+ @param {object} - Grid Object (required)
142
+ @param {string} - API URL like https://foo.com (required)
143
+ @param {string} - the row id value from afterDelRow (required)
144
+ @param {array} - id list, ids from the column header colmodel (required)
140
145
  @param {object} - settings - extra key:value to send to your server
141
146
  @example
142
- afterDelRow: async function(rowid){
143
- const _api = await get_api_url('sapir');
144
- const api = _api + '/column2';
145
- let info = {"msg":"failed"};
146
- var jqu = new Jqgrid_utils();
147
- info = await jqu.delete_row_to_api(col_model,api,[rowid],{
148
- server : '232',
149
- db : 'sl_h',
150
- table : 'kpi',
151
- operator: 'delete',
152
- });
153
- log.info(JSON.parse(info).msg);
154
- },
147
+
148
+ loadComplete: async function()
149
+ {
150
+ $grid.jqGrid('setGridParam',{record_data:$grid.jqGrid("getGridParam").data});
151
+ },
152
+ afterDelRow: async function(rowid)
153
+ {
154
+ const _api = await get_api_url('sapir');
155
+ const api = _api + '/column2';
156
+ let info = {"msg":"failed"};
157
+ var jqu = new Jqgrid_utils();
158
+
159
+ info = await jqu.delete_row_to_api($grid,api,rowid,['id'],{
160
+ server : '232',
161
+ db : 'sl_h',
162
+ table : 'kpi',
163
+ operator: 'delete',
164
+ });
165
+ log.info(JSON.parse(info).msg);
166
+ },
167
+
168
+
169
+
170
+
171
+
155
172
  */
156
173
 
157
- async delete_row_to_api(col_model,api='', ids=[], data={})
158
- {
159
- let info = {"msg":"failed"};
160
- let self = this;
161
- if(api != '')
174
+ async delete_row_to_api(_self, api='', rowid, _ids=[], data={})
162
175
  {
163
- data['values'] = ids;
164
- if(! data.hasOwnProperty("id"))
176
+ let info = {"msg":"failed"};
177
+ let self = this;
178
+ let ids = [];
179
+ let values = {};
180
+ const rd = _self.jqGrid("getGridParam", "record_data");
181
+ for(let i in rd)
182
+ {
183
+ if (rd[i]['id'] === rowid)
184
+ {
185
+ for(let ii in _ids)
186
+ {
187
+ if(rd[i].hasOwnProperty(_ids[ii]))
188
+ {
189
+ values[_ids[ii]] = rd[i][_ids[ii]];
190
+ ids.push(_ids[ii]);
191
+ }
192
+ }
193
+ break;
194
+ }
195
+ }
196
+
197
+
198
+
199
+ if(api != '' && Object.keys(values).length == ids.length )
165
200
  {
166
- data['id'] = 'id';
201
+ data['ids'] = ids;
202
+ data['values'] = values;
203
+ //console.log(data);
204
+ info = await self.adelete_api(api,JSON.stringify(data));
167
205
  }
168
- info = await self.adelete_api(api,JSON.stringify(data));
169
- }
170
- return info;
206
+ return info;
171
207
  }
172
208
 
173
209
 
package/jqgrid_utils.js CHANGED
@@ -24,6 +24,7 @@ module.exports = class Vanilla_website_utils
24
24
  /**
25
25
  * Takes the updated columns data and send it to your API post server
26
26
  @alias module:Jqgrid_utils
27
+ @param {object} - Grid Object (required)
27
28
  @param {string} - API URL like https://foo.com (required)
28
29
  @param {array} - id list, ids from the column header (required)
29
30
  @param {object} - settings - extra key:value to send to your server
@@ -36,7 +37,7 @@ module.exports = class Vanilla_website_utils
36
37
  const api = _api + '/column2';
37
38
  let info = {"msg":"failed"};
38
39
  var jqu = new Jqgrid_utils();
39
- info = await jqu.update_row_to_api(col_model,api,['id'],row,{server : '232',db : 'sl_h',table : 'kpi',});
40
+ info = await jqu.update_row_to_api($grid,,api,['id'],row,{server : '232',db : 'sl_h',table : 'kpi',});
40
41
  log.info(JSON.parse(info).msg);
41
42
  },
42
43
 
@@ -49,7 +50,7 @@ module.exports = class Vanilla_website_utils
49
50
  */
50
51
 
51
52
 
52
- async update_row_to_api(col_model, api='',_ids=['id'],row={}, data)
53
+ async update_row_to_api(_self, api='',_ids=['id'],row={}, data)
53
54
  {
54
55
  let self = this;
55
56
  let infos = [];
@@ -132,41 +133,76 @@ module.exports = class Vanilla_website_utils
132
133
 
133
134
 
134
135
  /**
135
- * Take your row id value and send it to your delete post API server
136
- @alias module:Jqgrid_utils
137
- @param {string} - API URL like https://foo.com
138
- @param {array} - id list, ids from the column header (required)
136
+ * After Delete a Grid Row send to and DELETE REST Request
137
+ * You need to define loadComplete and afterDelRow
138
+ * The Grid data needs to be saved as record within loadComplete
139
+ @alias module:Jqgrid_utils
140
+ @param {object} - Grid Object (required)
141
+ @param {string} - API URL like https://foo.com (required)
142
+ @param {string} - the row id value from afterDelRow (required)
143
+ @param {array} - id list, ids from the column header colmodel (required)
139
144
  @param {object} - settings - extra key:value to send to your server
140
145
  @example
141
- afterDelRow: async function(rowid){
142
- const _api = await get_api_url('sapir');
143
- const api = _api + '/column2';
144
- let info = {"msg":"failed"};
145
- var jqu = new Jqgrid_utils();
146
- info = await jqu.delete_row_to_api(col_model,api,[rowid],{
147
- server : '232',
148
- db : 'sl_h',
149
- table : 'kpi',
150
- operator: 'delete',
151
- });
152
- log.info(JSON.parse(info).msg);
153
- },
146
+
147
+ loadComplete: async function()
148
+ {
149
+ $grid.jqGrid('setGridParam',{record_data:$grid.jqGrid("getGridParam").data});
150
+ },
151
+ afterDelRow: async function(rowid)
152
+ {
153
+ const _api = await get_api_url('sapir');
154
+ const api = _api + '/column2';
155
+ let info = {"msg":"failed"};
156
+ var jqu = new Jqgrid_utils();
157
+
158
+ info = await jqu.delete_row_to_api($grid,api,rowid,['id'],{
159
+ server : '232',
160
+ db : 'sl_h',
161
+ table : 'kpi',
162
+ operator: 'delete',
163
+ });
164
+ log.info(JSON.parse(info).msg);
165
+ },
166
+
167
+
168
+
169
+
170
+
154
171
  */
155
172
 
156
- async delete_row_to_api(col_model,api='', ids=[], data={})
157
- {
158
- let info = {"msg":"failed"};
159
- let self = this;
160
- if(api != '')
173
+ async delete_row_to_api(_self, api='', rowid, _ids=[], data={})
161
174
  {
162
- data['values'] = ids;
163
- if(! data.hasOwnProperty("id"))
175
+ let info = {"msg":"failed"};
176
+ let self = this;
177
+ let ids = [];
178
+ let values = {};
179
+ const rd = _self.jqGrid("getGridParam", "record_data");
180
+ for(let i in rd)
181
+ {
182
+ if (rd[i]['id'] === rowid)
183
+ {
184
+ for(let ii in _ids)
185
+ {
186
+ if(rd[i].hasOwnProperty(_ids[ii]))
187
+ {
188
+ values[_ids[ii]] = rd[i][_ids[ii]];
189
+ ids.push(_ids[ii]);
190
+ }
191
+ }
192
+ break;
193
+ }
194
+ }
195
+
196
+
197
+
198
+ if(api != '' && Object.keys(values).length == ids.length )
164
199
  {
165
- data['id'] = 'id';
200
+ data['ids'] = ids;
201
+ data['values'] = values;
202
+ //console.log(data);
203
+ info = await self.adelete_api(api,JSON.stringify(data));
166
204
  }
167
- info = await self.adelete_api(api,JSON.stringify(data));
168
- }
169
- return info;
205
+ return info;
170
206
  }
171
207
 
172
208
 
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.22.0"
32
+ "version": "1.23.0"
33
33
  }