1
|
|
|
import Vuex from "vuex"; |
2
|
|
|
import Vue from 'vue'; |
3
|
|
|
|
4
|
|
|
import moment from 'moment' |
5
|
|
|
|
6
|
|
|
Vue.filter('formatDate', function(value) { |
7
|
|
|
if (value) { |
|
|
|
|
8
|
|
|
return moment(String(value)).format('MM/DD/YYYY hh:mm') |
9
|
|
|
} |
10
|
|
|
}); |
11
|
|
|
|
12
|
|
|
export const state = () => ({ |
13
|
|
|
person: {}, |
14
|
|
|
people: {}, |
15
|
|
|
chatMessages: '', |
16
|
|
|
role: {}, |
17
|
|
|
permission: [], |
18
|
|
|
}); |
19
|
|
|
|
20
|
|
|
export const getters = { |
21
|
|
|
getPerson: (state) => state.person, |
22
|
|
|
getPeople: (state) => state.people, |
23
|
|
|
isAuthenticated(state) { |
24
|
|
|
return state.auth.loggedIn |
25
|
|
|
}, |
26
|
|
|
|
27
|
|
|
loggedInUser(state) { |
28
|
|
|
return state.auth.user |
29
|
|
|
}, |
30
|
|
|
getRole: (state) => state.role, |
31
|
|
|
getPermission: (state) => state.permission, |
32
|
|
|
}; |
33
|
|
|
|
34
|
|
|
export const mutations = { |
35
|
|
|
SET_PERSON(state, person) { |
36
|
|
|
state.person = person; |
37
|
|
|
}, |
38
|
|
|
SET_PEOPLE(state, people) { |
39
|
|
|
state.people = people; |
40
|
|
|
}, |
41
|
|
|
SET_ROLE(state , role) { |
42
|
|
|
state.role = role |
43
|
|
|
}, |
44
|
|
|
SET_PERMISSION(state , permission) { |
45
|
|
|
state.permission = permission |
46
|
|
|
}, |
47
|
|
|
SET_UNREAD_COUNT(state, count){ |
48
|
|
|
state.auth.user.unreadMsgCount = count; |
49
|
|
|
} |
50
|
|
|
}; |
51
|
|
|
|
52
|
|
|
export const actions = { |
53
|
|
|
loadPerson({ commit, state }, id) { |
54
|
|
|
const person = state.people.find(person => person.id == id) |
55
|
|
|
commit("SET_PERSON", person); |
56
|
|
|
}, |
57
|
|
|
|
58
|
|
|
loadAccount({ commit, state }, id) { |
59
|
|
|
const account = state.accounts.find(account => account.id == id) |
60
|
|
|
commit("SET_ACCOUNT", account); |
61
|
|
|
}, |
62
|
|
|
async loadPeople({ commit }) { |
63
|
|
|
const people = await this.$axios.$get("/api/person?start=0&length=10"); |
64
|
|
|
commit("SET_PEOPLE", people); |
65
|
|
|
}, |
66
|
|
|
async deletePeople({ commit, dispatch }, id) { |
67
|
|
|
this.$axios |
68
|
|
|
.$delete("/api/person/" + id) |
69
|
|
|
.then(response => ( this.$router.push('/people') )) |
|
|
|
|
70
|
|
|
}, |
71
|
|
|
async loadRole({ commit }) { |
72
|
|
|
const role = await this.$axios.$get("/api/roles"); |
73
|
|
|
commit("SET_ROLE", role); |
74
|
|
|
}, |
75
|
|
|
async loadPermission({ commit }) { |
76
|
|
|
const permission = await this.$axios.$get("/api/permissions"); |
77
|
|
|
commit("SET_PERMISSION", permission); |
78
|
|
|
}, |
79
|
|
|
}; |
80
|
|
|
|
81
|
|
|
export default { |
82
|
|
|
state, |
83
|
|
|
getters, |
84
|
|
|
mutations, |
85
|
|
|
actions, |
86
|
|
|
}; |
87
|
|
|
|
This check looks for functions where a
return
statement is found in some execution paths, but not in all.Consider this little piece of code
The function
isBig
will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly returnundefined
.This behaviour may not be what you had intended. In any case, you can add a
return undefined
to the other execution path to make the return value explicit.