@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,589 @@
|
|
|
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.validate
|
|
13
|
+
* @description
|
|
14
|
+
*
|
|
15
|
+
* # ui.grid.validate
|
|
16
|
+
*
|
|
17
|
+
* <div class="alert alert-warning" role="alert"><strong>Alpha</strong> This feature is in development. There will almost certainly be breaking api changes, or there are major outstanding bugs.</div>
|
|
18
|
+
*
|
|
19
|
+
* This module provides the ability to validate cells upon change.
|
|
20
|
+
*
|
|
21
|
+
* Design information:
|
|
22
|
+
* -------------------
|
|
23
|
+
*
|
|
24
|
+
* Validation is not based on angularjs validation, since it would work only when editing the field.
|
|
25
|
+
*
|
|
26
|
+
* Instead it adds custom properties to any field considered as invalid.
|
|
27
|
+
*
|
|
28
|
+
* <br/>
|
|
29
|
+
* <br/>
|
|
30
|
+
*
|
|
31
|
+
* <div doc-module-components="ui.grid.expandable"></div>
|
|
32
|
+
*/
|
|
33
|
+
var module = angular.module('ui.grid.validate', ['ui.grid']);
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @ngdoc service
|
|
37
|
+
* @name ui.grid.validate.service:uiGridValidateService
|
|
38
|
+
*
|
|
39
|
+
* @description Services for validation features
|
|
40
|
+
*/
|
|
41
|
+
module.service('uiGridValidateService', ['$sce', '$q', '$http', 'i18nService', 'uiGridConstants', function ($sce, $q, $http, i18nService, uiGridConstants) {
|
|
42
|
+
|
|
43
|
+
var service = {
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @ngdoc object
|
|
47
|
+
* @name validatorFactories
|
|
48
|
+
* @propertyOf ui.grid.validate.service:uiGridValidateService
|
|
49
|
+
* @description object containing all the factories used to validate data.<br/>
|
|
50
|
+
* These factories will be in the form <br/>
|
|
51
|
+
* ```
|
|
52
|
+
* {
|
|
53
|
+
* validatorFactory: function(argument) {
|
|
54
|
+
* return function(newValue, oldValue, rowEntity, colDef) {
|
|
55
|
+
* return true || false || promise
|
|
56
|
+
* }
|
|
57
|
+
* },
|
|
58
|
+
* messageFunction: function(argument) {
|
|
59
|
+
* return string
|
|
60
|
+
* }
|
|
61
|
+
* }
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* Promises should return true or false as result according to the result of validation.
|
|
65
|
+
*/
|
|
66
|
+
validatorFactories: {},
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @ngdoc service
|
|
70
|
+
* @name setExternalFactoryFunction
|
|
71
|
+
* @methodOf ui.grid.validate.service:uiGridValidateService
|
|
72
|
+
* @description Adds a way to retrieve validators from an external service
|
|
73
|
+
* <p>Validators from this external service have a higher priority than default
|
|
74
|
+
* ones
|
|
75
|
+
* @param {function} externalFactoryFunction a function that accepts name and argument to pass to a
|
|
76
|
+
* validator factory and that returns an object with the same properties as
|
|
77
|
+
* you can see in {@link ui.grid.validate.service:uiGridValidateService#properties_validatorFactories validatorFactories}
|
|
78
|
+
*/
|
|
79
|
+
setExternalFactoryFunction: function(externalFactoryFunction) {
|
|
80
|
+
service.externalFactoryFunction = externalFactoryFunction;
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @ngdoc service
|
|
85
|
+
* @name clearExternalFactory
|
|
86
|
+
* @methodOf ui.grid.validate.service:uiGridValidateService
|
|
87
|
+
* @description Removes any link to external factory from this service
|
|
88
|
+
*/
|
|
89
|
+
clearExternalFactory: function() {
|
|
90
|
+
delete service.externalFactoryFunction;
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @ngdoc service
|
|
95
|
+
* @name getValidatorFromExternalFactory
|
|
96
|
+
* @methodOf ui.grid.validate.service:uiGridValidateService
|
|
97
|
+
* @description Retrieves a validator by executing a validatorFactory
|
|
98
|
+
* stored in an external service.
|
|
99
|
+
* @param {string} name the name of the validator to retrieve
|
|
100
|
+
* @param {object} argument an argument to pass to the validator factory
|
|
101
|
+
*/
|
|
102
|
+
getValidatorFromExternalFactory: function(name, argument) {
|
|
103
|
+
return service.externalFactoryFunction(name, argument).validatorFactory(argument);
|
|
104
|
+
},
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* @ngdoc service
|
|
108
|
+
* @name getMessageFromExternalFactory
|
|
109
|
+
* @methodOf ui.grid.validate.service:uiGridValidateService
|
|
110
|
+
* @description Retrieves a message stored in an external service.
|
|
111
|
+
* @param {string} name the name of the validator
|
|
112
|
+
* @param {object} argument an argument to pass to the message function
|
|
113
|
+
*/
|
|
114
|
+
getMessageFromExternalFactory: function(name, argument) {
|
|
115
|
+
return service.externalFactoryFunction(name, argument).messageFunction(argument);
|
|
116
|
+
},
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* @ngdoc service
|
|
120
|
+
* @name setValidator
|
|
121
|
+
* @methodOf ui.grid.validate.service:uiGridValidateService
|
|
122
|
+
* @description Adds a new validator to the service
|
|
123
|
+
* @param {string} name the name of the validator, must be unique
|
|
124
|
+
* @param {function} validatorFactory a factory that return a validatorFunction
|
|
125
|
+
* @param {function} messageFunction a function that return the error message
|
|
126
|
+
*/
|
|
127
|
+
setValidator: function(name, validatorFactory, messageFunction) {
|
|
128
|
+
service.validatorFactories[name] = {
|
|
129
|
+
validatorFactory: validatorFactory,
|
|
130
|
+
messageFunction: messageFunction
|
|
131
|
+
};
|
|
132
|
+
},
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* @ngdoc service
|
|
136
|
+
* @name getValidator
|
|
137
|
+
* @methodOf ui.grid.validate.service:uiGridValidateService
|
|
138
|
+
* @description Returns a validator registered to the service
|
|
139
|
+
* or retrieved from the external factory
|
|
140
|
+
* @param {string} name the name of the validator to retrieve
|
|
141
|
+
* @param {object} argument an argument to pass to the validator factory
|
|
142
|
+
* @returns {object} the validator function
|
|
143
|
+
*/
|
|
144
|
+
getValidator: function(name, argument) {
|
|
145
|
+
if (service.externalFactoryFunction) {
|
|
146
|
+
var validator = service.getValidatorFromExternalFactory(name, argument);
|
|
147
|
+
if (validator) {
|
|
148
|
+
return validator;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
if (!service.validatorFactories[name]) {
|
|
152
|
+
throw ("Invalid validator name: " + name);
|
|
153
|
+
}
|
|
154
|
+
return service.validatorFactories[name].validatorFactory(argument);
|
|
155
|
+
},
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* @ngdoc service
|
|
159
|
+
* @name getMessage
|
|
160
|
+
* @methodOf ui.grid.validate.service:uiGridValidateService
|
|
161
|
+
* @description Returns the error message related to the validator
|
|
162
|
+
* @param {string} name the name of the validator
|
|
163
|
+
* @param {object} argument an argument to pass to the message function
|
|
164
|
+
* @returns {string} the error message related to the validator
|
|
165
|
+
*/
|
|
166
|
+
getMessage: function(name, argument) {
|
|
167
|
+
if (service.externalFactoryFunction) {
|
|
168
|
+
var message = service.getMessageFromExternalFactory(name, argument);
|
|
169
|
+
if (message) {
|
|
170
|
+
return message;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return service.validatorFactories[name].messageFunction(argument);
|
|
174
|
+
},
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* @ngdoc service
|
|
178
|
+
* @name isInvalid
|
|
179
|
+
* @methodOf ui.grid.validate.service:uiGridValidateService
|
|
180
|
+
* @description Returns true if the cell (identified by rowEntity, colDef) is invalid
|
|
181
|
+
* @param {object} rowEntity the row entity of the cell
|
|
182
|
+
* @param {object} colDef the colDef of the cell
|
|
183
|
+
* @returns {boolean} true if the cell is invalid
|
|
184
|
+
*/
|
|
185
|
+
isInvalid: function (rowEntity, colDef) {
|
|
186
|
+
return rowEntity['$$invalid'+colDef.name];
|
|
187
|
+
},
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* @ngdoc service
|
|
191
|
+
* @name setInvalid
|
|
192
|
+
* @methodOf ui.grid.validate.service:uiGridValidateService
|
|
193
|
+
* @description Makes the cell invalid by adding the proper field to the entity
|
|
194
|
+
* @param {object} rowEntity the row entity of the cell
|
|
195
|
+
* @param {object} colDef the colDef of the cell
|
|
196
|
+
*/
|
|
197
|
+
setInvalid: function (rowEntity, colDef) {
|
|
198
|
+
rowEntity['$$invalid'+colDef.name] = true;
|
|
199
|
+
},
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* @ngdoc service
|
|
203
|
+
* @name setValid
|
|
204
|
+
* @methodOf ui.grid.validate.service:uiGridValidateService
|
|
205
|
+
* @description Makes the cell valid by removing the proper error field from the entity
|
|
206
|
+
* @param {object} rowEntity the row entity of the cell
|
|
207
|
+
* @param {object} colDef the colDef of the cell
|
|
208
|
+
*/
|
|
209
|
+
setValid: function (rowEntity, colDef) {
|
|
210
|
+
delete rowEntity['$$invalid'+colDef.name];
|
|
211
|
+
},
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* @ngdoc service
|
|
215
|
+
* @name setError
|
|
216
|
+
* @methodOf ui.grid.validate.service:uiGridValidateService
|
|
217
|
+
* @description Adds the proper error to the entity errors field
|
|
218
|
+
* @param {object} rowEntity the row entity of the cell
|
|
219
|
+
* @param {object} colDef the colDef of the cell
|
|
220
|
+
* @param {string} validatorName the name of the validator that is failing
|
|
221
|
+
*/
|
|
222
|
+
setError: function(rowEntity, colDef, validatorName) {
|
|
223
|
+
if (!rowEntity['$$errors'+colDef.name]) {
|
|
224
|
+
rowEntity['$$errors'+colDef.name] = {};
|
|
225
|
+
}
|
|
226
|
+
rowEntity['$$errors'+colDef.name][validatorName] = true;
|
|
227
|
+
},
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* @ngdoc service
|
|
231
|
+
* @name clearError
|
|
232
|
+
* @methodOf ui.grid.validate.service:uiGridValidateService
|
|
233
|
+
* @description Removes the proper error from the entity errors field
|
|
234
|
+
* @param {object} rowEntity the row entity of the cell
|
|
235
|
+
* @param {object} colDef the colDef of the cell
|
|
236
|
+
* @param {string} validatorName the name of the validator that is failing
|
|
237
|
+
*/
|
|
238
|
+
clearError: function(rowEntity, colDef, validatorName) {
|
|
239
|
+
if (!rowEntity['$$errors'+colDef.name]) {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
if (validatorName in rowEntity['$$errors'+colDef.name]) {
|
|
243
|
+
delete rowEntity['$$errors'+colDef.name][validatorName];
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* @ngdoc function
|
|
249
|
+
* @name getErrorMessages
|
|
250
|
+
* @methodOf ui.grid.validate.service:uiGridValidateService
|
|
251
|
+
* @description returns an array of i18n-ed error messages.
|
|
252
|
+
* @param {object} rowEntity gridOptions.data[] array instance whose errors we are looking for
|
|
253
|
+
* @param {object} colDef the column whose errors we are looking for
|
|
254
|
+
* @returns {array} An array of strings containing all the error messages for the cell
|
|
255
|
+
*/
|
|
256
|
+
getErrorMessages: function(rowEntity, colDef) {
|
|
257
|
+
var errors = [];
|
|
258
|
+
|
|
259
|
+
if (!rowEntity['$$errors'+colDef.name] || Object.keys(rowEntity['$$errors'+colDef.name]).length === 0) {
|
|
260
|
+
return errors;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
Object.keys(rowEntity['$$errors'+colDef.name]).sort().forEach(function(validatorName) {
|
|
264
|
+
errors.push(service.getMessage(validatorName, colDef.validators[validatorName]));
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
return errors;
|
|
268
|
+
},
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* @ngdoc function
|
|
272
|
+
* @name getFormattedErrors
|
|
273
|
+
* @methodOf ui.grid.validate.service:uiGridValidateService
|
|
274
|
+
* @description returns the error i18n-ed and formatted in html to be shown inside the page.
|
|
275
|
+
* @param {object} rowEntity gridOptions.data[] array instance whose errors we are looking for
|
|
276
|
+
* @param {object} colDef the column whose errors we are looking for
|
|
277
|
+
* @returns {object} An object that can be used in a template (like a cellTemplate) to display the
|
|
278
|
+
* message inside the page (i.e. inside a div)
|
|
279
|
+
*/
|
|
280
|
+
getFormattedErrors: function(rowEntity, colDef) {
|
|
281
|
+
var msgString = "",
|
|
282
|
+
errors = service.getErrorMessages(rowEntity, colDef);
|
|
283
|
+
|
|
284
|
+
if (!errors.length) {
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
errors.forEach(function(errorMsg) {
|
|
289
|
+
msgString += errorMsg + "<br/>";
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
return $sce.trustAsHtml('<p><b>' + i18nService.getSafeText('validate.error') + '</b></p>' + msgString );
|
|
293
|
+
},
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* @ngdoc function
|
|
297
|
+
* @name getTitleFormattedErrors
|
|
298
|
+
* @methodOf ui.grid.validate.service:uiGridValidateService
|
|
299
|
+
* @description returns the error i18n-ed and formatted in javaScript to be shown inside an html
|
|
300
|
+
* title attribute.
|
|
301
|
+
* @param {object} rowEntity gridOptions.data[] array instance whose errors we are looking for
|
|
302
|
+
* @param {object} colDef the column whose errors we are looking for
|
|
303
|
+
* @returns {object} An object that can be used in a template (like a cellTemplate) to display the
|
|
304
|
+
* message inside an html title attribute
|
|
305
|
+
*/
|
|
306
|
+
getTitleFormattedErrors: function(rowEntity, colDef) {
|
|
307
|
+
var newLine = "\n",
|
|
308
|
+
msgString = "",
|
|
309
|
+
errors = service.getErrorMessages(rowEntity, colDef);
|
|
310
|
+
|
|
311
|
+
if (!errors.length) {
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
errors.forEach(function(errorMsg) {
|
|
316
|
+
msgString += errorMsg + newLine;
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
return $sce.trustAsHtml(i18nService.getSafeText('validate.error') + newLine + msgString);
|
|
320
|
+
},
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* @ngdoc function
|
|
324
|
+
* @name getTitleFormattedErrors
|
|
325
|
+
* @methodOf ui.grid.validate.service:uiGridValidateService
|
|
326
|
+
* @description Executes all validators on a cell (identified by row entity and column definition) and sets or clears errors
|
|
327
|
+
* @param {object} rowEntity the row entity of the cell we want to run the validators on
|
|
328
|
+
* @param {object} colDef the column definition of the cell we want to run the validators on
|
|
329
|
+
* @param {object} newValue the value the user just entered
|
|
330
|
+
* @param {object} oldValue the value the field had before
|
|
331
|
+
*/
|
|
332
|
+
runValidators: function(rowEntity, colDef, newValue, oldValue, grid) {
|
|
333
|
+
if (newValue === oldValue) {
|
|
334
|
+
// If the value has not changed we perform no validation
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
if (typeof(colDef.name) === 'undefined' || !colDef.name) {
|
|
339
|
+
throw new Error('colDef.name is required to perform validation');
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
service.setValid(rowEntity, colDef);
|
|
343
|
+
|
|
344
|
+
var validateClosureFactory = function(rowEntity, colDef, validatorName) {
|
|
345
|
+
return function(value) {
|
|
346
|
+
if (!value) {
|
|
347
|
+
service.setInvalid(rowEntity, colDef);
|
|
348
|
+
service.setError(rowEntity, colDef, validatorName);
|
|
349
|
+
if (grid) {
|
|
350
|
+
grid.api.validate.raise.validationFailed(rowEntity, colDef, newValue, oldValue);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
var promises = [];
|
|
357
|
+
|
|
358
|
+
for (var validatorName in colDef.validators) {
|
|
359
|
+
service.clearError(rowEntity, colDef, validatorName);
|
|
360
|
+
var validatorFunction = service.getValidator(validatorName, colDef.validators[validatorName]);
|
|
361
|
+
|
|
362
|
+
// We pass the arguments as oldValue, newValue so they are in the same order
|
|
363
|
+
// as ng-model validators (modelValue, viewValue)
|
|
364
|
+
var promise = $q.when(validatorFunction(oldValue, newValue, rowEntity, colDef))
|
|
365
|
+
.then(validateClosureFactory(rowEntity, colDef, validatorName));
|
|
366
|
+
|
|
367
|
+
promises.push(promise);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
return $q.all(promises);
|
|
371
|
+
},
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* @ngdoc function
|
|
375
|
+
* @name createDefaultValidators
|
|
376
|
+
* @methodOf ui.grid.validate.service:uiGridValidateService
|
|
377
|
+
* @description adds the basic validators to the list of service validators
|
|
378
|
+
*/
|
|
379
|
+
createDefaultValidators: function() {
|
|
380
|
+
service.setValidator('minLength', function (argument) {
|
|
381
|
+
return function (oldValue, newValue) {
|
|
382
|
+
if (newValue === undefined || newValue === null || newValue === '') {
|
|
383
|
+
return true;
|
|
384
|
+
}
|
|
385
|
+
return newValue.length >= argument;
|
|
386
|
+
};
|
|
387
|
+
}, function(argument) {
|
|
388
|
+
return i18nService.getSafeText('validate.minLength').replace('THRESHOLD', argument);
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
service.setValidator('maxLength', function (argument) {
|
|
392
|
+
return function (oldValue, newValue) {
|
|
393
|
+
if (newValue === undefined || newValue === null || newValue === '') {
|
|
394
|
+
return true;
|
|
395
|
+
}
|
|
396
|
+
return newValue.length <= argument;
|
|
397
|
+
};
|
|
398
|
+
}, function(threshold) {
|
|
399
|
+
return i18nService.getSafeText('validate.maxLength').replace('THRESHOLD', threshold);
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
service.setValidator('required', function (argument) {
|
|
403
|
+
return function (oldValue, newValue) {
|
|
404
|
+
if (argument) {
|
|
405
|
+
return !(newValue === undefined || newValue === null || newValue === '');
|
|
406
|
+
}
|
|
407
|
+
return true;
|
|
408
|
+
};
|
|
409
|
+
}, function() {
|
|
410
|
+
return i18nService.getSafeText('validate.required');
|
|
411
|
+
});
|
|
412
|
+
},
|
|
413
|
+
|
|
414
|
+
initializeGrid: function (scope, grid) {
|
|
415
|
+
grid.validate = {
|
|
416
|
+
|
|
417
|
+
isInvalid: service.isInvalid,
|
|
418
|
+
|
|
419
|
+
getErrorMessages: service.getErrorMessages,
|
|
420
|
+
|
|
421
|
+
getFormattedErrors: service.getFormattedErrors,
|
|
422
|
+
|
|
423
|
+
getTitleFormattedErrors: service.getTitleFormattedErrors,
|
|
424
|
+
|
|
425
|
+
runValidators: service.runValidators
|
|
426
|
+
};
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* @ngdoc object
|
|
430
|
+
* @name ui.grid.validate.api:PublicApi
|
|
431
|
+
*
|
|
432
|
+
* @description Public Api for validation feature
|
|
433
|
+
*/
|
|
434
|
+
var publicApi = {
|
|
435
|
+
events: {
|
|
436
|
+
validate: {
|
|
437
|
+
/**
|
|
438
|
+
* @ngdoc event
|
|
439
|
+
* @name validationFailed
|
|
440
|
+
* @eventOf ui.grid.validate.api:PublicApi
|
|
441
|
+
* @description raised when one or more failure happened during validation
|
|
442
|
+
* <pre>
|
|
443
|
+
* gridApi.validate.on.validationFailed(scope, function(rowEntity, colDef, newValue, oldValue){...})
|
|
444
|
+
* </pre>
|
|
445
|
+
* @param {object} rowEntity the options.data element whose validation failed
|
|
446
|
+
* @param {object} colDef the column whose validation failed
|
|
447
|
+
* @param {object} newValue new value
|
|
448
|
+
* @param {object} oldValue old value
|
|
449
|
+
*/
|
|
450
|
+
validationFailed: function (rowEntity, colDef, newValue, oldValue) {
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
},
|
|
454
|
+
methods: {
|
|
455
|
+
validate: {
|
|
456
|
+
/**
|
|
457
|
+
* @ngdoc function
|
|
458
|
+
* @name isInvalid
|
|
459
|
+
* @methodOf ui.grid.validate.api:PublicApi
|
|
460
|
+
* @description checks if a cell (identified by rowEntity, colDef) is invalid
|
|
461
|
+
* @param {object} rowEntity gridOptions.data[] array instance we want to check
|
|
462
|
+
* @param {object} colDef the column whose errors we want to check
|
|
463
|
+
* @returns {boolean} true if the cell value is not valid
|
|
464
|
+
*/
|
|
465
|
+
isInvalid: function(rowEntity, colDef) {
|
|
466
|
+
return grid.validate.isInvalid(rowEntity, colDef);
|
|
467
|
+
},
|
|
468
|
+
/**
|
|
469
|
+
* @ngdoc function
|
|
470
|
+
* @name getErrorMessages
|
|
471
|
+
* @methodOf ui.grid.validate.api:PublicApi
|
|
472
|
+
* @description returns an array of i18n-ed error messages.
|
|
473
|
+
* @param {object} rowEntity gridOptions.data[] array instance whose errors we are looking for
|
|
474
|
+
* @param {object} colDef the column whose errors we are looking for
|
|
475
|
+
* @returns {array} An array of strings containing all the error messages for the cell
|
|
476
|
+
*/
|
|
477
|
+
getErrorMessages: function (rowEntity, colDef) {
|
|
478
|
+
return grid.validate.getErrorMessages(rowEntity, colDef);
|
|
479
|
+
},
|
|
480
|
+
/**
|
|
481
|
+
* @ngdoc function
|
|
482
|
+
* @name getFormattedErrors
|
|
483
|
+
* @methodOf ui.grid.validate.api:PublicApi
|
|
484
|
+
* @description returns the error i18n-ed and formatted in html to be shown inside the page.
|
|
485
|
+
* @param {object} rowEntity gridOptions.data[] array instance whose errors we are looking for
|
|
486
|
+
* @param {object} colDef the column whose errors we are looking for
|
|
487
|
+
* @returns {object} An object that can be used in a template (like a cellTemplate) to display the
|
|
488
|
+
* message inside the page (i.e. inside a div)
|
|
489
|
+
*/
|
|
490
|
+
getFormattedErrors: function (rowEntity, colDef) {
|
|
491
|
+
return grid.validate.getFormattedErrors(rowEntity, colDef);
|
|
492
|
+
},
|
|
493
|
+
/**
|
|
494
|
+
* @ngdoc function
|
|
495
|
+
* @name getTitleFormattedErrors
|
|
496
|
+
* @methodOf ui.grid.validate.api:PublicApi
|
|
497
|
+
* @description returns the error i18n-ed and formatted in javaScript to be shown inside an html
|
|
498
|
+
* title attribute.
|
|
499
|
+
* @param {object} rowEntity gridOptions.data[] array instance whose errors we are looking for
|
|
500
|
+
* @param {object} colDef the column whose errors we are looking for
|
|
501
|
+
* @returns {object} An object that can be used in a template (like a cellTemplate) to display the
|
|
502
|
+
* message inside an html title attribute
|
|
503
|
+
*/
|
|
504
|
+
getTitleFormattedErrors: function (rowEntity, colDef) {
|
|
505
|
+
return grid.validate.getTitleFormattedErrors(rowEntity, colDef);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
};
|
|
510
|
+
|
|
511
|
+
grid.api.registerEventsFromObject(publicApi.events);
|
|
512
|
+
grid.api.registerMethodsFromObject(publicApi.methods);
|
|
513
|
+
|
|
514
|
+
if (grid.edit) {
|
|
515
|
+
grid.api.edit.on.afterCellEdit(scope, function(rowEntity, colDef, newValue, oldValue) {
|
|
516
|
+
grid.validate.runValidators(rowEntity, colDef, newValue, oldValue, grid);
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
service.createDefaultValidators();
|
|
521
|
+
}
|
|
522
|
+
};
|
|
523
|
+
|
|
524
|
+
return service;
|
|
525
|
+
}]);
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* @ngdoc directive
|
|
529
|
+
* @name ui.grid.validate.directive:uiGridValidate
|
|
530
|
+
* @element div
|
|
531
|
+
* @restrict A
|
|
532
|
+
* @description Adds validating features to the ui-grid directive.
|
|
533
|
+
* @example
|
|
534
|
+
<example module="app">
|
|
535
|
+
<file name="app.js">
|
|
536
|
+
var app = angular.module('app', ['ui.grid', 'ui.grid.edit', 'ui.grid.validate']);
|
|
537
|
+
|
|
538
|
+
app.controller('MainCtrl', ['$scope', function ($scope) {
|
|
539
|
+
$scope.data = [
|
|
540
|
+
{ name: 'Bob', title: 'CEO' },
|
|
541
|
+
{ name: 'Frank', title: 'Lowly Developer' }
|
|
542
|
+
];
|
|
543
|
+
|
|
544
|
+
$scope.columnDefs = [
|
|
545
|
+
{name: 'name', enableCellEdit: true, validators: {minLength: 3, maxLength: 9}, cellTemplate: 'ui-grid/cellTitleValidator'},
|
|
546
|
+
{name: 'title', enableCellEdit: true, validators: {required: true}, cellTemplate: 'ui-grid/cellTitleValidator'}
|
|
547
|
+
];
|
|
548
|
+
}]);
|
|
549
|
+
</file>
|
|
550
|
+
<file name="index.html">
|
|
551
|
+
<div ng-controller="MainCtrl">
|
|
552
|
+
<div ui-grid="{ data: data, columnDefs: columnDefs }" ui-grid-edit ui-grid-validate></div>
|
|
553
|
+
</div>
|
|
554
|
+
</file>
|
|
555
|
+
</example>
|
|
556
|
+
*/
|
|
557
|
+
|
|
558
|
+
module.directive('uiGridValidate', ['gridUtil', 'uiGridValidateService', function (gridUtil, uiGridValidateService) {
|
|
559
|
+
return {
|
|
560
|
+
priority: 0,
|
|
561
|
+
replace: true,
|
|
562
|
+
require: '^uiGrid',
|
|
563
|
+
scope: false,
|
|
564
|
+
compile: function () {
|
|
565
|
+
return {
|
|
566
|
+
pre: function ($scope, $elm, $attrs, uiGridCtrl) {
|
|
567
|
+
uiGridValidateService.initializeGrid($scope, uiGridCtrl.grid);
|
|
568
|
+
},
|
|
569
|
+
post: function ($scope, $elm, $attrs, uiGridCtrl) {
|
|
570
|
+
}
|
|
571
|
+
};
|
|
572
|
+
}
|
|
573
|
+
};
|
|
574
|
+
}]);
|
|
575
|
+
})();
|
|
576
|
+
|
|
577
|
+
angular.module('ui.grid.validate').run(['$templateCache', function($templateCache) {
|
|
578
|
+
'use strict';
|
|
579
|
+
|
|
580
|
+
$templateCache.put('ui-grid/cellTitleValidator',
|
|
581
|
+
"<div class=\"ui-grid-cell-contents\" ng-class=\"{invalid:grid.validate.isInvalid(row.entity,col.colDef)}\" title=\"{{grid.validate.getTitleFormattedErrors(row.entity,col.colDef)}}\">{{COL_FIELD CUSTOM_FILTERS}}</div>"
|
|
582
|
+
);
|
|
583
|
+
|
|
584
|
+
|
|
585
|
+
$templateCache.put('ui-grid/cellTooltipValidator',
|
|
586
|
+
"<div class=\"ui-grid-cell-contents\" ng-class=\"{invalid:grid.validate.isInvalid(row.entity,col.colDef)}\" tooltip-html-unsafe=\"{{grid.validate.getFormattedErrors(row.entity,col.colDef)}}\" tooltip-enable=\"grid.validate.isInvalid(row.entity,col.colDef)\" tooltip-append-to-body=\"true\" tooltip-placement=\"top\" title=\"TOOLTIP\">{{COL_FIELD CUSTOM_FILTERS}}</div>"
|
|
587
|
+
);
|
|
588
|
+
|
|
589
|
+
}]);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* ui-grid - v4.12.7 - 2024-04-12
|
|
3
|
+
* http://ui-grid.info/
|
|
4
|
+
* Copyright (c) 2024 ; License: MIT
|
|
5
|
+
*/
|
|
6
|
+
!function(){"use strict";var t=angular.module("ui.grid.validate",["ui.grid"]);t.service("uiGridValidateService",["$sce","$q","$http","i18nService","uiGridConstants",function(a,d,t,i,r){var s={validatorFactories:{},setExternalFactoryFunction:function(t){s.externalFactoryFunction=t},clearExternalFactory:function(){delete s.externalFactoryFunction},getValidatorFromExternalFactory:function(t,r){return s.externalFactoryFunction(t,r).validatorFactory(r)},getMessageFromExternalFactory:function(t,r){return s.externalFactoryFunction(t,r).messageFunction(r)},setValidator:function(t,r,e){s.validatorFactories[t]={validatorFactory:r,messageFunction:e}},getValidator:function(t,r){if(s.externalFactoryFunction){var e=s.getValidatorFromExternalFactory(t,r);if(e)return e}if(s.validatorFactories[t])return s.validatorFactories[t].validatorFactory(r);throw"Invalid validator name: "+t},getMessage:function(t,r){if(s.externalFactoryFunction){var e=s.getMessageFromExternalFactory(t,r);if(e)return e}return s.validatorFactories[t].messageFunction(r)},isInvalid:function(t,r){return t["$$invalid"+r.name]},setInvalid:function(t,r){t["$$invalid"+r.name]=!0},setValid:function(t,r){delete t["$$invalid"+r.name]},setError:function(t,r,e){t["$$errors"+r.name]||(t["$$errors"+r.name]={}),t["$$errors"+r.name][e]=!0},clearError:function(t,r,e){t["$$errors"+r.name]&&e in t["$$errors"+r.name]&&delete t["$$errors"+r.name][e]},getErrorMessages:function(t,r){var e=[];return t["$$errors"+r.name]&&0!==Object.keys(t["$$errors"+r.name]).length&&Object.keys(t["$$errors"+r.name]).sort().forEach(function(t){e.push(s.getMessage(t,r.validators[t]))}),e},getFormattedErrors:function(t,r){var e="",t=s.getErrorMessages(t,r);if(t.length)return t.forEach(function(t){e+=t+"<br/>"}),a.trustAsHtml("<p><b>"+i.getSafeText("validate.error")+"</b></p>"+e)},getTitleFormattedErrors:function(t,r){var e="",t=s.getErrorMessages(t,r);if(t.length)return t.forEach(function(t){e+=t+"\n"}),a.trustAsHtml(i.getSafeText("validate.error")+"\n"+e)},runValidators:function(t,r,i,n,o){if(i!==n){if(void 0===r.name||!r.name)throw new Error("colDef.name is required to perform validation");s.setValid(t,r);var e,a=[];for(e in r.validators){s.clearError(t,r,e);var l=s.getValidator(e,r.validators[e]),l=d.when(l(n,i,t,r)).then(function(r,e,a){return function(t){t||(s.setInvalid(r,e),s.setError(r,e,a),o&&o.api.validate.raise.validationFailed(r,e,i,n))}}(t,r,e));a.push(l)}return d.all(a)}},createDefaultValidators:function(){s.setValidator("minLength",function(e){return function(t,r){return null==r||""===r||r.length>=e}},function(t){return i.getSafeText("validate.minLength").replace("THRESHOLD",t)}),s.setValidator("maxLength",function(e){return function(t,r){return null==r||""===r||r.length<=e}},function(t){return i.getSafeText("validate.maxLength").replace("THRESHOLD",t)}),s.setValidator("required",function(e){return function(t,r){return!e||!(null==r||""===r)}},function(){return i.getSafeText("validate.required")})},initializeGrid:function(t,i){i.validate={isInvalid:s.isInvalid,getErrorMessages:s.getErrorMessages,getFormattedErrors:s.getFormattedErrors,getTitleFormattedErrors:s.getTitleFormattedErrors,runValidators:s.runValidators};var r={validate:{validationFailed:function(t,r,e,a){}}},e={validate:{isInvalid:function(t,r){return i.validate.isInvalid(t,r)},getErrorMessages:function(t,r){return i.validate.getErrorMessages(t,r)},getFormattedErrors:function(t,r){return i.validate.getFormattedErrors(t,r)},getTitleFormattedErrors:function(t,r){return i.validate.getTitleFormattedErrors(t,r)}}};i.api.registerEventsFromObject(r),i.api.registerMethodsFromObject(e),i.edit&&i.api.edit.on.afterCellEdit(t,function(t,r,e,a){i.validate.runValidators(t,r,e,a,i)}),s.createDefaultValidators()}};return s}]),t.directive("uiGridValidate",["gridUtil","uiGridValidateService",function(t,i){return{priority:0,replace:!0,require:"^uiGrid",scope:!1,compile:function(){return{pre:function(t,r,e,a){i.initializeGrid(t,a.grid)},post:function(t,r,e,a){}}}}}])}(),angular.module("ui.grid.validate").run(["$templateCache",function(t){"use strict";t.put("ui-grid/cellTitleValidator",'<div class="ui-grid-cell-contents" ng-class="{invalid:grid.validate.isInvalid(row.entity,col.colDef)}" title="{{grid.validate.getTitleFormattedErrors(row.entity,col.colDef)}}">{{COL_FIELD CUSTOM_FILTERS}}</div>'),t.put("ui-grid/cellTooltipValidator",'<div class="ui-grid-cell-contents" ng-class="{invalid:grid.validate.isInvalid(row.entity,col.colDef)}" tooltip-html-unsafe="{{grid.validate.getFormattedErrors(row.entity,col.colDef)}}" tooltip-enable="grid.validate.isInvalid(row.entity,col.colDef)" tooltip-append-to-body="true" tooltip-placement="top" title="TOOLTIP">{{COL_FIELD CUSTOM_FILTERS}}</div>')}]);
|