-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c441ab1
commit 3b5cec8
Showing
13 changed files
with
791 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<template> | ||
<CRow> | ||
<CCol col="12" lg="6"> | ||
<CCard no-header> | ||
<CCardBody> | ||
<h4> | ||
Create Email Template | ||
</h4> | ||
<CAlert | ||
:show.sync="dismissCountDown" | ||
color="primary" | ||
fade | ||
> | ||
({{dismissCountDown}}) {{ message }} | ||
</CAlert> | ||
|
||
<CInput label="Name" type="text" placeholder="Name" v-model="template.name"></CInput> | ||
|
||
<CInput label="Subject" type="text" placeholder="Subject" v-model="template.subject"></CInput> | ||
|
||
<CTextarea textarea="true" label="Content" :rows="15" placeholder="Content.." v-model="template.content"></CTextarea> | ||
|
||
<CButton color="primary" @click="store()">Create</CButton> | ||
<CButton color="primary" @click="goBack">Back</CButton> | ||
</CCardBody> | ||
</CCard> | ||
</CCol> | ||
</CRow> | ||
</template> | ||
|
||
<script> | ||
import axios from 'axios' | ||
export default { | ||
name: 'CreateEmailTemplate', | ||
data: () => { | ||
return { | ||
template: { | ||
name: '', | ||
subject: '', | ||
content: '', | ||
}, | ||
message: '', | ||
dismissSecs: 7, | ||
dismissCountDown: 0, | ||
showDismissibleAlert: false | ||
} | ||
}, | ||
methods: { | ||
goBack() { | ||
this.$router.go(-1) | ||
// this.$router.replace({path: '/users'}) | ||
}, | ||
store() { | ||
let self = this; | ||
axios.post( '/api/mail?token=' + localStorage.getItem("api_token"), | ||
self.template | ||
) | ||
.then(function (response) { | ||
self.template = { | ||
name: '', | ||
subject: '', | ||
content: '', | ||
} | ||
self.message = 'Successfully created Email Template.'; | ||
self.showAlert(); | ||
}).catch(function (error) { | ||
if(error.response.data.message == 'The given data was invalid.'){ | ||
self.message = ''; | ||
for (let key in error.response.data.errors) { | ||
if (error.response.data.errors.hasOwnProperty(key)) { | ||
self.message += error.response.data.errors[key][0] + ' '; | ||
} | ||
} | ||
self.showAlert(); | ||
}else{ | ||
console.log(error); | ||
self.$router.push({ path: 'login' }); | ||
} | ||
}); | ||
}, | ||
countDownChanged (dismissCountDown) { | ||
this.dismissCountDown = dismissCountDown | ||
}, | ||
showAlert () { | ||
this.dismissCountDown = this.dismissSecs | ||
}, | ||
}, | ||
mounted: function(){ | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<template> | ||
<CRow> | ||
<CCol col="12" lg="6"> | ||
<CCard> | ||
<CCardBody> | ||
<h3> | ||
Edit Email Template | ||
</h3> | ||
<CAlert | ||
:show.sync="dismissCountDown" | ||
color="primary" | ||
fade | ||
> | ||
({{dismissCountDown}}) {{ message }} | ||
</CAlert> | ||
|
||
<CInput label="Name" type="text" placeholder="Name" v-model="template.name"></CInput> | ||
<CInput label="Subject" type="text" placeholder="Subject" v-model="template.subject"></CInput> | ||
<CTextarea textarea="true" label="Content" :rows="15" placeholder="Content.." v-model="template.content"></CTextarea> | ||
|
||
<CButton color="primary" @click="update()">Save</CButton> | ||
<CButton color="primary" @click="goBack">Back</CButton> | ||
</CCardBody> | ||
</CCard> | ||
</CCol> | ||
</CRow> | ||
</template> | ||
|
||
<script> | ||
import axios from 'axios' | ||
export default { | ||
name: 'EditEmailTemplate', | ||
data: () => { | ||
return { | ||
template: { | ||
name: '', | ||
subject: '', | ||
content: '', | ||
}, | ||
message: '', | ||
dismissSecs: 7, | ||
dismissCountDown: 0, | ||
} | ||
}, | ||
methods: { | ||
goBack() { | ||
this.$router.go(-1) | ||
// this.$router.replace({path: '/users'}) | ||
}, | ||
update() { | ||
let self = this; | ||
axios.post( '/api/mail/' + self.$route.params.id + '?token=' + localStorage.getItem("api_token"), | ||
{ | ||
_method: 'PUT', | ||
name: self.template.name, | ||
subject: self.template.subject, | ||
content: self.template.content, | ||
}) | ||
.then(function (response) { | ||
self.message = 'Successfully updated note.'; | ||
self.showAlert(); | ||
}).catch(function (error) { | ||
if(error.response.data.message == 'The given data was invalid.'){ | ||
self.message = ''; | ||
for (let key in error.response.data.errors) { | ||
if (error.response.data.errors.hasOwnProperty(key)) { | ||
self.message += error.response.data.errors[key][0] + ' '; | ||
} | ||
} | ||
self.showAlert(); | ||
}else{ | ||
console.log(error); | ||
self.$router.push({ path: '/login' }); | ||
} | ||
}); | ||
}, | ||
showAlert () { | ||
this.dismissCountDown = this.dismissSecs | ||
}, | ||
}, | ||
mounted: function(){ | ||
let self = this; | ||
axios.get( '/api/mail/' + self.$route.params.id + '/edit?token=' + localStorage.getItem("api_token")) | ||
.then(function (response) { | ||
self.template = response.data.template; | ||
}).catch(function (error) { | ||
console.log(error); | ||
self.$router.push({ path: '/login' }); | ||
}); | ||
} | ||
} | ||
</script> |
Oops, something went wrong.