This commit is contained in:
Matthieu Bessat 2020-07-22 14:31:00 +02:00
parent e987cf6c69
commit 4be9fea9fc

View file

@ -3,78 +3,97 @@ import Vuex from 'vuex'
Vue.use(Vuex)
export default new Vuex.Store({
state: {
alert: {
color: '',
text: '',
enabled: false
},
title: '',
tags: [],
data: {
name: '',
tags: [],
descriptionShort: '',
descriptionLong: '',
thumbnail: {
key: '',
contentType: '',
location: '',
type: 'thumbnail'
},
contacts: {
facebook: '',
twitter: '',
instagram: '',
website: '',
address: '',
person: '',
email: '',
phone: '',
peoples: []
}
},
delegate: {
validationState: 'unaware',
admiName: '',
email: '',
publicUrl: ''
},
debug: false,
validateMain: false,
validateMainCallback: (d = false) => d
interface AlertInterface {
color: string;
text: string;
enabled: boolean;
}
interface State {
alert: AlertInterface;
title: string;
tags: any;
data: any;
delegate: any;
debug: boolean;
validateMain: boolean;
validateMainCallback: any;
}
const defaultState: State = {
alert: {
color: '',
text: '',
enabled: false
},
title: '',
tags: [],
data: {
name: '',
tags: [],
descriptionShort: '',
descriptionLong: '',
thumbnail: {
key: '',
contentType: '',
location: '',
type: 'thumbnail'
},
contacts: {
facebook: '',
twitter: '',
instagram: '',
website: '',
address: '',
person: '',
email: '',
phone: '',
peoples: []
}
},
delegate: {
validationState: 'unaware',
admiName: '',
email: '',
publicUrl: ''
},
debug: false,
validateMain: false,
validateMainCallback: (d = false) => d
}
export default new Vuex.Store({
state: defaultState,
mutations: {
SET_DEBUG (state, payload) {
SET_DEBUG (state: State, payload) {
state.debug = payload
},
SET_TITLE (state, payload) {
SET_TITLE (state: State, payload) {
state.title = payload
window.document.title = state.title + ' | Panel forum des associations'
},
ADD_ALERT (state, payload) {
ADD_ALERT (state: State, payload) {
state.alert = {
color: payload.color,
text: payload.text,
enabled: true
}
},
DISABLE_ALERT (state) {
DISABLE_ALERT (state: State) {
state.alert.enabled = false
},
SET_DATA (state, payload) {
SET_DATA (state: State, payload) {
if (payload !== null) {
state.data = { ...state.data, ...payload }
}
},
SET_TAGS (state, payload) {
SET_TAGS (state: State, payload) {
state.tags = payload
},
SET_DELEGATE (state, payload) {
SET_DELEGATE (state: State, payload) {
state.delegate = { ...state.delegate, ...payload }
},
VALIDATE_MAIN (state, callback) {
VALIDATE_MAIN (state: State, callback) {
state.validateMain = true
state.validateMainCallback = (d: boolean) => {
state.validateMain = false