Fixing bug on request saving

This bug appeared when saving a request with no collections available
This commit is contained in:
adevr
2019-12-08 23:21:53 +00:00
parent cd8b4d0dd1
commit c4bd471516
2 changed files with 50 additions and 3 deletions

View File

@@ -128,7 +128,11 @@ export default {
const userSelectedAnyCollection = const userSelectedAnyCollection =
this.$data.requestData.collectionIndex !== undefined; this.$data.requestData.collectionIndex !== undefined;
if (!userSelectedAnyCollection) return []; if (!userSelectedAnyCollection) return [];
const noCollectionAvailable =
this.$store.state.postwoman.collections[this.$data.requestData.collectionIndex] !== undefined;
if (!noCollectionAvailable) return [];
return this.$store.state.postwoman.collections[ return this.$store.state.postwoman.collections[
this.$data.requestData.collectionIndex this.$data.requestData.collectionIndex
].folders; ].folders;
@@ -151,6 +155,10 @@ export default {
const collection = this.$store.state.postwoman.collections[ const collection = this.$store.state.postwoman.collections[
this.$data.requestData.collectionIndex this.$data.requestData.collectionIndex
]; ];
const noCollectionAvailable =
this.$store.state.postwoman.collections[this.$data.requestData.collectionIndex] !== undefined;
if (!noCollectionAvailable) return [];
const requests = collection.requests; const requests = collection.requests;
return requests; return requests;
} }

View File

@@ -44,7 +44,17 @@
<ul> <ul>
<li> <li>
<label for="method">{{ $t("method") }}</label> <label for="method">{{ $t("method") }}</label>
<select id="method" v-model="method" @change="methodChange"> <input
id="method"
name="method"
type="text"
v-model="method"
@change="methodChange"
value="GET"
placeholder="GET"
list="preMethods"
/>
<datalist id="preMethods">
<option value="GET">GET</option> <option value="GET">GET</option>
<option value="HEAD">HEAD</option> <option value="HEAD">HEAD</option>
<option value="POST">POST</option> <option value="POST">POST</option>
@@ -54,7 +64,17 @@
<option value="OPTIONS">OPTIONS</option> <option value="OPTIONS">OPTIONS</option>
<option value="TRACE">TRACE</option> <option value="TRACE">TRACE</option>
<option value="PATCH">PATCH</option> <option value="PATCH">PATCH</option>
</select> </datalist>
<!-- <select id="method" v-model="method" @change="methodChange">
<option>GET</option>
<option>HEAD</option>
<option>POST</option>
<option>PUT</option>
<option>DELETE</option>
<option>OPTIONS</option>
<option>PATCH</option>
<option>LIST</option>
</select> -->
</li> </li>
<li> <li>
<label for="url">{{ $t("url") }}</label> <label for="url">{{ $t("url") }}</label>
@@ -85,7 +105,14 @@
type="text" type="text"
v-model="label" v-model="label"
placeholder="(optional)" placeholder="(optional)"
list="preLabels"
/> />
<datalist id="preLabels">
<option value="Login"></option>
<option value="Logout"></option>
<option value="Bug"></option>
<option value="Users"></option>
</datalist>
</li> </li>
<li> <li>
<label class="hide-on-small-screen" for="send">&nbsp;</label> <label class="hide-on-small-screen" for="send">&nbsp;</label>
@@ -1360,6 +1387,11 @@ export default {
} }
}, },
methods: { methods: {
checkCollections() {
const checkCollectionAvailability =
this.$store.state.postwoman.collections && this.$store.state.postwoman.collections.length > 0 ;
return checkCollectionAvailability;
},
scrollInto(view) { scrollInto(view) {
this.$refs[view].$el.scrollIntoView({ this.$refs[view].$el.scrollIntoView({
behavior: "smooth" behavior: "smooth"
@@ -1958,6 +1990,13 @@ export default {
); );
}, },
saveRequest() { saveRequest() {
if (!this.checkCollections()) {
this.$toast.error("Create a Collection", {
icon: "error"
});
return;
}
this.editRequest = { this.editRequest = {
url: this.url, url: this.url,
path: this.path, path: this.path,