Skip to content

Commit

Permalink
feat: remember voted feature by local cookie
Browse files Browse the repository at this point in the history
  • Loading branch information
Youen Chene committed Oct 10, 2017
1 parent d74da04 commit 332e015
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 18 deletions.
47 changes: 30 additions & 17 deletions front/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion front/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"vue-router": "^2.6.0",
"vuex": "^2.3.1",
"axios": "^0.16.2",
"vee-validate": "2.0.0-rc.13"
"vee-validate": "2.0.0-rc.13",
"vue-cookie": "latest"
},
"devDependencies": {
"autoprefixer": "^7.1.2 ",
Expand Down
5 changes: 5 additions & 0 deletions front/src/store/store.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import Vuex from 'vuex';
import Vue from 'vue';
import VueCookie from 'vue-cookie';
import featmgtService from '../service/featuremanagement';

Vue.use(Vuex);
Vue.use(VueCookie);


const state = {
features: [],
Expand Down Expand Up @@ -43,6 +46,7 @@ const actions = {

const mutations = {
FILL_ALL_FEATURE(state, features) {
features.forEach((f) => { if (Vue.cookie.get(f.id) === 'v') { f.voted = true; } });
state.features = features;
},
NEW_FEATURE(state, feature) {
Expand All @@ -61,6 +65,7 @@ const mutations = {
VOTE_FEATURE(state, value) {
value.feature.score += value.note;
value.feature.voted = true;
Vue.cookie.set(value.feature.id, 'v', 60);
},
};

Expand Down

0 comments on commit 332e015

Please sign in to comment.