Skip to content

Commit

Permalink
add post/event (fix): Fix add/post event toggle
Browse files Browse the repository at this point in the history
This allows  and   event to toggle the visibility of the creation form.
  • Loading branch information
mrmod committed Mar 15, 2020
1 parent 31d2d82 commit 6b9e11b
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 7 deletions.
7 changes: 6 additions & 1 deletion app/javascript/components/AddEvent.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<template>
<div id="add-event">
<span class="md-display-1" @click='toggleShowAddEvent'>Create a new event</span>
<EditableEvent v-if='showAddEvent' :event='event' v-on:createEvent='createEvent'/>
<EditableEvent
v-if='showAddEvent'
:event='event'
v-on:createEvent='createEvent'
v-on:changeMode='toggleShowAddEvent' />
</div>
</template>
<script>
Expand All @@ -25,6 +29,7 @@ export default {
business_id: this.event.business_id,
parent_id: this.event.parent_id,
errors: null,
showAddEvent: false,
}
}
return {
Expand Down
10 changes: 8 additions & 2 deletions app/javascript/components/AddPost.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
<template>
<div id="add-post">
<span class="md-display-1" @click='toggleShowAddPost'>Create a new post</span>
<EditablePost v-if='showAddPost' v-on:createPost='createPost' :post='post' />
<span class="md-display-1"
@click='toggleShowAddPost'>Create a new post</span>
<EditablePost
v-if='showAddPost'
v-on:createPost='createPost'
v-on:changeMode='toggleShowAddPost'
:post='post' />
</div>
</template>
<script>
Expand All @@ -20,6 +25,7 @@ export default {
private: this.post.private,
text: this.post.text,
topic: this.post.topic,
showAddPost: false,
}
}
return {
Expand Down
18 changes: 17 additions & 1 deletion app/javascript/components/EventList.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<template>
<div id="event-list">
<AddEvent v-on:eventAdded='$emit("eventAdded")' />
<AddEvent
:event='newEvent'
v-on:eventAdded='$emit("eventAdded")' />
<Event
v-on:eventDeleted='$emit("eventDeleted")'
v-for='event in events'
Expand All @@ -20,5 +22,19 @@ export default {
props: {
events: Array, // id, name, theme, description, start/end_time, parent/business_id
},
computed: {
newEvent: function() {
return {
name: '',
theme: '',
description: '',
start_time: '',
end_time: '',
business_id: this.$currentUser.business_id,
showAddEvent: false,
errors: null,
}
}
}
}
</script>
12 changes: 9 additions & 3 deletions app/javascript/components/PostList.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div id="post-list">
<AddPost v-on:addedPost='$emit("reloadPosts")' />
<AddPost :post='newPost' v-on:addedPost='$emit("reloadPosts")' />
<Post
:loadMedia='true'
:post='post'
Expand All @@ -18,8 +18,14 @@ export default {
posts: Array,
},
components: { AddPost, Post },
data: () => {
return {
computed: {
newPost: function() {
return {
employee_id: this.$currentUser.employee_id,
private: false,
text: '',
topic: '',
}
}
}
}
Expand Down

0 comments on commit 6b9e11b

Please sign in to comment.