jqgrid_utils 1.2.1 → 1.2.2
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 +114 -5
- package/_README.md +56 -0
- package/dist/jqgrid_utils.js +93 -12
- package/jqgrid_utils.js +93 -12
- package/make_doc.sh +4 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -54,10 +54,103 @@ Discover All Functions:
|
|
|
54
54
|
},
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
-
<a name="
|
|
57
|
+
<a name="module_Vanilla_website_utils"></a>
|
|
58
|
+
|
|
59
|
+
## Vanilla\_website\_utils
|
|
60
|
+
A module for Vanilla_website_utils
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
* [Vanilla_website_utils](#module_Vanilla_website_utils)
|
|
64
|
+
* [module.exports#set_link()](#exp_module_Vanilla_website_utils--module.exports+set_link) ⏏
|
|
65
|
+
* [module.exports#grid_set_captain()](#exp_module_Vanilla_website_utils--module.exports+grid_set_captain) ⏏
|
|
66
|
+
* [module.exports#resize_saved_cell_width()](#exp_module_Vanilla_website_utils--module.exports+resize_saved_cell_width) ⏏
|
|
67
|
+
* [module.exports#resize_cell()](#exp_module_Vanilla_website_utils--module.exports+resize_cell) ⏏
|
|
68
|
+
* [module.exports#upsert_row()](#exp_module_Vanilla_website_utils--module.exports+upsert_row) ⏏
|
|
69
|
+
* [module.exports#insert_row()](#exp_module_Vanilla_website_utils--module.exports+insert_row) ⏏
|
|
70
|
+
* [module.exports#update_row()](#exp_module_Vanilla_website_utils--module.exports+update_row) ⏏
|
|
71
|
+
* [module.exports#delete_row()](#exp_module_Vanilla_website_utils--module.exports+delete_row) ⏏
|
|
72
|
+
* [module.exports#adelete_api()](#exp_module_Vanilla_website_utils--module.exports+adelete_api) ⏏
|
|
73
|
+
* [module.exports#post_json()](#exp_module_Vanilla_website_utils--module.exports+post_json) ⏏
|
|
74
|
+
* [module.exports#put_json()](#exp_module_Vanilla_website_utils--module.exports+put_json) ⏏
|
|
75
|
+
* [module.exports#hide_del_icon()](#exp_module_Vanilla_website_utils--module.exports+hide_del_icon) ⏏
|
|
76
|
+
* [module.exports#add_link_details()](#exp_module_Vanilla_website_utils--module.exports+add_link_details) ⏏
|
|
77
|
+
* [module.exports#add_link_details_separator()](#exp_module_Vanilla_website_utils--module.exports+add_link_details_separator) ⏏
|
|
78
|
+
* [module.exports#__cell_format()](#exp_module_Vanilla_website_utils--module.exports+__cell_format) ⏏
|
|
79
|
+
* [module.exports#subgrid(_id, id, data_url)](#exp_module_Vanilla_website_utils--module.exports+subgrid) ⏏
|
|
80
|
+
* [module.exports#add_image(col_model, edit_field, size, link)](#exp_module_Vanilla_website_utils--module.exports+add_image) ⏏
|
|
81
|
+
|
|
82
|
+
<a name="exp_module_Vanilla_website_utils--module.exports+set_link"></a>
|
|
83
|
+
|
|
84
|
+
### module.exports#set\_link() ⏏
|
|
85
|
+
**Kind**: Exported function
|
|
86
|
+
<a name="exp_module_Vanilla_website_utils--module.exports+grid_set_captain"></a>
|
|
87
|
+
|
|
88
|
+
### module.exports#grid\_set\_captain() ⏏
|
|
89
|
+
**Kind**: Exported function
|
|
90
|
+
<a name="exp_module_Vanilla_website_utils--module.exports+resize_saved_cell_width"></a>
|
|
91
|
+
|
|
92
|
+
### module.exports#resize\_saved\_cell\_width() ⏏
|
|
93
|
+
**Kind**: Exported function
|
|
94
|
+
<a name="exp_module_Vanilla_website_utils--module.exports+resize_cell"></a>
|
|
95
|
+
|
|
96
|
+
### module.exports#resize\_cell() ⏏
|
|
97
|
+
**Kind**: Exported function
|
|
98
|
+
<a name="exp_module_Vanilla_website_utils--module.exports+upsert_row"></a>
|
|
99
|
+
|
|
100
|
+
### module.exports#upsert\_row() ⏏
|
|
101
|
+
**Kind**: Exported function
|
|
102
|
+
<a name="exp_module_Vanilla_website_utils--module.exports+insert_row"></a>
|
|
103
|
+
|
|
104
|
+
### module.exports#insert\_row() ⏏
|
|
105
|
+
**Kind**: Exported function
|
|
106
|
+
<a name="exp_module_Vanilla_website_utils--module.exports+update_row"></a>
|
|
107
|
+
|
|
108
|
+
### module.exports#update\_row() ⏏
|
|
109
|
+
**Kind**: Exported function
|
|
110
|
+
<a name="exp_module_Vanilla_website_utils--module.exports+delete_row"></a>
|
|
111
|
+
|
|
112
|
+
### module.exports#delete\_row() ⏏
|
|
113
|
+
**Kind**: Exported function
|
|
114
|
+
<a name="exp_module_Vanilla_website_utils--module.exports+adelete_api"></a>
|
|
115
|
+
|
|
116
|
+
### module.exports#adelete\_api() ⏏
|
|
117
|
+
**Kind**: Exported function
|
|
118
|
+
<a name="exp_module_Vanilla_website_utils--module.exports+post_json"></a>
|
|
119
|
+
|
|
120
|
+
### module.exports#post\_json() ⏏
|
|
121
|
+
**Kind**: Exported function
|
|
122
|
+
<a name="exp_module_Vanilla_website_utils--module.exports+put_json"></a>
|
|
123
|
+
|
|
124
|
+
### module.exports#put\_json() ⏏
|
|
125
|
+
**Kind**: Exported function
|
|
126
|
+
<a name="exp_module_Vanilla_website_utils--module.exports+hide_del_icon"></a>
|
|
127
|
+
|
|
128
|
+
### module.exports#hide\_del\_icon() ⏏
|
|
129
|
+
**Kind**: Exported function
|
|
130
|
+
<a name="exp_module_Vanilla_website_utils--module.exports+add_link_details"></a>
|
|
131
|
+
|
|
132
|
+
### module.exports#add\_link\_details() ⏏
|
|
133
|
+
**Kind**: Exported function
|
|
134
|
+
**Example**
|
|
135
|
+
```js
|
|
136
|
+
// example: col_model = await jqu.add_link_details(col_model,'http://foo.bar'' , 'target_field','target="_blank"',{"key":"field1","key":"field2"});
|
|
137
|
+
```
|
|
138
|
+
<a name="exp_module_Vanilla_website_utils--module.exports+add_link_details_separator"></a>
|
|
139
|
+
|
|
140
|
+
### module.exports#add\_link\_details\_separator() ⏏
|
|
141
|
+
**Kind**: Exported function
|
|
142
|
+
**Example**
|
|
143
|
+
```js
|
|
144
|
+
// col_model = await jqu.add_link_details_separator(col_model, 'https://foo.com' , 'couchdb','target="_blank"',{"mykey":"myval"});
|
|
145
|
+
```
|
|
146
|
+
<a name="exp_module_Vanilla_website_utils--module.exports+__cell_format"></a>
|
|
58
147
|
|
|
59
|
-
|
|
60
|
-
**Kind**:
|
|
148
|
+
### module.exports#\_\_cell\_format() ⏏
|
|
149
|
+
**Kind**: Exported function
|
|
150
|
+
<a name="exp_module_Vanilla_website_utils--module.exports+subgrid"></a>
|
|
151
|
+
|
|
152
|
+
### module.exports#subgrid(_id, id, data_url) ⏏
|
|
153
|
+
**Kind**: Exported function
|
|
61
154
|
|
|
62
155
|
| Param | Type | Description |
|
|
63
156
|
| --- | --- | --- |
|
|
@@ -68,6 +161,22 @@ Discover All Functions:
|
|
|
68
161
|
**Example**
|
|
69
162
|
```js
|
|
70
163
|
let data_url = api + '/phone_detail?f=data&_id=';
|
|
71
|
-
let col_model_url = api + '/phone_detail?f=col_model';
|
|
72
|
-
let col_model = JSON.parse(await vwu.aget_api(col_model_url))
|
|
164
|
+
let col_model_url = api + '/phone_detail?f=col_model';
|
|
165
|
+
let col_model = JSON.parse(await vwu.aget_api(col_model_url))
|
|
166
|
+
```
|
|
167
|
+
<a name="exp_module_Vanilla_website_utils--module.exports+add_image"></a>
|
|
168
|
+
|
|
169
|
+
### module.exports#add\_image(col_model, edit_field, size, link) ⏏
|
|
170
|
+
**Kind**: Exported function
|
|
171
|
+
|
|
172
|
+
| Param | Type | Default | Description |
|
|
173
|
+
| --- | --- | --- | --- |
|
|
174
|
+
| col_model | <code>object</code> | | col_model for the grid |
|
|
175
|
+
| edit_field | <code>string</code> | | field what include the image/picture href path like http://mypicture.png |
|
|
176
|
+
| size | <code>int</code> | | size of the picture |
|
|
177
|
+
| link | <code>bolen</code> | <code>false</code> | image path should be a link |
|
|
178
|
+
|
|
179
|
+
**Example**
|
|
180
|
+
```js
|
|
181
|
+
col_model = await jqu.add_image(col_model, 'image', 60, false);
|
|
73
182
|
```
|
package/_README.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Jqgrid_utils
|
|
2
|
+
Convenient Functions for free jqGrid
|
|
3
|
+
|
|
4
|
+
Demo:
|
|
5
|
+
https://jqgrid_utils.calantas.org
|
|
6
|
+
|
|
7
|
+
# Example Usage:
|
|
8
|
+
|
|
9
|
+
Add a the library to your website
|
|
10
|
+
|
|
11
|
+
``
|
|
12
|
+
`html
|
|
13
|
+
<script src="../node_modules/jqgrid_utils/dist/jqgrid_utils.js"></script>
|
|
14
|
+
`
|
|
15
|
+
``
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
Example Usage:
|
|
19
|
+
```javascript
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Discover All Functions:
|
|
24
|
+
|
|
25
|
+
* To add the Qty of rows to the Caption text
|
|
26
|
+
* grid_set_captain(_grid, data)
|
|
27
|
+
* _grid: the DOM ID of grid(type: string), example: '#grid'
|
|
28
|
+
* data: the grid data(type: array) (Optional)
|
|
29
|
+
* example:
|
|
30
|
+
```javascript
|
|
31
|
+
let gu = new Jqgrid_utils();
|
|
32
|
+
loadComplete: function(data)
|
|
33
|
+
{
|
|
34
|
+
await gu.grid_set_captain(_grid, data);
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Functions:
|
|
39
|
+
|
|
40
|
+
### add grid_load_complete to don't show the delete icon
|
|
41
|
+
```javascript
|
|
42
|
+
loadComplete: async function(data)
|
|
43
|
+
{
|
|
44
|
+
jqu.s_hide_del_icon();
|
|
45
|
+
grid_load_complete;
|
|
46
|
+
},
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
```javascript
|
|
50
|
+
loadComplete: async function(data)
|
|
51
|
+
{
|
|
52
|
+
await jqu.hide_del_icon();
|
|
53
|
+
grid_load_complete;
|
|
54
|
+
},
|
|
55
|
+
```
|
|
56
|
+
|
package/dist/jqgrid_utils.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Jqgrid_utils = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
|
|
2
|
+
/**
|
|
3
|
+
* A module for Vanilla_website_utils
|
|
4
|
+
* @module Vanilla_website_utils
|
|
5
|
+
*/
|
|
6
|
+
|
|
2
7
|
'use strict';
|
|
3
8
|
|
|
4
9
|
module.exports = class Vanilla_website_utils
|
|
@@ -22,7 +27,9 @@ module.exports = class Vanilla_website_utils
|
|
|
22
27
|
this.set_link(col_model, edit_field, url ,attr);
|
|
23
28
|
}
|
|
24
29
|
|
|
25
|
-
|
|
30
|
+
/**
|
|
31
|
+
@alias module:Vanilla_website_utils
|
|
32
|
+
*/
|
|
26
33
|
async set_link(col_model, edit_field, url ,attr='')
|
|
27
34
|
{
|
|
28
35
|
for(let i=0;i< col_model.length;i++)
|
|
@@ -44,6 +51,9 @@ module.exports = class Vanilla_website_utils
|
|
|
44
51
|
this.grid_set_captain(_grid, data=[]);
|
|
45
52
|
}
|
|
46
53
|
|
|
54
|
+
/**
|
|
55
|
+
@alias module:Vanilla_website_utils
|
|
56
|
+
*/
|
|
47
57
|
async grid_set_captain(_grid, data=[])
|
|
48
58
|
{
|
|
49
59
|
const grid = jQuery(_grid);
|
|
@@ -68,7 +78,9 @@ module.exports = class Vanilla_website_utils
|
|
|
68
78
|
{
|
|
69
79
|
this.grid_set_captain(col_model, page, grid);
|
|
70
80
|
}
|
|
71
|
-
|
|
81
|
+
/**
|
|
82
|
+
@alias module:Vanilla_website_utils
|
|
83
|
+
*/
|
|
72
84
|
async resize_saved_cell_width(col_model,page=false, grid=false)
|
|
73
85
|
{
|
|
74
86
|
let key = page ? page : this.page;
|
|
@@ -84,7 +96,9 @@ module.exports = class Vanilla_website_utils
|
|
|
84
96
|
return col_model;
|
|
85
97
|
}
|
|
86
98
|
|
|
87
|
-
|
|
99
|
+
/**
|
|
100
|
+
@alias module:Vanilla_website_utils
|
|
101
|
+
*/
|
|
88
102
|
resize_cell(width, index, _page=false)
|
|
89
103
|
{
|
|
90
104
|
const page = _page ? _page : localStorage.getItem('page');
|
|
@@ -98,7 +112,9 @@ module.exports = class Vanilla_website_utils
|
|
|
98
112
|
|
|
99
113
|
|
|
100
114
|
|
|
101
|
-
|
|
115
|
+
/**
|
|
116
|
+
@alias module:Vanilla_website_utils
|
|
117
|
+
*/
|
|
102
118
|
async upsert_row(row, url, req = {})
|
|
103
119
|
{
|
|
104
120
|
if (row.rowid.startsWith('jqg'))
|
|
@@ -113,7 +129,9 @@ async upsert_row(row, url, req = {})
|
|
|
113
129
|
}
|
|
114
130
|
}
|
|
115
131
|
|
|
116
|
-
|
|
132
|
+
/**
|
|
133
|
+
@alias module:Vanilla_website_utils
|
|
134
|
+
*/
|
|
117
135
|
async insert_row(row, url)
|
|
118
136
|
{
|
|
119
137
|
let req = {};
|
|
@@ -135,7 +153,9 @@ async insert_row(row, url)
|
|
|
135
153
|
}
|
|
136
154
|
|
|
137
155
|
|
|
138
|
-
|
|
156
|
+
/**
|
|
157
|
+
@alias module:Vanilla_website_utils
|
|
158
|
+
*/
|
|
139
159
|
async update_row(row, url, req = {})
|
|
140
160
|
{
|
|
141
161
|
let ret = '';
|
|
@@ -156,7 +176,9 @@ async update_row(row, url, req = {})
|
|
|
156
176
|
return ret;
|
|
157
177
|
}
|
|
158
178
|
|
|
159
|
-
|
|
179
|
+
/**
|
|
180
|
+
@alias module:Vanilla_website_utils
|
|
181
|
+
*/
|
|
160
182
|
async delete_row(_id, url)
|
|
161
183
|
{
|
|
162
184
|
let ret = '';
|
|
@@ -174,7 +196,9 @@ async delete_row(_id, url)
|
|
|
174
196
|
}
|
|
175
197
|
|
|
176
198
|
|
|
177
|
-
|
|
199
|
+
/**
|
|
200
|
+
@alias module:Vanilla_website_utils
|
|
201
|
+
*/
|
|
178
202
|
async adelete_api(url, json = false)
|
|
179
203
|
{
|
|
180
204
|
const ctype = json ? "application/json;charset=UTF-8" : "application/x-www-form-urlencoded";
|
|
@@ -190,6 +214,9 @@ async adelete_api(url, json = false)
|
|
|
190
214
|
}
|
|
191
215
|
|
|
192
216
|
|
|
217
|
+
/**
|
|
218
|
+
@alias module:Vanilla_website_utils
|
|
219
|
+
*/
|
|
193
220
|
async post_json(url, data)
|
|
194
221
|
{
|
|
195
222
|
return new Promise((resolve, reject) =>
|
|
@@ -203,6 +230,9 @@ async post_json(url, data)
|
|
|
203
230
|
});
|
|
204
231
|
}
|
|
205
232
|
|
|
233
|
+
/**
|
|
234
|
+
@alias module:Vanilla_website_utils
|
|
235
|
+
*/
|
|
206
236
|
async put_json(url, data)
|
|
207
237
|
{
|
|
208
238
|
return new Promise((resolve, reject) =>
|
|
@@ -222,6 +252,9 @@ s_hide_del_icon()
|
|
|
222
252
|
hide_del_icon();
|
|
223
253
|
}
|
|
224
254
|
|
|
255
|
+
/**
|
|
256
|
+
@alias module:Vanilla_website_utils
|
|
257
|
+
*/
|
|
225
258
|
async hide_del_icon()
|
|
226
259
|
{
|
|
227
260
|
jQuery('.ui-inline-del').each(function(index) {jQuery(this).html('');});
|
|
@@ -229,8 +262,11 @@ async hide_del_icon()
|
|
|
229
262
|
|
|
230
263
|
|
|
231
264
|
|
|
232
|
-
|
|
265
|
+
/**
|
|
266
|
+
@alias module:Vanilla_website_utils
|
|
267
|
+
@example
|
|
233
268
|
// example: col_model = await jqu.add_link_details(col_model,'http://foo.bar'' , 'target_field','target="_blank"',{"key":"field1","key":"field2"});
|
|
269
|
+
*/
|
|
234
270
|
async add_link_details(col_model, url, edit_field, attr = '', keys, format)
|
|
235
271
|
{
|
|
236
272
|
let self = this;
|
|
@@ -298,8 +334,11 @@ async add_link_details(col_model, url, edit_field, attr = '', keys, format)
|
|
|
298
334
|
}
|
|
299
335
|
|
|
300
336
|
|
|
301
|
-
|
|
302
|
-
|
|
337
|
+
/**
|
|
338
|
+
@alias module:Vanilla_website_utils
|
|
339
|
+
@example
|
|
340
|
+
// col_model = await jqu.add_link_details_separator(col_model, 'https://foo.com' , 'couchdb','target="_blank"',{"mykey":"myval"});
|
|
341
|
+
*/
|
|
303
342
|
async add_link_details_separator(col_model, url, edit_field, attr = '', keys, format)
|
|
304
343
|
{
|
|
305
344
|
url = url + '/';
|
|
@@ -362,7 +401,9 @@ async add_link_details_separator(col_model, url, edit_field, attr = '', keys, fo
|
|
|
362
401
|
|
|
363
402
|
|
|
364
403
|
|
|
365
|
-
|
|
404
|
+
/**
|
|
405
|
+
@alias module:Vanilla_website_utils
|
|
406
|
+
*/
|
|
366
407
|
__cell_format(cell_value, format)
|
|
367
408
|
{
|
|
368
409
|
if (format == 'format_ok')
|
|
@@ -382,6 +423,7 @@ __cell_format(cell_value, format)
|
|
|
382
423
|
|
|
383
424
|
|
|
384
425
|
/**
|
|
426
|
+
@alias module:Vanilla_website_utils
|
|
385
427
|
@param {string} - row_id
|
|
386
428
|
@param {string} - data id
|
|
387
429
|
@param {object} - col_model for the table
|
|
@@ -409,6 +451,45 @@ async subgrid(_id, id, data_url, col_model)
|
|
|
409
451
|
}
|
|
410
452
|
|
|
411
453
|
|
|
454
|
+
/**
|
|
455
|
+
@alias module:Vanilla_website_utils
|
|
456
|
+
@param {object} - col_model for the grid
|
|
457
|
+
@param {string} - field what include the image/picture href path like http://mypicture.png
|
|
458
|
+
@param {int} - size of the picture
|
|
459
|
+
@param {bolen} - image path should be a link
|
|
460
|
+
@example
|
|
461
|
+
* col_model = await jqu.add_image(col_model, 'image', 60, false);
|
|
462
|
+
*/
|
|
463
|
+
async add_image(col_model, edit_field, size, link=false)
|
|
464
|
+
{
|
|
465
|
+
if (size === undefined)
|
|
466
|
+
{
|
|
467
|
+
size = 60;
|
|
468
|
+
}
|
|
469
|
+
for (let i = 0; i < col_model.length; i++)
|
|
470
|
+
{
|
|
471
|
+
if (col_model[i]['name'] === edit_field)
|
|
472
|
+
{
|
|
473
|
+
col_model[i]['picture'] = true;
|
|
474
|
+
col_model[i]['width'] = size;
|
|
475
|
+
col_model[i]['height'] = size;
|
|
476
|
+
col_model[i]['formatter'] = function(cell_val)
|
|
477
|
+
{
|
|
478
|
+
if(link)
|
|
479
|
+
{
|
|
480
|
+
return '<a target="blank" href="' + cell_val + '"><img src="' + cell_val + '" alt="my image" width="' + size + '" /></a>';
|
|
481
|
+
}
|
|
482
|
+
else
|
|
483
|
+
{
|
|
484
|
+
return '<img src="' + cell_val + '" alt="my image" width="' + size + '" />';
|
|
485
|
+
}
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
return col_model;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
|
|
412
493
|
|
|
413
494
|
};
|
|
414
495
|
|
package/jqgrid_utils.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A module for Vanilla_website_utils
|
|
3
|
+
* @module Vanilla_website_utils
|
|
4
|
+
*/
|
|
5
|
+
|
|
1
6
|
'use strict';
|
|
2
7
|
|
|
3
8
|
module.exports = class Vanilla_website_utils
|
|
@@ -21,7 +26,9 @@ module.exports = class Vanilla_website_utils
|
|
|
21
26
|
this.set_link(col_model, edit_field, url ,attr);
|
|
22
27
|
}
|
|
23
28
|
|
|
24
|
-
|
|
29
|
+
/**
|
|
30
|
+
@alias module:Vanilla_website_utils
|
|
31
|
+
*/
|
|
25
32
|
async set_link(col_model, edit_field, url ,attr='')
|
|
26
33
|
{
|
|
27
34
|
for(let i=0;i< col_model.length;i++)
|
|
@@ -43,6 +50,9 @@ module.exports = class Vanilla_website_utils
|
|
|
43
50
|
this.grid_set_captain(_grid, data=[]);
|
|
44
51
|
}
|
|
45
52
|
|
|
53
|
+
/**
|
|
54
|
+
@alias module:Vanilla_website_utils
|
|
55
|
+
*/
|
|
46
56
|
async grid_set_captain(_grid, data=[])
|
|
47
57
|
{
|
|
48
58
|
const grid = jQuery(_grid);
|
|
@@ -67,7 +77,9 @@ module.exports = class Vanilla_website_utils
|
|
|
67
77
|
{
|
|
68
78
|
this.grid_set_captain(col_model, page, grid);
|
|
69
79
|
}
|
|
70
|
-
|
|
80
|
+
/**
|
|
81
|
+
@alias module:Vanilla_website_utils
|
|
82
|
+
*/
|
|
71
83
|
async resize_saved_cell_width(col_model,page=false, grid=false)
|
|
72
84
|
{
|
|
73
85
|
let key = page ? page : this.page;
|
|
@@ -83,7 +95,9 @@ module.exports = class Vanilla_website_utils
|
|
|
83
95
|
return col_model;
|
|
84
96
|
}
|
|
85
97
|
|
|
86
|
-
|
|
98
|
+
/**
|
|
99
|
+
@alias module:Vanilla_website_utils
|
|
100
|
+
*/
|
|
87
101
|
resize_cell(width, index, _page=false)
|
|
88
102
|
{
|
|
89
103
|
const page = _page ? _page : localStorage.getItem('page');
|
|
@@ -97,7 +111,9 @@ module.exports = class Vanilla_website_utils
|
|
|
97
111
|
|
|
98
112
|
|
|
99
113
|
|
|
100
|
-
|
|
114
|
+
/**
|
|
115
|
+
@alias module:Vanilla_website_utils
|
|
116
|
+
*/
|
|
101
117
|
async upsert_row(row, url, req = {})
|
|
102
118
|
{
|
|
103
119
|
if (row.rowid.startsWith('jqg'))
|
|
@@ -112,7 +128,9 @@ async upsert_row(row, url, req = {})
|
|
|
112
128
|
}
|
|
113
129
|
}
|
|
114
130
|
|
|
115
|
-
|
|
131
|
+
/**
|
|
132
|
+
@alias module:Vanilla_website_utils
|
|
133
|
+
*/
|
|
116
134
|
async insert_row(row, url)
|
|
117
135
|
{
|
|
118
136
|
let req = {};
|
|
@@ -134,7 +152,9 @@ async insert_row(row, url)
|
|
|
134
152
|
}
|
|
135
153
|
|
|
136
154
|
|
|
137
|
-
|
|
155
|
+
/**
|
|
156
|
+
@alias module:Vanilla_website_utils
|
|
157
|
+
*/
|
|
138
158
|
async update_row(row, url, req = {})
|
|
139
159
|
{
|
|
140
160
|
let ret = '';
|
|
@@ -155,7 +175,9 @@ async update_row(row, url, req = {})
|
|
|
155
175
|
return ret;
|
|
156
176
|
}
|
|
157
177
|
|
|
158
|
-
|
|
178
|
+
/**
|
|
179
|
+
@alias module:Vanilla_website_utils
|
|
180
|
+
*/
|
|
159
181
|
async delete_row(_id, url)
|
|
160
182
|
{
|
|
161
183
|
let ret = '';
|
|
@@ -173,7 +195,9 @@ async delete_row(_id, url)
|
|
|
173
195
|
}
|
|
174
196
|
|
|
175
197
|
|
|
176
|
-
|
|
198
|
+
/**
|
|
199
|
+
@alias module:Vanilla_website_utils
|
|
200
|
+
*/
|
|
177
201
|
async adelete_api(url, json = false)
|
|
178
202
|
{
|
|
179
203
|
const ctype = json ? "application/json;charset=UTF-8" : "application/x-www-form-urlencoded";
|
|
@@ -189,6 +213,9 @@ async adelete_api(url, json = false)
|
|
|
189
213
|
}
|
|
190
214
|
|
|
191
215
|
|
|
216
|
+
/**
|
|
217
|
+
@alias module:Vanilla_website_utils
|
|
218
|
+
*/
|
|
192
219
|
async post_json(url, data)
|
|
193
220
|
{
|
|
194
221
|
return new Promise((resolve, reject) =>
|
|
@@ -202,6 +229,9 @@ async post_json(url, data)
|
|
|
202
229
|
});
|
|
203
230
|
}
|
|
204
231
|
|
|
232
|
+
/**
|
|
233
|
+
@alias module:Vanilla_website_utils
|
|
234
|
+
*/
|
|
205
235
|
async put_json(url, data)
|
|
206
236
|
{
|
|
207
237
|
return new Promise((resolve, reject) =>
|
|
@@ -221,6 +251,9 @@ s_hide_del_icon()
|
|
|
221
251
|
hide_del_icon();
|
|
222
252
|
}
|
|
223
253
|
|
|
254
|
+
/**
|
|
255
|
+
@alias module:Vanilla_website_utils
|
|
256
|
+
*/
|
|
224
257
|
async hide_del_icon()
|
|
225
258
|
{
|
|
226
259
|
jQuery('.ui-inline-del').each(function(index) {jQuery(this).html('');});
|
|
@@ -228,8 +261,11 @@ async hide_del_icon()
|
|
|
228
261
|
|
|
229
262
|
|
|
230
263
|
|
|
231
|
-
|
|
264
|
+
/**
|
|
265
|
+
@alias module:Vanilla_website_utils
|
|
266
|
+
@example
|
|
232
267
|
// example: col_model = await jqu.add_link_details(col_model,'http://foo.bar'' , 'target_field','target="_blank"',{"key":"field1","key":"field2"});
|
|
268
|
+
*/
|
|
233
269
|
async add_link_details(col_model, url, edit_field, attr = '', keys, format)
|
|
234
270
|
{
|
|
235
271
|
let self = this;
|
|
@@ -297,8 +333,11 @@ async add_link_details(col_model, url, edit_field, attr = '', keys, format)
|
|
|
297
333
|
}
|
|
298
334
|
|
|
299
335
|
|
|
300
|
-
|
|
301
|
-
|
|
336
|
+
/**
|
|
337
|
+
@alias module:Vanilla_website_utils
|
|
338
|
+
@example
|
|
339
|
+
// col_model = await jqu.add_link_details_separator(col_model, 'https://foo.com' , 'couchdb','target="_blank"',{"mykey":"myval"});
|
|
340
|
+
*/
|
|
302
341
|
async add_link_details_separator(col_model, url, edit_field, attr = '', keys, format)
|
|
303
342
|
{
|
|
304
343
|
url = url + '/';
|
|
@@ -361,7 +400,9 @@ async add_link_details_separator(col_model, url, edit_field, attr = '', keys, fo
|
|
|
361
400
|
|
|
362
401
|
|
|
363
402
|
|
|
364
|
-
|
|
403
|
+
/**
|
|
404
|
+
@alias module:Vanilla_website_utils
|
|
405
|
+
*/
|
|
365
406
|
__cell_format(cell_value, format)
|
|
366
407
|
{
|
|
367
408
|
if (format == 'format_ok')
|
|
@@ -381,6 +422,7 @@ __cell_format(cell_value, format)
|
|
|
381
422
|
|
|
382
423
|
|
|
383
424
|
/**
|
|
425
|
+
@alias module:Vanilla_website_utils
|
|
384
426
|
@param {string} - row_id
|
|
385
427
|
@param {string} - data id
|
|
386
428
|
@param {object} - col_model for the table
|
|
@@ -408,6 +450,45 @@ async subgrid(_id, id, data_url, col_model)
|
|
|
408
450
|
}
|
|
409
451
|
|
|
410
452
|
|
|
453
|
+
/**
|
|
454
|
+
@alias module:Vanilla_website_utils
|
|
455
|
+
@param {object} - col_model for the grid
|
|
456
|
+
@param {string} - field what include the image/picture href path like http://mypicture.png
|
|
457
|
+
@param {int} - size of the picture
|
|
458
|
+
@param {bolen} - image path should be a link
|
|
459
|
+
@example
|
|
460
|
+
* col_model = await jqu.add_image(col_model, 'image', 60, false);
|
|
461
|
+
*/
|
|
462
|
+
async add_image(col_model, edit_field, size, link=false)
|
|
463
|
+
{
|
|
464
|
+
if (size === undefined)
|
|
465
|
+
{
|
|
466
|
+
size = 60;
|
|
467
|
+
}
|
|
468
|
+
for (let i = 0; i < col_model.length; i++)
|
|
469
|
+
{
|
|
470
|
+
if (col_model[i]['name'] === edit_field)
|
|
471
|
+
{
|
|
472
|
+
col_model[i]['picture'] = true;
|
|
473
|
+
col_model[i]['width'] = size;
|
|
474
|
+
col_model[i]['height'] = size;
|
|
475
|
+
col_model[i]['formatter'] = function(cell_val)
|
|
476
|
+
{
|
|
477
|
+
if(link)
|
|
478
|
+
{
|
|
479
|
+
return '<a target="blank" href="' + cell_val + '"><img src="' + cell_val + '" alt="my image" width="' + size + '" /></a>';
|
|
480
|
+
}
|
|
481
|
+
else
|
|
482
|
+
{
|
|
483
|
+
return '<img src="' + cell_val + '" alt="my image" width="' + size + '" />';
|
|
484
|
+
}
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
return col_model;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
|
|
411
492
|
|
|
412
493
|
};
|
|
413
494
|
|
package/make_doc.sh
ADDED
package/package.json
CHANGED