@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,1325 @@
|
|
|
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.edit
|
|
13
|
+
* @description
|
|
14
|
+
*
|
|
15
|
+
* # ui.grid.edit
|
|
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 cell editing capability to ui.grid. The goal was to emulate keying data in a spreadsheet via
|
|
20
|
+
* a keyboard.
|
|
21
|
+
* <br/>
|
|
22
|
+
* <br/>
|
|
23
|
+
* To really get the full spreadsheet-like data entry, the ui.grid.cellNav module should be used. This will allow the
|
|
24
|
+
* user to key data and then tab, arrow, or enter to the cells beside or below.
|
|
25
|
+
*
|
|
26
|
+
* <div doc-module-components="ui.grid.edit"></div>
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
var module = angular.module('ui.grid.edit', ['ui.grid']);
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @ngdoc object
|
|
33
|
+
* @name ui.grid.edit.constant:uiGridEditConstants
|
|
34
|
+
*
|
|
35
|
+
* @description constants available in edit module
|
|
36
|
+
*/
|
|
37
|
+
module.constant('uiGridEditConstants', {
|
|
38
|
+
EDITABLE_CELL_TEMPLATE: /EDITABLE_CELL_TEMPLATE/g,
|
|
39
|
+
// must be lowercase because template bulder converts to lower
|
|
40
|
+
EDITABLE_CELL_DIRECTIVE: /editable_cell_directive/g,
|
|
41
|
+
events: {
|
|
42
|
+
BEGIN_CELL_EDIT: 'uiGridEventBeginCellEdit',
|
|
43
|
+
END_CELL_EDIT: 'uiGridEventEndCellEdit',
|
|
44
|
+
CANCEL_CELL_EDIT: 'uiGridEventCancelCellEdit'
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @ngdoc service
|
|
50
|
+
* @name ui.grid.edit.service:uiGridEditService
|
|
51
|
+
*
|
|
52
|
+
* @description Services for editing features
|
|
53
|
+
*/
|
|
54
|
+
module.service('uiGridEditService', ['$q', 'uiGridConstants', 'gridUtil',
|
|
55
|
+
function ($q, uiGridConstants, gridUtil) {
|
|
56
|
+
|
|
57
|
+
var service = {
|
|
58
|
+
|
|
59
|
+
initializeGrid: function (grid) {
|
|
60
|
+
|
|
61
|
+
service.defaultGridOptions(grid.options);
|
|
62
|
+
|
|
63
|
+
grid.registerColumnBuilder(service.editColumnBuilder);
|
|
64
|
+
grid.edit = {};
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @ngdoc object
|
|
68
|
+
* @name ui.grid.edit.api:PublicApi
|
|
69
|
+
*
|
|
70
|
+
* @description Public Api for edit feature
|
|
71
|
+
*/
|
|
72
|
+
var publicApi = {
|
|
73
|
+
events: {
|
|
74
|
+
edit: {
|
|
75
|
+
/**
|
|
76
|
+
* @ngdoc event
|
|
77
|
+
* @name afterCellEdit
|
|
78
|
+
* @eventOf ui.grid.edit.api:PublicApi
|
|
79
|
+
* @description raised when cell editing is complete
|
|
80
|
+
* <pre>
|
|
81
|
+
* gridApi.edit.on.afterCellEdit(scope,function(rowEntity, colDef) {})
|
|
82
|
+
* </pre>
|
|
83
|
+
* @param {object} rowEntity the options.data element that was edited
|
|
84
|
+
* @param {object} colDef the column that was edited
|
|
85
|
+
* @param {object} newValue new value
|
|
86
|
+
* @param {object} oldValue old value
|
|
87
|
+
*/
|
|
88
|
+
afterCellEdit: function (rowEntity, colDef, newValue, oldValue) {
|
|
89
|
+
},
|
|
90
|
+
/**
|
|
91
|
+
* @ngdoc event
|
|
92
|
+
* @name beginCellEdit
|
|
93
|
+
* @eventOf ui.grid.edit.api:PublicApi
|
|
94
|
+
* @description raised when cell editing starts on a cell
|
|
95
|
+
* <pre>
|
|
96
|
+
* gridApi.edit.on.beginCellEdit(scope,function(rowEntity, colDef) {})
|
|
97
|
+
* </pre>
|
|
98
|
+
* @param {object} rowEntity the options.data element that was edited
|
|
99
|
+
* @param {object} colDef the column that was edited
|
|
100
|
+
* @param {object} triggerEvent the event that triggered the edit. Useful to prevent losing keystrokes on some
|
|
101
|
+
* complex editors
|
|
102
|
+
*/
|
|
103
|
+
beginCellEdit: function (rowEntity, colDef, triggerEvent) {
|
|
104
|
+
},
|
|
105
|
+
/**
|
|
106
|
+
* @ngdoc event
|
|
107
|
+
* @name cancelCellEdit
|
|
108
|
+
* @eventOf ui.grid.edit.api:PublicApi
|
|
109
|
+
* @description raised when cell editing is cancelled on a cell
|
|
110
|
+
* <pre>
|
|
111
|
+
* gridApi.edit.on.cancelCellEdit(scope,function(rowEntity, colDef) {})
|
|
112
|
+
* </pre>
|
|
113
|
+
* @param {object} rowEntity the options.data element that was edited
|
|
114
|
+
* @param {object} colDef the column that was edited
|
|
115
|
+
*/
|
|
116
|
+
cancelCellEdit: function (rowEntity, colDef) {
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
methods: {
|
|
121
|
+
edit: { }
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
grid.api.registerEventsFromObject(publicApi.events);
|
|
126
|
+
// grid.api.registerMethodsFromObject(publicApi.methods);
|
|
127
|
+
},
|
|
128
|
+
|
|
129
|
+
defaultGridOptions: function (gridOptions) {
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* @ngdoc object
|
|
133
|
+
* @name ui.grid.edit.api:GridOptions
|
|
134
|
+
*
|
|
135
|
+
* @description Options for configuring the edit feature, these are available to be
|
|
136
|
+
* set using the ui-grid {@link ui.grid.class:GridOptions gridOptions}
|
|
137
|
+
*/
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* @ngdoc object
|
|
141
|
+
* @name enableCellEdit
|
|
142
|
+
* @propertyOf ui.grid.edit.api:GridOptions
|
|
143
|
+
* @description If defined, sets the default value for the editable flag on each individual colDefs
|
|
144
|
+
* if their individual enableCellEdit configuration is not defined. Defaults to undefined.
|
|
145
|
+
*/
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* @ngdoc object
|
|
149
|
+
* @name cellEditableCondition
|
|
150
|
+
* @propertyOf ui.grid.edit.api:GridOptions
|
|
151
|
+
* @description If specified, either a value or function to be used by all columns before editing.
|
|
152
|
+
* If false, then editing of cell is not allowed.
|
|
153
|
+
* @example
|
|
154
|
+
* <pre>
|
|
155
|
+
* function($scope, triggerEvent) {
|
|
156
|
+
* //use $scope.row.entity, $scope.col.colDef and triggerEvent to determine if editing is allowed
|
|
157
|
+
* return true;
|
|
158
|
+
* }
|
|
159
|
+
* </pre>
|
|
160
|
+
*/
|
|
161
|
+
gridOptions.cellEditableCondition = gridOptions.cellEditableCondition === undefined ? true : gridOptions.cellEditableCondition;
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* @ngdoc object
|
|
165
|
+
* @name editableCellTemplate
|
|
166
|
+
* @propertyOf ui.grid.edit.api:GridOptions
|
|
167
|
+
* @description If specified, cellTemplate to use as the editor for all columns.
|
|
168
|
+
* <br/> defaults to 'ui-grid/cellTextEditor'
|
|
169
|
+
*/
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* @ngdoc object
|
|
173
|
+
* @name enableCellEditOnFocus
|
|
174
|
+
* @propertyOf ui.grid.edit.api:GridOptions
|
|
175
|
+
* @description If true, then editor is invoked as soon as cell receives focus. Default false.
|
|
176
|
+
* <br/>_requires cellNav feature and the edit feature to be enabled_
|
|
177
|
+
*/
|
|
178
|
+
// enableCellEditOnFocus can only be used if cellnav module is used
|
|
179
|
+
gridOptions.enableCellEditOnFocus = gridOptions.enableCellEditOnFocus === undefined ? false : gridOptions.enableCellEditOnFocus;
|
|
180
|
+
},
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* @ngdoc service
|
|
184
|
+
* @name editColumnBuilder
|
|
185
|
+
* @methodOf ui.grid.edit.service:uiGridEditService
|
|
186
|
+
* @description columnBuilder function that adds edit properties to grid column
|
|
187
|
+
* @returns {promise} promise that will load any needed templates when resolved
|
|
188
|
+
*/
|
|
189
|
+
editColumnBuilder: function (colDef, col, gridOptions) {
|
|
190
|
+
|
|
191
|
+
var promises = [];
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* @ngdoc object
|
|
195
|
+
* @name ui.grid.edit.api:ColumnDef
|
|
196
|
+
*
|
|
197
|
+
* @description Column Definition for edit feature, these are available to be
|
|
198
|
+
* set using the ui-grid {@link ui.grid.class:GridOptions.columnDef gridOptions.columnDefs}
|
|
199
|
+
*/
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* @ngdoc object
|
|
203
|
+
* @name enableCellEdit
|
|
204
|
+
* @propertyOf ui.grid.edit.api:ColumnDef
|
|
205
|
+
* @description enable editing on column
|
|
206
|
+
*/
|
|
207
|
+
colDef.enableCellEdit = colDef.enableCellEdit === undefined ? (gridOptions.enableCellEdit === undefined ?
|
|
208
|
+
(colDef.type !== 'object') : gridOptions.enableCellEdit) : colDef.enableCellEdit;
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* @ngdoc object
|
|
212
|
+
* @name cellEditableCondition
|
|
213
|
+
* @propertyOf ui.grid.edit.api:ColumnDef
|
|
214
|
+
* @description If specified, either a value or function evaluated before editing cell. If falsy, then editing of cell is not allowed.
|
|
215
|
+
* @example
|
|
216
|
+
* <pre>
|
|
217
|
+
* function($scope, triggerEvent) {
|
|
218
|
+
* //use $scope.row.entity, $scope.col.colDef and triggerEvent to determine if editing is allowed
|
|
219
|
+
* return true;
|
|
220
|
+
* }
|
|
221
|
+
* </pre>
|
|
222
|
+
*/
|
|
223
|
+
colDef.cellEditableCondition = colDef.cellEditableCondition === undefined ? gridOptions.cellEditableCondition : colDef.cellEditableCondition;
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* @ngdoc object
|
|
227
|
+
* @name editableCellTemplate
|
|
228
|
+
* @propertyOf ui.grid.edit.api:ColumnDef
|
|
229
|
+
* @description cell template to be used when editing this column. Can be Url or text template
|
|
230
|
+
* <br/>Defaults to gridOptions.editableCellTemplate
|
|
231
|
+
*/
|
|
232
|
+
if (colDef.enableCellEdit) {
|
|
233
|
+
colDef.editableCellTemplate = colDef.editableCellTemplate || gridOptions.editableCellTemplate || 'ui-grid/cellEditor';
|
|
234
|
+
|
|
235
|
+
promises.push(gridUtil.getTemplate(colDef.editableCellTemplate)
|
|
236
|
+
.then(
|
|
237
|
+
function (template) {
|
|
238
|
+
col.editableCellTemplate = template;
|
|
239
|
+
},
|
|
240
|
+
function (res) {
|
|
241
|
+
// Todo handle response error here?
|
|
242
|
+
throw new Error("Couldn't fetch/use colDef.editableCellTemplate '" + colDef.editableCellTemplate + "'");
|
|
243
|
+
}));
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* @ngdoc object
|
|
248
|
+
* @name enableCellEditOnFocus
|
|
249
|
+
* @propertyOf ui.grid.edit.api:ColumnDef
|
|
250
|
+
* @requires ui.grid.cellNav
|
|
251
|
+
* @description If true, then editor is invoked as soon as cell receives focus. Default false.
|
|
252
|
+
* <br>_requires both the cellNav feature and the edit feature to be enabled_
|
|
253
|
+
*/
|
|
254
|
+
// enableCellEditOnFocus can only be used if cellnav module is used
|
|
255
|
+
colDef.enableCellEditOnFocus = colDef.enableCellEditOnFocus === undefined ? gridOptions.enableCellEditOnFocus : colDef.enableCellEditOnFocus;
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* @ngdoc string
|
|
260
|
+
* @name editModelField
|
|
261
|
+
* @propertyOf ui.grid.edit.api:ColumnDef
|
|
262
|
+
* @description a bindable string value that is used when binding to edit controls instead of colDef.field
|
|
263
|
+
* <br/> example: You have a complex property on and object like state:{abbrev: 'MS',name: 'Mississippi'}. The
|
|
264
|
+
* grid should display state.name in the cell and sort/filter based on the state.name property but the editor
|
|
265
|
+
* requires the full state object.
|
|
266
|
+
* <br/>colDef.field = 'state.name'
|
|
267
|
+
* <br/>colDef.editModelField = 'state'
|
|
268
|
+
*/
|
|
269
|
+
// colDef.editModelField
|
|
270
|
+
|
|
271
|
+
return $q.all(promises);
|
|
272
|
+
},
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* @ngdoc service
|
|
276
|
+
* @name isStartEditKey
|
|
277
|
+
* @methodOf ui.grid.edit.service:uiGridEditService
|
|
278
|
+
* @description Determines if a keypress should start editing. Decorate this service to override with your
|
|
279
|
+
* own key events. See service decorator in angular docs.
|
|
280
|
+
* @param {Event} evt keydown event
|
|
281
|
+
* @returns {boolean} true if an edit should start
|
|
282
|
+
*/
|
|
283
|
+
isStartEditKey: function (evt) {
|
|
284
|
+
return !(evt.metaKey ||
|
|
285
|
+
evt.keyCode === uiGridConstants.keymap.ESC ||
|
|
286
|
+
evt.keyCode === uiGridConstants.keymap.SHIFT ||
|
|
287
|
+
evt.keyCode === uiGridConstants.keymap.CTRL ||
|
|
288
|
+
evt.keyCode === uiGridConstants.keymap.ALT ||
|
|
289
|
+
evt.keyCode === uiGridConstants.keymap.WIN ||
|
|
290
|
+
evt.keyCode === uiGridConstants.keymap.CAPSLOCK ||
|
|
291
|
+
|
|
292
|
+
evt.keyCode === uiGridConstants.keymap.LEFT ||
|
|
293
|
+
(evt.keyCode === uiGridConstants.keymap.TAB && evt.shiftKey) ||
|
|
294
|
+
|
|
295
|
+
evt.keyCode === uiGridConstants.keymap.RIGHT ||
|
|
296
|
+
evt.keyCode === uiGridConstants.keymap.TAB ||
|
|
297
|
+
|
|
298
|
+
evt.keyCode === uiGridConstants.keymap.UP ||
|
|
299
|
+
(evt.keyCode === uiGridConstants.keymap.ENTER && evt.shiftKey) ||
|
|
300
|
+
|
|
301
|
+
evt.keyCode === uiGridConstants.keymap.DOWN ||
|
|
302
|
+
evt.keyCode === uiGridConstants.keymap.ENTER);
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
return service;
|
|
307
|
+
|
|
308
|
+
}]);
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* @ngdoc directive
|
|
312
|
+
* @name ui.grid.edit.directive:uiGridEdit
|
|
313
|
+
* @element div
|
|
314
|
+
* @restrict A
|
|
315
|
+
*
|
|
316
|
+
* @description Adds editing features to the ui-grid directive.
|
|
317
|
+
*
|
|
318
|
+
* @example
|
|
319
|
+
<example module="app">
|
|
320
|
+
<file name="app.js">
|
|
321
|
+
var app = angular.module('app', ['ui.grid', 'ui.grid.edit']);
|
|
322
|
+
|
|
323
|
+
app.controller('MainCtrl', ['$scope', function ($scope) {
|
|
324
|
+
$scope.data = [
|
|
325
|
+
{ name: 'Bob', title: 'CEO' },
|
|
326
|
+
{ name: 'Frank', title: 'Lowly Developer' }
|
|
327
|
+
];
|
|
328
|
+
|
|
329
|
+
$scope.columnDefs = [
|
|
330
|
+
{name: 'name', enableCellEdit: true},
|
|
331
|
+
{name: 'title', enableCellEdit: true}
|
|
332
|
+
];
|
|
333
|
+
}]);
|
|
334
|
+
</file>
|
|
335
|
+
<file name="index.html">
|
|
336
|
+
<div ng-controller="MainCtrl">
|
|
337
|
+
<div ui-grid="{ data: data, columnDefs: columnDefs }" ui-grid-edit></div>
|
|
338
|
+
</div>
|
|
339
|
+
</file>
|
|
340
|
+
</example>
|
|
341
|
+
*/
|
|
342
|
+
module.directive('uiGridEdit', ['gridUtil', 'uiGridEditService', function (gridUtil, uiGridEditService) {
|
|
343
|
+
return {
|
|
344
|
+
replace: true,
|
|
345
|
+
priority: 0,
|
|
346
|
+
require: '^uiGrid',
|
|
347
|
+
scope: false,
|
|
348
|
+
compile: function () {
|
|
349
|
+
return {
|
|
350
|
+
pre: function ($scope, $elm, $attrs, uiGridCtrl) {
|
|
351
|
+
uiGridEditService.initializeGrid(uiGridCtrl.grid);
|
|
352
|
+
},
|
|
353
|
+
post: function ($scope, $elm, $attrs, uiGridCtrl) {
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
}]);
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* @ngdoc directive
|
|
362
|
+
* @name ui.grid.edit.directive:uiGridRenderContainer
|
|
363
|
+
* @element div
|
|
364
|
+
* @restrict A
|
|
365
|
+
*
|
|
366
|
+
* @description Adds keydown listeners to renderContainer element so we can capture when to begin edits
|
|
367
|
+
*
|
|
368
|
+
*/
|
|
369
|
+
module.directive('uiGridViewport', [ 'uiGridEditConstants',
|
|
370
|
+
function ( uiGridEditConstants) {
|
|
371
|
+
return {
|
|
372
|
+
replace: true,
|
|
373
|
+
priority: -99998, // run before cellNav
|
|
374
|
+
require: ['^uiGrid', '^uiGridRenderContainer'],
|
|
375
|
+
scope: false,
|
|
376
|
+
compile: function () {
|
|
377
|
+
return {
|
|
378
|
+
post: function ($scope, $elm, $attrs, controllers) {
|
|
379
|
+
var uiGridCtrl = controllers[0];
|
|
380
|
+
|
|
381
|
+
// Skip attaching if edit and cellNav is not enabled
|
|
382
|
+
if (!uiGridCtrl.grid.api.edit || !uiGridCtrl.grid.api.cellNav) { return; }
|
|
383
|
+
|
|
384
|
+
var containerId = controllers[1].containerId;
|
|
385
|
+
// no need to process for other containers
|
|
386
|
+
if (containerId !== 'body') {
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// refocus on the grid
|
|
391
|
+
$scope.$on(uiGridEditConstants.events.CANCEL_CELL_EDIT, function () {
|
|
392
|
+
uiGridCtrl.focus();
|
|
393
|
+
});
|
|
394
|
+
$scope.$on(uiGridEditConstants.events.END_CELL_EDIT, function () {
|
|
395
|
+
uiGridCtrl.focus();
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
}]);
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* @ngdoc directive
|
|
405
|
+
* @name ui.grid.edit.directive:uiGridCell
|
|
406
|
+
* @element div
|
|
407
|
+
* @restrict A
|
|
408
|
+
*
|
|
409
|
+
* @description Stacks on top of ui.grid.uiGridCell to provide in-line editing capabilities to the cell
|
|
410
|
+
* Editing Actions.
|
|
411
|
+
*
|
|
412
|
+
* Binds edit start events to the uiGridCell element. When the events fire, the gridCell element is appended
|
|
413
|
+
* with the columnDef.editableCellTemplate element ('cellEditor.html' by default).
|
|
414
|
+
*
|
|
415
|
+
* The editableCellTemplate should respond to uiGridEditConstants.events.BEGIN\_CELL\_EDIT angular event
|
|
416
|
+
* and do the initial steps needed to edit the cell (setfocus on input element, etc).
|
|
417
|
+
*
|
|
418
|
+
* When the editableCellTemplate recognizes that the editing is ended (blur event, Enter key, etc.)
|
|
419
|
+
* it should emit the uiGridEditConstants.events.END\_CELL\_EDIT event.
|
|
420
|
+
*
|
|
421
|
+
* If editableCellTemplate recognizes that the editing has been cancelled (esc key)
|
|
422
|
+
* it should emit the uiGridEditConstants.events.CANCEL\_CELL\_EDIT event. The original value
|
|
423
|
+
* will be set back on the model by the uiGridCell directive.
|
|
424
|
+
*
|
|
425
|
+
* Events that invoke editing:
|
|
426
|
+
* - dblclick
|
|
427
|
+
* - F2 keydown (when using cell selection)
|
|
428
|
+
*
|
|
429
|
+
* Events that end editing:
|
|
430
|
+
* - Dependent on the specific editableCellTemplate
|
|
431
|
+
* - Standards should be blur and enter keydown
|
|
432
|
+
*
|
|
433
|
+
* Events that cancel editing:
|
|
434
|
+
* - Dependent on the specific editableCellTemplate
|
|
435
|
+
* - Standards should be Esc keydown
|
|
436
|
+
*
|
|
437
|
+
* Grid Events that end editing:
|
|
438
|
+
* - uiGridConstants.events.GRID_SCROLL
|
|
439
|
+
*
|
|
440
|
+
*/
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* @ngdoc object
|
|
444
|
+
* @name ui.grid.edit.api:GridRow
|
|
445
|
+
*
|
|
446
|
+
* @description GridRow options for edit feature, these are available to be
|
|
447
|
+
* set internally only, by other features
|
|
448
|
+
*/
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* @ngdoc object
|
|
452
|
+
* @name enableCellEdit
|
|
453
|
+
* @propertyOf ui.grid.edit.api:GridRow
|
|
454
|
+
* @description enable editing on row, grouping for example might disable editing on group header rows
|
|
455
|
+
*/
|
|
456
|
+
|
|
457
|
+
module.directive('uiGridCell',
|
|
458
|
+
['$compile', '$injector', '$timeout', 'uiGridConstants', 'uiGridEditConstants', 'gridUtil', '$parse', 'uiGridEditService', '$rootScope', '$q',
|
|
459
|
+
function ($compile, $injector, $timeout, uiGridConstants, uiGridEditConstants, gridUtil, $parse, uiGridEditService, $rootScope, $q) {
|
|
460
|
+
var touchstartTimeout = 500;
|
|
461
|
+
if ($injector.has('uiGridCellNavService')) {
|
|
462
|
+
var uiGridCellNavService = $injector.get('uiGridCellNavService');
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
return {
|
|
466
|
+
priority: -100, // run after default uiGridCell directive
|
|
467
|
+
restrict: 'A',
|
|
468
|
+
scope: false,
|
|
469
|
+
require: '?^uiGrid',
|
|
470
|
+
link: function ($scope, $elm, $attrs, uiGridCtrl) {
|
|
471
|
+
var html,
|
|
472
|
+
origCellValue,
|
|
473
|
+
cellModel,
|
|
474
|
+
cancelTouchstartTimeout,
|
|
475
|
+
inEdit = false;
|
|
476
|
+
|
|
477
|
+
var editCellScope;
|
|
478
|
+
|
|
479
|
+
if (!$scope.col.colDef.enableCellEdit) {
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
var cellNavNavigateDereg = function() {};
|
|
484
|
+
var viewPortKeyDownDereg = function() {};
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
var setEditable = function() {
|
|
488
|
+
if ($scope.col.colDef.enableCellEdit && $scope.row.enableCellEdit !== false) {
|
|
489
|
+
if (!$scope.beginEditEventsWired) { // prevent multiple attachments
|
|
490
|
+
registerBeginEditEvents();
|
|
491
|
+
}
|
|
492
|
+
} else {
|
|
493
|
+
if ($scope.beginEditEventsWired) {
|
|
494
|
+
cancelBeginEditEvents();
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
};
|
|
498
|
+
|
|
499
|
+
setEditable();
|
|
500
|
+
|
|
501
|
+
var rowWatchDereg = $scope.$watch('row', function (n, o) {
|
|
502
|
+
if (n !== o) {
|
|
503
|
+
setEditable();
|
|
504
|
+
}
|
|
505
|
+
});
|
|
506
|
+
|
|
507
|
+
|
|
508
|
+
$scope.$on('$destroy', function destroyEvents() {
|
|
509
|
+
rowWatchDereg();
|
|
510
|
+
// unbind all jquery events in order to avoid memory leaks
|
|
511
|
+
$elm.off();
|
|
512
|
+
});
|
|
513
|
+
|
|
514
|
+
function registerBeginEditEvents() {
|
|
515
|
+
$elm.on('dblclick', beginEdit);
|
|
516
|
+
|
|
517
|
+
// Add touchstart handling. If the users starts a touch and it doesn't end after X milliseconds, then start the edit
|
|
518
|
+
$elm.on('touchstart', touchStart);
|
|
519
|
+
|
|
520
|
+
if (uiGridCtrl && uiGridCtrl.grid.api.cellNav) {
|
|
521
|
+
|
|
522
|
+
viewPortKeyDownDereg = uiGridCtrl.grid.api.cellNav.on.viewPortKeyDown($scope, function (evt, rowCol) {
|
|
523
|
+
if (rowCol === null) {
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
if (rowCol.row === $scope.row && rowCol.col === $scope.col && !$scope.col.colDef.enableCellEditOnFocus) {
|
|
528
|
+
// important to do this before scrollToIfNecessary
|
|
529
|
+
beginEditKeyDown(evt);
|
|
530
|
+
}
|
|
531
|
+
});
|
|
532
|
+
|
|
533
|
+
cellNavNavigateDereg = uiGridCtrl.grid.api.cellNav.on.navigate($scope, function (newRowCol, oldRowCol, evt) {
|
|
534
|
+
if ($scope.col.colDef.enableCellEditOnFocus) {
|
|
535
|
+
// Don't begin edit if the cell hasn't changed
|
|
536
|
+
if (newRowCol.row === $scope.row && newRowCol.col === $scope.col &&
|
|
537
|
+
(evt === null || (evt && (evt.type === 'click' || evt.type === 'keydown')))) {
|
|
538
|
+
$timeout(function() {
|
|
539
|
+
beginEdit(evt);
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
$scope.beginEditEventsWired = true;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
function touchStart(event) {
|
|
550
|
+
// jQuery masks events
|
|
551
|
+
if (typeof(event.originalEvent) !== 'undefined' && event.originalEvent !== undefined) {
|
|
552
|
+
event = event.originalEvent;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
// Bind touchend handler
|
|
556
|
+
$elm.on('touchend', touchEnd);
|
|
557
|
+
|
|
558
|
+
// Start a timeout
|
|
559
|
+
cancelTouchstartTimeout = $timeout(function() { }, touchstartTimeout);
|
|
560
|
+
|
|
561
|
+
// Timeout's done! Start the edit
|
|
562
|
+
cancelTouchstartTimeout.then(function () {
|
|
563
|
+
// Use setTimeout to start the edit because beginEdit expects to be outside of $digest
|
|
564
|
+
setTimeout(beginEdit, 0);
|
|
565
|
+
|
|
566
|
+
// Undbind the touchend handler, we don't need it anymore
|
|
567
|
+
$elm.off('touchend', touchEnd);
|
|
568
|
+
}).catch(angular.noop);
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
// Cancel any touchstart timeout
|
|
572
|
+
function touchEnd() {
|
|
573
|
+
$timeout.cancel(cancelTouchstartTimeout);
|
|
574
|
+
$elm.off('touchend', touchEnd);
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
function cancelBeginEditEvents() {
|
|
578
|
+
$elm.off('dblclick', beginEdit);
|
|
579
|
+
$elm.off('keydown', beginEditKeyDown);
|
|
580
|
+
$elm.off('touchstart', touchStart);
|
|
581
|
+
cellNavNavigateDereg();
|
|
582
|
+
viewPortKeyDownDereg();
|
|
583
|
+
$scope.beginEditEventsWired = false;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
function beginEditKeyDown(evt) {
|
|
587
|
+
if (uiGridEditService.isStartEditKey(evt)) {
|
|
588
|
+
beginEdit(evt);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
function shouldEdit(col, row, triggerEvent) {
|
|
593
|
+
return !row.isSaving &&
|
|
594
|
+
( angular.isFunction(col.colDef.cellEditableCondition) ?
|
|
595
|
+
col.colDef.cellEditableCondition($scope, triggerEvent) :
|
|
596
|
+
col.colDef.cellEditableCondition );
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
|
|
600
|
+
function beginEdit(triggerEvent) {
|
|
601
|
+
// we need to scroll the cell into focus before invoking the editor
|
|
602
|
+
$scope.grid.api.core.scrollToIfNecessary($scope.row, $scope.col)
|
|
603
|
+
.then(function () {
|
|
604
|
+
beginEditAfterScroll(triggerEvent);
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
/**
|
|
609
|
+
* @ngdoc property
|
|
610
|
+
* @name editDropdownOptionsArray
|
|
611
|
+
* @propertyOf ui.grid.edit.api:ColumnDef
|
|
612
|
+
* @description an array of values in the format
|
|
613
|
+
* [ {id: xxx, value: xxx} ], which is populated
|
|
614
|
+
* into the edit dropdown
|
|
615
|
+
*
|
|
616
|
+
*/
|
|
617
|
+
/**
|
|
618
|
+
* @ngdoc property
|
|
619
|
+
* @name editDropdownIdLabel
|
|
620
|
+
* @propertyOf ui.grid.edit.api:ColumnDef
|
|
621
|
+
* @description the label for the "id" field
|
|
622
|
+
* in the editDropdownOptionsArray. Defaults
|
|
623
|
+
* to 'id'
|
|
624
|
+
* @example
|
|
625
|
+
* <pre>
|
|
626
|
+
* $scope.gridOptions = {
|
|
627
|
+
* columnDefs: [
|
|
628
|
+
* {name: 'status', editableCellTemplate: 'ui-grid/dropdownEditor',
|
|
629
|
+
* editDropdownOptionsArray: [{code: 1, status: 'active'}, {code: 2, status: 'inactive'}],
|
|
630
|
+
* editDropdownIdLabel: 'code', editDropdownValueLabel: 'status' }
|
|
631
|
+
* ],
|
|
632
|
+
* </pre>
|
|
633
|
+
*
|
|
634
|
+
*/
|
|
635
|
+
/**
|
|
636
|
+
* @ngdoc property
|
|
637
|
+
* @name editDropdownRowEntityOptionsArrayPath
|
|
638
|
+
* @propertyOf ui.grid.edit.api:ColumnDef
|
|
639
|
+
* @description a path to a property on row.entity containing an
|
|
640
|
+
* array of values in the format
|
|
641
|
+
* [ {id: xxx, value: xxx} ], which will be used to populate
|
|
642
|
+
* the edit dropdown. This can be used when the dropdown values are dependent on
|
|
643
|
+
* the backing row entity.
|
|
644
|
+
* If this property is set then editDropdownOptionsArray will be ignored.
|
|
645
|
+
* @example
|
|
646
|
+
* <pre>
|
|
647
|
+
* $scope.gridOptions = {
|
|
648
|
+
* columnDefs: [
|
|
649
|
+
* {name: 'status', editableCellTemplate: 'ui-grid/dropdownEditor',
|
|
650
|
+
* editDropdownRowEntityOptionsArrayPath: 'foo.bars[0].baz',
|
|
651
|
+
* editDropdownIdLabel: 'code', editDropdownValueLabel: 'status' }
|
|
652
|
+
* ],
|
|
653
|
+
* </pre>
|
|
654
|
+
*
|
|
655
|
+
*/
|
|
656
|
+
/**
|
|
657
|
+
* @ngdoc service
|
|
658
|
+
* @name editDropdownOptionsFunction
|
|
659
|
+
* @methodOf ui.grid.edit.api:ColumnDef
|
|
660
|
+
* @description a function returning an array of values in the format
|
|
661
|
+
* [ {id: xxx, value: xxx} ], which will be used to populate
|
|
662
|
+
* the edit dropdown. This can be used when the dropdown values are dependent on
|
|
663
|
+
* the backing row entity with some kind of algorithm.
|
|
664
|
+
* If this property is set then both editDropdownOptionsArray and
|
|
665
|
+
* editDropdownRowEntityOptionsArrayPath will be ignored.
|
|
666
|
+
* @param {object} rowEntity the options.data element that the returned array refers to
|
|
667
|
+
* @param {object} colDef the column that implements this dropdown
|
|
668
|
+
* @returns {object} an array of values in the format
|
|
669
|
+
* [ {id: xxx, value: xxx} ] used to populate the edit dropdown
|
|
670
|
+
* @example
|
|
671
|
+
* <pre>
|
|
672
|
+
* $scope.gridOptions = {
|
|
673
|
+
* columnDefs: [
|
|
674
|
+
* {name: 'status', editableCellTemplate: 'ui-grid/dropdownEditor',
|
|
675
|
+
* editDropdownOptionsFunction: function(rowEntity, colDef) {
|
|
676
|
+
* if (rowEntity.foo === 'bar') {
|
|
677
|
+
* return [{id: 'bar1', value: 'BAR 1'},
|
|
678
|
+
* {id: 'bar2', value: 'BAR 2'},
|
|
679
|
+
* {id: 'bar3', value: 'BAR 3'}];
|
|
680
|
+
* } else {
|
|
681
|
+
* return [{id: 'foo1', value: 'FOO 1'},
|
|
682
|
+
* {id: 'foo2', value: 'FOO 2'}];
|
|
683
|
+
* }
|
|
684
|
+
* },
|
|
685
|
+
* editDropdownIdLabel: 'code', editDropdownValueLabel: 'status' }
|
|
686
|
+
* ],
|
|
687
|
+
* </pre>
|
|
688
|
+
*
|
|
689
|
+
*/
|
|
690
|
+
/**
|
|
691
|
+
* @ngdoc property
|
|
692
|
+
* @name editDropdownValueLabel
|
|
693
|
+
* @propertyOf ui.grid.edit.api:ColumnDef
|
|
694
|
+
* @description the label for the "value" field
|
|
695
|
+
* in the editDropdownOptionsArray. Defaults
|
|
696
|
+
* to 'value'
|
|
697
|
+
* @example
|
|
698
|
+
* <pre>
|
|
699
|
+
* $scope.gridOptions = {
|
|
700
|
+
* columnDefs: [
|
|
701
|
+
* {name: 'status', editableCellTemplate: 'ui-grid/dropdownEditor',
|
|
702
|
+
* editDropdownOptionsArray: [{code: 1, status: 'active'}, {code: 2, status: 'inactive'}],
|
|
703
|
+
* editDropdownIdLabel: 'code', editDropdownValueLabel: 'status' }
|
|
704
|
+
* ],
|
|
705
|
+
* </pre>
|
|
706
|
+
*
|
|
707
|
+
*/
|
|
708
|
+
/**
|
|
709
|
+
* @ngdoc property
|
|
710
|
+
* @name editDropdownFilter
|
|
711
|
+
* @propertyOf ui.grid.edit.api:ColumnDef
|
|
712
|
+
* @description A filter that you would like to apply to the values in the options list
|
|
713
|
+
* of the dropdown. For example if you were using angular-translate you might set this
|
|
714
|
+
* to `'translate'`
|
|
715
|
+
* @example
|
|
716
|
+
* <pre>
|
|
717
|
+
* $scope.gridOptions = {
|
|
718
|
+
* columnDefs: [
|
|
719
|
+
* {name: 'status', editableCellTemplate: 'ui-grid/dropdownEditor',
|
|
720
|
+
* editDropdownOptionsArray: [{code: 1, status: 'active'}, {code: 2, status: 'inactive'}],
|
|
721
|
+
* editDropdownIdLabel: 'code', editDropdownValueLabel: 'status', editDropdownFilter: 'translate' }
|
|
722
|
+
* ],
|
|
723
|
+
* </pre>
|
|
724
|
+
*
|
|
725
|
+
*/
|
|
726
|
+
function beginEditAfterScroll(triggerEvent) {
|
|
727
|
+
// If we are already editing, then just skip this so we don't try editing twice...
|
|
728
|
+
if (inEdit) {
|
|
729
|
+
return;
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
if (!shouldEdit($scope.col, $scope.row, triggerEvent)) {
|
|
733
|
+
return;
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
var modelField = $scope.row.getQualifiedColField($scope.col);
|
|
737
|
+
if ($scope.col.colDef.editModelField) {
|
|
738
|
+
modelField = gridUtil.preEval('row.entity.' + $scope.col.colDef.editModelField);
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
cellModel = $parse(modelField);
|
|
742
|
+
|
|
743
|
+
// get original value from the cell
|
|
744
|
+
origCellValue = cellModel($scope);
|
|
745
|
+
|
|
746
|
+
html = $scope.col.editableCellTemplate;
|
|
747
|
+
html = html.replace(uiGridConstants.MODEL_COL_FIELD, modelField);
|
|
748
|
+
html = html.replace(uiGridConstants.COL_FIELD, 'grid.getCellValue(row, col)');
|
|
749
|
+
|
|
750
|
+
var optionFilter = $scope.col.colDef.editDropdownFilter ? '|' + $scope.col.colDef.editDropdownFilter : '';
|
|
751
|
+
html = html.replace(uiGridConstants.CUSTOM_FILTERS, optionFilter);
|
|
752
|
+
|
|
753
|
+
var inputType = 'text';
|
|
754
|
+
switch ($scope.col.colDef.type) {
|
|
755
|
+
case 'boolean':
|
|
756
|
+
inputType = 'checkbox';
|
|
757
|
+
break;
|
|
758
|
+
case 'number':
|
|
759
|
+
inputType = 'number';
|
|
760
|
+
break;
|
|
761
|
+
case 'date':
|
|
762
|
+
inputType = 'date';
|
|
763
|
+
break;
|
|
764
|
+
}
|
|
765
|
+
html = html.replace('INPUT_TYPE', inputType);
|
|
766
|
+
|
|
767
|
+
// In order to fill dropdown options we use:
|
|
768
|
+
// - A function/promise or
|
|
769
|
+
// - An array inside of row entity if no function exists or
|
|
770
|
+
// - A single array for the whole column if none of the previous exists.
|
|
771
|
+
var editDropdownOptionsFunction = $scope.col.colDef.editDropdownOptionsFunction;
|
|
772
|
+
if (editDropdownOptionsFunction) {
|
|
773
|
+
$q.when(editDropdownOptionsFunction($scope.row.entity, $scope.col.colDef))
|
|
774
|
+
.then(function(result) {
|
|
775
|
+
$scope.editDropdownOptionsArray = result;
|
|
776
|
+
});
|
|
777
|
+
} else {
|
|
778
|
+
var editDropdownRowEntityOptionsArrayPath = $scope.col.colDef.editDropdownRowEntityOptionsArrayPath;
|
|
779
|
+
if (editDropdownRowEntityOptionsArrayPath) {
|
|
780
|
+
$scope.editDropdownOptionsArray = resolveObjectFromPath($scope.row.entity, editDropdownRowEntityOptionsArrayPath);
|
|
781
|
+
}
|
|
782
|
+
else {
|
|
783
|
+
$scope.editDropdownOptionsArray = $scope.col.colDef.editDropdownOptionsArray;
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
$scope.editDropdownIdLabel = $scope.col.colDef.editDropdownIdLabel ? $scope.col.colDef.editDropdownIdLabel : 'id';
|
|
787
|
+
$scope.editDropdownValueLabel = $scope.col.colDef.editDropdownValueLabel ? $scope.col.colDef.editDropdownValueLabel : 'value';
|
|
788
|
+
|
|
789
|
+
var createEditor = function() {
|
|
790
|
+
inEdit = true;
|
|
791
|
+
cancelBeginEditEvents();
|
|
792
|
+
var cellElement = angular.element(html);
|
|
793
|
+
$elm.append(cellElement);
|
|
794
|
+
editCellScope = $scope.$new();
|
|
795
|
+
$compile(cellElement)(editCellScope);
|
|
796
|
+
var gridCellContentsEl = angular.element($elm.children()[0]);
|
|
797
|
+
gridCellContentsEl.addClass('ui-grid-cell-contents-hidden');
|
|
798
|
+
};
|
|
799
|
+
if (!$rootScope.$$phase) {
|
|
800
|
+
$scope.$apply(createEditor);
|
|
801
|
+
} else {
|
|
802
|
+
createEditor();
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
// stop editing when grid is scrolled
|
|
806
|
+
var deregOnGridScroll = $scope.col.grid.api.core.on.scrollBegin($scope, function () {
|
|
807
|
+
if ($scope.grid.disableScrolling) {
|
|
808
|
+
return;
|
|
809
|
+
}
|
|
810
|
+
endEdit();
|
|
811
|
+
$scope.grid.api.edit.raise.afterCellEdit($scope.row.entity, $scope.col.colDef, cellModel($scope), origCellValue);
|
|
812
|
+
deregOnGridScroll();
|
|
813
|
+
deregOnEndCellEdit();
|
|
814
|
+
deregOnCancelCellEdit();
|
|
815
|
+
});
|
|
816
|
+
|
|
817
|
+
// end editing
|
|
818
|
+
var deregOnEndCellEdit = $scope.$on(uiGridEditConstants.events.END_CELL_EDIT, function () {
|
|
819
|
+
endEdit();
|
|
820
|
+
$scope.grid.api.edit.raise.afterCellEdit($scope.row.entity, $scope.col.colDef, cellModel($scope), origCellValue);
|
|
821
|
+
deregOnEndCellEdit();
|
|
822
|
+
deregOnGridScroll();
|
|
823
|
+
deregOnCancelCellEdit();
|
|
824
|
+
});
|
|
825
|
+
|
|
826
|
+
// cancel editing
|
|
827
|
+
var deregOnCancelCellEdit = $scope.$on(uiGridEditConstants.events.CANCEL_CELL_EDIT, function () {
|
|
828
|
+
cancelEdit();
|
|
829
|
+
deregOnCancelCellEdit();
|
|
830
|
+
deregOnGridScroll();
|
|
831
|
+
deregOnEndCellEdit();
|
|
832
|
+
});
|
|
833
|
+
|
|
834
|
+
$scope.$broadcast(uiGridEditConstants.events.BEGIN_CELL_EDIT, triggerEvent);
|
|
835
|
+
$timeout(function () {
|
|
836
|
+
// execute in a timeout to give any complex editor templates a cycle to completely render
|
|
837
|
+
$scope.grid.api.edit.raise.beginCellEdit($scope.row.entity, $scope.col.colDef, triggerEvent);
|
|
838
|
+
});
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
function endEdit() {
|
|
842
|
+
$scope.grid.disableScrolling = false;
|
|
843
|
+
if (!inEdit) {
|
|
844
|
+
return;
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
// sometimes the events can't keep up with the keyboard and grid focus is lost, so always focus
|
|
848
|
+
// back to grid here. The focus call needs to be before the $destroy and removal of the control,
|
|
849
|
+
// otherwise ng-model-options of UpdateOn: 'blur' will not work.
|
|
850
|
+
if (uiGridCtrl && uiGridCtrl.grid.api.cellNav) {
|
|
851
|
+
uiGridCtrl.focus();
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
var gridCellContentsEl = angular.element($elm.children()[0]);
|
|
855
|
+
// remove edit element
|
|
856
|
+
editCellScope.$destroy();
|
|
857
|
+
var children = $elm.children();
|
|
858
|
+
for (var i = 1; i < children.length; i++) {
|
|
859
|
+
angular.element(children[i]).remove();
|
|
860
|
+
}
|
|
861
|
+
gridCellContentsEl.removeClass('ui-grid-cell-contents-hidden');
|
|
862
|
+
inEdit = false;
|
|
863
|
+
registerBeginEditEvents();
|
|
864
|
+
$scope.grid.api.core.notifyDataChange( uiGridConstants.dataChange.EDIT );
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
function cancelEdit() {
|
|
868
|
+
$scope.grid.disableScrolling = false;
|
|
869
|
+
if (!inEdit) {
|
|
870
|
+
return;
|
|
871
|
+
}
|
|
872
|
+
cellModel.assign($scope, origCellValue);
|
|
873
|
+
$scope.$apply();
|
|
874
|
+
|
|
875
|
+
$scope.grid.api.edit.raise.cancelCellEdit($scope.row.entity, $scope.col.colDef);
|
|
876
|
+
endEdit();
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
// resolves a string path against the given object
|
|
880
|
+
// shamelessly borrowed from
|
|
881
|
+
// http://stackoverflow.com/questions/6491463/accessing-nested-javascript-objects-with-string-key
|
|
882
|
+
function resolveObjectFromPath(object, path) {
|
|
883
|
+
path = path.replace(/\[(\w+)\]/g, '.$1'); // convert indexes to properties
|
|
884
|
+
path = path.replace(/^\./, ''); // strip a leading dot
|
|
885
|
+
var a = path.split('.');
|
|
886
|
+
while (a.length) {
|
|
887
|
+
var n = a.shift();
|
|
888
|
+
if (n in object) {
|
|
889
|
+
object = object[n];
|
|
890
|
+
} else {
|
|
891
|
+
return;
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
return object;
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
};
|
|
898
|
+
}]);
|
|
899
|
+
|
|
900
|
+
/**
|
|
901
|
+
* @ngdoc directive
|
|
902
|
+
* @name ui.grid.edit.directive:uiGridEditor
|
|
903
|
+
* @element div
|
|
904
|
+
* @restrict A
|
|
905
|
+
*
|
|
906
|
+
* @description input editor directive for editable fields.
|
|
907
|
+
* Provides EndEdit and CancelEdit events
|
|
908
|
+
*
|
|
909
|
+
* Events that end editing:
|
|
910
|
+
* blur and enter keydown
|
|
911
|
+
*
|
|
912
|
+
* Events that cancel editing:
|
|
913
|
+
* - Esc keydown
|
|
914
|
+
*
|
|
915
|
+
*/
|
|
916
|
+
module.directive('uiGridEditor',
|
|
917
|
+
['gridUtil', 'uiGridConstants', 'uiGridEditConstants','$timeout', 'uiGridEditService',
|
|
918
|
+
function (gridUtil, uiGridConstants, uiGridEditConstants, $timeout, uiGridEditService) {
|
|
919
|
+
return {
|
|
920
|
+
scope: true,
|
|
921
|
+
require: ['?^uiGrid', '?^uiGridRenderContainer', 'ngModel'],
|
|
922
|
+
compile: function () {
|
|
923
|
+
return {
|
|
924
|
+
pre: function ($scope, $elm, $attrs) {
|
|
925
|
+
|
|
926
|
+
},
|
|
927
|
+
post: function ($scope, $elm, $attrs, controllers) {
|
|
928
|
+
var uiGridCtrl, renderContainerCtrl, ngModel;
|
|
929
|
+
if (controllers[0]) { uiGridCtrl = controllers[0]; }
|
|
930
|
+
if (controllers[1]) { renderContainerCtrl = controllers[1]; }
|
|
931
|
+
if (controllers[2]) { ngModel = controllers[2]; }
|
|
932
|
+
|
|
933
|
+
// set focus at start of edit
|
|
934
|
+
$scope.$on(uiGridEditConstants.events.BEGIN_CELL_EDIT, function () {
|
|
935
|
+
// must be in a timeout since it requires a new digest cycle
|
|
936
|
+
$timeout(function () {
|
|
937
|
+
$elm[0].focus();
|
|
938
|
+
// only select text if it is not being replaced below in the cellNav viewPortKeyPress
|
|
939
|
+
if ($elm[0].select && ($scope.col.colDef.enableCellEditOnFocus || !(uiGridCtrl && uiGridCtrl.grid.api.cellNav))) {
|
|
940
|
+
$elm[0].select();
|
|
941
|
+
}
|
|
942
|
+
else {
|
|
943
|
+
// some browsers (Chrome) stupidly, imo, support the w3 standard that number, email, ...
|
|
944
|
+
// fields should not allow setSelectionRange. We ignore the error for those browsers
|
|
945
|
+
// https://www.w3.org/Bugs/Public/show_bug.cgi?id=24796
|
|
946
|
+
try {
|
|
947
|
+
$elm[0].setSelectionRange($elm[0].value.length, $elm[0].value.length);
|
|
948
|
+
}
|
|
949
|
+
catch (ex) {
|
|
950
|
+
// ignore
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
});
|
|
954
|
+
|
|
955
|
+
// set the keystroke that started the edit event
|
|
956
|
+
// we must do this because the BeginEdit is done in a different event loop than the intitial
|
|
957
|
+
// keydown event
|
|
958
|
+
// fire this event for the keypress that is received
|
|
959
|
+
if (uiGridCtrl && uiGridCtrl.grid.api.cellNav) {
|
|
960
|
+
var viewPortKeyDownUnregister = uiGridCtrl.grid.api.cellNav.on.viewPortKeyPress($scope, function (evt, rowCol) {
|
|
961
|
+
if (uiGridEditService.isStartEditKey(evt)) {
|
|
962
|
+
var code = typeof evt.which === 'number' ? evt.which : evt.keyCode;
|
|
963
|
+
if (code > 0) {
|
|
964
|
+
ngModel.$setViewValue(String.fromCharCode(code), evt);
|
|
965
|
+
ngModel.$render();
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
viewPortKeyDownUnregister();
|
|
969
|
+
});
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
// macOS will blur the checkbox when clicked in Safari and Firefox,
|
|
973
|
+
// to get around this, we disable the blur handler on mousedown,
|
|
974
|
+
// and then focus the checkbox and re-enable the blur handler after $timeout
|
|
975
|
+
$elm.on('mousedown', function(evt) {
|
|
976
|
+
if ($elm[0].type === 'checkbox') {
|
|
977
|
+
$elm.off('blur', $scope.stopEdit);
|
|
978
|
+
$timeout(function() {
|
|
979
|
+
$elm[0].focus();
|
|
980
|
+
$elm.on('blur', $scope.stopEdit);
|
|
981
|
+
});
|
|
982
|
+
}
|
|
983
|
+
});
|
|
984
|
+
|
|
985
|
+
if ($elm[0]) {
|
|
986
|
+
$elm[0].focus();
|
|
987
|
+
}
|
|
988
|
+
$elm.on('blur', $scope.stopEdit);
|
|
989
|
+
});
|
|
990
|
+
|
|
991
|
+
|
|
992
|
+
$scope.deepEdit = false;
|
|
993
|
+
|
|
994
|
+
$scope.stopEdit = function (evt) {
|
|
995
|
+
if ($scope.inputForm && !$scope.inputForm.$valid) {
|
|
996
|
+
evt.stopPropagation();
|
|
997
|
+
$scope.$emit(uiGridEditConstants.events.CANCEL_CELL_EDIT);
|
|
998
|
+
}
|
|
999
|
+
else {
|
|
1000
|
+
$scope.$emit(uiGridEditConstants.events.END_CELL_EDIT);
|
|
1001
|
+
}
|
|
1002
|
+
$scope.deepEdit = false;
|
|
1003
|
+
};
|
|
1004
|
+
|
|
1005
|
+
|
|
1006
|
+
$elm.on('click', function (evt) {
|
|
1007
|
+
if ($elm[0].type !== 'checkbox') {
|
|
1008
|
+
$scope.deepEdit = true;
|
|
1009
|
+
$scope.$applyAsync(function () {
|
|
1010
|
+
$scope.grid.disableScrolling = true;
|
|
1011
|
+
});
|
|
1012
|
+
}
|
|
1013
|
+
});
|
|
1014
|
+
|
|
1015
|
+
$elm.on('keydown', function (evt) {
|
|
1016
|
+
switch (evt.keyCode) {
|
|
1017
|
+
case uiGridConstants.keymap.ESC:
|
|
1018
|
+
evt.stopPropagation();
|
|
1019
|
+
$scope.$emit(uiGridEditConstants.events.CANCEL_CELL_EDIT);
|
|
1020
|
+
break;
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
if ($scope.deepEdit &&
|
|
1024
|
+
(evt.keyCode === uiGridConstants.keymap.LEFT ||
|
|
1025
|
+
evt.keyCode === uiGridConstants.keymap.RIGHT ||
|
|
1026
|
+
evt.keyCode === uiGridConstants.keymap.UP ||
|
|
1027
|
+
evt.keyCode === uiGridConstants.keymap.DOWN)) {
|
|
1028
|
+
evt.stopPropagation();
|
|
1029
|
+
}
|
|
1030
|
+
// Pass the keydown event off to the cellNav service, if it exists
|
|
1031
|
+
else if (uiGridCtrl && uiGridCtrl.grid.api.cellNav) {
|
|
1032
|
+
evt.uiGridTargetRenderContainerId = renderContainerCtrl.containerId;
|
|
1033
|
+
if (uiGridCtrl.cellNav.handleKeyDown(evt) !== null) {
|
|
1034
|
+
$scope.stopEdit(evt);
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
else {
|
|
1038
|
+
// handle enter and tab for editing not using cellNav
|
|
1039
|
+
switch (evt.keyCode) {
|
|
1040
|
+
case uiGridConstants.keymap.ENTER: // Enter (Leave Field)
|
|
1041
|
+
case uiGridConstants.keymap.TAB:
|
|
1042
|
+
evt.stopPropagation();
|
|
1043
|
+
evt.preventDefault();
|
|
1044
|
+
$scope.stopEdit(evt);
|
|
1045
|
+
break;
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
return true;
|
|
1050
|
+
});
|
|
1051
|
+
|
|
1052
|
+
$scope.$on('$destroy', function unbindEvents() {
|
|
1053
|
+
// unbind all jquery events in order to avoid memory leaks
|
|
1054
|
+
$elm.off();
|
|
1055
|
+
});
|
|
1056
|
+
}
|
|
1057
|
+
};
|
|
1058
|
+
}
|
|
1059
|
+
};
|
|
1060
|
+
}]);
|
|
1061
|
+
|
|
1062
|
+
/**
|
|
1063
|
+
* @ngdoc directive
|
|
1064
|
+
* @name ui.grid.edit.directive:input
|
|
1065
|
+
* @element input
|
|
1066
|
+
* @restrict E
|
|
1067
|
+
*
|
|
1068
|
+
* @description directive to provide binding between input[date] value and ng-model for angular 1.2
|
|
1069
|
+
* It is similar to input[date] directive of angular 1.3
|
|
1070
|
+
*
|
|
1071
|
+
* Supported date format for input is 'yyyy-MM-dd'
|
|
1072
|
+
* The directive will set the $valid property of input element and the enclosing form to false if
|
|
1073
|
+
* model is invalid date or value of input is entered wrong.
|
|
1074
|
+
*
|
|
1075
|
+
*/
|
|
1076
|
+
module.directive('uiGridEditor', ['$filter', function ($filter) {
|
|
1077
|
+
function parseDateString(dateString) {
|
|
1078
|
+
if (typeof(dateString) === 'undefined' || dateString === '') {
|
|
1079
|
+
return null;
|
|
1080
|
+
}
|
|
1081
|
+
var parts = dateString.split('-');
|
|
1082
|
+
if (parts.length !== 3) {
|
|
1083
|
+
return null;
|
|
1084
|
+
}
|
|
1085
|
+
var year = parseInt(parts[0], 10);
|
|
1086
|
+
var month = parseInt(parts[1], 10);
|
|
1087
|
+
var day = parseInt(parts[2], 10);
|
|
1088
|
+
|
|
1089
|
+
if (month < 1 || year < 1 || day < 1) {
|
|
1090
|
+
return null;
|
|
1091
|
+
}
|
|
1092
|
+
return new Date(year, (month - 1), day);
|
|
1093
|
+
}
|
|
1094
|
+
return {
|
|
1095
|
+
priority: -100, // run after default uiGridEditor directive
|
|
1096
|
+
require: '?ngModel',
|
|
1097
|
+
link: function (scope, element, attrs, ngModel) {
|
|
1098
|
+
if (angular.version.minor === 2 && attrs.type && attrs.type === 'date' && ngModel) {
|
|
1099
|
+
ngModel.$formatters.push(function (modelValue) {
|
|
1100
|
+
ngModel.$setValidity(null,(!modelValue || !isNaN(modelValue.getTime())));
|
|
1101
|
+
return $filter('date')(modelValue, 'yyyy-MM-dd');
|
|
1102
|
+
});
|
|
1103
|
+
|
|
1104
|
+
ngModel.$parsers.push(function (viewValue) {
|
|
1105
|
+
if (viewValue && viewValue.length > 0) {
|
|
1106
|
+
var dateValue = parseDateString(viewValue);
|
|
1107
|
+
ngModel.$setValidity(null, (dateValue && !isNaN(dateValue.getTime())));
|
|
1108
|
+
return dateValue;
|
|
1109
|
+
}
|
|
1110
|
+
else {
|
|
1111
|
+
ngModel.$setValidity(null, true);
|
|
1112
|
+
return null;
|
|
1113
|
+
}
|
|
1114
|
+
});
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
};
|
|
1118
|
+
}]);
|
|
1119
|
+
|
|
1120
|
+
|
|
1121
|
+
/**
|
|
1122
|
+
* @ngdoc directive
|
|
1123
|
+
* @name ui.grid.edit.directive:uiGridEditDropdown
|
|
1124
|
+
* @element div
|
|
1125
|
+
* @restrict A
|
|
1126
|
+
*
|
|
1127
|
+
* @description dropdown editor for editable fields.
|
|
1128
|
+
* Provides EndEdit and CancelEdit events
|
|
1129
|
+
*
|
|
1130
|
+
* Events that end editing:
|
|
1131
|
+
* blur and enter keydown, and any left/right nav
|
|
1132
|
+
*
|
|
1133
|
+
* Events that cancel editing:
|
|
1134
|
+
* - Esc keydown
|
|
1135
|
+
*
|
|
1136
|
+
*/
|
|
1137
|
+
module.directive('uiGridEditDropdown',
|
|
1138
|
+
['uiGridConstants', 'uiGridEditConstants', '$timeout',
|
|
1139
|
+
function (uiGridConstants, uiGridEditConstants, $timeout) {
|
|
1140
|
+
return {
|
|
1141
|
+
require: ['?^uiGrid', '?^uiGridRenderContainer'],
|
|
1142
|
+
scope: true,
|
|
1143
|
+
compile: function () {
|
|
1144
|
+
return {
|
|
1145
|
+
pre: function ($scope, $elm, $attrs) {
|
|
1146
|
+
|
|
1147
|
+
},
|
|
1148
|
+
post: function ($scope, $elm, $attrs, controllers) {
|
|
1149
|
+
var uiGridCtrl = controllers[0];
|
|
1150
|
+
var renderContainerCtrl = controllers[1];
|
|
1151
|
+
|
|
1152
|
+
// set focus at start of edit
|
|
1153
|
+
$scope.$on(uiGridEditConstants.events.BEGIN_CELL_EDIT, function () {
|
|
1154
|
+
$timeout(function() {
|
|
1155
|
+
$elm[0].focus();
|
|
1156
|
+
});
|
|
1157
|
+
|
|
1158
|
+
$elm[0].style.width = ($elm[0].parentElement.offsetWidth - 1) + 'px';
|
|
1159
|
+
$elm.on('blur', function (evt) {
|
|
1160
|
+
$scope.stopEdit(evt);
|
|
1161
|
+
});
|
|
1162
|
+
});
|
|
1163
|
+
|
|
1164
|
+
|
|
1165
|
+
$scope.stopEdit = function (evt) {
|
|
1166
|
+
// no need to validate a dropdown - invalid values shouldn't be
|
|
1167
|
+
// available in the list
|
|
1168
|
+
$scope.$emit(uiGridEditConstants.events.END_CELL_EDIT);
|
|
1169
|
+
};
|
|
1170
|
+
|
|
1171
|
+
$elm.on('keydown', function (evt) {
|
|
1172
|
+
switch (evt.keyCode) {
|
|
1173
|
+
case uiGridConstants.keymap.ESC:
|
|
1174
|
+
evt.stopPropagation();
|
|
1175
|
+
$scope.$emit(uiGridEditConstants.events.CANCEL_CELL_EDIT);
|
|
1176
|
+
break;
|
|
1177
|
+
}
|
|
1178
|
+
if (uiGridCtrl && uiGridCtrl.grid.api.cellNav) {
|
|
1179
|
+
evt.uiGridTargetRenderContainerId = renderContainerCtrl.containerId;
|
|
1180
|
+
if (uiGridCtrl.cellNav.handleKeyDown(evt) !== null) {
|
|
1181
|
+
$scope.stopEdit(evt);
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
else {
|
|
1185
|
+
// handle enter and tab for editing not using cellNav
|
|
1186
|
+
switch (evt.keyCode) {
|
|
1187
|
+
case uiGridConstants.keymap.ENTER: // Enter (Leave Field)
|
|
1188
|
+
case uiGridConstants.keymap.TAB:
|
|
1189
|
+
evt.stopPropagation();
|
|
1190
|
+
evt.preventDefault();
|
|
1191
|
+
$scope.stopEdit(evt);
|
|
1192
|
+
break;
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
return true;
|
|
1196
|
+
});
|
|
1197
|
+
|
|
1198
|
+
$scope.$on('$destroy', function unbindEvents() {
|
|
1199
|
+
// unbind jquery events to prevent memory leaks
|
|
1200
|
+
$elm.off();
|
|
1201
|
+
});
|
|
1202
|
+
}
|
|
1203
|
+
};
|
|
1204
|
+
}
|
|
1205
|
+
};
|
|
1206
|
+
}]);
|
|
1207
|
+
|
|
1208
|
+
/**
|
|
1209
|
+
* @ngdoc directive
|
|
1210
|
+
* @name ui.grid.edit.directive:uiGridEditFileChooser
|
|
1211
|
+
* @element div
|
|
1212
|
+
* @restrict A
|
|
1213
|
+
*
|
|
1214
|
+
* @description input editor directive for editable fields.
|
|
1215
|
+
* Provides EndEdit and CancelEdit events
|
|
1216
|
+
*
|
|
1217
|
+
* Events that end editing:
|
|
1218
|
+
* blur and enter keydown
|
|
1219
|
+
*
|
|
1220
|
+
* Events that cancel editing:
|
|
1221
|
+
* - Esc keydown
|
|
1222
|
+
*
|
|
1223
|
+
*/
|
|
1224
|
+
module.directive('uiGridEditFileChooser',
|
|
1225
|
+
['gridUtil', 'uiGridConstants', 'uiGridEditConstants',
|
|
1226
|
+
function (gridUtil, uiGridConstants, uiGridEditConstants) {
|
|
1227
|
+
return {
|
|
1228
|
+
scope: true,
|
|
1229
|
+
require: ['?^uiGrid', '?^uiGridRenderContainer'],
|
|
1230
|
+
compile: function () {
|
|
1231
|
+
return {
|
|
1232
|
+
pre: function ($scope, $elm, $attrs) {
|
|
1233
|
+
|
|
1234
|
+
},
|
|
1235
|
+
post: function ($scope, $elm) {
|
|
1236
|
+
function handleFileSelect(event) {
|
|
1237
|
+
var target = event.srcElement || event.target;
|
|
1238
|
+
|
|
1239
|
+
if (target && target.files && target.files.length > 0) {
|
|
1240
|
+
/**
|
|
1241
|
+
* @ngdoc property
|
|
1242
|
+
* @name editFileChooserCallback
|
|
1243
|
+
* @propertyOf ui.grid.edit.api:ColumnDef
|
|
1244
|
+
* @description A function that should be called when any files have been chosen
|
|
1245
|
+
* by the user. You should use this to process the files appropriately for your
|
|
1246
|
+
* application.
|
|
1247
|
+
*
|
|
1248
|
+
* It passes the gridCol, the gridRow (from which you can get gridRow.entity),
|
|
1249
|
+
* and the files. The files are in the format as returned from the file chooser,
|
|
1250
|
+
* an array of files, with each having useful information such as:
|
|
1251
|
+
* - `files[0].lastModifiedDate`
|
|
1252
|
+
* - `files[0].name`
|
|
1253
|
+
* - `files[0].size` (appears to be in bytes)
|
|
1254
|
+
* - `files[0].type` (MIME type by the looks)
|
|
1255
|
+
*
|
|
1256
|
+
* Typically you would do something with these files - most commonly you would
|
|
1257
|
+
* use the filename or read the file itself in. The example function does both.
|
|
1258
|
+
*
|
|
1259
|
+
* @example
|
|
1260
|
+
* <pre>
|
|
1261
|
+
* editFileChooserCallBack: function(gridRow, gridCol, files ) {
|
|
1262
|
+
* // ignore all but the first file, it can only choose one anyway
|
|
1263
|
+
* // set the filename into this column
|
|
1264
|
+
* gridRow.entity.filename = file[0].name;
|
|
1265
|
+
*
|
|
1266
|
+
* // read the file and set it into a hidden column, which we may do stuff with later
|
|
1267
|
+
* var setFile = function(fileContent) {
|
|
1268
|
+
* gridRow.entity.file = fileContent.currentTarget.result;
|
|
1269
|
+
* };
|
|
1270
|
+
* var reader = new FileReader();
|
|
1271
|
+
* reader.onload = setFile;
|
|
1272
|
+
* reader.readAsText( files[0] );
|
|
1273
|
+
* }
|
|
1274
|
+
* </pre>
|
|
1275
|
+
*/
|
|
1276
|
+
if ( typeof($scope.col.colDef.editFileChooserCallback) === 'function' ) {
|
|
1277
|
+
$scope.col.colDef.editFileChooserCallback($scope.row, $scope.col, target.files);
|
|
1278
|
+
} else {
|
|
1279
|
+
gridUtil.logError('You need to set colDef.editFileChooserCallback to use the file chooser');
|
|
1280
|
+
}
|
|
1281
|
+
|
|
1282
|
+
target.form.reset();
|
|
1283
|
+
$scope.$emit(uiGridEditConstants.events.END_CELL_EDIT);
|
|
1284
|
+
} else {
|
|
1285
|
+
$scope.$emit(uiGridEditConstants.events.CANCEL_CELL_EDIT);
|
|
1286
|
+
}
|
|
1287
|
+
$elm[0].removeEventListener('change', handleFileSelect, false);
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
$elm[0].addEventListener('change', handleFileSelect, false);
|
|
1291
|
+
|
|
1292
|
+
$scope.$on(uiGridEditConstants.events.BEGIN_CELL_EDIT, function () {
|
|
1293
|
+
$elm[0].focus();
|
|
1294
|
+
$elm[0].select();
|
|
1295
|
+
|
|
1296
|
+
$elm.on('blur', function () {
|
|
1297
|
+
$scope.$emit(uiGridEditConstants.events.END_CELL_EDIT);
|
|
1298
|
+
$elm.off();
|
|
1299
|
+
});
|
|
1300
|
+
});
|
|
1301
|
+
}
|
|
1302
|
+
};
|
|
1303
|
+
}
|
|
1304
|
+
};
|
|
1305
|
+
}]);
|
|
1306
|
+
})();
|
|
1307
|
+
|
|
1308
|
+
angular.module('ui.grid.edit').run(['$templateCache', function($templateCache) {
|
|
1309
|
+
'use strict';
|
|
1310
|
+
|
|
1311
|
+
$templateCache.put('ui-grid/cellEditor',
|
|
1312
|
+
"<div><form name=\"inputForm\"><input type=\"INPUT_TYPE\" ng-class=\"'colt' + col.uid\" ui-grid-editor ng-model=\"MODEL_COL_FIELD\"></form></div>"
|
|
1313
|
+
);
|
|
1314
|
+
|
|
1315
|
+
|
|
1316
|
+
$templateCache.put('ui-grid/dropdownEditor',
|
|
1317
|
+
"<div><form name=\"inputForm\"><select ng-class=\"'colt' + col.uid\" ui-grid-edit-dropdown ng-model=\"MODEL_COL_FIELD\" ng-options=\"field[editDropdownIdLabel] as field[editDropdownValueLabel] CUSTOM_FILTERS for field in editDropdownOptionsArray\"></select></form></div>"
|
|
1318
|
+
);
|
|
1319
|
+
|
|
1320
|
+
|
|
1321
|
+
$templateCache.put('ui-grid/fileChooserEditor',
|
|
1322
|
+
"<div><form name=\"inputForm\"><input ng-class=\"'colt' + col.uid\" ui-grid-edit-file-chooser type=\"file\" id=\"files\" name=\"files[]\" ng-model=\"MODEL_COL_FIELD\"></form></div>"
|
|
1323
|
+
);
|
|
1324
|
+
|
|
1325
|
+
}]);
|