Make lang prop dynamic.

This commit is contained in:
Hossein Nedaee
2019-11-11 21:44:29 +03:30
parent 179010ddbf
commit 4ca78a2fe5
2 changed files with 18 additions and 10 deletions

View File

@@ -42,7 +42,6 @@ export default {
this.editor.session.setValue(value,1); this.editor.session.setValue(value,1);
this.cacheValue = value; this.cacheValue = value;
} }
}, },
theme() { theme() {
this.editor.setTheme('ace/theme/' + this.defineTheme()) this.editor.setTheme('ace/theme/' + this.defineTheme())

View File

@@ -570,7 +570,7 @@
<div id="response-details-wrapper"> <div id="response-details-wrapper">
<ResponseBody <ResponseBody
:value="responseBodyText" :value="responseBodyText"
lang="json" :lang="responseBodyType"
:options="{ :options="{
maxLines: '16', maxLines: '16',
minLines: '16', minLines: '16',
@@ -733,6 +733,7 @@ export default {
urlExcludes: {}, urlExcludes: {},
responseBodyText: '', responseBodyText: '',
responseBodyType: 'text'
}; };
}, },
watch: { watch: {
@@ -753,18 +754,26 @@ export default {
else this.setRouteQueryState(); else this.setRouteQueryState();
}, },
"response.body": function(val) { "response.body": function(val) {
if ( if (
this.response.body !== "(waiting to send request)" && this.response.body === "(waiting to send request)" ||
this.response.body !== "Loading..." this.response.body === "Loading..."
) {
this.responseBodyText = this.response.body;
this.responseBodyType = 'text';
} else {
if(this.responseType === "application/json" ||
this.responseType === "application/hal+json"
) { ) {
this.responseBodyText = this.responseBodyText = JSON.stringify(this.response.body, null, 2)
this.responseType === "application/json" || this.responseBodyType = 'json'
this.responseType === "application/hal+json" } else if (this.responseType === "text/html") {
? JSON.stringify(this.response.body, null, 2) this.responseBodyText = this.response.body;
: this.response.body; this.responseBodyType = 'html'
} else { } else {
this.responseBodyText = this.response.body; this.responseBodyText = this.response.body;
this.responseBodyType = 'text';
} }
}
}, },
params: { params: {
handler: function(newValue) { handler: function(newValue) {