@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.
- package/chunk-A3NTIEMP.js +1 -0
- package/chunk-CAY35YP7.js +7 -0
- package/chunk-H3QHLLCN.js +1 -0
- package/chunk-KE4BCZO4.js +851 -0
- package/chunk-OHPEWN32.js +1198 -0
- package/chunk-WSQOM5HU.js +1 -0
- package/component-lib.js +1 -0
- package/index.html +12 -0
- package/main.js +3264 -0
- package/modules/angular/LICENSE.md +21 -0
- package/modules/angular/README.md +67 -0
- package/modules/angular/angular-csp.css +25 -0
- package/modules/angular/angular.js +36600 -0
- package/modules/angular/angular.min.js +352 -0
- package/modules/angular/angular.min.js.gzip +0 -0
- package/modules/angular/angular.min.js.map +8 -0
- package/modules/angular/bower.json +9 -0
- package/modules/angular/index.js +2 -0
- package/modules/angular/package.json +25 -0
- package/modules/angular-ui-grid/CHANGELOG.md +1973 -0
- package/modules/angular-ui-grid/README.md +59 -0
- package/modules/angular-ui-grid/css/ui-grid.cellnav.css +25 -0
- package/modules/angular-ui-grid/css/ui-grid.cellnav.min.css +1 -0
- package/modules/angular-ui-grid/css/ui-grid.core.css +866 -0
- package/modules/angular-ui-grid/css/ui-grid.core.min.css +5 -0
- package/modules/angular-ui-grid/css/ui-grid.edit.css +23 -0
- package/modules/angular-ui-grid/css/ui-grid.edit.min.css +1 -0
- package/modules/angular-ui-grid/css/ui-grid.empty-base-layer.css +6 -0
- package/modules/angular-ui-grid/css/ui-grid.empty-base-layer.min.css +1 -0
- package/modules/angular-ui-grid/css/ui-grid.expandable.css +16 -0
- package/modules/angular-ui-grid/css/ui-grid.expandable.min.css +1 -0
- package/modules/angular-ui-grid/css/ui-grid.exporter.css +0 -0
- package/modules/angular-ui-grid/css/ui-grid.exporter.min.css +0 -0
- package/modules/angular-ui-grid/css/ui-grid.grouping.css +3 -0
- package/modules/angular-ui-grid/css/ui-grid.grouping.min.css +1 -0
- package/modules/angular-ui-grid/css/ui-grid.importer.css +0 -0
- package/modules/angular-ui-grid/css/ui-grid.importer.min.css +0 -0
- package/modules/angular-ui-grid/css/ui-grid.move-columns.css +9 -0
- package/modules/angular-ui-grid/css/ui-grid.move-columns.min.css +1 -0
- package/modules/angular-ui-grid/css/ui-grid.pagination.css +299 -0
- package/modules/angular-ui-grid/css/ui-grid.pagination.min.css +1 -0
- package/modules/angular-ui-grid/css/ui-grid.pinning.css +67 -0
- package/modules/angular-ui-grid/css/ui-grid.pinning.min.css +1 -0
- package/modules/angular-ui-grid/css/ui-grid.resize-columns.css +38 -0
- package/modules/angular-ui-grid/css/ui-grid.resize-columns.min.css +1 -0
- package/modules/angular-ui-grid/css/ui-grid.row-edit.css +9 -0
- package/modules/angular-ui-grid/css/ui-grid.row-edit.min.css +1 -0
- package/modules/angular-ui-grid/css/ui-grid.selection.css +25 -0
- package/modules/angular-ui-grid/css/ui-grid.selection.min.css +1 -0
- package/modules/angular-ui-grid/css/ui-grid.tree-base.css +4 -0
- package/modules/angular-ui-grid/css/ui-grid.tree-base.min.css +1 -0
- package/modules/angular-ui-grid/css/ui-grid.tree-view.css +6 -0
- package/modules/angular-ui-grid/css/ui-grid.tree-view.min.css +1 -0
- package/modules/angular-ui-grid/css/ui-grid.validate.css +3 -0
- package/modules/angular-ui-grid/css/ui-grid.validate.min.css +1 -0
- package/modules/angular-ui-grid/fonts/ui-grid.eot +0 -0
- package/modules/angular-ui-grid/fonts/ui-grid.svg +56 -0
- package/modules/angular-ui-grid/fonts/ui-grid.ttf +0 -0
- package/modules/angular-ui-grid/fonts/ui-grid.woff +0 -0
- package/modules/angular-ui-grid/less/animation.less +85 -0
- package/modules/angular-ui-grid/less/body.less +84 -0
- package/modules/angular-ui-grid/less/cell.less +46 -0
- package/modules/angular-ui-grid/less/cellnav.less +29 -0
- package/modules/angular-ui-grid/less/core.less +11 -0
- package/modules/angular-ui-grid/less/edit.less +27 -0
- package/modules/angular-ui-grid/less/elements.less +156 -0
- package/modules/angular-ui-grid/less/emptyBaseLayer.less +8 -0
- package/modules/angular-ui-grid/less/expandable.less +29 -0
- package/modules/angular-ui-grid/less/exporter.less +4 -0
- package/modules/angular-ui-grid/less/footer.less +76 -0
- package/modules/angular-ui-grid/less/grid.less +86 -0
- package/modules/angular-ui-grid/less/grouping.less +5 -0
- package/modules/angular-ui-grid/less/header.less +250 -0
- package/modules/angular-ui-grid/less/icons.less +151 -0
- package/modules/angular-ui-grid/less/importer.less +4 -0
- package/modules/angular-ui-grid/less/main.less +2 -0
- package/modules/angular-ui-grid/less/menu.less +91 -0
- package/modules/angular-ui-grid/less/moveColumns.less +12 -0
- package/modules/angular-ui-grid/less/pagination.less +297 -0
- package/modules/angular-ui-grid/less/pinning.less +86 -0
- package/modules/angular-ui-grid/less/resizeColumns.less +53 -0
- package/modules/angular-ui-grid/less/rowEdit.less +19 -0
- package/modules/angular-ui-grid/less/rtl.less +67 -0
- package/modules/angular-ui-grid/less/selection.less +29 -0
- package/modules/angular-ui-grid/less/sorting.less +16 -0
- package/modules/angular-ui-grid/less/treeBase.less +6 -0
- package/modules/angular-ui-grid/less/treeView.less +8 -0
- package/modules/angular-ui-grid/less/validate.less +5 -0
- package/modules/angular-ui-grid/less/variables.less +90 -0
- package/modules/angular-ui-grid/package.json +144 -0
- package/modules/angular-ui-grid/ui-grid.auto-resize.js +69 -0
- package/modules/angular-ui-grid/ui-grid.auto-resize.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.cellnav.js +1181 -0
- package/modules/angular-ui-grid/ui-grid.cellnav.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.core.js +12737 -0
- package/modules/angular-ui-grid/ui-grid.core.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.css +3208 -0
- package/modules/angular-ui-grid/ui-grid.edit.js +1325 -0
- package/modules/angular-ui-grid/ui-grid.edit.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.empty-base-layer.js +178 -0
- package/modules/angular-ui-grid/ui-grid.empty-base-layer.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.expandable.js +651 -0
- package/modules/angular-ui-grid/ui-grid.expandable.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.exporter.js +1777 -0
- package/modules/angular-ui-grid/ui-grid.exporter.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.grouping.js +1291 -0
- package/modules/angular-ui-grid/ui-grid.grouping.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.importer.js +791 -0
- package/modules/angular-ui-grid/ui-grid.importer.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.infinite-scroll.js +552 -0
- package/modules/angular-ui-grid/ui-grid.infinite-scroll.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.js +30867 -0
- package/modules/angular-ui-grid/ui-grid.language.all.js +3214 -0
- package/modules/angular-ui-grid/ui-grid.language.all.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.language.ar.js +118 -0
- package/modules/angular-ui-grid/ui-grid.language.ar.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.language.bg.js +115 -0
- package/modules/angular-ui-grid/ui-grid.language.bg.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.language.cs.js +96 -0
- package/modules/angular-ui-grid/ui-grid.language.cs.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.language.da.js +90 -0
- package/modules/angular-ui-grid/ui-grid.language.da.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.language.de.js +133 -0
- package/modules/angular-ui-grid/ui-grid.language.de.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.language.es-ct.js +133 -0
- package/modules/angular-ui-grid/ui-grid.language.es-ct.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.language.es.js +106 -0
- package/modules/angular-ui-grid/ui-grid.language.es.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.language.fa.js +93 -0
- package/modules/angular-ui-grid/ui-grid.language.fa.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.language.fi.js +76 -0
- package/modules/angular-ui-grid/ui-grid.language.fi.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.language.fr.js +128 -0
- package/modules/angular-ui-grid/ui-grid.language.fr.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.language.he.js +71 -0
- package/modules/angular-ui-grid/ui-grid.language.he.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.language.hy.js +76 -0
- package/modules/angular-ui-grid/ui-grid.language.hy.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.language.is.js +118 -0
- package/modules/angular-ui-grid/ui-grid.language.is.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.language.it.js +112 -0
- package/modules/angular-ui-grid/ui-grid.language.it.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.language.ja.js +118 -0
- package/modules/angular-ui-grid/ui-grid.language.ja.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.language.ko.js +77 -0
- package/modules/angular-ui-grid/ui-grid.language.ko.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.language.nl.js +91 -0
- package/modules/angular-ui-grid/ui-grid.language.nl.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.language.no.js +115 -0
- package/modules/angular-ui-grid/ui-grid.language.no.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.language.pl.js +126 -0
- package/modules/angular-ui-grid/ui-grid.language.pl.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.language.pt-br.js +133 -0
- package/modules/angular-ui-grid/ui-grid.language.pt-br.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.language.pt.js +133 -0
- package/modules/angular-ui-grid/ui-grid.language.pt.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.language.ro.js +112 -0
- package/modules/angular-ui-grid/ui-grid.language.ro.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.language.rs-lat.js +126 -0
- package/modules/angular-ui-grid/ui-grid.language.rs-lat.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.language.ru.js +115 -0
- package/modules/angular-ui-grid/ui-grid.language.ru.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.language.sk.js +127 -0
- package/modules/angular-ui-grid/ui-grid.language.sk.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.language.sv.js +126 -0
- package/modules/angular-ui-grid/ui-grid.language.sv.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.language.ta.js +87 -0
- package/modules/angular-ui-grid/ui-grid.language.ta.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.language.tr.js +112 -0
- package/modules/angular-ui-grid/ui-grid.language.tr.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.language.ua.js +112 -0
- package/modules/angular-ui-grid/ui-grid.language.ua.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.language.zh-cn.js +112 -0
- package/modules/angular-ui-grid/ui-grid.language.zh-cn.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.language.zh-tw.js +77 -0
- package/modules/angular-ui-grid/ui-grid.language.zh-tw.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.min.css +5 -0
- package/modules/angular-ui-grid/ui-grid.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.move-columns.js +582 -0
- package/modules/angular-ui-grid/ui-grid.move-columns.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.pagination.js +510 -0
- package/modules/angular-ui-grid/ui-grid.pagination.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.pinning.js +281 -0
- package/modules/angular-ui-grid/ui-grid.pinning.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.resize-columns.js +574 -0
- package/modules/angular-ui-grid/ui-grid.resize-columns.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.row-edit.js +717 -0
- package/modules/angular-ui-grid/ui-grid.row-edit.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.saveState.js +831 -0
- package/modules/angular-ui-grid/ui-grid.saveState.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.selection.js +1196 -0
- package/modules/angular-ui-grid/ui-grid.selection.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.tree-base.js +1743 -0
- package/modules/angular-ui-grid/ui-grid.tree-base.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.tree-view.js +218 -0
- package/modules/angular-ui-grid/ui-grid.tree-view.min.js +6 -0
- package/modules/angular-ui-grid/ui-grid.validate.js +589 -0
- package/modules/angular-ui-grid/ui-grid.validate.min.js +6 -0
- package/package.json +8 -0
- package/polyfills.js +2 -0
- package/styles.css +1 -0
|
@@ -0,0 +1,831 @@
|
|
|
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.saveState
|
|
13
|
+
* @description
|
|
14
|
+
*
|
|
15
|
+
* # ui.grid.saveState
|
|
16
|
+
*
|
|
17
|
+
* <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>
|
|
18
|
+
*
|
|
19
|
+
* This module provides the ability to save the grid state, and restore
|
|
20
|
+
* it when the user returns to the page.
|
|
21
|
+
*
|
|
22
|
+
* No UI is provided, the caller should provide their own UI/buttons
|
|
23
|
+
* as appropriate. Usually the navigate events would be used to save
|
|
24
|
+
* the grid state and restore it.
|
|
25
|
+
*
|
|
26
|
+
* <br/>
|
|
27
|
+
* <br/>
|
|
28
|
+
*
|
|
29
|
+
* <div doc-module-components="ui.grid.save-state"></div>
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
var module = angular.module('ui.grid.saveState', ['ui.grid', 'ui.grid.selection', 'ui.grid.cellNav', 'ui.grid.grouping', 'ui.grid.pinning', 'ui.grid.treeView']);
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @ngdoc object
|
|
36
|
+
* @name ui.grid.saveState.constant:uiGridSaveStateConstants
|
|
37
|
+
*
|
|
38
|
+
* @description constants available in save state module
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
module.constant('uiGridSaveStateConstants', {
|
|
42
|
+
featureName: 'saveState'
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @ngdoc service
|
|
47
|
+
* @name ui.grid.saveState.service:uiGridSaveStateService
|
|
48
|
+
*
|
|
49
|
+
* @description Services for saveState feature
|
|
50
|
+
*/
|
|
51
|
+
module.service('uiGridSaveStateService',
|
|
52
|
+
function () {
|
|
53
|
+
var service = {
|
|
54
|
+
|
|
55
|
+
initializeGrid: function (grid) {
|
|
56
|
+
|
|
57
|
+
// add feature namespace and any properties to grid for needed state
|
|
58
|
+
grid.saveState = {};
|
|
59
|
+
this.defaultGridOptions(grid.options);
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @ngdoc object
|
|
63
|
+
* @name ui.grid.saveState.api:PublicApi
|
|
64
|
+
*
|
|
65
|
+
* @description Public Api for saveState feature
|
|
66
|
+
*/
|
|
67
|
+
var publicApi = {
|
|
68
|
+
events: {
|
|
69
|
+
saveState: {
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
methods: {
|
|
73
|
+
saveState: {
|
|
74
|
+
/**
|
|
75
|
+
* @ngdoc function
|
|
76
|
+
* @name save
|
|
77
|
+
* @methodOf ui.grid.saveState.api:PublicApi
|
|
78
|
+
* @description Packages the current state of the grid into
|
|
79
|
+
* an object, and provides it to the user for saving
|
|
80
|
+
* @returns {object} the state as a javascript object that can be saved
|
|
81
|
+
*/
|
|
82
|
+
save: function () {
|
|
83
|
+
return service.save(grid);
|
|
84
|
+
},
|
|
85
|
+
/**
|
|
86
|
+
* @ngdoc function
|
|
87
|
+
* @name restore
|
|
88
|
+
* @methodOf ui.grid.saveState.api:PublicApi
|
|
89
|
+
* @description Restores the provided state into the grid
|
|
90
|
+
* @param {scope} $scope a scope that we can broadcast on
|
|
91
|
+
* @param {object} state the state that should be restored into the grid
|
|
92
|
+
* @returns {object} the promise created by refresh
|
|
93
|
+
*/
|
|
94
|
+
restore: function ( $scope, state) {
|
|
95
|
+
return service.restore(grid, $scope, state);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
grid.api.registerEventsFromObject(publicApi.events);
|
|
102
|
+
|
|
103
|
+
grid.api.registerMethodsFromObject(publicApi.methods);
|
|
104
|
+
},
|
|
105
|
+
|
|
106
|
+
defaultGridOptions: function (gridOptions) {
|
|
107
|
+
// default option to true unless it was explicitly set to false
|
|
108
|
+
/**
|
|
109
|
+
* @ngdoc object
|
|
110
|
+
* @name ui.grid.saveState.api:GridOptions
|
|
111
|
+
*
|
|
112
|
+
* @description GridOptions for saveState feature, these are available to be
|
|
113
|
+
* set using the ui-grid {@link ui.grid.class:GridOptions gridOptions}
|
|
114
|
+
*/
|
|
115
|
+
/**
|
|
116
|
+
* @ngdoc object
|
|
117
|
+
* @name saveWidths
|
|
118
|
+
* @propertyOf ui.grid.saveState.api:GridOptions
|
|
119
|
+
* @description Save the current column widths. Note that unless
|
|
120
|
+
* you've provided the user with some way to resize their columns (say
|
|
121
|
+
* the resize columns feature), then this makes little sense.
|
|
122
|
+
* <br/>Defaults to true
|
|
123
|
+
*/
|
|
124
|
+
gridOptions.saveWidths = gridOptions.saveWidths !== false;
|
|
125
|
+
/**
|
|
126
|
+
* @ngdoc object
|
|
127
|
+
* @name saveOrder
|
|
128
|
+
* @propertyOf ui.grid.saveState.api:GridOptions
|
|
129
|
+
* @description Restore the current column order. Note that unless
|
|
130
|
+
* you've provided the user with some way to reorder their columns (for
|
|
131
|
+
* example the move columns feature), this makes little sense.
|
|
132
|
+
* <br/>Defaults to true
|
|
133
|
+
*/
|
|
134
|
+
gridOptions.saveOrder = gridOptions.saveOrder !== false;
|
|
135
|
+
/**
|
|
136
|
+
* @ngdoc object
|
|
137
|
+
* @name saveScroll
|
|
138
|
+
* @propertyOf ui.grid.saveState.api:GridOptions
|
|
139
|
+
* @description Save the current scroll position. Note that this
|
|
140
|
+
* is saved as the percentage of the grid scrolled - so if your
|
|
141
|
+
* user returns to a grid with a significantly different number of
|
|
142
|
+
* rows (perhaps some data has been deleted) then the scroll won't
|
|
143
|
+
* actually show the same rows as before. If you want to scroll to
|
|
144
|
+
* a specific row then you should instead use the saveFocus option, which
|
|
145
|
+
* is the default.
|
|
146
|
+
*
|
|
147
|
+
* Note that this element will only be saved if the cellNav feature is
|
|
148
|
+
* enabled
|
|
149
|
+
* <br/>Defaults to false
|
|
150
|
+
*/
|
|
151
|
+
gridOptions.saveScroll = gridOptions.saveScroll === true;
|
|
152
|
+
/**
|
|
153
|
+
* @ngdoc object
|
|
154
|
+
* @name saveFocus
|
|
155
|
+
* @propertyOf ui.grid.saveState.api:GridOptions
|
|
156
|
+
* @description Save the current focused cell. On returning
|
|
157
|
+
* to this focused cell we'll also scroll. This option is
|
|
158
|
+
* preferred to the saveScroll option, so is set to true by
|
|
159
|
+
* default. If saveScroll is set to true then this option will
|
|
160
|
+
* be disabled.
|
|
161
|
+
*
|
|
162
|
+
* By default this option saves the current row number and column
|
|
163
|
+
* number, and returns to that row and column. However, if you define
|
|
164
|
+
* a saveRowIdentity function, then it will return you to the currently
|
|
165
|
+
* selected column within that row (in a business sense - so if some
|
|
166
|
+
* rows have been deleted, it will still find the same data, presuming it
|
|
167
|
+
* still exists in the list. If it isn't in the list then it will instead
|
|
168
|
+
* return to the same row number - i.e. scroll percentage)
|
|
169
|
+
*
|
|
170
|
+
* Note that this option will do nothing if the cellNav
|
|
171
|
+
* feature is not enabled.
|
|
172
|
+
*
|
|
173
|
+
* <br/>Defaults to true (unless saveScroll is true)
|
|
174
|
+
*/
|
|
175
|
+
gridOptions.saveFocus = gridOptions.saveScroll !== true && gridOptions.saveFocus !== false;
|
|
176
|
+
/**
|
|
177
|
+
* @ngdoc object
|
|
178
|
+
* @name saveRowIdentity
|
|
179
|
+
* @propertyOf ui.grid.saveState.api:GridOptions
|
|
180
|
+
* @description A function that can be called, passing in a rowEntity,
|
|
181
|
+
* and that will return a unique id for that row. This might simply
|
|
182
|
+
* return the `id` field from that row (if you have one), or it might
|
|
183
|
+
* concatenate some fields within the row to make a unique value.
|
|
184
|
+
*
|
|
185
|
+
* This value will be used to find the same row again and set the focus
|
|
186
|
+
* to it, if it exists when we return.
|
|
187
|
+
*
|
|
188
|
+
* <br/>Defaults to undefined
|
|
189
|
+
*/
|
|
190
|
+
/**
|
|
191
|
+
* @ngdoc object
|
|
192
|
+
* @name saveVisible
|
|
193
|
+
* @propertyOf ui.grid.saveState.api:GridOptions
|
|
194
|
+
* @description Save whether or not columns are visible.
|
|
195
|
+
*
|
|
196
|
+
* <br/>Defaults to true
|
|
197
|
+
*/
|
|
198
|
+
gridOptions.saveVisible = gridOptions.saveVisible !== false;
|
|
199
|
+
/**
|
|
200
|
+
* @ngdoc object
|
|
201
|
+
* @name saveSort
|
|
202
|
+
* @propertyOf ui.grid.saveState.api:GridOptions
|
|
203
|
+
* @description Save the current sort state for each column
|
|
204
|
+
*
|
|
205
|
+
* <br/>Defaults to true
|
|
206
|
+
*/
|
|
207
|
+
gridOptions.saveSort = gridOptions.saveSort !== false;
|
|
208
|
+
/**
|
|
209
|
+
* @ngdoc object
|
|
210
|
+
* @name saveFilter
|
|
211
|
+
* @propertyOf ui.grid.saveState.api:GridOptions
|
|
212
|
+
* @description Save the current filter state for each column
|
|
213
|
+
*
|
|
214
|
+
* <br/>Defaults to true
|
|
215
|
+
*/
|
|
216
|
+
gridOptions.saveFilter = gridOptions.saveFilter !== false;
|
|
217
|
+
/**
|
|
218
|
+
* @ngdoc object
|
|
219
|
+
* @name saveSelection
|
|
220
|
+
* @propertyOf ui.grid.saveState.api:GridOptions
|
|
221
|
+
* @description Save the currently selected rows. If the `saveRowIdentity` callback
|
|
222
|
+
* is defined, then it will save the id of the row and select that. If not, then
|
|
223
|
+
* it will attempt to select the rows by row number, which will give the wrong results
|
|
224
|
+
* if the data set has changed in the mean-time.
|
|
225
|
+
*
|
|
226
|
+
* Note that this option only does anything
|
|
227
|
+
* if the selection feature is enabled.
|
|
228
|
+
*
|
|
229
|
+
* <br/>Defaults to true
|
|
230
|
+
*/
|
|
231
|
+
gridOptions.saveSelection = gridOptions.saveSelection !== false;
|
|
232
|
+
/**
|
|
233
|
+
* @ngdoc object
|
|
234
|
+
* @name saveGrouping
|
|
235
|
+
* @propertyOf ui.grid.saveState.api:GridOptions
|
|
236
|
+
* @description Save the grouping configuration. If set to true and the
|
|
237
|
+
* grouping feature is not enabled then does nothing.
|
|
238
|
+
*
|
|
239
|
+
* <br/>Defaults to true
|
|
240
|
+
*/
|
|
241
|
+
gridOptions.saveGrouping = gridOptions.saveGrouping !== false;
|
|
242
|
+
/**
|
|
243
|
+
* @ngdoc object
|
|
244
|
+
* @name saveGroupingExpandedStates
|
|
245
|
+
* @propertyOf ui.grid.saveState.api:GridOptions
|
|
246
|
+
* @description Save the grouping row expanded states. If set to true and the
|
|
247
|
+
* grouping feature is not enabled then does nothing.
|
|
248
|
+
*
|
|
249
|
+
* This can be quite a bit of data, in many cases you wouldn't want to save this
|
|
250
|
+
* information.
|
|
251
|
+
*
|
|
252
|
+
* <br/>Defaults to false
|
|
253
|
+
*/
|
|
254
|
+
gridOptions.saveGroupingExpandedStates = gridOptions.saveGroupingExpandedStates === true;
|
|
255
|
+
/**
|
|
256
|
+
* @ngdoc object
|
|
257
|
+
* @name savePinning
|
|
258
|
+
* @propertyOf ui.grid.saveState.api:GridOptions
|
|
259
|
+
* @description Save pinning state for columns.
|
|
260
|
+
*
|
|
261
|
+
* <br/>Defaults to true
|
|
262
|
+
*/
|
|
263
|
+
gridOptions.savePinning = gridOptions.savePinning !== false;
|
|
264
|
+
/**
|
|
265
|
+
* @ngdoc object
|
|
266
|
+
* @name saveTreeView
|
|
267
|
+
* @propertyOf ui.grid.saveState.api:GridOptions
|
|
268
|
+
* @description Save the treeView configuration. If set to true and the
|
|
269
|
+
* treeView feature is not enabled then does nothing.
|
|
270
|
+
*
|
|
271
|
+
* <br/>Defaults to true
|
|
272
|
+
*/
|
|
273
|
+
gridOptions.saveTreeView = gridOptions.saveTreeView !== false;
|
|
274
|
+
},
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* @ngdoc function
|
|
278
|
+
* @name save
|
|
279
|
+
* @methodOf ui.grid.saveState.service:uiGridSaveStateService
|
|
280
|
+
* @description Saves the current grid state into an object, and
|
|
281
|
+
* passes that object back to the caller
|
|
282
|
+
* @param {Grid} grid the grid whose state we'd like to save
|
|
283
|
+
* @returns {object} the state ready to be saved
|
|
284
|
+
*/
|
|
285
|
+
save: function (grid) {
|
|
286
|
+
var savedState = {};
|
|
287
|
+
|
|
288
|
+
savedState.columns = service.saveColumns( grid );
|
|
289
|
+
savedState.scrollFocus = service.saveScrollFocus( grid );
|
|
290
|
+
savedState.selection = service.saveSelection( grid );
|
|
291
|
+
savedState.grouping = service.saveGrouping( grid );
|
|
292
|
+
savedState.treeView = service.saveTreeView( grid );
|
|
293
|
+
savedState.pagination = service.savePagination( grid );
|
|
294
|
+
|
|
295
|
+
return savedState;
|
|
296
|
+
},
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* @ngdoc function
|
|
301
|
+
* @name restore
|
|
302
|
+
* @methodOf ui.grid.saveState.service:uiGridSaveStateService
|
|
303
|
+
* @description Applies the provided state to the grid
|
|
304
|
+
*
|
|
305
|
+
* @param {Grid} grid the grid whose state we'd like to restore
|
|
306
|
+
* @param {scope} $scope a scope that we can broadcast on
|
|
307
|
+
* @param {object} state the state we'd like to restore
|
|
308
|
+
* @returns {object} the promise created by refresh
|
|
309
|
+
*/
|
|
310
|
+
restore: function( grid, $scope, state ) {
|
|
311
|
+
if ( state.columns ) {
|
|
312
|
+
service.restoreColumns( grid, state.columns );
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
if ( state.scrollFocus ) {
|
|
316
|
+
service.restoreScrollFocus( grid, $scope, state.scrollFocus );
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
if ( state.selection ) {
|
|
320
|
+
service.restoreSelection( grid, state.selection );
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
if ( state.grouping ) {
|
|
324
|
+
service.restoreGrouping( grid, state.grouping );
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
if ( state.treeView ) {
|
|
328
|
+
service.restoreTreeView( grid, state.treeView );
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
if ( state.pagination ) {
|
|
332
|
+
service.restorePagination( grid, state.pagination );
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
return grid.refresh();
|
|
336
|
+
},
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* @ngdoc function
|
|
341
|
+
* @name saveColumns
|
|
342
|
+
* @methodOf ui.grid.saveState.service:uiGridSaveStateService
|
|
343
|
+
* @description Saves the column setup, including sort, filters, ordering,
|
|
344
|
+
* pinning and column widths.
|
|
345
|
+
*
|
|
346
|
+
* Works through the current columns, storing them in order. Stores the
|
|
347
|
+
* column name, then the visible flag, width, sort and filters for each column.
|
|
348
|
+
*
|
|
349
|
+
* @param {Grid} grid the grid whose state we'd like to save
|
|
350
|
+
* @returns {array} the columns state ready to be saved
|
|
351
|
+
*/
|
|
352
|
+
saveColumns: function( grid ) {
|
|
353
|
+
var columns = [];
|
|
354
|
+
|
|
355
|
+
grid.getOnlyDataColumns().forEach( function( column ) {
|
|
356
|
+
var savedColumn = {};
|
|
357
|
+
savedColumn.name = column.name;
|
|
358
|
+
|
|
359
|
+
if ( grid.options.saveVisible ) {
|
|
360
|
+
savedColumn.visible = column.visible;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
if ( grid.options.saveWidths ) {
|
|
364
|
+
savedColumn.width = column.width;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
// these two must be copied, not just pointed too - otherwise our saved state is pointing to the same object as current state
|
|
368
|
+
if ( grid.options.saveSort ) {
|
|
369
|
+
savedColumn.sort = angular.copy( column.sort );
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
if ( grid.options.saveFilter ) {
|
|
373
|
+
savedColumn.filters = [];
|
|
374
|
+
column.filters.forEach( function( filter ) {
|
|
375
|
+
var copiedFilter = {};
|
|
376
|
+
angular.forEach( filter, function( value, key) {
|
|
377
|
+
if ( key !== 'condition' && key !== '$$hashKey' && key !== 'placeholder') {
|
|
378
|
+
copiedFilter[key] = value;
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
savedColumn.filters.push(copiedFilter);
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
if ( !!grid.api.pinning && grid.options.savePinning ) {
|
|
386
|
+
savedColumn.pinned = column.renderContainer ? column.renderContainer : '';
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
columns.push( savedColumn );
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
return columns;
|
|
393
|
+
},
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* @ngdoc function
|
|
398
|
+
* @name saveScrollFocus
|
|
399
|
+
* @methodOf ui.grid.saveState.service:uiGridSaveStateService
|
|
400
|
+
* @description Saves the currently scroll or focus.
|
|
401
|
+
*
|
|
402
|
+
* If cellNav isn't present then does nothing - we can't return
|
|
403
|
+
* to the scroll position without cellNav anyway.
|
|
404
|
+
*
|
|
405
|
+
* If the cellNav module is present, and saveFocus is true, then
|
|
406
|
+
* it saves the currently focused cell. If rowIdentity is present
|
|
407
|
+
* then saves using rowIdentity, otherwise saves visibleRowNum.
|
|
408
|
+
*
|
|
409
|
+
* If the cellNav module is not present, and saveScroll is true, then
|
|
410
|
+
* it approximates the current scroll row and column, and saves that.
|
|
411
|
+
*
|
|
412
|
+
* @param {Grid} grid the grid whose state we'd like to save
|
|
413
|
+
* @returns {object} the selection state ready to be saved
|
|
414
|
+
*/
|
|
415
|
+
saveScrollFocus: function( grid ) {
|
|
416
|
+
if ( !grid.api.cellNav ) {
|
|
417
|
+
return {};
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
var scrollFocus = {};
|
|
421
|
+
if ( grid.options.saveFocus ) {
|
|
422
|
+
scrollFocus.focus = true;
|
|
423
|
+
var rowCol = grid.api.cellNav.getFocusedCell();
|
|
424
|
+
if ( rowCol !== null ) {
|
|
425
|
+
if ( rowCol.col !== null ) {
|
|
426
|
+
scrollFocus.colName = rowCol.col.colDef.name;
|
|
427
|
+
}
|
|
428
|
+
if ( rowCol.row !== null ) {
|
|
429
|
+
scrollFocus.rowVal = service.getRowVal( grid, rowCol.row );
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
if ( grid.options.saveScroll || grid.options.saveFocus && !scrollFocus.colName && !scrollFocus.rowVal ) {
|
|
435
|
+
scrollFocus.focus = false;
|
|
436
|
+
if ( grid.renderContainers.body.prevRowScrollIndex ) {
|
|
437
|
+
scrollFocus.rowVal = service.getRowVal( grid, grid.renderContainers.body.visibleRowCache[ grid.renderContainers.body.prevRowScrollIndex ]);
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
if ( grid.renderContainers.body.prevColScrollIndex ) {
|
|
441
|
+
scrollFocus.colName = grid.renderContainers.body.visibleColumnCache[ grid.renderContainers.body.prevColScrollIndex ].name;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
return scrollFocus;
|
|
446
|
+
},
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* @ngdoc function
|
|
451
|
+
* @name saveSelection
|
|
452
|
+
* @methodOf ui.grid.saveState.service:uiGridSaveStateService
|
|
453
|
+
* @description Saves the currently selected rows, if the selection feature is enabled
|
|
454
|
+
* @param {Grid} grid the grid whose state we'd like to save
|
|
455
|
+
* @returns {array} the selection state ready to be saved
|
|
456
|
+
*/
|
|
457
|
+
saveSelection: function( grid ) {
|
|
458
|
+
if ( !grid.api.selection || !grid.options.saveSelection ) {
|
|
459
|
+
return [];
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
return grid.api.selection.getSelectedGridRows().map( function( gridRow ) {
|
|
463
|
+
return service.getRowVal( grid, gridRow );
|
|
464
|
+
});
|
|
465
|
+
},
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* @ngdoc function
|
|
470
|
+
* @name saveGrouping
|
|
471
|
+
* @methodOf ui.grid.saveState.service:uiGridSaveStateService
|
|
472
|
+
* @description Saves the grouping state, if the grouping feature is enabled
|
|
473
|
+
* @param {Grid} grid the grid whose state we'd like to save
|
|
474
|
+
* @returns {object} the grouping state ready to be saved
|
|
475
|
+
*/
|
|
476
|
+
saveGrouping: function( grid ) {
|
|
477
|
+
if ( !grid.api.grouping || !grid.options.saveGrouping ) {
|
|
478
|
+
return {};
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
return grid.api.grouping.getGrouping( grid.options.saveGroupingExpandedStates );
|
|
482
|
+
},
|
|
483
|
+
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* @ngdoc function
|
|
487
|
+
* @name savePagination
|
|
488
|
+
* @methodOf ui.grid.saveState.service:uiGridSaveStateService
|
|
489
|
+
* @description Saves the pagination state, if the pagination feature is enabled
|
|
490
|
+
* @param {Grid} grid the grid whose state we'd like to save
|
|
491
|
+
* @returns {object} the pagination state ready to be saved
|
|
492
|
+
*/
|
|
493
|
+
savePagination: function( grid ) {
|
|
494
|
+
if ( !grid.api.pagination || !grid.options.paginationPageSize ) {
|
|
495
|
+
return {};
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
return {
|
|
499
|
+
paginationCurrentPage: grid.options.paginationCurrentPage,
|
|
500
|
+
paginationPageSize: grid.options.paginationPageSize
|
|
501
|
+
};
|
|
502
|
+
},
|
|
503
|
+
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* @ngdoc function
|
|
507
|
+
* @name saveTreeView
|
|
508
|
+
* @methodOf ui.grid.saveState.service:uiGridSaveStateService
|
|
509
|
+
* @description Saves the tree view state, if the tree feature is enabled
|
|
510
|
+
* @param {Grid} grid the grid whose state we'd like to save
|
|
511
|
+
* @returns {object} the tree view state ready to be saved
|
|
512
|
+
*/
|
|
513
|
+
saveTreeView: function( grid ) {
|
|
514
|
+
if ( !grid.api.treeView || !grid.options.saveTreeView ) {
|
|
515
|
+
return {};
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
return grid.api.treeView.getTreeView();
|
|
519
|
+
},
|
|
520
|
+
|
|
521
|
+
|
|
522
|
+
/**
|
|
523
|
+
* @ngdoc function
|
|
524
|
+
* @name getRowVal
|
|
525
|
+
* @methodOf ui.grid.saveState.service:uiGridSaveStateService
|
|
526
|
+
* @description Helper function that gets either the rowNum or
|
|
527
|
+
* the saveRowIdentity, given a gridRow
|
|
528
|
+
* @param {Grid} grid the grid the row is in
|
|
529
|
+
* @param {GridRow} gridRow the row we want the rowNum for
|
|
530
|
+
* @returns {object} an object containing { identity: true/false, row: rowNumber/rowIdentity }
|
|
531
|
+
*
|
|
532
|
+
*/
|
|
533
|
+
getRowVal: function( grid, gridRow ) {
|
|
534
|
+
if ( !gridRow ) {
|
|
535
|
+
return null;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
var rowVal = {};
|
|
539
|
+
if ( grid.options.saveRowIdentity ) {
|
|
540
|
+
rowVal.identity = true;
|
|
541
|
+
rowVal.row = grid.options.saveRowIdentity( gridRow.entity );
|
|
542
|
+
}
|
|
543
|
+
else {
|
|
544
|
+
rowVal.identity = false;
|
|
545
|
+
rowVal.row = grid.renderContainers.body.visibleRowCache.indexOf( gridRow );
|
|
546
|
+
}
|
|
547
|
+
return rowVal;
|
|
548
|
+
},
|
|
549
|
+
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* @ngdoc function
|
|
553
|
+
* @name restoreColumns
|
|
554
|
+
* @methodOf ui.grid.saveState.service:uiGridSaveStateService
|
|
555
|
+
* @description Restores the columns, including order, visible, width,
|
|
556
|
+
* pinning, sort and filters.
|
|
557
|
+
*
|
|
558
|
+
* @param {Grid} grid the grid whose state we'd like to restore
|
|
559
|
+
* @param {object} columnsState the list of columns we had before, with their state
|
|
560
|
+
*/
|
|
561
|
+
restoreColumns: function( grid, columnsState ) {
|
|
562
|
+
var isSortChanged = false;
|
|
563
|
+
|
|
564
|
+
columnsState.forEach( function( columnState, index ) {
|
|
565
|
+
var currentCol = grid.getColumn( columnState.name );
|
|
566
|
+
|
|
567
|
+
if ( currentCol && !grid.isRowHeaderColumn(currentCol) ) {
|
|
568
|
+
if ( grid.options.saveVisible &&
|
|
569
|
+
( currentCol.visible !== columnState.visible ||
|
|
570
|
+
currentCol.colDef.visible !== columnState.visible ) ) {
|
|
571
|
+
currentCol.visible = columnState.visible;
|
|
572
|
+
currentCol.colDef.visible = columnState.visible;
|
|
573
|
+
grid.api.core.raise.columnVisibilityChanged(currentCol);
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
if ( grid.options.saveWidths && currentCol.width !== columnState.width) {
|
|
577
|
+
currentCol.width = columnState.width;
|
|
578
|
+
currentCol.hasCustomWidth = true;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
if ( grid.options.saveSort &&
|
|
582
|
+
!angular.equals(currentCol.sort, columnState.sort) &&
|
|
583
|
+
!( currentCol.sort === undefined && angular.isEmpty(columnState.sort) ) ) {
|
|
584
|
+
currentCol.sort = angular.copy( columnState.sort );
|
|
585
|
+
isSortChanged = true;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
if ( grid.options.saveFilter &&
|
|
589
|
+
!angular.equals(currentCol.filters, columnState.filters ) ) {
|
|
590
|
+
columnState.filters.forEach( function( filter, index ) {
|
|
591
|
+
angular.extend( currentCol.filters[index], filter );
|
|
592
|
+
if ( typeof(filter.term) === 'undefined' || filter.term === null ) {
|
|
593
|
+
delete currentCol.filters[index].term;
|
|
594
|
+
}
|
|
595
|
+
});
|
|
596
|
+
grid.api.core.raise.filterChanged( currentCol );
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
if ( !!grid.api.pinning && grid.options.savePinning && currentCol.renderContainer !== columnState.pinned ) {
|
|
600
|
+
grid.api.pinning.pinColumn(currentCol, columnState.pinned);
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
var currentIndex = grid.getOnlyDataColumns().indexOf( currentCol );
|
|
604
|
+
if (currentIndex !== -1) {
|
|
605
|
+
if (grid.options.saveOrder && currentIndex !== index) {
|
|
606
|
+
var column = grid.columns.splice(currentIndex + grid.rowHeaderColumns.length, 1)[0];
|
|
607
|
+
grid.columns.splice(index + grid.rowHeaderColumns.length, 0, column);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
});
|
|
612
|
+
|
|
613
|
+
if ( isSortChanged ) {
|
|
614
|
+
grid.api.core.raise.sortChanged( grid, grid.getColumnSorting() );
|
|
615
|
+
}
|
|
616
|
+
},
|
|
617
|
+
|
|
618
|
+
|
|
619
|
+
/**
|
|
620
|
+
* @ngdoc function
|
|
621
|
+
* @name restoreScrollFocus
|
|
622
|
+
* @methodOf ui.grid.saveState.service:uiGridSaveStateService
|
|
623
|
+
* @description Scrolls to the position that was saved. If focus is true, then
|
|
624
|
+
* sets focus to the specified row/col. If focus is false, then scrolls to the
|
|
625
|
+
* specified row/col.
|
|
626
|
+
*
|
|
627
|
+
* @param {Grid} grid the grid whose state we'd like to restore
|
|
628
|
+
* @param {scope} $scope a scope that we can broadcast on
|
|
629
|
+
* @param {object} scrollFocusState the scroll/focus state ready to be restored
|
|
630
|
+
*/
|
|
631
|
+
restoreScrollFocus: function( grid, $scope, scrollFocusState ) {
|
|
632
|
+
if ( !grid.api.cellNav ) {
|
|
633
|
+
return;
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
var colDef, row;
|
|
637
|
+
if ( scrollFocusState.colName ) {
|
|
638
|
+
var colDefs = grid.options.columnDefs.filter( function( colDef ) { return colDef.name === scrollFocusState.colName; });
|
|
639
|
+
if ( colDefs.length > 0 ) {
|
|
640
|
+
colDef = colDefs[0];
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
if ( scrollFocusState.rowVal && scrollFocusState.rowVal.row ) {
|
|
645
|
+
if ( scrollFocusState.rowVal.identity ) {
|
|
646
|
+
row = service.findRowByIdentity( grid, scrollFocusState.rowVal );
|
|
647
|
+
}
|
|
648
|
+
else {
|
|
649
|
+
row = grid.renderContainers.body.visibleRowCache[ scrollFocusState.rowVal.row ];
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
var entity = row && row.entity ? row.entity : null ;
|
|
654
|
+
|
|
655
|
+
if ( colDef || entity ) {
|
|
656
|
+
if (scrollFocusState.focus ) {
|
|
657
|
+
grid.api.cellNav.scrollToFocus( entity, colDef );
|
|
658
|
+
}
|
|
659
|
+
else {
|
|
660
|
+
grid.scrollTo( entity, colDef );
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
},
|
|
664
|
+
|
|
665
|
+
|
|
666
|
+
/**
|
|
667
|
+
* @ngdoc function
|
|
668
|
+
* @name restoreSelection
|
|
669
|
+
* @methodOf ui.grid.saveState.service:uiGridSaveStateService
|
|
670
|
+
* @description Selects the rows that are provided in the selection
|
|
671
|
+
* state. If you are using `saveRowIdentity` and more than one row matches the identity
|
|
672
|
+
* function then only the first is selected.
|
|
673
|
+
* @param {Grid} grid the grid whose state we'd like to restore
|
|
674
|
+
* @param {object} selectionState the selection state ready to be restored
|
|
675
|
+
*/
|
|
676
|
+
restoreSelection: function( grid, selectionState ) {
|
|
677
|
+
if ( !grid.api.selection ) {
|
|
678
|
+
return;
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
grid.api.selection.clearSelectedRows();
|
|
682
|
+
|
|
683
|
+
selectionState.forEach(function( rowVal ) {
|
|
684
|
+
if ( rowVal.identity ) {
|
|
685
|
+
var foundRow = service.findRowByIdentity( grid, rowVal );
|
|
686
|
+
|
|
687
|
+
if ( foundRow ) {
|
|
688
|
+
grid.api.selection.selectRow( foundRow.entity );
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
}
|
|
692
|
+
else {
|
|
693
|
+
grid.api.selection.selectRowByVisibleIndex( rowVal.row );
|
|
694
|
+
}
|
|
695
|
+
});
|
|
696
|
+
},
|
|
697
|
+
|
|
698
|
+
|
|
699
|
+
/**
|
|
700
|
+
* @ngdoc function
|
|
701
|
+
* @name restoreGrouping
|
|
702
|
+
* @methodOf ui.grid.saveState.service:uiGridSaveStateService
|
|
703
|
+
* @description Restores the grouping configuration, if the grouping feature
|
|
704
|
+
* is enabled.
|
|
705
|
+
* @param {Grid} grid the grid whose state we'd like to restore
|
|
706
|
+
* @param {object} groupingState the grouping state ready to be restored
|
|
707
|
+
*/
|
|
708
|
+
restoreGrouping: function( grid, groupingState ) {
|
|
709
|
+
if ( !grid.api.grouping || typeof(groupingState) === 'undefined' || groupingState === null || angular.equals(groupingState, {}) ) {
|
|
710
|
+
return;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
grid.api.grouping.setGrouping( groupingState );
|
|
714
|
+
},
|
|
715
|
+
|
|
716
|
+
/**
|
|
717
|
+
* @ngdoc function
|
|
718
|
+
* @name restoreTreeView
|
|
719
|
+
* @methodOf ui.grid.saveState.service:uiGridSaveStateService
|
|
720
|
+
* @description Restores the tree view configuration, if the tree view feature
|
|
721
|
+
* is enabled.
|
|
722
|
+
* @param {Grid} grid the grid whose state we'd like to restore
|
|
723
|
+
* @param {object} treeViewState the tree view state ready to be restored
|
|
724
|
+
*/
|
|
725
|
+
restoreTreeView: function( grid, treeViewState ) {
|
|
726
|
+
if ( !grid.api.treeView || typeof(treeViewState) === 'undefined' || treeViewState === null || angular.equals(treeViewState, {}) ) {
|
|
727
|
+
return;
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
grid.api.treeView.setTreeView( treeViewState );
|
|
731
|
+
},
|
|
732
|
+
|
|
733
|
+
/**
|
|
734
|
+
* @ngdoc function
|
|
735
|
+
* @name restorePagination
|
|
736
|
+
* @methodOf ui.grid.saveState.service:uiGridSaveStateService
|
|
737
|
+
* @description Restores the pagination information, if pagination is enabled.
|
|
738
|
+
* @param {Grid} grid the grid whose state we'd like to restore
|
|
739
|
+
* @param {object} pagination the pagination object to be restored
|
|
740
|
+
* @param {number} pagination.paginationCurrentPage the page number to restore
|
|
741
|
+
* @param {number} pagination.paginationPageSize the number of items displayed per page
|
|
742
|
+
*/
|
|
743
|
+
restorePagination: function( grid, pagination ) {
|
|
744
|
+
if ( !grid.api.pagination || !grid.options.paginationPageSize ) {
|
|
745
|
+
return;
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
grid.options.paginationCurrentPage = pagination.paginationCurrentPage;
|
|
749
|
+
grid.options.paginationPageSize = pagination.paginationPageSize;
|
|
750
|
+
},
|
|
751
|
+
|
|
752
|
+
/**
|
|
753
|
+
* @ngdoc function
|
|
754
|
+
* @name findRowByIdentity
|
|
755
|
+
* @methodOf ui.grid.saveState.service:uiGridSaveStateService
|
|
756
|
+
* @description Finds a row given it's identity value, returns the first found row
|
|
757
|
+
* if any are found, otherwise returns null if no rows are found.
|
|
758
|
+
* @param {Grid} grid the grid whose state we'd like to restore
|
|
759
|
+
* @param {object} rowVal the row we'd like to find
|
|
760
|
+
* @returns {gridRow} the found row, or null if none found
|
|
761
|
+
*/
|
|
762
|
+
findRowByIdentity: function( grid, rowVal ) {
|
|
763
|
+
if ( !grid.options.saveRowIdentity ) {
|
|
764
|
+
return null;
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
var filteredRows = grid.rows.filter( function( gridRow ) {
|
|
768
|
+
return ( grid.options.saveRowIdentity( gridRow.entity ) === rowVal.row );
|
|
769
|
+
});
|
|
770
|
+
|
|
771
|
+
if ( filteredRows.length > 0 ) {
|
|
772
|
+
return filteredRows[0];
|
|
773
|
+
} else {
|
|
774
|
+
return null;
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
};
|
|
778
|
+
|
|
779
|
+
return service;
|
|
780
|
+
}
|
|
781
|
+
);
|
|
782
|
+
|
|
783
|
+
/**
|
|
784
|
+
* @ngdoc directive
|
|
785
|
+
* @name ui.grid.saveState.directive:uiGridSaveState
|
|
786
|
+
* @element div
|
|
787
|
+
* @restrict A
|
|
788
|
+
*
|
|
789
|
+
* @description Adds saveState features to grid
|
|
790
|
+
*
|
|
791
|
+
* @example
|
|
792
|
+
<example module="app">
|
|
793
|
+
<file name="app.js">
|
|
794
|
+
var app = angular.module('app', ['ui.grid', 'ui.grid.saveState']);
|
|
795
|
+
|
|
796
|
+
app.controller('MainCtrl', ['$scope', function ($scope) {
|
|
797
|
+
$scope.data = [
|
|
798
|
+
{ name: 'Bob', title: 'CEO' },
|
|
799
|
+
{ name: 'Frank', title: 'Lowly Developer' }
|
|
800
|
+
];
|
|
801
|
+
|
|
802
|
+
$scope.gridOptions = {
|
|
803
|
+
columnDefs: [
|
|
804
|
+
{name: 'name'},
|
|
805
|
+
{name: 'title', enableCellEdit: true}
|
|
806
|
+
],
|
|
807
|
+
data: $scope.data
|
|
808
|
+
};
|
|
809
|
+
}]);
|
|
810
|
+
</file>
|
|
811
|
+
<file name="index.html">
|
|
812
|
+
<div ng-controller="MainCtrl">
|
|
813
|
+
<div ui-grid="gridOptions" ui-grid-save-state></div>
|
|
814
|
+
</div>
|
|
815
|
+
</file>
|
|
816
|
+
</example>
|
|
817
|
+
*/
|
|
818
|
+
module.directive('uiGridSaveState', ['uiGridSaveStateConstants', 'uiGridSaveStateService', 'gridUtil', '$compile',
|
|
819
|
+
function (uiGridSaveStateConstants, uiGridSaveStateService, gridUtil, $compile) {
|
|
820
|
+
return {
|
|
821
|
+
replace: true,
|
|
822
|
+
priority: 0,
|
|
823
|
+
require: '^uiGrid',
|
|
824
|
+
scope: false,
|
|
825
|
+
link: function ($scope, $elm, $attrs, uiGridCtrl) {
|
|
826
|
+
uiGridSaveStateService.initializeGrid(uiGridCtrl.grid);
|
|
827
|
+
}
|
|
828
|
+
};
|
|
829
|
+
}
|
|
830
|
+
]);
|
|
831
|
+
})();
|