Skip to content

Commit

Permalink
cleanup(refactor): Split out router and store
Browse files Browse the repository at this point in the history
Split router and Store into their own service packages. Introduce vuex-router-sync to keep routing information in the store after page refreshes.
  • Loading branch information
mrmod committed Apr 14, 2020
1 parent 23f3843 commit 9ebf163
Show file tree
Hide file tree
Showing 14 changed files with 453 additions and 375 deletions.
10 changes: 8 additions & 2 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,20 @@ Things look good so far. Below are the things we talked about and wanted to get
# Bugs
* Adding an image to an Event fails to reload the comment data
* Private posts feature ; tagging in people
* Refresh of resourceful pages loses the store data since there's no resource information in the route
* Editability of Events, Posts, and Comments isn't checking permissions properly
* Refresh of resourceful pages loses the store data since there's no resource information in the route [Done]
* Editability of Events, Posts, and Comments isn't checking permissions properly [Done]

# Things

* Posts don't need tags right now
* Posts should be sortable by post.created_at and latest commented
* Posts should be the default view
* Who commented and when they commented
* Maybe make comments more distinct from the rest of the page?
* Keep the business category information and founding information with the My Business page
* Neighbors should show the other businesses in the same region
** Triggered from a click on MyBusiness.Location showing a list of them broken down by category
* When a region is created, a GoogleBusiness search will find businesses in the region and email them

# Features

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/v1/businesses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def show
# GET /businesses/:business_id/locations
def show_locations
@business = Business.find_by_id params[:business_id]
render json: @business.locations
render json: @business.locations, include: [:region]
end

# POST /businesses/:business_id/locations
Expand Down
21 changes: 15 additions & 6 deletions app/javascript/components/ShowEvent.vue
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
<template>
<div id="show-event">
<Event :event='event' />
<CommentList :comments='comments' :model_type='"Event"' :model_id='event.id' />
<Event v-if='isLoaded' :event='event' />
<CommentList v-if='isLoaded' :comments='comments' :model_type='"Event"' :model_id='event.id' />
</div>
</template>
<script>
import Event from './Event'
import EditableEvent from './EditableEvent.vue'
import CommentList from './CommentList.vue'
import {resourceId} from '../services/routing'
export default {
name: 'ShowEvent',
components: {CommentList, EditableEvent, Event},
data() {
return {isLoaded: false}
},
created() {
this.$store.dispatch('getEventComments', resourceId(this.$route))
Promise.all([
this.$store.dispatch('getEventComments', this.id),
this.$store.dispatch('getOneEvent', this.id),
])
.then(() => this.isLoaded = true)
},
computed: {
id() {
return this.$store.getters.id
},
event() {
return this.$store.getters.event(resourceId(this.$route))
return this.$store.getters.event(this.id)
},
comments() {
return this.$store.getters.eventComments(resourceId(this.$route))
return this.$store.getters.eventComments(this.id)
}
}
}
Expand Down
29 changes: 23 additions & 6 deletions app/javascript/components/ShowPost.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
<template>
<div id="post">
<Post
<Post v-if='isLoaded'
:post='post'
:media='media'>
<TagList :tags='tags' v-on:deleteTag='deleteTag' />
</Post>

<CommentList :comments='comments' :model_type='"Post"' :model_id='post.id' />
<CommentList
v-if='isLoaded'
:comments='comments'
:model_type='"Post"'
:model_id='post.id' />
</div>
</template>
<script>
Expand All @@ -25,20 +29,33 @@ export default {
data: function() {
return {
inViewMode: true,
isLoaded: false,
}
},
mounted() {
let id = this.$store.getters.id
return Promise.all([
this.$store.dispatch('getPostComments', id),
this.$store.dispatch('getOnePost', id),
this.$store.dispatch('getPostMedia', id),
])
.then(() => this.isLoaded = true)
},
computed: {
id() {
return this.$store.getters.id
},
comments: function() {
return this.$store.getters.postComments(parseInt(this.$route.params.id))
return this.$store.getters.postComments(this.id)
},
post: function() {
return this.$store.getters.post(parseInt(this.$route.params.id))
return this.$store.getters.post(this.id)
},
media: function() {
return this.$store.getters.postMedia(parseInt(this.$route.params.id))
return this.$store.getters.postMedia(this.id)
},
tags: function() {
return this.$store.getters.postTags(parseInt(this.$route.params.id))
return this.$store.getters.postTags(this.id)
},
isEditor: function() {
return parseInt(this.employee_id) === parseInt(this.$currentUser.employee_id)
Expand Down
Loading

0 comments on commit 9ebf163

Please sign in to comment.