Browse Source

Feature: Pins for board works well

pull/169/head
winkidney 5 years ago
committed by Isaac Bythewood
parent
commit
4b5a55725f
6 changed files with 68 additions and 5 deletions
  1. +2
    -0
      pinry-spa/src/components/Pins.vue
  2. +15
    -0
      pinry-spa/src/components/api.js
  3. +6
    -0
      pinry-spa/src/router/index.js
  4. +40
    -0
      pinry-spa/src/views/Pins4Board.vue
  5. +1
    -1
      pinry-spa/src/views/Pins4Tag.vue
  6. +4
    -4
      pinry-spa/src/views/Pins4User.vue

+ 2
- 0
pinry-spa/src/components/Pins.vue View File

@@ -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);
} }


+ 15
- 0
pinry-spa/src/components/api.js View File

@@ -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,
}; };

+ 6
- 0
pinry-spa/src/router/index.js View File

@@ -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({


+ 40
- 0
pinry-spa/src/views/Pins4Board.vue View File

@@ -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
- 1
pinry-spa/src/views/Pins4Tag.vue View File

@@ -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>


+ 4
- 4
pinry-spa/src/views/Pins4User.vue View File

@@ -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;
}, },
}, },


Loading…
Cancel
Save