-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(posts): Reuse add/edit component
- Loading branch information
Showing
9 changed files
with
152 additions
and
53 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
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,65 @@ | ||
<template> | ||
<div id="editable-post"> | ||
<Errors :errors='errors' /> | ||
<md-field> | ||
<md-input placeholder='What is this post about?' v-model='topic'></md-input> | ||
</md-field> | ||
<md-field> | ||
<md-input placeholder='Describe what you are talking about' v-model='text'></md-input> | ||
</md-field> | ||
<md-switch v-model='private'>Private?</md-switch> | ||
<md-button class="md-raised md-primary" @click='savePost'>Save</md-button> | ||
<md-button class="md-accent" @click='cancel'> | ||
Cancel | ||
</md-button> | ||
</div> | ||
</template> | ||
<script> | ||
import Errors from './Errors.vue' | ||
export default { | ||
name: 'EditablePost', | ||
components: {Errors}, | ||
props: { | ||
post: {type: Object, required: false}, | ||
}, | ||
data: function() { | ||
if (this.post) { | ||
return { | ||
id: this.post.id, | ||
topic: this.post.topic, | ||
text: this.post.text, | ||
employee_id: this.post.employee_id, | ||
private: this.post.private, | ||
errors: null, | ||
} | ||
} | ||
return { | ||
employee_id: this.$currentUser.employee_id, | ||
private: false, | ||
text: '', | ||
topic: '', | ||
showAddPost: false, | ||
errors: null, | ||
} | ||
}, | ||
methods: { | ||
savePost: function() { | ||
const post = { | ||
id: this.id, | ||
topic: this.topic, | ||
text: this.text, | ||
employee_id: this.employee_id, | ||
private: this.private, | ||
} | ||
if (this.post) { | ||
this.$emit('updatePost', post) | ||
} else { | ||
this.$emit('createPost', post) | ||
} | ||
}, | ||
cancel: function() { | ||
this.$emit('changeMode') | ||
} | ||
} | ||
} | ||
</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
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
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