bootstrap-table-rails 1.12.2 → 1.13.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -12
- data/lib/bootstrap-table-rails/version.rb +1 -1
- data/vendor/assets/javascripts/bootstrap-table/bootstrap-table-locale-all.js +2534 -1841
- data/vendor/assets/javascripts/bootstrap-table/bootstrap-table.css +202 -283
- data/vendor/assets/javascripts/bootstrap-table/bootstrap-table.js +3114 -2555
- data/vendor/assets/javascripts/bootstrap-table/extensions/accent-neutralise/bootstrap-table-accent-neutralise.js +247 -152
- data/vendor/assets/javascripts/bootstrap-table/extensions/addrbar/bootstrap-table-addrbar.js +271 -0
- data/vendor/assets/javascripts/bootstrap-table/extensions/auto-refresh/bootstrap-table-auto-refresh.js +77 -68
- data/vendor/assets/javascripts/bootstrap-table/extensions/cookie/bootstrap-table-cookie.js +452 -315
- data/vendor/assets/javascripts/bootstrap-table/extensions/copy-rows/bootstrap-table-copy-rows.js +105 -86
- data/vendor/assets/javascripts/bootstrap-table/extensions/defer-url/bootstrap-table-defer-url.js +44 -27
- data/vendor/assets/javascripts/bootstrap-table/extensions/editable/bootstrap-table-editable.js +229 -115
- data/vendor/assets/javascripts/bootstrap-table/extensions/export/bootstrap-table-export.js +319 -162
- data/vendor/assets/javascripts/bootstrap-table/extensions/filter-control/bootstrap-table-filter-control.js +733 -566
- data/vendor/assets/javascripts/bootstrap-table/extensions/group-by-v2/bootstrap-table-group-by.js +175 -167
- data/vendor/assets/javascripts/bootstrap-table/extensions/group-by/bootstrap-table-group-by.js +227 -213
- data/vendor/assets/javascripts/bootstrap-table/extensions/i18n-enhance/bootstrap-table-i18n-enhance.js +44 -29
- data/vendor/assets/javascripts/bootstrap-table/extensions/key-events/bootstrap-table-key-events.js +92 -70
- data/vendor/assets/javascripts/bootstrap-table/extensions/mobile/bootstrap-table-mobile.js +134 -118
- data/vendor/assets/javascripts/bootstrap-table/extensions/multi-column-toggle/bootstrap-table-multi-toggle.js +92 -75
- data/vendor/assets/javascripts/bootstrap-table/extensions/multiple-search/bootstrap-table-multiple-search.js +72 -58
- data/vendor/assets/javascripts/bootstrap-table/extensions/multiple-selection-row/bootstrap-table-multiple-selection-row.js +129 -113
- data/vendor/assets/javascripts/bootstrap-table/extensions/multiple-sort/bootstrap-table-multiple-sort.js +362 -349
- data/vendor/assets/javascripts/bootstrap-table/extensions/natural-sorting/bootstrap-table-natural-sorting.js +66 -50
- data/vendor/assets/javascripts/bootstrap-table/extensions/{page-jumpto/bootstrap-table-jumpto.css → page-jump-to/bootstrap-table-page-jump-to.css} +0 -0
- data/vendor/assets/javascripts/bootstrap-table/extensions/page-jump-to/bootstrap-table-page-jump-to.js +58 -0
- data/vendor/assets/javascripts/bootstrap-table/extensions/pipeline/bootstrap-table-pipeline.js +341 -0
- data/vendor/assets/javascripts/bootstrap-table/extensions/print/bootstrap-table-print.js +122 -126
- data/vendor/assets/javascripts/bootstrap-table/extensions/reorder-columns/bootstrap-table-reorder-columns.js +183 -167
- data/vendor/assets/javascripts/bootstrap-table/extensions/reorder-rows/bootstrap-table-reorder-rows.js +124 -110
- data/vendor/assets/javascripts/bootstrap-table/extensions/resizable/bootstrap-table-resizable.js +66 -55
- data/vendor/assets/javascripts/bootstrap-table/extensions/select2-filter/bootstrap-table-select2-filter.js +281 -272
- data/vendor/assets/javascripts/bootstrap-table/extensions/sticky-header/bootstrap-table-sticky-header.css +13 -13
- data/vendor/assets/javascripts/bootstrap-table/extensions/sticky-header/bootstrap-table-sticky-header.js +182 -106
- data/vendor/assets/javascripts/bootstrap-table/extensions/toolbar/bootstrap-table-toolbar.js +324 -162
- data/vendor/assets/javascripts/bootstrap-table/extensions/tree-column/bootstrap-table-tree-column.js +127 -115
- data/vendor/assets/javascripts/bootstrap-table/extensions/treegrid/bootstrap-table-treegrid.js +106 -96
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-af-ZA.js +48 -35
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-ar-SA.js +49 -35
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-ca-ES.js +52 -39
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-cs-CZ.js +52 -39
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-da-DK.js +60 -32
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-de-DE.js +61 -48
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-el-GR.js +36 -23
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-en-US.js +57 -44
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-es-AR.js +39 -26
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-es-CL.js +54 -41
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-es-CR.js +48 -35
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-es-ES.js +103 -38
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-es-MX.js +59 -46
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-es-NI.js +48 -35
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-es-SP.js +49 -36
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-et-EE.js +51 -38
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-eu-EU.js +51 -38
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-fa-IR.js +51 -38
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-fi-FI.js +62 -0
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-fr-BE.js +36 -23
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-fr-FR.js +103 -90
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-he-IL.js +51 -38
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-hr-HR.js +52 -39
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-hu-HU.js +51 -38
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-id-ID.js +57 -44
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-it-IT.js +59 -47
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-ja-JP.js +51 -38
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-ka-GE.js +49 -36
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-ko-KR.js +45 -32
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-ms-MY.js +51 -38
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-nb-NO.js +45 -32
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-nl-NL.js +60 -47
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-pl-PL.js +45 -32
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-pt-BR.js +49 -36
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-pt-PT.js +51 -38
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-ro-RO.js +51 -38
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-ru-RU.js +82 -68
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-sk-SK.js +57 -44
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-sv-SE.js +45 -32
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-th-TH.js +45 -32
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-tr-TR.js +49 -36
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-uk-UA.js +82 -69
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-ur-PK.js +45 -32
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-uz-Latn-UZ.js +57 -44
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-vi-VN.js +36 -23
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-zh-CN.js +54 -41
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-zh-TW.js +48 -35
- metadata +6 -8
- data/vendor/assets/javascripts/bootstrap-table/extensions/angular/bootstrap-table-angular.js +0 -107
- data/vendor/assets/javascripts/bootstrap-table/extensions/click-edit-row/bootstrap-table-click-edit-row.css +0 -21
- data/vendor/assets/javascripts/bootstrap-table/extensions/click-edit-row/bootstrap-table-click-edit-row.js +0 -142
- data/vendor/assets/javascripts/bootstrap-table/extensions/filter/bootstrap-table-filter.js +0 -67
- data/vendor/assets/javascripts/bootstrap-table/extensions/flat-json/bootstrap-table-flat-json.js +0 -62
- data/vendor/assets/javascripts/bootstrap-table/extensions/page-jumpto/bootstrap-table-jumpto.js +0 -50
data/vendor/assets/javascripts/bootstrap-table/extensions/group-by-v2/bootstrap-table-group-by.js
CHANGED
@@ -1,226 +1,234 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
1
|
+
(function (global, factory) {
|
2
|
+
if (typeof define === "function" && define.amd) {
|
3
|
+
define([], factory);
|
4
|
+
} else if (typeof exports !== "undefined") {
|
5
|
+
factory();
|
6
|
+
} else {
|
7
|
+
var mod = {
|
8
|
+
exports: {}
|
9
|
+
};
|
10
|
+
factory();
|
11
|
+
global.bootstrapTableGroupBy = mod.exports;
|
12
|
+
}
|
13
|
+
})(this, function () {
|
8
14
|
'use strict';
|
9
15
|
|
10
|
-
|
11
|
-
|
16
|
+
/**
|
17
|
+
* @author: Yura Knoxville
|
18
|
+
* @version: v1.1.0
|
19
|
+
*/
|
12
20
|
|
13
|
-
|
14
|
-
var sprintf = function (str) {
|
15
|
-
var args = arguments,
|
16
|
-
flag = true,
|
17
|
-
i = 1;
|
21
|
+
(function ($) {
|
18
22
|
|
19
|
-
|
20
|
-
var arg = args[i++];
|
23
|
+
'use strict';
|
21
24
|
|
22
|
-
|
23
|
-
flag = false;
|
24
|
-
return '';
|
25
|
-
}
|
26
|
-
return arg;
|
27
|
-
});
|
28
|
-
return flag ? str : '';
|
29
|
-
};
|
30
|
-
|
31
|
-
var groupBy = function (array , f) {
|
32
|
-
var groups = {};
|
33
|
-
array.forEach(function(o) {
|
34
|
-
var group = f(o);
|
35
|
-
groups[group] = groups[group] || [];
|
36
|
-
groups[group].push(o);
|
37
|
-
});
|
25
|
+
var initBodyCaller, tableGroups;
|
38
26
|
|
39
|
-
return
|
40
|
-
|
27
|
+
// it only does '%s', and return '' when arguments are undefined
|
28
|
+
var sprintf = function sprintf(str) {
|
29
|
+
var args = arguments,
|
30
|
+
flag = true,
|
31
|
+
i = 1;
|
41
32
|
|
42
|
-
|
43
|
-
|
44
|
-
groupByField: ''
|
45
|
-
});
|
33
|
+
str = str.replace(/%s/g, function () {
|
34
|
+
var arg = args[i++];
|
46
35
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
36
|
+
if (typeof arg === 'undefined') {
|
37
|
+
flag = false;
|
38
|
+
return '';
|
39
|
+
}
|
40
|
+
return arg;
|
41
|
+
});
|
42
|
+
return flag ? str : '';
|
43
|
+
};
|
51
44
|
|
52
|
-
|
53
|
-
|
45
|
+
var groupBy = function groupBy(array, f) {
|
46
|
+
var groups = {};
|
47
|
+
array.forEach(function (o) {
|
48
|
+
var group = f(o);
|
49
|
+
groups[group] = groups[group] || [];
|
50
|
+
groups[group].push(o);
|
51
|
+
});
|
54
52
|
|
55
|
-
|
56
|
-
|
53
|
+
return groups;
|
54
|
+
};
|
57
55
|
|
58
|
-
|
56
|
+
$.extend($.fn.bootstrapTable.defaults, {
|
57
|
+
groupBy: false,
|
58
|
+
groupByField: '',
|
59
|
+
groupByFormatter: undefined
|
60
|
+
});
|
59
61
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
62
|
+
var BootstrapTable = $.fn.bootstrapTable.Constructor,
|
63
|
+
_initSort = BootstrapTable.prototype.initSort,
|
64
|
+
_initBody = BootstrapTable.prototype.initBody,
|
65
|
+
_updateSelected = BootstrapTable.prototype.updateSelected;
|
66
|
+
|
67
|
+
BootstrapTable.prototype.initSort = function () {
|
68
|
+
_initSort.apply(this, Array.prototype.slice.apply(arguments));
|
65
69
|
|
66
70
|
var that = this;
|
67
|
-
|
68
|
-
return [item[that.options.groupByField]];
|
69
|
-
});
|
71
|
+
tableGroups = [];
|
70
72
|
|
71
|
-
|
72
|
-
$.each(groups, function(key, value) {
|
73
|
-
tableGroups.push({
|
74
|
-
id: index,
|
75
|
-
name: key
|
76
|
-
});
|
73
|
+
if (this.options.groupBy && this.options.groupByField !== '') {
|
77
74
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
}
|
75
|
+
if (this.options.sortName != this.options.groupByField) {
|
76
|
+
this.data.sort(function (a, b) {
|
77
|
+
return a[that.options.groupByField].localeCompare(b[that.options.groupByField]);
|
78
|
+
});
|
79
|
+
}
|
82
80
|
|
83
|
-
|
81
|
+
var that = this;
|
82
|
+
var groups = groupBy(that.data, function (item) {
|
83
|
+
return [item[that.options.groupByField]];
|
84
84
|
});
|
85
85
|
|
86
|
-
index
|
87
|
-
|
88
|
-
|
89
|
-
|
86
|
+
var index = 0;
|
87
|
+
$.each(groups, function (key, value) {
|
88
|
+
tableGroups.push({
|
89
|
+
id: index,
|
90
|
+
name: key,
|
91
|
+
data: value
|
92
|
+
});
|
90
93
|
|
91
|
-
|
92
|
-
|
94
|
+
value.forEach(function (item) {
|
95
|
+
if (!item._data) {
|
96
|
+
item._data = {};
|
97
|
+
}
|
93
98
|
|
94
|
-
|
99
|
+
item._data['parent-index'] = index;
|
100
|
+
});
|
95
101
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
102
|
+
index++;
|
103
|
+
});
|
104
|
+
}
|
105
|
+
};
|
100
106
|
|
101
|
-
|
102
|
-
|
103
|
-
checkBox = true;
|
104
|
-
} else {
|
105
|
-
if (column.visible) {
|
106
|
-
visibleColumns += 1;
|
107
|
-
}
|
108
|
-
}
|
109
|
-
});
|
107
|
+
BootstrapTable.prototype.initBody = function () {
|
108
|
+
initBodyCaller = true;
|
110
109
|
|
111
|
-
|
112
|
-
visibleColumns += 1;
|
113
|
-
}
|
110
|
+
_initBody.apply(this, Array.prototype.slice.apply(arguments));
|
114
111
|
|
115
|
-
|
116
|
-
var
|
112
|
+
if (this.options.groupBy && this.options.groupByField !== '') {
|
113
|
+
var that = this,
|
114
|
+
checkBox = false,
|
115
|
+
visibleColumns = 0;
|
117
116
|
|
118
|
-
|
117
|
+
this.columns.forEach(function (column) {
|
118
|
+
if (column.checkbox) {
|
119
|
+
checkBox = true;
|
120
|
+
} else {
|
121
|
+
if (column.visible) {
|
122
|
+
visibleColumns += 1;
|
123
|
+
}
|
124
|
+
}
|
125
|
+
});
|
119
126
|
|
120
|
-
if (
|
121
|
-
|
127
|
+
if (this.options.detailView && !this.options.cardView) {
|
128
|
+
visibleColumns += 1;
|
122
129
|
}
|
123
130
|
|
124
|
-
|
125
|
-
html
|
126
|
-
'<input name="btSelectGroup" type="checkbox" />',
|
127
|
-
'</td>'
|
128
|
-
);
|
129
|
-
}
|
131
|
+
tableGroups.forEach(function (item) {
|
132
|
+
var html = [];
|
130
133
|
|
131
|
-
|
132
|
-
sprintf(' colspan="%s"', visibleColumns),
|
133
|
-
'>', item.name, '</td>'
|
134
|
-
);
|
134
|
+
html.push(sprintf('<tr class="info groupBy expanded" data-group-index="%s">', item.id));
|
135
135
|
|
136
|
-
|
136
|
+
if (that.options.detailView && !that.options.cardView) {
|
137
|
+
html.push('<td class="detail"></td>');
|
138
|
+
}
|
137
139
|
|
138
|
-
|
139
|
-
|
140
|
+
if (checkBox) {
|
141
|
+
html.push('<td class="bs-checkbox">', '<input name="btSelectGroup" type="checkbox" />', '</td>');
|
142
|
+
}
|
143
|
+
var formattedValue = item.name;
|
144
|
+
if (typeof that.options.groupByFormatter == "function") {
|
145
|
+
formattedValue = that.options.groupByFormatter(item.name, item.id, item.data);
|
146
|
+
}
|
147
|
+
html.push('<td', sprintf(' colspan="%s"', visibleColumns), '>', formattedValue, '</td>');
|
140
148
|
|
141
|
-
|
142
|
-
this.$body.find('[name="btSelectGroup"]').each(function() {
|
143
|
-
var self = $(this);
|
149
|
+
html.push('</tr>');
|
144
150
|
|
145
|
-
|
146
|
-
group: self,
|
147
|
-
item: that.$selectItem.filter(function () {
|
148
|
-
return ($(this).closest('tr').data('parent-index') ===
|
149
|
-
self.closest('tr').data('group-index'));
|
150
|
-
})
|
151
|
+
that.$body.find('tr[data-parent-index=' + item.id + ']:first').before($(html.join('')));
|
151
152
|
});
|
152
|
-
});
|
153
153
|
|
154
|
-
|
155
|
-
.
|
154
|
+
this.$selectGroup = [];
|
155
|
+
this.$body.find('[name="btSelectGroup"]').each(function () {
|
156
|
+
var self = $(this);
|
157
|
+
|
158
|
+
that.$selectGroup.push({
|
159
|
+
group: self,
|
160
|
+
item: that.$selectItem.filter(function () {
|
161
|
+
return $(this).closest('tr').data('parent-index') === self.closest('tr').data('group-index');
|
162
|
+
})
|
163
|
+
});
|
164
|
+
});
|
165
|
+
|
166
|
+
this.$container.off('click', '.groupBy').on('click', '.groupBy', function () {
|
156
167
|
$(this).toggleClass('expanded');
|
157
|
-
that.$body.find('tr[data-parent-index='
|
168
|
+
that.$body.find('tr[data-parent-index=' + $(this).closest('tr').data('group-index') + ']').toggleClass('hidden');
|
158
169
|
});
|
159
170
|
|
160
|
-
|
161
|
-
.on('click', '[name="btSelectGroup"]', function (event) {
|
171
|
+
this.$container.off('click', '[name="btSelectGroup"]').on('click', '[name="btSelectGroup"]', function (event) {
|
162
172
|
event.stopImmediatePropagation();
|
163
173
|
|
164
174
|
var self = $(this);
|
165
175
|
var checked = self.prop('checked');
|
166
176
|
that[checked ? 'checkGroup' : 'uncheckGroup']($(this).closest('tr').data('group-index'));
|
167
177
|
});
|
168
|
-
|
178
|
+
}
|
169
179
|
|
170
|
-
|
171
|
-
|
172
|
-
|
180
|
+
initBodyCaller = false;
|
181
|
+
this.updateSelected();
|
182
|
+
};
|
173
183
|
|
174
|
-
|
175
|
-
|
176
|
-
|
184
|
+
BootstrapTable.prototype.updateSelected = function () {
|
185
|
+
if (!initBodyCaller) {
|
186
|
+
_updateSelected.apply(this, Array.prototype.slice.apply(arguments));
|
177
187
|
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
item.item.filter(':enabled').filter(':checked').length;
|
188
|
+
if (this.options.groupBy && this.options.groupByField !== '') {
|
189
|
+
this.$selectGroup.forEach(function (item) {
|
190
|
+
var checkGroup = item.item.filter(':enabled').length === item.item.filter(':enabled').filter(':checked').length;
|
182
191
|
|
183
|
-
|
184
|
-
|
192
|
+
item.group.prop('checked', checkGroup);
|
193
|
+
});
|
194
|
+
}
|
185
195
|
}
|
186
|
-
}
|
187
|
-
};
|
188
|
-
|
189
|
-
BootstrapTable.prototype.getGroupSelections = function (index) {
|
190
|
-
var that = this;
|
191
|
-
|
192
|
-
return $.grep(this.data, function (row) {
|
193
|
-
return (row[that.header.stateField] && (row._data['parent-index'] === index));
|
194
|
-
});
|
195
|
-
};
|
196
|
+
};
|
196
197
|
|
197
|
-
|
198
|
-
|
199
|
-
};
|
198
|
+
BootstrapTable.prototype.getGroupSelections = function (index) {
|
199
|
+
var that = this;
|
200
200
|
|
201
|
-
|
202
|
-
|
203
|
-
|
201
|
+
return $.grep(this.data, function (row) {
|
202
|
+
return row[that.header.stateField] && row._data['parent-index'] === index;
|
203
|
+
});
|
204
|
+
};
|
204
205
|
|
205
|
-
|
206
|
-
|
207
|
-
var filter = function() {
|
208
|
-
return ($(this).closest('tr').data('parent-index') === index);
|
206
|
+
BootstrapTable.prototype.checkGroup = function (index) {
|
207
|
+
this.checkGroup_(index, true);
|
209
208
|
};
|
210
209
|
|
211
|
-
|
212
|
-
|
213
|
-
}
|
210
|
+
BootstrapTable.prototype.uncheckGroup = function (index) {
|
211
|
+
this.checkGroup_(index, false);
|
212
|
+
};
|
214
213
|
|
215
|
-
|
214
|
+
BootstrapTable.prototype.checkGroup_ = function (index, checked) {
|
215
|
+
var rows;
|
216
|
+
var filter = function filter() {
|
217
|
+
return $(this).closest('tr').data('parent-index') === index;
|
218
|
+
};
|
216
219
|
|
220
|
+
if (!checked) {
|
221
|
+
rows = this.getGroupSelections(index);
|
222
|
+
}
|
217
223
|
|
218
|
-
|
219
|
-
this.updateSelected();
|
220
|
-
if (checked) {
|
221
|
-
rows = this.getGroupSelections(index);
|
222
|
-
}
|
223
|
-
this.trigger(checked ? 'check-all' : 'uncheck-all', rows);
|
224
|
-
};
|
224
|
+
this.$selectItem.filter(filter).prop('checked', checked);
|
225
225
|
|
226
|
-
|
226
|
+
this.updateRows();
|
227
|
+
this.updateSelected();
|
228
|
+
if (checked) {
|
229
|
+
rows = this.getGroupSelections(index);
|
230
|
+
}
|
231
|
+
this.trigger(checked ? 'check-all' : 'uncheck-all', rows);
|
232
|
+
};
|
233
|
+
})(jQuery);
|
234
|
+
});
|
data/vendor/assets/javascripts/bootstrap-table/extensions/group-by/bootstrap-table-group-by.js
CHANGED
@@ -1,243 +1,257 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
(function (global, factory) {
|
2
|
+
if (typeof define === "function" && define.amd) {
|
3
|
+
define([], factory);
|
4
|
+
} else if (typeof exports !== "undefined") {
|
5
|
+
factory();
|
6
|
+
} else {
|
7
|
+
var mod = {
|
8
|
+
exports: {}
|
9
|
+
};
|
10
|
+
factory();
|
11
|
+
global.bootstrapTableGroupBy = mod.exports;
|
12
|
+
}
|
13
|
+
})(this, function () {
|
14
|
+
'use strict';
|
6
15
|
|
7
|
-
|
16
|
+
/**
|
17
|
+
* @author: Dennis Hernández
|
18
|
+
* @webSite: http://djhvscf.github.io/Blog
|
19
|
+
* @version: v1.1.0
|
20
|
+
*/
|
8
21
|
|
9
|
-
|
22
|
+
!function ($) {
|
10
23
|
|
11
|
-
|
12
|
-
dataTTId = 'data-tt-id',
|
13
|
-
dataTTParentId = 'data-tt-parent-id',
|
14
|
-
obj = {},
|
15
|
-
parentId = undefined;
|
24
|
+
'use strict';
|
16
25
|
|
17
|
-
|
18
|
-
|
26
|
+
var originalRowAttr,
|
27
|
+
dataTTId = 'data-tt-id',
|
28
|
+
dataTTParentId = 'data-tt-parent-id',
|
29
|
+
obj = {},
|
30
|
+
parentId = undefined;
|
19
31
|
|
20
|
-
|
21
|
-
|
22
|
-
return $(parentRows[i]).attr('data-tt-id');
|
23
|
-
}
|
24
|
-
}
|
32
|
+
var getParentRowId = function getParentRowId(that, id) {
|
33
|
+
var parentRows = that.$body.find('tr').not('[' + 'data-tt-parent-id]');
|
25
34
|
|
26
|
-
|
27
|
-
|
35
|
+
for (var i = 0; i < parentRows.length; i++) {
|
36
|
+
if (i === id) {
|
37
|
+
return $(parentRows[i]).attr('data-tt-id');
|
38
|
+
}
|
39
|
+
}
|
28
40
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
41
|
+
return undefined;
|
42
|
+
};
|
43
|
+
|
44
|
+
var sumData = function sumData(that, data) {
|
45
|
+
var sumRow = {};
|
46
|
+
$.each(data, function (i, row) {
|
47
|
+
if (!row.IsParent) {
|
48
|
+
for (var prop in row) {
|
49
|
+
if (!isNaN(parseFloat(row[prop]))) {
|
50
|
+
if (that.columns[that.fieldsColumnsIndex[prop]].groupBySumGroup) {
|
51
|
+
if (sumRow[prop] === undefined) {
|
52
|
+
sumRow[prop] = 0;
|
53
|
+
}
|
54
|
+
sumRow[prop] += +row[prop];
|
38
55
|
}
|
39
|
-
sumRow[prop] += +row[prop];
|
40
56
|
}
|
41
57
|
}
|
42
58
|
}
|
59
|
+
});
|
60
|
+
return sumRow;
|
61
|
+
};
|
62
|
+
|
63
|
+
var rowAttr = function rowAttr(row, index) {
|
64
|
+
//Call the User Defined Function
|
65
|
+
originalRowAttr.apply([row, index]);
|
66
|
+
|
67
|
+
obj[dataTTId.toString()] = index;
|
68
|
+
|
69
|
+
if (!row.IsParent) {
|
70
|
+
obj[dataTTParentId.toString()] = parentId === undefined ? index : parentId;
|
71
|
+
} else {
|
72
|
+
parentId = index;
|
73
|
+
delete obj[dataTTParentId.toString()];
|
43
74
|
}
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
75
|
+
|
76
|
+
return obj;
|
77
|
+
};
|
78
|
+
|
79
|
+
var setObjectKeys = function setObjectKeys() {
|
80
|
+
// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys
|
81
|
+
Object.keys = function (o) {
|
82
|
+
if (o !== Object(o)) {
|
83
|
+
throw new TypeError('Object.keys called on a non-object');
|
84
|
+
}
|
85
|
+
var k = [],
|
86
|
+
p;
|
87
|
+
for (p in o) {
|
88
|
+
if (Object.prototype.hasOwnProperty.call(o, p)) {
|
89
|
+
k.push(p);
|
90
|
+
}
|
91
|
+
}
|
92
|
+
return k;
|
93
|
+
};
|
94
|
+
};
|
95
|
+
|
96
|
+
var getDataArrayFromItem = function getDataArrayFromItem(that, item) {
|
97
|
+
var itemDataArray = [];
|
98
|
+
for (var i = 0; i < that.options.groupByField.length; i++) {
|
99
|
+
itemDataArray.push(item[that.options.groupByField[i]]);
|
69
100
|
}
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
101
|
+
|
102
|
+
return itemDataArray;
|
103
|
+
};
|
104
|
+
|
105
|
+
var getNewRow = function getNewRow(that, result, index) {
|
106
|
+
var newRow = {};
|
107
|
+
for (var i = 0; i < that.options.groupByField.length; i++) {
|
108
|
+
newRow[that.options.groupByField[i].toString()] = result[index][0][that.options.groupByField[i]];
|
109
|
+
}
|
110
|
+
|
111
|
+
newRow.IsParent = true;
|
112
|
+
|
113
|
+
return newRow;
|
114
|
+
};
|
115
|
+
|
116
|
+
var groupBy = function groupBy(array, f) {
|
117
|
+
var groups = {};
|
118
|
+
$.each(array, function (i, o) {
|
119
|
+
var group = JSON.stringify(f(o));
|
120
|
+
groups[group] = groups[group] || [];
|
121
|
+
groups[group].push(o);
|
122
|
+
});
|
123
|
+
return Object.keys(groups).map(function (group) {
|
124
|
+
return groups[group];
|
125
|
+
});
|
126
|
+
};
|
127
|
+
|
128
|
+
var makeGrouped = function makeGrouped(that, data) {
|
129
|
+
var newData = [],
|
130
|
+
sumRow = {};
|
131
|
+
|
132
|
+
var result = groupBy(data, function (item) {
|
133
|
+
return getDataArrayFromItem(that, item);
|
134
|
+
});
|
135
|
+
|
136
|
+
for (var i = 0; i < result.length; i++) {
|
137
|
+
result[i].unshift(getNewRow(that, result, i));
|
138
|
+
if (that.options.groupBySumGroup) {
|
139
|
+
sumRow = sumData(that, result[i]);
|
140
|
+
if (!$.isEmptyObject(sumRow)) {
|
141
|
+
result[i].push(sumRow);
|
142
|
+
}
|
75
143
|
}
|
76
144
|
}
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
return newRow;
|
99
|
-
};
|
100
|
-
|
101
|
-
var groupBy = function (array, f) {
|
102
|
-
var groups = {};
|
103
|
-
$.each(array, function (i, o) {
|
104
|
-
var group = JSON.stringify(f(o));
|
105
|
-
groups[group] = groups[group] || [];
|
106
|
-
groups[group].push(o);
|
107
|
-
});
|
108
|
-
return Object.keys(groups).map(function (group) {
|
109
|
-
return groups[group];
|
145
|
+
|
146
|
+
newData = newData.concat.apply(newData, result);
|
147
|
+
|
148
|
+
if (!that.options.loaded && newData.length > 0) {
|
149
|
+
that.options.loaded = true;
|
150
|
+
that.options.originalData = that.options.data;
|
151
|
+
that.options.data = newData;
|
152
|
+
}
|
153
|
+
|
154
|
+
return newData;
|
155
|
+
};
|
156
|
+
|
157
|
+
$.extend($.fn.bootstrapTable.defaults, {
|
158
|
+
groupBy: false,
|
159
|
+
groupByField: [],
|
160
|
+
groupBySumGroup: false,
|
161
|
+
groupByInitExpanded: undefined, //node, 'all'
|
162
|
+
//internal variables
|
163
|
+
loaded: false,
|
164
|
+
originalData: undefined
|
110
165
|
});
|
111
|
-
};
|
112
166
|
|
113
|
-
|
114
|
-
var newData = [],
|
115
|
-
sumRow = {};
|
167
|
+
$.fn.bootstrapTable.methods.push('collapseAll', 'expandAll', 'refreshGroupByField');
|
116
168
|
|
117
|
-
|
118
|
-
|
169
|
+
$.extend($.fn.bootstrapTable.COLUMN_DEFAULTS, {
|
170
|
+
groupBySumGroup: false
|
119
171
|
});
|
120
172
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
that.options.originalData = that.options.data;
|
136
|
-
that.options.data = newData;
|
137
|
-
}
|
138
|
-
|
139
|
-
return newData;
|
140
|
-
};
|
141
|
-
|
142
|
-
$.extend($.fn.bootstrapTable.defaults, {
|
143
|
-
groupBy: false,
|
144
|
-
groupByField: [],
|
145
|
-
groupBySumGroup: false,
|
146
|
-
groupByInitExpanded: undefined, //node, 'all'
|
147
|
-
//internal variables
|
148
|
-
loaded: false,
|
149
|
-
originalData: undefined
|
150
|
-
});
|
151
|
-
|
152
|
-
$.fn.bootstrapTable.methods.push('collapseAll', 'expandAll', 'refreshGroupByField');
|
153
|
-
|
154
|
-
$.extend($.fn.bootstrapTable.COLUMN_DEFAULTS, {
|
155
|
-
groupBySumGroup: false
|
156
|
-
});
|
157
|
-
|
158
|
-
var BootstrapTable = $.fn.bootstrapTable.Constructor,
|
159
|
-
_init = BootstrapTable.prototype.init,
|
160
|
-
_initData = BootstrapTable.prototype.initData;
|
161
|
-
|
162
|
-
BootstrapTable.prototype.init = function () {
|
163
|
-
//Temporal validation
|
164
|
-
if (!this.options.sortName) {
|
165
|
-
if ((this.options.groupBy) && (this.options.groupByField.length > 0)) {
|
166
|
-
var that = this;
|
167
|
-
|
168
|
-
// Compatibility: IE < 9 and old browsers
|
169
|
-
if (!Object.keys) {
|
170
|
-
$.fn.bootstrapTable.utils.objectKeys();
|
171
|
-
}
|
173
|
+
var BootstrapTable = $.fn.bootstrapTable.Constructor,
|
174
|
+
_init = BootstrapTable.prototype.init,
|
175
|
+
_initData = BootstrapTable.prototype.initData;
|
176
|
+
|
177
|
+
BootstrapTable.prototype.init = function () {
|
178
|
+
//Temporal validation
|
179
|
+
if (!this.options.sortName) {
|
180
|
+
if (this.options.groupBy && this.options.groupByField.length > 0) {
|
181
|
+
var that = this;
|
182
|
+
|
183
|
+
// Compatibility: IE < 9 and old browsers
|
184
|
+
if (!Object.keys) {
|
185
|
+
$.fn.bootstrapTable.utils.objectKeys();
|
186
|
+
}
|
172
187
|
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
188
|
+
//Make sure that the internal variables are set correctly
|
189
|
+
this.options.loaded = false;
|
190
|
+
this.options.originalData = undefined;
|
191
|
+
|
192
|
+
originalRowAttr = this.options.rowAttributes;
|
193
|
+
this.options.rowAttributes = rowAttr;
|
194
|
+
this.$el.off('post-body.bs.table').on('post-body.bs.table', function () {
|
195
|
+
that.$el.treetable({
|
196
|
+
expandable: true,
|
197
|
+
onNodeExpand: function onNodeExpand() {
|
198
|
+
if (that.options.height) {
|
199
|
+
that.resetHeader();
|
200
|
+
}
|
201
|
+
},
|
202
|
+
onNodeCollapse: function onNodeCollapse() {
|
203
|
+
if (that.options.height) {
|
204
|
+
that.resetHeader();
|
205
|
+
}
|
185
206
|
}
|
186
|
-
},
|
187
|
-
|
188
|
-
|
189
|
-
|
207
|
+
}, true);
|
208
|
+
|
209
|
+
if (that.options.groupByInitExpanded !== undefined) {
|
210
|
+
if (typeof that.options.groupByInitExpanded === 'number') {
|
211
|
+
that.expandNode(that.options.groupByInitExpanded);
|
212
|
+
} else if (that.options.groupByInitExpanded.toLowerCase() === 'all') {
|
213
|
+
that.expandAll();
|
190
214
|
}
|
191
215
|
}
|
192
|
-
}
|
216
|
+
});
|
217
|
+
}
|
218
|
+
}
|
219
|
+
_init.apply(this, Array.prototype.slice.apply(arguments));
|
220
|
+
};
|
193
221
|
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
222
|
+
BootstrapTable.prototype.initData = function (data, type) {
|
223
|
+
//Temporal validation
|
224
|
+
if (!this.options.sortName) {
|
225
|
+
if (this.options.groupBy && this.options.groupByField.length > 0) {
|
226
|
+
|
227
|
+
this.options.groupByField = typeof this.options.groupByField === 'string' ? this.options.groupByField.replace('[', '').replace(']', '').replace(/ /g, '').toLowerCase().split(',') : this.options.groupByField;
|
228
|
+
|
229
|
+
data = makeGrouped(this, data ? data : this.options.data);
|
230
|
+
}
|
202
231
|
}
|
203
|
-
|
204
|
-
|
205
|
-
};
|
232
|
+
_initData.apply(this, [data, type]);
|
233
|
+
};
|
206
234
|
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
if ((this.options.groupBy) && (this.options.groupByField.length > 0)) {
|
235
|
+
BootstrapTable.prototype.expandAll = function () {
|
236
|
+
this.$el.treetable('expandAll');
|
237
|
+
};
|
211
238
|
|
212
|
-
|
213
|
-
|
214
|
-
|
239
|
+
BootstrapTable.prototype.collapseAll = function () {
|
240
|
+
this.$el.treetable('collapseAll');
|
241
|
+
};
|
242
|
+
|
243
|
+
BootstrapTable.prototype.expandNode = function (id) {
|
244
|
+
id = getParentRowId(this, id);
|
245
|
+
if (id !== undefined) {
|
246
|
+
this.$el.treetable('expandNode', id);
|
247
|
+
}
|
248
|
+
};
|
215
249
|
|
216
|
-
|
250
|
+
BootstrapTable.prototype.refreshGroupByField = function (groupByFields) {
|
251
|
+
if (!$.fn.bootstrapTable.utils.compareObjects(this.options.groupByField, groupByFields)) {
|
252
|
+
this.options.groupByField = groupByFields;
|
253
|
+
this.load(this.options.originalData);
|
217
254
|
}
|
218
|
-
}
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
BootstrapTable.prototype.expandAll = function () {
|
223
|
-
this.$el.treetable('expandAll');
|
224
|
-
};
|
225
|
-
|
226
|
-
BootstrapTable.prototype.collapseAll = function () {
|
227
|
-
this.$el.treetable('collapseAll');
|
228
|
-
};
|
229
|
-
|
230
|
-
BootstrapTable.prototype.expandNode = function (id) {
|
231
|
-
id = getParentRowId(this, id);
|
232
|
-
if (id !== undefined) {
|
233
|
-
this.$el.treetable('expandNode', id);
|
234
|
-
}
|
235
|
-
};
|
236
|
-
|
237
|
-
BootstrapTable.prototype.refreshGroupByField = function (groupByFields) {
|
238
|
-
if (!$.fn.bootstrapTable.utils.compareObjects(this.options.groupByField, groupByFields)) {
|
239
|
-
this.options.groupByField = groupByFields;
|
240
|
-
this.load(this.options.originalData);
|
241
|
-
}
|
242
|
-
};
|
243
|
-
}(jQuery);
|
255
|
+
};
|
256
|
+
}(jQuery);
|
257
|
+
});
|