@everymatrix/stage-mm-verification-report 1.0.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.
Files changed (201) hide show
  1. package/chunk-A3NTIEMP.js +1 -0
  2. package/chunk-CAY35YP7.js +7 -0
  3. package/chunk-H3QHLLCN.js +1 -0
  4. package/chunk-KE4BCZO4.js +851 -0
  5. package/chunk-OHPEWN32.js +1198 -0
  6. package/chunk-WSQOM5HU.js +1 -0
  7. package/component-lib.js +1 -0
  8. package/index.html +12 -0
  9. package/main.js +3264 -0
  10. package/modules/angular/LICENSE.md +21 -0
  11. package/modules/angular/README.md +67 -0
  12. package/modules/angular/angular-csp.css +25 -0
  13. package/modules/angular/angular.js +36600 -0
  14. package/modules/angular/angular.min.js +352 -0
  15. package/modules/angular/angular.min.js.gzip +0 -0
  16. package/modules/angular/angular.min.js.map +8 -0
  17. package/modules/angular/bower.json +9 -0
  18. package/modules/angular/index.js +2 -0
  19. package/modules/angular/package.json +25 -0
  20. package/modules/angular-ui-grid/CHANGELOG.md +1973 -0
  21. package/modules/angular-ui-grid/README.md +59 -0
  22. package/modules/angular-ui-grid/css/ui-grid.cellnav.css +25 -0
  23. package/modules/angular-ui-grid/css/ui-grid.cellnav.min.css +1 -0
  24. package/modules/angular-ui-grid/css/ui-grid.core.css +866 -0
  25. package/modules/angular-ui-grid/css/ui-grid.core.min.css +5 -0
  26. package/modules/angular-ui-grid/css/ui-grid.edit.css +23 -0
  27. package/modules/angular-ui-grid/css/ui-grid.edit.min.css +1 -0
  28. package/modules/angular-ui-grid/css/ui-grid.empty-base-layer.css +6 -0
  29. package/modules/angular-ui-grid/css/ui-grid.empty-base-layer.min.css +1 -0
  30. package/modules/angular-ui-grid/css/ui-grid.expandable.css +16 -0
  31. package/modules/angular-ui-grid/css/ui-grid.expandable.min.css +1 -0
  32. package/modules/angular-ui-grid/css/ui-grid.exporter.css +0 -0
  33. package/modules/angular-ui-grid/css/ui-grid.exporter.min.css +0 -0
  34. package/modules/angular-ui-grid/css/ui-grid.grouping.css +3 -0
  35. package/modules/angular-ui-grid/css/ui-grid.grouping.min.css +1 -0
  36. package/modules/angular-ui-grid/css/ui-grid.importer.css +0 -0
  37. package/modules/angular-ui-grid/css/ui-grid.importer.min.css +0 -0
  38. package/modules/angular-ui-grid/css/ui-grid.move-columns.css +9 -0
  39. package/modules/angular-ui-grid/css/ui-grid.move-columns.min.css +1 -0
  40. package/modules/angular-ui-grid/css/ui-grid.pagination.css +299 -0
  41. package/modules/angular-ui-grid/css/ui-grid.pagination.min.css +1 -0
  42. package/modules/angular-ui-grid/css/ui-grid.pinning.css +67 -0
  43. package/modules/angular-ui-grid/css/ui-grid.pinning.min.css +1 -0
  44. package/modules/angular-ui-grid/css/ui-grid.resize-columns.css +38 -0
  45. package/modules/angular-ui-grid/css/ui-grid.resize-columns.min.css +1 -0
  46. package/modules/angular-ui-grid/css/ui-grid.row-edit.css +9 -0
  47. package/modules/angular-ui-grid/css/ui-grid.row-edit.min.css +1 -0
  48. package/modules/angular-ui-grid/css/ui-grid.selection.css +25 -0
  49. package/modules/angular-ui-grid/css/ui-grid.selection.min.css +1 -0
  50. package/modules/angular-ui-grid/css/ui-grid.tree-base.css +4 -0
  51. package/modules/angular-ui-grid/css/ui-grid.tree-base.min.css +1 -0
  52. package/modules/angular-ui-grid/css/ui-grid.tree-view.css +6 -0
  53. package/modules/angular-ui-grid/css/ui-grid.tree-view.min.css +1 -0
  54. package/modules/angular-ui-grid/css/ui-grid.validate.css +3 -0
  55. package/modules/angular-ui-grid/css/ui-grid.validate.min.css +1 -0
  56. package/modules/angular-ui-grid/fonts/ui-grid.eot +0 -0
  57. package/modules/angular-ui-grid/fonts/ui-grid.svg +56 -0
  58. package/modules/angular-ui-grid/fonts/ui-grid.ttf +0 -0
  59. package/modules/angular-ui-grid/fonts/ui-grid.woff +0 -0
  60. package/modules/angular-ui-grid/less/animation.less +85 -0
  61. package/modules/angular-ui-grid/less/body.less +84 -0
  62. package/modules/angular-ui-grid/less/cell.less +46 -0
  63. package/modules/angular-ui-grid/less/cellnav.less +29 -0
  64. package/modules/angular-ui-grid/less/core.less +11 -0
  65. package/modules/angular-ui-grid/less/edit.less +27 -0
  66. package/modules/angular-ui-grid/less/elements.less +156 -0
  67. package/modules/angular-ui-grid/less/emptyBaseLayer.less +8 -0
  68. package/modules/angular-ui-grid/less/expandable.less +29 -0
  69. package/modules/angular-ui-grid/less/exporter.less +4 -0
  70. package/modules/angular-ui-grid/less/footer.less +76 -0
  71. package/modules/angular-ui-grid/less/grid.less +86 -0
  72. package/modules/angular-ui-grid/less/grouping.less +5 -0
  73. package/modules/angular-ui-grid/less/header.less +250 -0
  74. package/modules/angular-ui-grid/less/icons.less +151 -0
  75. package/modules/angular-ui-grid/less/importer.less +4 -0
  76. package/modules/angular-ui-grid/less/main.less +2 -0
  77. package/modules/angular-ui-grid/less/menu.less +91 -0
  78. package/modules/angular-ui-grid/less/moveColumns.less +12 -0
  79. package/modules/angular-ui-grid/less/pagination.less +297 -0
  80. package/modules/angular-ui-grid/less/pinning.less +86 -0
  81. package/modules/angular-ui-grid/less/resizeColumns.less +53 -0
  82. package/modules/angular-ui-grid/less/rowEdit.less +19 -0
  83. package/modules/angular-ui-grid/less/rtl.less +67 -0
  84. package/modules/angular-ui-grid/less/selection.less +29 -0
  85. package/modules/angular-ui-grid/less/sorting.less +16 -0
  86. package/modules/angular-ui-grid/less/treeBase.less +6 -0
  87. package/modules/angular-ui-grid/less/treeView.less +8 -0
  88. package/modules/angular-ui-grid/less/validate.less +5 -0
  89. package/modules/angular-ui-grid/less/variables.less +90 -0
  90. package/modules/angular-ui-grid/package.json +144 -0
  91. package/modules/angular-ui-grid/ui-grid.auto-resize.js +69 -0
  92. package/modules/angular-ui-grid/ui-grid.auto-resize.min.js +6 -0
  93. package/modules/angular-ui-grid/ui-grid.cellnav.js +1181 -0
  94. package/modules/angular-ui-grid/ui-grid.cellnav.min.js +6 -0
  95. package/modules/angular-ui-grid/ui-grid.core.js +12737 -0
  96. package/modules/angular-ui-grid/ui-grid.core.min.js +6 -0
  97. package/modules/angular-ui-grid/ui-grid.css +3208 -0
  98. package/modules/angular-ui-grid/ui-grid.edit.js +1325 -0
  99. package/modules/angular-ui-grid/ui-grid.edit.min.js +6 -0
  100. package/modules/angular-ui-grid/ui-grid.empty-base-layer.js +178 -0
  101. package/modules/angular-ui-grid/ui-grid.empty-base-layer.min.js +6 -0
  102. package/modules/angular-ui-grid/ui-grid.expandable.js +651 -0
  103. package/modules/angular-ui-grid/ui-grid.expandable.min.js +6 -0
  104. package/modules/angular-ui-grid/ui-grid.exporter.js +1777 -0
  105. package/modules/angular-ui-grid/ui-grid.exporter.min.js +6 -0
  106. package/modules/angular-ui-grid/ui-grid.grouping.js +1291 -0
  107. package/modules/angular-ui-grid/ui-grid.grouping.min.js +6 -0
  108. package/modules/angular-ui-grid/ui-grid.importer.js +791 -0
  109. package/modules/angular-ui-grid/ui-grid.importer.min.js +6 -0
  110. package/modules/angular-ui-grid/ui-grid.infinite-scroll.js +552 -0
  111. package/modules/angular-ui-grid/ui-grid.infinite-scroll.min.js +6 -0
  112. package/modules/angular-ui-grid/ui-grid.js +30867 -0
  113. package/modules/angular-ui-grid/ui-grid.language.all.js +3214 -0
  114. package/modules/angular-ui-grid/ui-grid.language.all.min.js +6 -0
  115. package/modules/angular-ui-grid/ui-grid.language.ar.js +118 -0
  116. package/modules/angular-ui-grid/ui-grid.language.ar.min.js +6 -0
  117. package/modules/angular-ui-grid/ui-grid.language.bg.js +115 -0
  118. package/modules/angular-ui-grid/ui-grid.language.bg.min.js +6 -0
  119. package/modules/angular-ui-grid/ui-grid.language.cs.js +96 -0
  120. package/modules/angular-ui-grid/ui-grid.language.cs.min.js +6 -0
  121. package/modules/angular-ui-grid/ui-grid.language.da.js +90 -0
  122. package/modules/angular-ui-grid/ui-grid.language.da.min.js +6 -0
  123. package/modules/angular-ui-grid/ui-grid.language.de.js +133 -0
  124. package/modules/angular-ui-grid/ui-grid.language.de.min.js +6 -0
  125. package/modules/angular-ui-grid/ui-grid.language.es-ct.js +133 -0
  126. package/modules/angular-ui-grid/ui-grid.language.es-ct.min.js +6 -0
  127. package/modules/angular-ui-grid/ui-grid.language.es.js +106 -0
  128. package/modules/angular-ui-grid/ui-grid.language.es.min.js +6 -0
  129. package/modules/angular-ui-grid/ui-grid.language.fa.js +93 -0
  130. package/modules/angular-ui-grid/ui-grid.language.fa.min.js +6 -0
  131. package/modules/angular-ui-grid/ui-grid.language.fi.js +76 -0
  132. package/modules/angular-ui-grid/ui-grid.language.fi.min.js +6 -0
  133. package/modules/angular-ui-grid/ui-grid.language.fr.js +128 -0
  134. package/modules/angular-ui-grid/ui-grid.language.fr.min.js +6 -0
  135. package/modules/angular-ui-grid/ui-grid.language.he.js +71 -0
  136. package/modules/angular-ui-grid/ui-grid.language.he.min.js +6 -0
  137. package/modules/angular-ui-grid/ui-grid.language.hy.js +76 -0
  138. package/modules/angular-ui-grid/ui-grid.language.hy.min.js +6 -0
  139. package/modules/angular-ui-grid/ui-grid.language.is.js +118 -0
  140. package/modules/angular-ui-grid/ui-grid.language.is.min.js +6 -0
  141. package/modules/angular-ui-grid/ui-grid.language.it.js +112 -0
  142. package/modules/angular-ui-grid/ui-grid.language.it.min.js +6 -0
  143. package/modules/angular-ui-grid/ui-grid.language.ja.js +118 -0
  144. package/modules/angular-ui-grid/ui-grid.language.ja.min.js +6 -0
  145. package/modules/angular-ui-grid/ui-grid.language.ko.js +77 -0
  146. package/modules/angular-ui-grid/ui-grid.language.ko.min.js +6 -0
  147. package/modules/angular-ui-grid/ui-grid.language.nl.js +91 -0
  148. package/modules/angular-ui-grid/ui-grid.language.nl.min.js +6 -0
  149. package/modules/angular-ui-grid/ui-grid.language.no.js +115 -0
  150. package/modules/angular-ui-grid/ui-grid.language.no.min.js +6 -0
  151. package/modules/angular-ui-grid/ui-grid.language.pl.js +126 -0
  152. package/modules/angular-ui-grid/ui-grid.language.pl.min.js +6 -0
  153. package/modules/angular-ui-grid/ui-grid.language.pt-br.js +133 -0
  154. package/modules/angular-ui-grid/ui-grid.language.pt-br.min.js +6 -0
  155. package/modules/angular-ui-grid/ui-grid.language.pt.js +133 -0
  156. package/modules/angular-ui-grid/ui-grid.language.pt.min.js +6 -0
  157. package/modules/angular-ui-grid/ui-grid.language.ro.js +112 -0
  158. package/modules/angular-ui-grid/ui-grid.language.ro.min.js +6 -0
  159. package/modules/angular-ui-grid/ui-grid.language.rs-lat.js +126 -0
  160. package/modules/angular-ui-grid/ui-grid.language.rs-lat.min.js +6 -0
  161. package/modules/angular-ui-grid/ui-grid.language.ru.js +115 -0
  162. package/modules/angular-ui-grid/ui-grid.language.ru.min.js +6 -0
  163. package/modules/angular-ui-grid/ui-grid.language.sk.js +127 -0
  164. package/modules/angular-ui-grid/ui-grid.language.sk.min.js +6 -0
  165. package/modules/angular-ui-grid/ui-grid.language.sv.js +126 -0
  166. package/modules/angular-ui-grid/ui-grid.language.sv.min.js +6 -0
  167. package/modules/angular-ui-grid/ui-grid.language.ta.js +87 -0
  168. package/modules/angular-ui-grid/ui-grid.language.ta.min.js +6 -0
  169. package/modules/angular-ui-grid/ui-grid.language.tr.js +112 -0
  170. package/modules/angular-ui-grid/ui-grid.language.tr.min.js +6 -0
  171. package/modules/angular-ui-grid/ui-grid.language.ua.js +112 -0
  172. package/modules/angular-ui-grid/ui-grid.language.ua.min.js +6 -0
  173. package/modules/angular-ui-grid/ui-grid.language.zh-cn.js +112 -0
  174. package/modules/angular-ui-grid/ui-grid.language.zh-cn.min.js +6 -0
  175. package/modules/angular-ui-grid/ui-grid.language.zh-tw.js +77 -0
  176. package/modules/angular-ui-grid/ui-grid.language.zh-tw.min.js +6 -0
  177. package/modules/angular-ui-grid/ui-grid.min.css +5 -0
  178. package/modules/angular-ui-grid/ui-grid.min.js +6 -0
  179. package/modules/angular-ui-grid/ui-grid.move-columns.js +582 -0
  180. package/modules/angular-ui-grid/ui-grid.move-columns.min.js +6 -0
  181. package/modules/angular-ui-grid/ui-grid.pagination.js +510 -0
  182. package/modules/angular-ui-grid/ui-grid.pagination.min.js +6 -0
  183. package/modules/angular-ui-grid/ui-grid.pinning.js +281 -0
  184. package/modules/angular-ui-grid/ui-grid.pinning.min.js +6 -0
  185. package/modules/angular-ui-grid/ui-grid.resize-columns.js +574 -0
  186. package/modules/angular-ui-grid/ui-grid.resize-columns.min.js +6 -0
  187. package/modules/angular-ui-grid/ui-grid.row-edit.js +717 -0
  188. package/modules/angular-ui-grid/ui-grid.row-edit.min.js +6 -0
  189. package/modules/angular-ui-grid/ui-grid.saveState.js +831 -0
  190. package/modules/angular-ui-grid/ui-grid.saveState.min.js +6 -0
  191. package/modules/angular-ui-grid/ui-grid.selection.js +1196 -0
  192. package/modules/angular-ui-grid/ui-grid.selection.min.js +6 -0
  193. package/modules/angular-ui-grid/ui-grid.tree-base.js +1743 -0
  194. package/modules/angular-ui-grid/ui-grid.tree-base.min.js +6 -0
  195. package/modules/angular-ui-grid/ui-grid.tree-view.js +218 -0
  196. package/modules/angular-ui-grid/ui-grid.tree-view.min.js +6 -0
  197. package/modules/angular-ui-grid/ui-grid.validate.js +589 -0
  198. package/modules/angular-ui-grid/ui-grid.validate.min.js +6 -0
  199. package/package.json +8 -0
  200. package/polyfills.js +2 -0
  201. package/styles.css +1 -0
@@ -0,0 +1,1196 @@
1
+ /*!
2
+ * ui-grid - v4.12.7 - 2024-04-12
3
+ * http://ui-grid.info/
4
+ * Copyright (c) 2024 ; License: MIT
5
+ */
6
+
7
+ (function () {
8
+ 'use strict';
9
+
10
+ /**
11
+ * @ngdoc overview
12
+ * @name ui.grid.selection
13
+ * @description
14
+ *
15
+ * # ui.grid.selection
16
+ * This module provides row selection
17
+ *
18
+ * <div class="alert alert-success" role="alert"><strong>Stable</strong> This feature is stable. There should no longer be breaking api changes without a deprecation warning.</div>
19
+ *
20
+ * <div doc-module-components="ui.grid.selection"></div>
21
+ */
22
+
23
+ var module = angular.module('ui.grid.selection', ['ui.grid']);
24
+
25
+ /**
26
+ * @ngdoc object
27
+ * @name ui.grid.selection.constant:uiGridSelectionConstants
28
+ *
29
+ * @description constants available in selection module
30
+ */
31
+ module.constant('uiGridSelectionConstants', {
32
+ featureName: 'selection',
33
+ selectionRowHeaderColName: 'selectionRowHeaderCol'
34
+ });
35
+
36
+ // add methods to GridRow
37
+ angular.module('ui.grid').config(['$provide', function ($provide) {
38
+ $provide.decorator('GridRow', ['$delegate', function ($delegate) {
39
+
40
+ /**
41
+ * @ngdoc object
42
+ * @name ui.grid.selection.api:GridRow
43
+ *
44
+ * @description GridRow prototype functions added for selection
45
+ */
46
+
47
+ /**
48
+ * @ngdoc object
49
+ * @name enableSelection
50
+ * @propertyOf ui.grid.selection.api:GridRow
51
+ * @description Enable row selection for this row, only settable by internal code.
52
+ *
53
+ * The grouping feature, for example, might set group header rows to not be selectable.
54
+ * <br/>Defaults to true
55
+ */
56
+
57
+ /**
58
+ * @ngdoc object
59
+ * @name isSelected
60
+ * @propertyOf ui.grid.selection.api:GridRow
61
+ * @description Selected state of row. Should be readonly. Make any changes to selected state using setSelected().
62
+ * <br/>Defaults to false
63
+ */
64
+
65
+ /**
66
+ * @ngdoc object
67
+ * @name isFocused
68
+ * @propertyOf ui.grid.selection.api:GridRow
69
+ * @description Focused state of row. Should be readonly. Make any changes to focused state using setFocused().
70
+ * <br/>Defaults to false
71
+ */
72
+
73
+ /**
74
+ * @ngdoc function
75
+ * @name setSelected
76
+ * @methodOf ui.grid.selection.api:GridRow
77
+ * @description Sets the isSelected property and updates the selectedCount
78
+ * Changes to isSelected state should only be made via this function
79
+ * @param {Boolean} selected value to set
80
+ */
81
+ $delegate.prototype.setSelected = function (selected) {
82
+ if (selected !== this.isSelected) {
83
+ this.isSelected = selected;
84
+ this.grid.selection.selectedCount += selected ? 1 : -1;
85
+ }
86
+ };
87
+
88
+ /**
89
+ * @ngdoc function
90
+ * @name setFocused
91
+ * @methodOf ui.grid.selection.api:GridRow
92
+ * @description Sets the isFocused property
93
+ * Changes to isFocused state should only be made via this function
94
+ * @param {Boolean} val value to set
95
+ */
96
+ $delegate.prototype.setFocused = function(val) {
97
+ if (val !== this.isFocused) {
98
+ this.grid.selection.focusedRow && (this.grid.selection.focusedRow.isFocused = false);
99
+ this.grid.selection.focusedRow = val ? this : null;
100
+ this.isFocused = val;
101
+ }
102
+ };
103
+
104
+ return $delegate;
105
+ }]);
106
+ }]);
107
+
108
+ /**
109
+ * @ngdoc service
110
+ * @name ui.grid.selection.service:uiGridSelectionService
111
+ *
112
+ * @description Services for selection features
113
+ */
114
+ module.service('uiGridSelectionService',
115
+ function () {
116
+ var service = {
117
+
118
+ initializeGrid: function (grid) {
119
+
120
+ // add feature namespace and any properties to grid for needed
121
+ /**
122
+ * @ngdoc object
123
+ * @name ui.grid.selection.grid:selection
124
+ *
125
+ * @description Grid properties and functions added for selection
126
+ */
127
+ grid.selection = {
128
+ lastSelectedRow: null,
129
+ /**
130
+ * @ngdoc object
131
+ * @name focusedRow
132
+ * @propertyOf ui.grid.selection.grid:selection
133
+ * @description Focused row.
134
+ */
135
+ focusedRow: null,
136
+ selectAll: false
137
+ };
138
+
139
+
140
+ /**
141
+ * @ngdoc object
142
+ * @name selectedCount
143
+ * @propertyOf ui.grid.selection.grid:selection
144
+ * @description Current count of selected rows
145
+ * @example
146
+ * var count = grid.selection.selectedCount
147
+ */
148
+ grid.selection.selectedCount = 0;
149
+
150
+ service.defaultGridOptions(grid.options);
151
+
152
+ /**
153
+ * @ngdoc object
154
+ * @name ui.grid.selection.api:PublicApi
155
+ *
156
+ * @description Public Api for selection feature
157
+ */
158
+ var publicApi = {
159
+ events: {
160
+ selection: {
161
+ /**
162
+ * @ngdoc event
163
+ * @name rowFocusChanged
164
+ * @eventOf ui.grid.selection.api:PublicApi
165
+ * @description is raised after the row.isFocused state is changed
166
+ * @param {object} scope the scope associated with the grid
167
+ * @param {GridRow} row the row that was focused/unfocused
168
+ * @param {Event} evt object if raised from an event
169
+ */
170
+ rowFocusChanged: function (scope, row, evt) {},
171
+ /**
172
+ * @ngdoc event
173
+ * @name rowSelectionChanged
174
+ * @eventOf ui.grid.selection.api:PublicApi
175
+ * @description is raised after the row.isSelected state is changed
176
+ * @param {object} scope the scope associated with the grid
177
+ * @param {GridRow} row the row that was selected/deselected
178
+ * @param {Event} evt object if raised from an event
179
+ */
180
+ rowSelectionChanged: function (scope, row, evt) {
181
+ },
182
+ /**
183
+ * @ngdoc event
184
+ * @name rowSelectionChangedBatch
185
+ * @eventOf ui.grid.selection.api:PublicApi
186
+ * @description is raised after the row.isSelected state is changed
187
+ * in bulk, if the `enableSelectionBatchEvent` option is set to true
188
+ * (which it is by default). This allows more efficient processing
189
+ * of bulk events.
190
+ * @param {object} scope the scope associated with the grid
191
+ * @param {array} rows the rows that were selected/deselected
192
+ * @param {Event} evt object if raised from an event
193
+ */
194
+ rowSelectionChangedBatch: function (scope, rows, evt) {
195
+ }
196
+ }
197
+ },
198
+ methods: {
199
+ selection: {
200
+ /**
201
+ * @ngdoc function
202
+ * @name toggleRowSelection
203
+ * @methodOf ui.grid.selection.api:PublicApi
204
+ * @description Toggles data row as selected or unselected
205
+ * @param {object} rowEntity gridOptions.data[] array instance
206
+ * @param {Event} evt object if raised from an event
207
+ */
208
+ toggleRowSelection: function (rowEntity, evt) {
209
+ var row = grid.getRow(rowEntity);
210
+ if (row != void 0 && row !== null) {
211
+ service.toggleRowSelection(grid, row, evt, grid.options.multiSelect, grid.options.noUnselect, true);
212
+ }
213
+ },
214
+ /**
215
+ * @ngdoc function
216
+ * @name selectRow
217
+ * @methodOf ui.grid.selection.api:PublicApi
218
+ * @description Select the data row
219
+ * @param {object} rowEntity gridOptions.data[] array instance
220
+ * @param {Event} evt object if raised from an event
221
+ */
222
+ selectRow: function (rowEntity, evt) {
223
+ var row = grid.getRow(rowEntity);
224
+ if (row != void 0 && row !== null && !row.isSelected) {
225
+ service.toggleRowSelection(grid, row, evt, grid.options.multiSelect, grid.options.noUnselect, true);
226
+ }
227
+ },
228
+ /**
229
+ * @ngdoc function
230
+ * @name selectRowByVisibleIndex
231
+ * @methodOf ui.grid.selection.api:PublicApi
232
+ * @description Select the specified row by visible index (i.e. if you
233
+ * specify row 0 you'll get the first visible row selected). In this context
234
+ * visible means of those rows that are theoretically visible (i.e. not filtered),
235
+ * rather than rows currently rendered on the screen.
236
+ * @param {number} rowNum index within the rowsVisible array
237
+ * @param {Event} evt object if raised from an event
238
+ */
239
+ selectRowByVisibleIndex: function (rowNum, evt) {
240
+ var row = grid.renderContainers.body.visibleRowCache[rowNum];
241
+ if (row != void 0 && row !== null && typeof (row) !== 'undefined' && !row.isSelected) {
242
+ service.toggleRowSelection(grid, row, evt, grid.options.multiSelect, grid.options.noUnselect, false);
243
+ }
244
+ },
245
+ /**
246
+ * @ngdoc function
247
+ * @name selectRowByKey
248
+ * @methodOf ui.grid.selection.api:PublicApi
249
+ * @description selects all GridRows who have an key that is equal to comparator
250
+ * so for Example if isInEntity == false then it does this check: row[key] === comparator
251
+ * if isInEntity == true then it does this check: row.entity[key] === comparator
252
+ * @param {boolean} isInEntity if true then key is in entity else it's directly in row
253
+ * @param {string | number} key the key to look for
254
+ * @param {any} comparator the value that key should have
255
+ * @param {Event} evt [optional] object if raised from an event
256
+ * @param {array} lookInRows [optional] the rows to look in - if not provided then looks in grid.rows
257
+ */
258
+ selectRowByKey: function (isInEntity, key, comparator, evt, lookInRows) {
259
+ var row = grid.findRowByKey(isInEntity, key, comparator, lookInRows);
260
+ if (row != void 0 && row !== null && typeof (row) !== 'undefined' && !row.isSelected) {
261
+ service.toggleRowSelection(grid, row, evt, grid.options.multiSelect, grid.options.noUnselect, false);
262
+ }
263
+ },
264
+ /**
265
+ * @ngdoc function
266
+ * @name unSelectRow
267
+ * @methodOf ui.grid.selection.api:PublicApi
268
+ * @description UnSelect the data row
269
+ * @param {object} rowEntity gridOptions.data[] array instance
270
+ * @param {Event} evt object if raised from an event
271
+ */
272
+ unSelectRow: function (rowEntity, evt) {
273
+ var row = grid.getRow(rowEntity);
274
+ if (row != void 0 && row !== null && row.isSelected) {
275
+ service.toggleRowSelection(grid, row, evt, grid.options.multiSelect, grid.options.noUnselect, true);
276
+ }
277
+ },
278
+ /**
279
+ * @ngdoc function
280
+ * @name unSelectRowByVisibleIndex
281
+ * @methodOf ui.grid.selection.api:PublicApi
282
+ * @description Unselect the specified row by visible index (i.e. if you
283
+ * specify row 0 you'll get the first visible row unselected). In this context
284
+ * visible means of those rows that are theoretically visible (i.e. not filtered),
285
+ * rather than rows currently rendered on the screen.
286
+ * @param {number} rowNum index within the rowsVisible array
287
+ * @param {Event} evt object if raised from an event
288
+ */
289
+ unSelectRowByVisibleIndex: function (rowNum, evt) {
290
+ var row = grid.renderContainers.body.visibleRowCache[rowNum];
291
+ if (row != void 0 && row !== null && typeof (row) !== 'undefined' && row.isSelected) {
292
+ service.toggleRowSelection(grid, row, evt, grid.options.multiSelect, grid.options.noUnselect, false);
293
+ }
294
+ },
295
+ /**
296
+ * @ngdoc function
297
+ * @name unSelectRowByKey
298
+ * @methodOf ui.grid.selection.api:PublicApi
299
+ * @description unselects the GridRows who have an key that is equal to comparator
300
+ * so for Example if isInEntity == false then it does this check: row[key] === comparator
301
+ * if isInEntity == true then it does this check: row.entity[key] === comparator
302
+ * @param {boolean} isInEntity if true then key is in entity else it's directly in row
303
+ * @param {string | number} key the key to look for
304
+ * @param {any} comparator the value that key should have
305
+ * @param {Event} evt [optional] object if raised from an event
306
+ * @param {array} lookInRows [optional] the rows to look in - if not provided then looks in grid.rows
307
+ */
308
+ unSelectRowByKey: function (isInEntity, key, comparator, evt, lookInRows) {
309
+ var row = grid.findRowByKey(isInEntity, key, comparator, lookInRows);
310
+ if (row != void 0 && row !== null && typeof (row) !== 'undefined' && row.isSelected) {
311
+ service.toggleRowSelection(grid, row, evt, grid.options.multiSelect, grid.options.noUnselect, false);
312
+ }
313
+ },
314
+ /**
315
+ * @ngdoc function
316
+ * @name selectAllRows
317
+ * @methodOf ui.grid.selection.api:PublicApi
318
+ * @description Selects all rows. Does nothing if multiSelect = false
319
+ * @param {Event} evt object if raised from an event
320
+ */
321
+ selectAllRows: function (evt) {
322
+ if (grid.options.multiSelect !== false) {
323
+ var changedRows = [];
324
+ grid.rows.forEach(function (row) {
325
+ if (!row.isSelected && row.enableSelection !== false && grid.options.isRowSelectable(row) !== false) {
326
+ row.setSelected(true);
327
+ service.decideRaiseSelectionEvent(grid, row, changedRows, evt);
328
+ }
329
+ });
330
+ grid.selection.selectAll = true;
331
+ service.decideRaiseSelectionBatchEvent(grid, changedRows, evt);
332
+ }
333
+ },
334
+ /**
335
+ * @ngdoc function
336
+ * @name selectAllVisibleRows
337
+ * @methodOf ui.grid.selection.api:PublicApi
338
+ * @description Selects all visible rows. Does nothing if multiSelect = false
339
+ * @param {Event} evt object if raised from an event
340
+ */
341
+ selectAllVisibleRows: function (evt) {
342
+ if (grid.options.multiSelect !== false) {
343
+ var changedRows = [];
344
+ grid.rows.forEach(function(row) {
345
+ if (row.visible) {
346
+ if (!row.isSelected && row.enableSelection !== false && grid.options.isRowSelectable(row) !== false) {
347
+ row.setSelected(true);
348
+ service.decideRaiseSelectionEvent(grid, row, changedRows, evt);
349
+ }
350
+ } else if (row.isSelected) {
351
+ row.setSelected(false);
352
+ service.decideRaiseSelectionEvent(grid, row, changedRows, evt);
353
+ }
354
+ });
355
+ grid.selection.selectAll = true;
356
+ service.decideRaiseSelectionBatchEvent(grid, changedRows, evt);
357
+ }
358
+ },
359
+ /**
360
+ * @ngdoc function
361
+ * @name clearSelectedRows
362
+ * @methodOf ui.grid.selection.api:PublicApi
363
+ * @description Unselects all rows
364
+ * @param {Event} evt object if raised from an event
365
+ */
366
+ clearSelectedRows: function (evt) {
367
+ service.clearSelectedRows(grid, evt);
368
+ },
369
+ /**
370
+ * @ngdoc function
371
+ * @name getSelectedRows
372
+ * @methodOf ui.grid.selection.api:PublicApi
373
+ * @description returns all selected Row's entity references
374
+ */
375
+ getSelectedRows: function () {
376
+ return service.mapAndFilterRowsByEntity(service.getSelectedRows(grid));
377
+ },
378
+ /**
379
+ * @ngdoc function
380
+ * @name getUnSelectedRows
381
+ * @methodOf ui.grid.selection.api:PublicApi
382
+ * @description returns all unselected Row's entity references
383
+ */
384
+ getUnSelectedRows: function () {
385
+ return service.mapAndFilterRowsByEntity(service.getUnSelectedRows(grid));
386
+ },
387
+ /**
388
+ * @ngdoc function
389
+ * @name getSelectedGridRows
390
+ * @methodOf ui.grid.selection.api:PublicApi
391
+ * @description returns all selectedRow's as gridRows
392
+ */
393
+ getSelectedGridRows: function () {
394
+ return service.getSelectedRows(grid);
395
+ },
396
+ /**
397
+ * @ngdoc function
398
+ * @name getSelectedGridRows
399
+ * @methodOf ui.grid.selection.api:PublicApi
400
+ * @description returns all unselected Row's as gridRows
401
+ */
402
+ getUnSelectedGridRows: function () {
403
+ return service.getUnSelectedRows(grid);
404
+ },
405
+ /**
406
+ * @ngdoc function
407
+ * @name getSelectedCount
408
+ * @methodOf ui.grid.selection.api:PublicApi
409
+ * @description returns the number of rows selected
410
+ */
411
+ getSelectedCount: function () {
412
+ return grid.selection.selectedCount;
413
+ },
414
+ /**
415
+ * @ngdoc function
416
+ * @name setMultiSelect
417
+ * @methodOf ui.grid.selection.api:PublicApi
418
+ * @description Sets the current gridOption.multiSelect to true or false
419
+ * @param {bool} multiSelect true to allow multiple rows
420
+ */
421
+ setMultiSelect: function (multiSelect) {
422
+ grid.options.multiSelect = multiSelect;
423
+ },
424
+ /**
425
+ * @ngdoc function
426
+ * @name setModifierKeysToMultiSelect
427
+ * @methodOf ui.grid.selection.api:PublicApi
428
+ * @description Sets the current gridOption.modifierKeysToMultiSelect to true or false
429
+ * @param {bool} modifierKeysToMultiSelect true to only allow multiple rows when using ctrlKey or shiftKey is used
430
+ */
431
+ setModifierKeysToMultiSelect: function (modifierKeysToMultiSelect) {
432
+ grid.options.modifierKeysToMultiSelect = modifierKeysToMultiSelect;
433
+ },
434
+ /**
435
+ * @ngdoc function
436
+ * @name getSelectAllState
437
+ * @methodOf ui.grid.selection.api:PublicApi
438
+ * @description Returns whether or not the selectAll checkbox is currently ticked. The
439
+ * grid doesn't automatically select rows when you add extra data - so when you add data
440
+ * you need to explicitly check whether the selectAll is set, and then call setVisible rows
441
+ * if it is
442
+ */
443
+ getSelectAllState: function () {
444
+ return grid.selection.selectAll;
445
+ }
446
+
447
+ }
448
+ }
449
+ };
450
+
451
+ grid.api.registerEventsFromObject(publicApi.events);
452
+
453
+ grid.api.registerMethodsFromObject(publicApi.methods);
454
+
455
+ },
456
+
457
+ defaultGridOptions: function (gridOptions) {
458
+ // default option to true unless it was explicitly set to false
459
+ /**
460
+ * @ngdoc object
461
+ * @name ui.grid.selection.api:GridOptions
462
+ *
463
+ * @description GridOptions for selection feature, these are available to be
464
+ * set using the ui-grid {@link ui.grid.class:GridOptions gridOptions}
465
+ */
466
+
467
+ /**
468
+ * @ngdoc object
469
+ * @name enableRowSelection
470
+ * @propertyOf ui.grid.selection.api:GridOptions
471
+ * @description Enable row selection for entire grid.
472
+ * <br/>Defaults to true
473
+ */
474
+ gridOptions.enableRowSelection = gridOptions.enableRowSelection !== false;
475
+ /**
476
+ * @ngdoc object
477
+ * @name multiSelect
478
+ * @propertyOf ui.grid.selection.api:GridOptions
479
+ * @description Enable multiple row selection for entire grid
480
+ * <br/>Defaults to true
481
+ */
482
+ gridOptions.multiSelect = gridOptions.multiSelect !== false;
483
+ /**
484
+ * @ngdoc object
485
+ * @name noUnselect
486
+ * @propertyOf ui.grid.selection.api:GridOptions
487
+ * @description Prevent a row from being unselected. Works in conjunction
488
+ * with `multiselect = false` and `gridApi.selection.selectRow()` to allow
489
+ * you to create a single selection only grid - a row is always selected, you
490
+ * can only select different rows, you can't unselect the row.
491
+ * <br/>Defaults to false
492
+ */
493
+ gridOptions.noUnselect = gridOptions.noUnselect === true;
494
+ /**
495
+ * @ngdoc object
496
+ * @name modifierKeysToMultiSelect
497
+ * @propertyOf ui.grid.selection.api:GridOptions
498
+ * @description Enable multiple row selection only when using the ctrlKey or shiftKey. Requires multiSelect to be true.
499
+ * <br/>Defaults to false
500
+ */
501
+ gridOptions.modifierKeysToMultiSelect = gridOptions.modifierKeysToMultiSelect === true;
502
+ /**
503
+ * @ngdoc object
504
+ * @name enableRowHeaderSelection
505
+ * @propertyOf ui.grid.selection.api:GridOptions
506
+ * @description Enable a row header to be used for selection
507
+ * <br/>Defaults to true
508
+ */
509
+ gridOptions.enableRowHeaderSelection = gridOptions.enableRowHeaderSelection !== false;
510
+ /**
511
+ * @ngdoc object
512
+ * @name enableFullRowSelection
513
+ * @propertyOf ui.grid.selection.api:GridOptions
514
+ * @description Enable selection by clicking anywhere on the row. Defaults to
515
+ * false if `enableRowHeaderSelection` is true, otherwise defaults to true.
516
+ */
517
+ if (typeof (gridOptions.enableFullRowSelection) === 'undefined') {
518
+ gridOptions.enableFullRowSelection = !gridOptions.enableRowHeaderSelection;
519
+ }
520
+ /**
521
+ * @ngdoc object
522
+ * @name enableFocusRowOnRowHeaderClick
523
+ * @propertyOf ui.grid.selection.api:GridOptions
524
+ * @description Enable focuse row by clicking on the row header. Defaults to
525
+ * true if `enableRowHeaderSelection` is true, otherwise defaults to false.
526
+ */
527
+ gridOptions.enableFocusRowOnRowHeaderClick = (gridOptions.enableFocusRowOnRowHeaderClick !== false)
528
+ || !gridOptions.enableRowHeaderSelection;
529
+ /**
530
+ * @ngdoc object
531
+ * @name enableSelectRowOnFocus
532
+ * @propertyOf ui.grid.selection.api:GridOptions
533
+ * @description Enable focuse row by clicking on the row anywhere. Defaults true.
534
+ */
535
+ gridOptions.enableSelectRowOnFocus = (gridOptions.enableSelectRowOnFocus !== false);
536
+ /**
537
+ * @ngdoc object
538
+ * @name enableSelectAll
539
+ * @propertyOf ui.grid.selection.api:GridOptions
540
+ * @description Enable the select all checkbox at the top of the selectionRowHeader
541
+ * <br/>Defaults to true
542
+ */
543
+ gridOptions.enableSelectAll = gridOptions.enableSelectAll !== false;
544
+ /**
545
+ * @ngdoc object
546
+ * @name enableSelectionBatchEvent
547
+ * @propertyOf ui.grid.selection.api:GridOptions
548
+ * @description If selected rows are changed in bulk, either via the API or
549
+ * via the selectAll checkbox, then a separate event is fired. Setting this
550
+ * option to false will cause the rowSelectionChanged event to be called multiple times
551
+ * instead
552
+ * <br/>Defaults to true
553
+ */
554
+ gridOptions.enableSelectionBatchEvent = gridOptions.enableSelectionBatchEvent !== false;
555
+ /**
556
+ * @ngdoc object
557
+ * @name selectionRowHeaderWidth
558
+ * @propertyOf ui.grid.selection.api:GridOptions
559
+ * @description can be used to set a custom width for the row header selection column
560
+ * <br/>Defaults to 30px
561
+ */
562
+ gridOptions.selectionRowHeaderWidth = angular.isDefined(gridOptions.selectionRowHeaderWidth) ? gridOptions.selectionRowHeaderWidth : 30;
563
+ /**
564
+ * @ngdoc object
565
+ * @name enableFooterTotalSelected
566
+ * @propertyOf ui.grid.selection.api:GridOptions
567
+ * @description Shows the total number of selected items in footer if true.
568
+ * <br/>Defaults to true.
569
+ * <br/>GridOptions.showGridFooter must also be set to true.
570
+ */
571
+ gridOptions.enableFooterTotalSelected = gridOptions.enableFooterTotalSelected !== false;
572
+
573
+ /**
574
+ * @ngdoc object
575
+ * @name isRowSelectable
576
+ * @propertyOf ui.grid.selection.api:GridOptions
577
+ * @description Makes it possible to specify a method that evaluates for each row and sets its "enableSelection" property.
578
+ */
579
+ gridOptions.isRowSelectable = angular.isDefined(gridOptions.isRowSelectable) ? gridOptions.isRowSelectable : angular.noop;
580
+ },
581
+
582
+ /**
583
+ * @ngdoc function
584
+ * @name toggleRowSelection
585
+ * @methodOf ui.grid.selection.service:uiGridSelectionService
586
+ * @description Toggles row as selected or unselected
587
+ * @param {Grid} grid grid object
588
+ * @param {GridRow} row row to select or deselect
589
+ * @param {Event} evt object if resulting from event
590
+ * @param {bool} multiSelect if false, only one row at time can be selected
591
+ * @param {bool} noUnselect if true then rows cannot be unselected
592
+ * @param {bool} [canBeInvisible=true] if false, row can only be selected when it's (theoretically) visible
593
+ */
594
+ toggleRowSelection: function (grid, row, evt, multiSelect, noUnselect, canBeInvisible) {
595
+ if ( row.enableSelection === false ) {
596
+ return;
597
+ }
598
+
599
+ if (canBeInvisible === void 0) {
600
+ canBeInvisible = true;
601
+ }
602
+
603
+ var selected = row.isSelected;
604
+
605
+ if (!multiSelect) {
606
+ if (!selected) {
607
+ service.clearSelectedRows(grid, evt);
608
+ }
609
+ else if (service.getSelectedRows(grid).length > 1) {
610
+ selected = false; // Enable reselect of the row
611
+ service.clearSelectedRows(grid, evt);
612
+ }
613
+ }
614
+
615
+ // only select row in this case
616
+ if (!(selected && noUnselect) && (canBeInvisible || row.visible)) {
617
+ row.setSelected(!selected);
618
+ if (row.isSelected === true) {
619
+ grid.selection.lastSelectedRow = row;
620
+ }
621
+
622
+ grid.selection.selectAll = grid.rows.length === service.getSelectedRows(grid).length;
623
+ grid.api.selection.raise.rowSelectionChanged(row, evt);
624
+ }
625
+ },
626
+ /**
627
+ * @ngdoc function
628
+ * @name shiftSelect
629
+ * @methodOf ui.grid.selection.service:uiGridSelectionService
630
+ * @description selects a group of rows from the last selected row using the shift key
631
+ * @param {Grid} grid grid object
632
+ * @param {GridRow} row clicked row
633
+ * @param {Event} evt object if raised from an event
634
+ * @param {bool} multiSelect if false, does nothing this is for multiSelect only
635
+ */
636
+ shiftSelect: function (grid, row, evt, multiSelect) {
637
+ if (!multiSelect) {
638
+ return;
639
+ }
640
+ var selectedRows = service.getSelectedRows(grid);
641
+ var fromRow = selectedRows.length > 0 ? grid.renderContainers.body.visibleRowCache.indexOf(grid.selection.lastSelectedRow) : 0;
642
+ var toRow = grid.renderContainers.body.visibleRowCache.indexOf(row);
643
+ // reverse select direction
644
+ if (fromRow > toRow) {
645
+ var tmp = fromRow;
646
+ fromRow = toRow;
647
+ toRow = tmp;
648
+ }
649
+
650
+ var changedRows = [];
651
+ for (var i = fromRow; i <= toRow; i++) {
652
+ var rowToSelect = grid.renderContainers.body.visibleRowCache[i];
653
+ if (rowToSelect) {
654
+ if (!rowToSelect.isSelected && rowToSelect.enableSelection !== false) {
655
+ rowToSelect.setSelected(true);
656
+ grid.selection.lastSelectedRow = rowToSelect;
657
+ service.decideRaiseSelectionEvent(grid, rowToSelect, changedRows, evt);
658
+ }
659
+ }
660
+ }
661
+ service.decideRaiseSelectionBatchEvent(grid, changedRows, evt);
662
+ },
663
+ /**
664
+ * @ngdoc function
665
+ * @name getSelectedRows
666
+ * @methodOf ui.grid.selection.service:uiGridSelectionService
667
+ * @description Returns all the selected rows
668
+ * @param {Grid} grid grid object
669
+ */
670
+ getSelectedRows: function (grid) {
671
+ return grid.rows.filter(function (row) {
672
+ return row.isSelected;
673
+ });
674
+ },
675
+ /**
676
+ * @ngdoc function
677
+ * @name getUnSelectedRows
678
+ * @methodOf ui.grid.selection.service:uiGridSelectionService
679
+ * @description Returns all the unselected rows
680
+ * @param {Grid} grid grid object
681
+ */
682
+ getUnSelectedRows: function (grid) {
683
+ return grid.rows.filter(function (row) {
684
+ return !row.isSelected;
685
+ });
686
+ },
687
+ /**
688
+ * @ngdoc function
689
+ * @name mapAndFilterRowsByEntity
690
+ * @methodOf ui.grid.selection.service:uiGridSelectionService
691
+ * @description Filters all rows by entity and then maps them to Array.
692
+ */
693
+ mapAndFilterRowsByEntity: function(gridRows) {
694
+ if (typeof gridRows.reduce === 'function') { // If reduce is available it will be taken, due to better performance
695
+ return gridRows.reduce(function (previousVal, currentRow) {
696
+ if (currentRow.entity.hasOwnProperty('$$hashKey') || !angular.isObject(currentRow.entity)) {
697
+ previousVal.push(currentRow.entity);
698
+ }
699
+ return previousVal;
700
+ }, []);
701
+ }
702
+
703
+ return gridRows.filter(function (gridRow) { // stays as polyfill
704
+ return gridRow.entity.hasOwnProperty('$$hashKey') || !angular.isObject(gridRow.entity);
705
+ }).map(function (gridRow) {
706
+ return gridRow.entity;
707
+ });
708
+ },
709
+
710
+ /**
711
+ * @ngdoc function
712
+ * @name clearSelectedRows
713
+ * @methodOf ui.grid.selection.service:uiGridSelectionService
714
+ * @description Clears all selected rows
715
+ * @param {Grid} grid grid object
716
+ * @param {Event} evt object if raised from an event
717
+ */
718
+ clearSelectedRows: function (grid, evt) {
719
+ var changedRows = [];
720
+ service.getSelectedRows(grid).forEach(function (row) {
721
+ if (row.isSelected && row.enableSelection !== false) {
722
+ row.setSelected(false);
723
+ service.decideRaiseSelectionEvent(grid, row, changedRows, evt);
724
+ }
725
+ });
726
+ grid.selection.selectAll = false;
727
+ grid.selection.selectedCount = 0;
728
+ service.decideRaiseSelectionBatchEvent(grid, changedRows, evt);
729
+ },
730
+
731
+ /**
732
+ * @ngdoc function
733
+ * @name decideRaiseSelectionEvent
734
+ * @methodOf ui.grid.selection.service:uiGridSelectionService
735
+ * @description Decides whether to raise a single event or a batch event
736
+ * @param {Grid} grid grid object
737
+ * @param {GridRow} row row that has changed
738
+ * @param {array} changedRows an array to which we can append the changed
739
+ * @param {Event} evt object if raised from an event
740
+ * row if we're doing batch events
741
+ */
742
+ decideRaiseSelectionEvent: function (grid, row, changedRows, evt) {
743
+ if (!grid.options.enableSelectionBatchEvent) {
744
+ grid.api.selection.raise.rowSelectionChanged(row, evt);
745
+ }
746
+ else {
747
+ changedRows.push(row);
748
+ }
749
+ },
750
+
751
+ /**
752
+ * @ngdoc function
753
+ * @name raiseSelectionEvent
754
+ * @methodOf ui.grid.selection.service:uiGridSelectionService
755
+ * @description Decides whether we need to raise a batch event, and
756
+ * raises it if we do.
757
+ * @param {Grid} grid grid object
758
+ * @param {array} changedRows an array of changed rows, only populated
759
+ * @param {Event} evt object if raised from an event
760
+ * if we're doing batch events
761
+ */
762
+ decideRaiseSelectionBatchEvent: function (grid, changedRows, evt) {
763
+ if (changedRows.length > 0) {
764
+ grid.api.selection.raise.rowSelectionChangedBatch(changedRows, evt);
765
+ }
766
+ }
767
+ };
768
+
769
+ return service;
770
+ });
771
+
772
+ /**
773
+ * @ngdoc directive
774
+ * @name ui.grid.selection.directive:uiGridSelection
775
+ * @element div
776
+ * @restrict A
777
+ *
778
+ * @description Adds selection features to grid
779
+ *
780
+ * @example
781
+ <example module="app">
782
+ <file name="app.js">
783
+ var app = angular.module('app', ['ui.grid', 'ui.grid.selection']);
784
+
785
+ app.controller('MainCtrl', ['$scope', function ($scope) {
786
+ $scope.data = [
787
+ { name: 'Bob', title: 'CEO' },
788
+ { name: 'Frank', title: 'Lowly Developer' }
789
+ ];
790
+
791
+ $scope.columnDefs = [
792
+ {name: 'name', enableCellEdit: true},
793
+ {name: 'title', enableCellEdit: true}
794
+ ];
795
+ }]);
796
+ </file>
797
+ <file name="index.html">
798
+ <div ng-controller="MainCtrl">
799
+ <div ui-grid="{ data: data, columnDefs: columnDefs }" ui-grid-selection></div>
800
+ </div>
801
+ </file>
802
+ </example>
803
+ */
804
+ module.directive('uiGridSelection', ['i18nService', 'uiGridSelectionConstants', 'uiGridSelectionService', 'uiGridConstants',
805
+ function (i18nService, uiGridSelectionConstants, uiGridSelectionService, uiGridConstants) {
806
+ return {
807
+ replace: true,
808
+ priority: 0,
809
+ require: '^uiGrid',
810
+ scope: false,
811
+ compile: function () {
812
+ return {
813
+ pre: function ($scope, $elm, $attrs, uiGridCtrl) {
814
+ uiGridSelectionService.initializeGrid(uiGridCtrl.grid);
815
+ if (uiGridCtrl.grid.options.enableRowHeaderSelection) {
816
+ var selectionRowHeaderDef = {
817
+ name: uiGridSelectionConstants.selectionRowHeaderColName,
818
+ displayName: i18nService.getSafeText('selection.displayName'),
819
+ width: uiGridCtrl.grid.options.selectionRowHeaderWidth,
820
+ minWidth: 10,
821
+ cellTemplate: 'ui-grid/selectionRowHeader',
822
+ headerCellTemplate: 'ui-grid/selectionHeaderCell',
823
+ enableColumnResizing: false,
824
+ enableColumnMenu: false,
825
+ exporterSuppressExport: true,
826
+ allowCellFocus: true
827
+ };
828
+
829
+ uiGridCtrl.grid.addRowHeaderColumn(selectionRowHeaderDef, 0);
830
+ }
831
+
832
+ var processorSet = false;
833
+
834
+ var processSelectableRows = function (rows) {
835
+ rows.forEach(function (row) {
836
+ row.enableSelection = uiGridCtrl.grid.options.isRowSelectable(row);
837
+ });
838
+ return rows;
839
+ };
840
+
841
+ var updateOptions = function () {
842
+ if (uiGridCtrl.grid.options.isRowSelectable !== angular.noop && processorSet !== true) {
843
+ uiGridCtrl.grid.registerRowsProcessor(processSelectableRows, 500);
844
+ processorSet = true;
845
+ }
846
+ };
847
+
848
+ updateOptions();
849
+
850
+ var dataChangeDereg = uiGridCtrl.grid.registerDataChangeCallback(updateOptions, [uiGridConstants.dataChange.OPTIONS]);
851
+
852
+ $scope.$on('$destroy', dataChangeDereg);
853
+ },
854
+ post: function ($scope, $elm, $attrs, uiGridCtrl) {
855
+
856
+ }
857
+ };
858
+ }
859
+ };
860
+ }]);
861
+
862
+ module.directive('uiGridSelectionRowHeaderButtons', ['$templateCache', 'uiGridSelectionService', 'gridUtil',
863
+ function ($templateCache, uiGridSelectionService, gridUtil) {
864
+ return {
865
+ replace: true,
866
+ restrict: 'E',
867
+ template: $templateCache.get('ui-grid/selectionRowHeaderButtons'),
868
+ scope: true,
869
+ require: '^uiGrid',
870
+ link: function ($scope, $elm, $attrs, uiGridCtrl) {
871
+ var self = uiGridCtrl.grid;
872
+ $scope.selectButtonClick = selectButtonClick;
873
+ $scope.selectButtonKeyDown = selectButtonKeyDown;
874
+
875
+ // On IE, prevent mousedowns on the select button from starting a selection.
876
+ // If this is not done and you shift+click on another row, the browser will select a big chunk of text
877
+ if (gridUtil.detectBrowser() === 'ie') {
878
+ $elm.on('mousedown', selectButtonMouseDown);
879
+ }
880
+
881
+ function selectButtonKeyDown(row, evt) {
882
+ if (evt.keyCode === 32 || evt.keyCode === 13) {
883
+ evt.preventDefault();
884
+ selectButtonClick(row, evt);
885
+ }
886
+ }
887
+
888
+ function selectButtonClick(row, evt) {
889
+ evt.stopPropagation();
890
+
891
+ if (evt.shiftKey) {
892
+ uiGridSelectionService.shiftSelect(self, row, evt, self.options.multiSelect);
893
+ }
894
+ else if (evt.ctrlKey || evt.metaKey) {
895
+ uiGridSelectionService.toggleRowSelection(self, row, evt,
896
+ self.options.multiSelect, self.options.noUnselect, false);
897
+ }
898
+ else if (row.groupHeader) {
899
+ uiGridSelectionService.toggleRowSelection(self, row, evt, self.options.multiSelect, self.options.noUnselect, false);
900
+ for (var i = 0; i < row.treeNode.children.length; i++) {
901
+ uiGridSelectionService.toggleRowSelection(self, row.treeNode.children[i].row, evt, self.options.multiSelect, self.options.noUnselect, false);
902
+ }
903
+ }
904
+ else {
905
+ uiGridSelectionService.toggleRowSelection(self, row, evt,
906
+ (self.options.multiSelect && !self.options.modifierKeysToMultiSelect), self.options.noUnselect, false);
907
+ }
908
+ self.options.enableFocusRowOnRowHeaderClick && row.setFocused(!row.isFocused) && self.api.selection.raise.rowFocusChanged(row, evt);
909
+ }
910
+
911
+ function selectButtonMouseDown(evt) {
912
+ if (evt.ctrlKey || evt.shiftKey) {
913
+ evt.target.onselectstart = function () { return false; };
914
+ window.setTimeout(function () { evt.target.onselectstart = null; }, 0);
915
+ }
916
+ }
917
+
918
+ $scope.$on('$destroy', function unbindEvents() {
919
+ $elm.off();
920
+ });
921
+ }
922
+ };
923
+ }]);
924
+
925
+ module.directive('uiGridSelectionSelectAllButtons', ['$templateCache', 'uiGridSelectionService',
926
+ function ($templateCache, uiGridSelectionService) {
927
+ return {
928
+ replace: true,
929
+ restrict: 'E',
930
+ template: $templateCache.get('ui-grid/selectionSelectAllButtons'),
931
+ scope: false,
932
+ link: function ($scope) {
933
+ var self = $scope.col.grid;
934
+
935
+ $scope.headerButtonKeyDown = function (evt) {
936
+ if (evt.keyCode === 32 || evt.keyCode === 13) {
937
+ evt.preventDefault();
938
+ $scope.headerButtonClick(evt);
939
+ }
940
+ };
941
+
942
+ $scope.headerButtonClick = function (evt) {
943
+ if (self.selection.selectAll) {
944
+ uiGridSelectionService.clearSelectedRows(self, evt);
945
+ if (self.options.noUnselect) {
946
+ self.api.selection.selectRowByVisibleIndex(0, evt);
947
+ }
948
+ self.selection.selectAll = false;
949
+ }
950
+ else if (self.options.multiSelect) {
951
+ self.api.selection.selectAllVisibleRows(evt);
952
+ self.selection.selectAll = true;
953
+ }
954
+ };
955
+ }
956
+ };
957
+ }]);
958
+
959
+ /**
960
+ * @ngdoc directive
961
+ * @name ui.grid.selection.directive:uiGridViewport
962
+ * @element div
963
+ *
964
+ * @description Stacks on top of ui.grid.uiGridViewport to alter the attributes used
965
+ * for the grid row
966
+ */
967
+ module.directive('uiGridViewport',
968
+ function () {
969
+ return {
970
+ priority: -200, // run after default directive
971
+ scope: false,
972
+ compile: function ($elm) {
973
+ var rowRepeatDiv = angular.element($elm[0].querySelector('.ui-grid-canvas:not(.ui-grid-empty-base-layer-container)').children[0]),
974
+ newNgClass = "'ui-grid-row-selected': row.isSelected, 'ui-grid-row-focused': row.isFocused}",
975
+ existingNgClass = rowRepeatDiv.attr('ng-class');
976
+
977
+ if (existingNgClass) {
978
+ newNgClass = existingNgClass.slice(0, -1) + ',' + newNgClass;
979
+ } else {
980
+ newNgClass = '{' + newNgClass;
981
+ }
982
+ rowRepeatDiv.attr('ng-class', newNgClass);
983
+
984
+ return {
985
+ pre: function ($scope, $elm, $attrs, controllers) {},
986
+ post: function ($scope, $elm, $attrs, controllers) {}
987
+ };
988
+ }
989
+ };
990
+ });
991
+
992
+ /**
993
+ * @ngdoc directive
994
+ * @name ui.grid.selection.directive:uiGridCell
995
+ * @element div
996
+ * @restrict A
997
+ *
998
+ * @description Stacks on top of ui.grid.uiGridCell to provide selection feature
999
+ */
1000
+ module.directive('uiGridCell',
1001
+ ['uiGridConstants', 'uiGridSelectionService',
1002
+ function (uiGridConstants, uiGridSelectionService) {
1003
+ return {
1004
+ priority: -200, // run after default uiGridCell directive
1005
+ restrict: 'A',
1006
+ require: '?^uiGrid',
1007
+ scope: false,
1008
+ link: function ($scope, $elm, $attrs, uiGridCtrl) {
1009
+ var touchStartTime = 0,
1010
+ touchStartPos = {},
1011
+ touchTimeout = 300,
1012
+ touchPosDiff = 100;
1013
+
1014
+ // Bind to keydown events in the render container
1015
+ if (uiGridCtrl.grid.api.cellNav) {
1016
+ uiGridCtrl.grid.api.cellNav.on.viewPortKeyDown($scope, function (evt, rowCol) {
1017
+ if (rowCol === null ||
1018
+ rowCol.row !== $scope.row ||
1019
+ rowCol.col !== $scope.col) {
1020
+ return;
1021
+ }
1022
+
1023
+ if (evt.keyCode === uiGridConstants.keymap.SPACE && $scope.col.colDef.name === 'selectionRowHeaderCol') {
1024
+ evt.preventDefault();
1025
+ uiGridSelectionService.toggleRowSelection($scope.grid, $scope.row, evt,
1026
+ ($scope.grid.options.multiSelect && !$scope.grid.options.modifierKeysToMultiSelect),
1027
+ $scope.grid.options.noUnselect, false);
1028
+ $scope.$apply();
1029
+ }
1030
+ });
1031
+ }
1032
+
1033
+ var selectCells = function (evt) {
1034
+ // if you click on expandable icon doesn't trigger selection
1035
+ if (evt.target.className === "ui-grid-icon-minus-squared" || evt.target.className === "ui-grid-icon-plus-squared") {
1036
+ return;
1037
+ }
1038
+
1039
+ // if we get a click, then stop listening for touchend
1040
+ $elm.off('touchend', touchEnd);
1041
+
1042
+ if (evt.shiftKey) {
1043
+ uiGridSelectionService.shiftSelect($scope.grid, $scope.row, evt, $scope.grid.options.multiSelect);
1044
+ }
1045
+ else if (evt.ctrlKey || evt.metaKey) {
1046
+ uiGridSelectionService.toggleRowSelection($scope.grid, $scope.row, evt,
1047
+ $scope.grid.options.multiSelect, $scope.grid.options.noUnselect, false);
1048
+ }
1049
+ else if ($scope.grid.options.enableSelectRowOnFocus) {
1050
+ uiGridSelectionService.toggleRowSelection($scope.grid, $scope.row, evt,
1051
+ ($scope.grid.options.multiSelect && !$scope.grid.options.modifierKeysToMultiSelect),
1052
+ $scope.grid.options.noUnselect, false);
1053
+ }
1054
+ $scope.row.setFocused(!$scope.row.isFocused);
1055
+ $scope.grid.api.selection.raise.rowFocusChanged($scope.row, evt);
1056
+ $scope.$apply();
1057
+
1058
+ // don't re-enable the touchend handler for a little while - some devices generate both, and it will
1059
+ // take a little while to move your hand from the mouse to the screen if you have both modes of input
1060
+ window.setTimeout(function () {
1061
+ $elm.on('touchend', touchEnd);
1062
+ }, touchTimeout);
1063
+ };
1064
+
1065
+ var touchStart = function (evt) {
1066
+ touchStartTime = (new Date()).getTime();
1067
+ touchStartPos = evt.changedTouches[0];
1068
+
1069
+ // if we get a touch event, then stop listening for click
1070
+ $elm.off('click', selectCells);
1071
+ };
1072
+
1073
+ var touchEnd = function (evt) {
1074
+ var touchEndTime = (new Date()).getTime();
1075
+ var touchEndPos = evt.changedTouches[0];
1076
+ var touchTime = touchEndTime - touchStartTime;
1077
+ var touchXDiff = Math.abs(touchStartPos.clientX - touchEndPos.clientX)
1078
+ var touchYDiff = Math.abs(touchStartPos.clientY - touchEndPos.clientY)
1079
+
1080
+
1081
+ if (touchXDiff < touchPosDiff && touchYDiff < touchPosDiff) {
1082
+ if (touchTime < touchTimeout) {
1083
+ // short touch
1084
+ selectCells(evt);
1085
+ }
1086
+ }
1087
+
1088
+ // don't re-enable the click handler for a little while - some devices generate both, and it will
1089
+ // take a little while to move your hand from the screen to the mouse if you have both modes of input
1090
+ window.setTimeout(function () {
1091
+ $elm.on('click', selectCells);
1092
+ }, touchTimeout);
1093
+ };
1094
+
1095
+ function registerRowSelectionEvents() {
1096
+ if ($scope.grid.options.enableRowSelection && $scope.grid.options.enableFullRowSelection && $scope.col.colDef.name !== 'selectionRowHeaderCol') {
1097
+ $elm.addClass('ui-grid-disable-selection');
1098
+ $elm.on('touchstart', touchStart);
1099
+ $elm.on('touchend', touchEnd);
1100
+ $elm.on('click', selectCells);
1101
+
1102
+ $scope.registered = true;
1103
+ }
1104
+ }
1105
+
1106
+ function unregisterRowSelectionEvents() {
1107
+ if ($scope.registered) {
1108
+ $elm.removeClass('ui-grid-disable-selection');
1109
+ $elm.off('touchstart', touchStart);
1110
+ $elm.off('touchend', touchEnd);
1111
+ $elm.off('click', selectCells);
1112
+
1113
+ $scope.registered = false;
1114
+ }
1115
+ }
1116
+
1117
+ registerRowSelectionEvents();
1118
+
1119
+ // register a dataChange callback so that we can change the selection configuration dynamically
1120
+ // if the user changes the options
1121
+ var dataChangeUnreg = $scope.grid.registerDataChangeCallback(function () {
1122
+ if ($scope.grid.options.enableRowSelection && $scope.grid.options.enableFullRowSelection &&
1123
+ !$scope.registered) {
1124
+ registerRowSelectionEvents();
1125
+ }
1126
+ else if ((!$scope.grid.options.enableRowSelection || !$scope.grid.options.enableFullRowSelection) &&
1127
+ $scope.registered) {
1128
+ unregisterRowSelectionEvents();
1129
+ }
1130
+ }, [uiGridConstants.dataChange.OPTIONS]);
1131
+
1132
+ $elm.on('$destroy', dataChangeUnreg);
1133
+ }
1134
+ };
1135
+ }]);
1136
+
1137
+ module.directive('uiGridGridFooter', ['$compile', 'gridUtil', function ($compile, gridUtil) {
1138
+ return {
1139
+ restrict: 'EA',
1140
+ replace: true,
1141
+ priority: -1000,
1142
+ require: '^uiGrid',
1143
+ scope: true,
1144
+ compile: function () {
1145
+ return {
1146
+ pre: function ($scope, $elm, $attrs, uiGridCtrl) {
1147
+ if (!uiGridCtrl.grid.options.showGridFooter) {
1148
+ return;
1149
+ }
1150
+
1151
+ gridUtil.getTemplate('ui-grid/gridFooterSelectedItems')
1152
+ .then(function (contents) {
1153
+ var template = angular.element(contents);
1154
+
1155
+ var newElm = $compile(template)($scope);
1156
+
1157
+ angular.element($elm[0].getElementsByClassName('ui-grid-grid-footer')[0]).append(newElm);
1158
+ });
1159
+ },
1160
+ post: function ($scope, $elm, $attrs, controllers) {
1161
+
1162
+ }
1163
+ };
1164
+ }
1165
+ };
1166
+ }]);
1167
+ })();
1168
+
1169
+ angular.module('ui.grid.selection').run(['$templateCache', function($templateCache) {
1170
+ 'use strict';
1171
+
1172
+ $templateCache.put('ui-grid/gridFooterSelectedItems',
1173
+ "<span ng-if=\"grid.selection.selectedCount !== 0 && grid.options.enableFooterTotalSelected\">({{\"search.selectedItems\" | t}} {{grid.selection.selectedCount}})</span>"
1174
+ );
1175
+
1176
+
1177
+ $templateCache.put('ui-grid/selectionHeaderCell',
1178
+ "<div><!-- <div class=\"ui-grid-vertical-bar\">&nbsp;</div> --><div class=\"ui-grid-cell-contents\" col-index=\"renderIndex\"><ui-grid-selection-select-all-buttons ng-if=\"grid.options.enableSelectAll\" role=\"checkbox\" ng-model=\"grid.selection.selectAll\"></ui-grid-selection-select-all-buttons></div></div>"
1179
+ );
1180
+
1181
+
1182
+ $templateCache.put('ui-grid/selectionRowHeader',
1183
+ "<div class=\"ui-grid-cell-contents ui-grid-disable-selection clickable\"><ui-grid-selection-row-header-buttons></ui-grid-selection-row-header-buttons></div>"
1184
+ );
1185
+
1186
+
1187
+ $templateCache.put('ui-grid/selectionRowHeaderButtons',
1188
+ "<div class=\"ui-grid-selection-row-header-buttons ui-grid-icon-ok clickable\" ng-class=\"{'ui-grid-row-selected': row.isSelected}\" tabindex=\"0\" ng-click=\"selectButtonClick(row, $event)\" ng-keydown=\"selectButtonKeyDown(row, $event)\" ng-attr-aria-label=\"{{('selection.aria.row' | t) + ' ' + (row.index + 1) + ', ' + col.displayName}}\" aria-checked=\"{{row.isSelected}}\" role=\"checkbox\" ng-model=\"row.isSelected\">&nbsp;</div>"
1189
+ );
1190
+
1191
+
1192
+ $templateCache.put('ui-grid/selectionSelectAllButtons',
1193
+ "<div role=\"checkbox\" tabindex=\"0\" class=\"ui-grid-selection-row-header-buttons ui-grid-icon-ok\" ui-grid-one-bind-aria-label=\"'selection.selectAll' | t\" aria-checked=\"{{grid.selection.selectAll}}\" ng-class=\"{'ui-grid-all-selected': grid.selection.selectAll}\" ng-click=\"headerButtonClick($event)\" ng-keydown=\"headerButtonKeyDown($event)\"></div>"
1194
+ );
1195
+
1196
+ }]);