2018-03-19 22:29:46 +01:00
|
|
|
<script>
|
|
|
|
StrolchInspectorBehavior = {
|
|
|
|
|
|
|
|
properties: {
|
|
|
|
basePath: {
|
|
|
|
type: String,
|
|
|
|
value: './'
|
|
|
|
},
|
|
|
|
dlgTitle: {
|
|
|
|
type: String
|
|
|
|
},
|
|
|
|
dlgText: {
|
|
|
|
type: String
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
toLocalDateTime: function (val) {
|
|
|
|
return Strolch.toLocalDateTime(val);
|
|
|
|
},
|
|
|
|
arrayToString: function (arr) {
|
|
|
|
var s = '';
|
|
|
|
for (var i = 0; i < arr.length; i++) {
|
|
|
|
s += arr[i];
|
|
|
|
if (i + 1 < arr.length)
|
|
|
|
s += ', ';
|
|
|
|
}
|
|
|
|
|
|
|
|
return s;
|
|
|
|
},
|
2018-09-11 12:17:24 +02:00
|
|
|
isEqual: function (o1, o2) {
|
|
|
|
return o1 == o2;
|
|
|
|
},
|
2018-03-19 22:29:46 +01:00
|
|
|
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
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2020-07-20 12:17:39 +02:00
|
|
|
onRequestError: function (e) {
|
|
|
|
this.onAjaxError(e);
|
|
|
|
},
|
2018-03-19 22:29:46 +01:00
|
|
|
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;
|
|
|
|
}
|
2018-12-03 17:43:44 +01:00
|
|
|
} else if (data.detail.error.message) {
|
|
|
|
dlgText = data.detail.error.message;
|
2018-03-19 22:29:46 +01:00
|
|
|
} else {
|
|
|
|
dlgText = data.detail.error;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.fire('strolch-show-dialog', {
|
|
|
|
title: this.dlgTitle,
|
|
|
|
text: dlgText
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|