2019-07-23 16:08:19 +00:00
|
|
|
<template>
|
|
|
|
<div style="">
|
|
|
|
<v-container grid-list-md>
|
|
|
|
<v-layout row wrap>
|
|
|
|
<v-flex md12>
|
|
|
|
<h1>New App</h1>
|
|
|
|
<v-text-field
|
|
|
|
label="Name"
|
|
|
|
value=""
|
|
|
|
type="text"
|
|
|
|
v-model="name"
|
|
|
|
error=true
|
2019-07-23 16:22:58 +00:00
|
|
|
:error=nameErrorFlag
|
|
|
|
:error-messages=nameError
|
2019-07-23 16:08:19 +00:00
|
|
|
></v-text-field>
|
|
|
|
<v-text-field
|
|
|
|
label="Description"
|
|
|
|
value=""
|
|
|
|
type="text"
|
|
|
|
v-model="description"
|
|
|
|
error=true
|
2019-07-23 16:22:58 +00:00
|
|
|
:error=descriptionErrorFlag
|
|
|
|
:error-messages=descriptionError
|
2019-07-23 16:08:19 +00:00
|
|
|
></v-text-field>
|
|
|
|
<v-text-field
|
|
|
|
label="URL"
|
|
|
|
value=""
|
|
|
|
type="text"
|
|
|
|
v-model="url"
|
2019-07-23 16:22:58 +00:00
|
|
|
:error-messages=urlError
|
|
|
|
:error=urlErrorFlag
|
2019-07-23 16:08:19 +00:00
|
|
|
></v-text-field>
|
|
|
|
</v-flex>
|
|
|
|
</v-layout>
|
|
|
|
|
|
|
|
<v-btn
|
|
|
|
color="success"
|
|
|
|
@click="createApp"
|
|
|
|
>
|
|
|
|
Create App
|
|
|
|
</v-btn>
|
|
|
|
|
|
|
|
</v-container>
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import AppService from '../services/Apps'
|
|
|
|
export default {
|
|
|
|
data () {
|
|
|
|
return {
|
|
|
|
name: '',
|
2019-07-23 16:22:58 +00:00
|
|
|
nameError: null,
|
|
|
|
nameErrorFlag: false,
|
2019-07-23 16:08:19 +00:00
|
|
|
description: '',
|
2019-07-23 16:22:58 +00:00
|
|
|
descriptionError: '',
|
|
|
|
descriptionErrorFlag: false,
|
|
|
|
url: '',
|
|
|
|
urlError: '',
|
|
|
|
urlErrorFlag: false
|
2019-07-23 16:08:19 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
createApp: function () {
|
2019-07-23 16:22:58 +00:00
|
|
|
this.nameErrorFlag = false;
|
|
|
|
this.nameError = null;
|
|
|
|
this.descriptionErrorFlag = false;
|
|
|
|
this.descriptionError = null;
|
|
|
|
this.urlErrorFlag = false;
|
|
|
|
this.urlError = null;
|
|
|
|
AppService.newApp(this.name, this.description, this.url).then((res) => {
|
|
|
|
this.$router.push({name: 'appDetails', params: {id: res.data.data.id}});
|
|
|
|
}).catch((error) => {
|
|
|
|
if(error.response.status == 422){
|
|
|
|
if(error.response.data.data.name != undefined) {
|
|
|
|
this.nameErrorFlag = true;
|
|
|
|
this.nameError = error.response.data.data.name[0]
|
|
|
|
}
|
|
|
|
if(error.response.data.data.description != undefined) {
|
|
|
|
this.descriptionErrorFlag = true;
|
|
|
|
this.descriptionError = error.response.data.data.description[0]
|
|
|
|
}
|
|
|
|
if(error.response.data.data.url != undefined) {
|
|
|
|
this.urlErrorFlag = true;
|
|
|
|
this.urlError = error.response.data.data.url[0]
|
|
|
|
}
|
|
|
|
console.log(error.response.data.data);
|
|
|
|
} else {
|
|
|
|
alert(error.response.data.msg);
|
|
|
|
}
|
|
|
|
});
|
2019-07-23 16:08:19 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted: function() {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|