@@ -123,6 +123,8 @@ export default { | |||||
promise = API.fetchPins(this.offset, this.pinFilters.tagFilter); | promise = API.fetchPins(this.offset, this.pinFilters.tagFilter); | ||||
} else if (this.pinFilters.userFilter) { | } else if (this.pinFilters.userFilter) { | ||||
promise = API.fetchPins(this.offset, null, this.pinFilters.userFilter); | promise = API.fetchPins(this.offset, null, this.pinFilters.userFilter); | ||||
} else if (this.pinFilters.boardFilter) { | |||||
promise = API.fetchPinsForBoard(this.pinFilters.boardFilter); | |||||
} else { | } else { | ||||
promise = API.fetchPins(this.offset); | promise = API.fetchPins(this.offset); | ||||
} | } | ||||
@@ -18,6 +18,21 @@ function fetchPins(offset, tagFilter, userFilter) { | |||||
); | ); | ||||
} | } | ||||
function fetchPinsForBoard(boardId) { | |||||
const url = `${API_PREFIX}boards/${boardId}`; | |||||
return new Promise( | |||||
(resolve, reject) => { | |||||
axios.get(url).then( | |||||
(resp) => { | |||||
resolve({ data: { results: resp.data.pins_detail } }); | |||||
}, | |||||
error => reject(error), | |||||
); | |||||
}, | |||||
); | |||||
} | |||||
export default { | export default { | ||||
fetchPins, | fetchPins, | ||||
fetchPinsForBoard, | |||||
}; | }; |
@@ -3,6 +3,7 @@ import VueRouter from 'vue-router'; | |||||
import Home from '../views/Home.vue'; | import Home from '../views/Home.vue'; | ||||
import Pins4Tag from '../views/Pins4Tag.vue'; | import Pins4Tag from '../views/Pins4Tag.vue'; | ||||
import Pins4User from '../views/Pins4User.vue'; | import Pins4User from '../views/Pins4User.vue'; | ||||
import Pins4Board from '../views/Pins4Board.vue'; | |||||
Vue.use(VueRouter); | Vue.use(VueRouter); | ||||
@@ -22,6 +23,11 @@ const routes = [ | |||||
name: 'user', | name: 'user', | ||||
component: Pins4User, | component: Pins4User, | ||||
}, | }, | ||||
{ | |||||
path: '/pins/boards/:boardId', | |||||
name: 'board', | |||||
component: Pins4Board, | |||||
}, | |||||
]; | ]; | ||||
const router = new VueRouter({ | const router = new VueRouter({ | ||||
@@ -0,0 +1,40 @@ | |||||
<template> | |||||
<div class="pins-for-board"> | |||||
<PHeader></PHeader> | |||||
<Pins :pin-filters="filters"></Pins> | |||||
</div> | |||||
</template> | |||||
<script> | |||||
import PHeader from '../components/PHeader.vue'; | |||||
import Pins from '../components/Pins.vue'; | |||||
export default { | |||||
name: 'p-header', | |||||
data() { | |||||
return { | |||||
filters: { boardFilter: null }, | |||||
}; | |||||
}, | |||||
components: { | |||||
PHeader, | |||||
Pins, | |||||
}, | |||||
created() { | |||||
this.initializeBoard(); | |||||
}, | |||||
beforeRouteUpdate(to, from, next) { | |||||
this.initializeBoard(); | |||||
next(); | |||||
}, | |||||
methods: { | |||||
initializeBoard() { | |||||
this.filters.boardFilter = this.$route.params.boardId; | |||||
}, | |||||
}, | |||||
}; | |||||
</script> | |||||
<!-- Add "scoped" attribute to limit CSS to this component only --> | |||||
<style scoped lang="scss"> | |||||
</style> |
@@ -1,5 +1,5 @@ | |||||
<template> | <template> | ||||
<div class="home"> | |||||
<div class="pins-for-tag"> | |||||
<PHeader></PHeader> | <PHeader></PHeader> | ||||
<Pins :pin-filters="filters"></Pins> | <Pins :pin-filters="filters"></Pins> | ||||
</div> | </div> | ||||
@@ -1,5 +1,5 @@ | |||||
<template> | <template> | ||||
<div class="home"> | |||||
<div class="pins-for-user"> | |||||
<PHeader></PHeader> | <PHeader></PHeader> | ||||
<Pins :pin-filters="filters"></Pins> | <Pins :pin-filters="filters"></Pins> | ||||
</div> | </div> | ||||
@@ -21,14 +21,14 @@ export default { | |||||
Pins, | Pins, | ||||
}, | }, | ||||
created() { | created() { | ||||
this.initializeUser(); | |||||
this.initializeBoard(); | |||||
}, | }, | ||||
beforeRouteUpdate(to, from, next) { | beforeRouteUpdate(to, from, next) { | ||||
this.initializeUser(); | |||||
this.initializeBoard(); | |||||
next(); | next(); | ||||
}, | }, | ||||
methods: { | methods: { | ||||
initializeUser() { | |||||
initializeBoard() { | |||||
this.filters.userFilter = this.$route.params.user; | this.filters.userFilter = this.$route.params.user; | ||||
}, | }, | ||||
}, | }, | ||||