forked from tungstenfabric/tf-webui-third-party
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjdorn-jsoneditor-0.7.25_2.patch
95 lines (88 loc) · 2.48 KB
/
jdorn-jsoneditor-0.7.25_2.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
--- jdorn-jsoneditor.js 2017-02-21 14:10:52.000000000 +0530
+++ jdorn-jsoneditor.js 2017-02-21 14:10:09.000000000 +0530
@@ -230,6 +230,7 @@
this.element = element;
this.options = options;
clickAddItem = false;
+ hideErrorContainer = true;
this.init();
};
JSONEditor.prototype = {
@@ -488,14 +489,18 @@
// Validate and cache results
self.validation_results = self.validator.validate(self.root.getValue());
+ if(hideErrorContainer){
+ if(self.options.show_errors !== "never") {
+ self.root.showValidationErrors(self.validation_results);
+ }
+ else {
+ self.root.showValidationErrors([]);
+ }
- if(self.options.show_errors !== "never") {
- self.root.showValidationErrors(self.validation_results);
- }
- else {
- self.root.showValidationErrors([]);
+ }else{
+ hideErrorContainer = true;
}
-
+
// Fire change event
self.trigger('change');
});
@@ -1811,7 +1816,7 @@
if(type && Array.isArray(type)) type = type[0];
if(typeof type === "string") {
- if(type === "number") return 0.0;
+ if(type === "number") return null;
if(type === "boolean") return false;
if(type === "integer") return 0;
if(type === "string") return "";
@@ -1957,7 +1962,9 @@
// Sanitize value before setting it
var sanitized = this.sanitize(value);
-
+ if(value == 'null' || value == null){
+ sanitized = null;
+ }
if(this.input.value === sanitized) {
return;
}
@@ -2150,10 +2157,21 @@
return;
}
- var val = this.value;
+ if(self.schema.type === 'number' && this.value == ""){
+ var val = this.value; hideErrorContainer = false;
+ }
+ if(this.value == ""){
+ var val = null;
+ }else{
+ var val = this.value;
+ }
+ //var val = this.value;
// sanitize value
var sanitized = self.sanitize(val);
+ if(val == null){
+ sanitized = null;
+ }
if(val !== sanitized) {
this.value = sanitized;
}
@@ -2416,7 +2434,15 @@
return 2;
},
getValue: function() {
- return this.value*1;
+ if(this.schema.type === 'number'){
+ if(this.value == '' || this.value == null || this.value == 'null'){
+ return null;
+ }else{
+ return this.value*1;
+ }
+ }else{
+ return this.value*1;
+ }
}
});