-
Notifications
You must be signed in to change notification settings - Fork 1
/
strolch-wc-inspector-behavior.html
93 lines (87 loc) · 2.74 KB
/
strolch-wc-inspector-behavior.html
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
<script>
StrolchInspectorBehavior = {
properties: {
basePath: {
type: String,
value: './'
},
dlgTitle: {
type: String
},
dlgText: {
type: String
}
},
toLocalDateTime: function (val) {
if (val == null || val.startsWith("1970-01-01T01:00:00"))
return "-";
return Strolch.toLocalDateTime(val);
},
arrayToString: function (arr) {
if (arr == null)
return "";
var s = '';
for (var i = 0; i < arr.length; i++) {
s += arr[i];
if (i + 1 < arr.length)
s += ', ';
}
return s;
},
isEqual: function (o1, o2) {
return o1 == o2;
},
isEmptyArray: function (arr) {
return arr == null || arr.length === 0;
},
isNotEmptyArray: function (list) {
return !this.isEmptyArray(list);
},
isEmptyString: function (v) {
return v != null && v.length === 0
},
isNotEmptyString: function (v) {
return v != null && v.length > 0
},
_handleAjaxError: function (data) {
var dlgText;
if (data.detail.request.response) {
dlgText = data.detail.request.response.msg;
} else {
dlgText = data.detail.error;
}
this.fire('strolch-show-dialog', {
title: this.dlgTitle,
text: dlgText
});
},
onRequestError: function (e) {
this.onAjaxError(e);
},
onAjaxError: function (data) {
var dlgText;
if (data.detail.request.response) {
if (data.detail.request.response.msg) {
dlgText = data.detail.request.response.msg;
} else if (data.detail.request.response.charAt(0) === '{') {
var json = JSON.parse(data.detail.request.response);
if (json.msg) {
dlgText = json.msg;
} else {
dlgText = data.detail.request.response;
}
} else {
dlgText = data.detail.request.response;
}
} else if (data.detail.error.message) {
dlgText = data.detail.error.message;
} else {
dlgText = data.detail.error;
}
this.fire('strolch-show-dialog', {
title: this.dlgTitle,
text: dlgText
});
}
};
</script>