| Server IP : 34.87.99.72 / Your IP : 216.73.217.31 Web Server : Apache/2.4.46 (Unix) OpenSSL/1.1.1n System : Linux zlock-bitnami-lamp-prod-v2-vm 4.19.0-16-cloud-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64 User : bitnami ( 1000) PHP Version : 7.4.18 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /opt/bitnami/apache/htdocs/app/resources/js/views/Boardcasts/ |
Upload File : |
<template>
<div>
<v-card class="radius-10">
<v-card-title>
<span class="headline">New Boardcast Message</span>
</v-card-title>
<v-divider class="mb-2"></v-divider>
<v-card-text class="py-4">
<v-row dense>
<v-col cols="12" md="12">
<v-text-field
v-model="form.title"
label="Title" placeholder="Title"
dense
counter
:error-messages="errors.title"
></v-text-field>
</v-col>
<v-col cols="12" md="12">
<v-textarea
v-model="form.content"
label="Content" placeholder="Content"
dense outlined
rows="2"
counter
:error-messages="errors.content"
></v-textarea>
</v-col>
</v-row>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn
color="blue darken-1" text title="Cancel"
@click="closeDialog()"
>
Cancel
</v-btn>
<v-btn
color="blue darken-1"
text title="Save"
:loading="submit_loading"
@click="submitForm(form)"
>
Save
</v-btn>
</v-card-actions>
</v-card>
</div>
</template>
<script>
import { errorHandlerMixin } from "@/js/mixins/ErrorHandlerMixin"
export default{
mixins: [
errorHandlerMixin
],
props:{
visible: {
type: Boolean,
required: true,
},
item: {
type: Object,
required: true,
default: ()=>{
return {}
}
},
action: {
type: String,
required: true,
},
},
data () {
return {
form : {},
errors : {},
submit_loading : false,
}
},
watch:{
'item':{
handler(){
this.form = this.item
},
immediate: true,
},
'visible':{
handler: function (newVal){
if(!newVal){
// reset
this.form = {}
this.errors = {}
}
},
immediate : true,
},
},
created(){
},
methods: {
initialize(){
this.closeDialog()
this.$emit('initialize')
},
closeDialog(){
this.$emit('update:visible',false)
},
submitForm(item){
this.saveModel(item)
},
saveModel(item){
this.submit_loading = true
this.errors = {}
let payload = {
title : item.title,
content : item.content,
}
let theApi = this.$api.createBoardcastMessage(payload)
theApi.then((res)=>{
this.$toast.success(res.data.message)
this.initialize()
}).catch((err) => {
this.errors = this.errorHandler_(err,[
"title",
"content",
])
}).finally(()=>{
this.submit_loading = false
})
},
}
}
</script>