fixed all eslint errors and warning, compiled as PROD
This commit is contained in:
@ -18,7 +18,6 @@ import Blabla from './modules/blabla'
|
||||
import Showrooms from './modules/showrooms'
|
||||
import Pages from './modules/pages'
|
||||
|
||||
|
||||
// https://github.com/vuejs/vuex/tree/dev/examples/shopping-cart
|
||||
|
||||
Vue.use(Vuex)
|
||||
@ -38,16 +37,16 @@ export default createStore(Vuex.Store, {
|
||||
loadMaterialsGQL ({ dispatch }, { ids, gqlfragment, callBack, callBackArgs }) {
|
||||
console.log('loadMaterialsGQL ids', ids)
|
||||
|
||||
let ast = gql`{
|
||||
const ast = gql`{
|
||||
materiaux(ids: [${ids}]) {
|
||||
...MateriauFields
|
||||
}
|
||||
}
|
||||
${ gqlfragment }
|
||||
${gqlfragment}
|
||||
`
|
||||
MGQ.post('', { query: print(ast) })
|
||||
.then(( resp ) => {
|
||||
console.log('loadMaterialsGQL resp', resp )
|
||||
.then((resp) => {
|
||||
console.log('loadMaterialsGQL resp', resp)
|
||||
// dispatch('parseMaterialsGQL', {
|
||||
// items: resp.data.data.materiaux,
|
||||
// callBack: callBack,
|
||||
@ -79,7 +78,7 @@ export default createStore(Vuex.Store, {
|
||||
// params[`filter[${uuid}][condition][operator]`] = '='
|
||||
// params[`filter[${uuid}][condition][memberOf]`] = 'uuids-groupe'
|
||||
// }
|
||||
// // console.log('search JSONAPI params', params);
|
||||
// // console.log('search JSONAPI params', params)
|
||||
// const q = qs.stringify(params)
|
||||
// return JSONAPI.get('node/materiau?' + q)
|
||||
// .then(({ data }) => {
|
||||
@ -98,12 +97,12 @@ export default createStore(Vuex.Store, {
|
||||
// // so we loop from uuids to conserve the original order
|
||||
// console.log('mixin parseMaterials', data, uuids, callBack, callBackArgs)
|
||||
// const items = []
|
||||
// // for (var i = 0; i < data.length; i++) {
|
||||
// // for (let i = 0; i < data.length; i++) {
|
||||
// for (let i = 0; i < uuids.length; i++) {
|
||||
// const uuid = uuids[i]
|
||||
// // https://stackoverflow.com/questions/11258077/how-to-find-index-of-an-object-by-key-and-value-in-an-javascript-array
|
||||
// const item_index = data.findIndex(p => p.id === uuid)
|
||||
// // console.log('item_index', item_index);
|
||||
// // console.log('item_index', item_index)
|
||||
// if (item_index === -1) continue
|
||||
//
|
||||
// const item_src = data[item_index]
|
||||
@ -121,14 +120,14 @@ export default createStore(Vuex.Store, {
|
||||
//
|
||||
// // get images included values
|
||||
// const img_src = relations.images.data
|
||||
// // console.log('img_src', img_src);
|
||||
// // console.log('img_src', img_src)
|
||||
// // this is a temporary deactivation of images
|
||||
// // img_src = [];
|
||||
// item.images = []
|
||||
// for (let j = 0; j < img_src.length; j++) {
|
||||
// if (img_src[j].meta.imageDerivatives) {
|
||||
// let img_styles = {}
|
||||
// for (var k = 0; k < imgStyle.length; k++) {
|
||||
// for (let k = 0; k < imgStyle.length; k++) {
|
||||
// img_styles[imgStyle[k]] = img_src[j].meta.imageDerivatives.links.[imgStyle[k]].href
|
||||
// }
|
||||
// item.images.push({
|
||||
|
@ -40,7 +40,7 @@ export default {
|
||||
console.log('blabla REST: data', data)
|
||||
if (data.length) {
|
||||
commit('setItems', data)
|
||||
// console.log('items.length', this.items.length);
|
||||
// console.log('items.length', this.items.length)
|
||||
if (state.infiniteLoadingState) { state.infiniteLoadingState.loaded() }
|
||||
} else {
|
||||
if (state.infiniteLoadingState) { state.infiniteLoadingState.complete() }
|
||||
@ -60,8 +60,8 @@ export default {
|
||||
getItemIndex ({ dispatch, commit, state }, nid) {
|
||||
console.log('getItemIndex nid', nid)
|
||||
return state.items.findIndex((e) => {
|
||||
console.log('findIndex', e.nid, nid);
|
||||
return e.nid == nid
|
||||
console.log('findIndex', e.nid, nid)
|
||||
return e.nid === nid
|
||||
})
|
||||
},
|
||||
getPrevNextItems ({ dispatch, commit, state }, index) {
|
||||
|
@ -20,7 +20,7 @@ export default {
|
||||
console.log('Common, setPagetitle', title)
|
||||
state.pagetitle = title
|
||||
},
|
||||
setHamMenuState (state, s){
|
||||
setHamMenuState (state, s) {
|
||||
state.hamburgerMenuToggle.checked = s
|
||||
}
|
||||
},
|
||||
|
@ -29,15 +29,15 @@ export default {
|
||||
|
||||
// actions
|
||||
actions: {
|
||||
getProducts({ dispatch, commit, state }) {
|
||||
getProducts ({ dispatch, commit, state }) {
|
||||
dispatch('loadProductsIds')
|
||||
},
|
||||
loadProductsIds({ dispatch, commit, state }) {
|
||||
loadProductsIds ({ dispatch, commit, state }) {
|
||||
REST.get('/pricing_rest?_format=json', {})
|
||||
.then(({ data }) => {
|
||||
console.log('getProducts REST: data', data)
|
||||
let ids = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
const ids = []
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
ids.push(data[i].product_id)
|
||||
}
|
||||
commit('setProductsIds', ids)
|
||||
@ -48,17 +48,17 @@ export default {
|
||||
Promise.reject(error)
|
||||
})
|
||||
},
|
||||
loadProducts({ dispatch, commit, state }) {
|
||||
let ast = gql`{
|
||||
loadProducts ({ dispatch, commit, state }) {
|
||||
const ast = gql`{
|
||||
products(ids: [${state.products_ids}]) {
|
||||
...ProductsFields
|
||||
}
|
||||
}
|
||||
${ productsGQL }
|
||||
${productsGQL}
|
||||
`
|
||||
MGQ.post('', { query: print(ast) })
|
||||
.then(( resp ) => {
|
||||
console.log('loadProductsGQL resp', resp )
|
||||
.then((resp) => {
|
||||
console.log('loadProductsGQL resp', resp)
|
||||
commit('setProducts', resp.data.data.products)
|
||||
})
|
||||
.catch(error => {
|
||||
|
@ -41,11 +41,11 @@ export default {
|
||||
state.uuids = []
|
||||
},
|
||||
setResults (state, items) {
|
||||
// console.log('setResults, items', items);
|
||||
if(items){ // avoid bug like items = [null]
|
||||
// console.log('setResults, items', items)
|
||||
if (items) { // avoid bug like items = [null]
|
||||
state.items = state.items.concat(items)
|
||||
}
|
||||
// console.log('setResults, state.items', state.items);
|
||||
// console.log('setResults, state.items', state.items)
|
||||
},
|
||||
updateItem (state, item) {
|
||||
// state.items[data.index] = data.item // this is not triggering vuejs refresh
|
||||
@ -101,9 +101,9 @@ export default {
|
||||
commit('resetCount')
|
||||
commit('resetNoresults')
|
||||
commit('resetOffset')
|
||||
if(state.keys || state.term){
|
||||
if (state.keys || state.term) {
|
||||
this.commit('Common/setPagetitle', state.keys)
|
||||
}else{
|
||||
} else {
|
||||
this.commit('Common/setPagetitle', 'Base')
|
||||
}
|
||||
dispatch('getResults')
|
||||
@ -121,7 +121,7 @@ export default {
|
||||
offset: state.offset,
|
||||
limit: state.limit
|
||||
}
|
||||
// console.log('Search getResults params', params);
|
||||
// console.log('Search getResults params', params)
|
||||
const q = qs.stringify(params)
|
||||
return MA.get('/materio_sapi/getresults?' + q)
|
||||
.then(({ data }) => {
|
||||
@ -138,17 +138,17 @@ export default {
|
||||
// gqlfragment: materiauGQL,
|
||||
// callBack: 'loadSearchResultsCallBack'
|
||||
// })
|
||||
let ast = gql`{
|
||||
const ast = gql`{
|
||||
searchresults(ids: [${data.nids}], lang: "${drupalDecoupled.lang_code}") {
|
||||
...SearchResultFields
|
||||
}
|
||||
}
|
||||
${ searchresultGQL }
|
||||
${searchresultGQL}
|
||||
`
|
||||
MGQ.post('', { query: print(ast) })
|
||||
.then(resp => {
|
||||
console.log('loadSearchResultsGQL resp', resp )
|
||||
dispatch("loadSearchResultsCallBack", { items: resp.data.data.searchresults})
|
||||
console.log('loadSearchResultsGQL resp', resp)
|
||||
dispatch('loadSearchResultsCallBack', { items: resp.data.data.searchresults })
|
||||
})
|
||||
.catch(error => {
|
||||
console.warn('Issue with loadSearchResults', error)
|
||||
@ -178,20 +178,20 @@ export default {
|
||||
}
|
||||
}
|
||||
},
|
||||
refreshItem({ commit, state }, { id }) {
|
||||
console.log("Search refreshItem: id", id);
|
||||
let ast = gql`{
|
||||
refreshItem ({ commit, state }, { id }) {
|
||||
console.log('Search refreshItem: id', id)
|
||||
const ast = gql`{
|
||||
searchresult(id: ${id}, lang: "${drupalDecoupled.lang_code}") {
|
||||
...SearchResultFields
|
||||
}
|
||||
}
|
||||
${ searchresultGQL }
|
||||
${searchresultGQL}
|
||||
`
|
||||
MGQ.post('', { query: print(ast) })
|
||||
.then(resp => {
|
||||
console.log('refreshItem searchresult resp', resp )
|
||||
console.log('refreshItem searchresult resp', resp)
|
||||
// dispatch("loadSearchResultsCallBack", { items: resp.data.data.searchresults})
|
||||
commit("updateItem", resp.data.data.searchresult)
|
||||
commit('updateItem', resp.data.data.searchresult)
|
||||
})
|
||||
.catch(error => {
|
||||
console.warn('Issue with refreshItem', error)
|
||||
|
@ -49,11 +49,11 @@ export default {
|
||||
state.logout_token = data.logout_token
|
||||
},
|
||||
setLoginMessage (state, message) {
|
||||
console.log('setLoginMessage', message);
|
||||
console.log('setLoginMessage', message)
|
||||
state.loginMessage = message
|
||||
},
|
||||
setRegisterMessage (state, message) {
|
||||
console.log('setRegisterMessage', message);
|
||||
console.log('setRegisterMessage', message)
|
||||
state.registerMessage = message
|
||||
},
|
||||
setUid (state, uid) {
|
||||
@ -75,12 +75,12 @@ export default {
|
||||
state.roles.indexOf('admin') !== -1 ||
|
||||
state.roles.indexOf('root') !== -1
|
||||
) {
|
||||
// console.log('is admin');
|
||||
// console.log('is admin')
|
||||
state.isAdmin = true
|
||||
}
|
||||
// check if has access to search
|
||||
if (state.roles.indexOf('adherent') !== -1) {
|
||||
// console.log('is admin');
|
||||
// console.log('is admin')
|
||||
state.canSearch = true
|
||||
state.isAdherent = true
|
||||
}
|
||||
@ -140,21 +140,21 @@ export default {
|
||||
REST.post('/user/register?_format=json', credentials, {
|
||||
'X-CSRF-Token': state.csrftoken,
|
||||
validateStatus: function (status) {
|
||||
return status >= 200 && status < 500;
|
||||
return status >= 200 && status < 500
|
||||
}
|
||||
})
|
||||
.then((response) => {
|
||||
console.log('user REST registered', response)
|
||||
if(response.status === 200){
|
||||
if (response.status === 200) {
|
||||
dispatch('userLogin', credentials).then(() => {
|
||||
resolve()
|
||||
})
|
||||
}else{
|
||||
} else {
|
||||
let message = ''
|
||||
switch (response.status) {
|
||||
case 422:
|
||||
message = "email is already registered"
|
||||
break;
|
||||
message = 'email is already registered'
|
||||
break
|
||||
default:
|
||||
message = response.data.message
|
||||
}
|
||||
@ -168,15 +168,15 @@ export default {
|
||||
})
|
||||
})
|
||||
},
|
||||
userLogin ({ dispatch, state }, credentials) {
|
||||
userLogin ({ dispatch, commit, state }, credentials) {
|
||||
return new Promise((resolve, reject) => {
|
||||
dispatch('getToken', credentials)
|
||||
// TODO: catch failed login
|
||||
.then(() => {
|
||||
// there no response here, check the original getToken method
|
||||
// console.log('dispatch getToken response', response);
|
||||
// check if getToken (login) went well
|
||||
if(state.isloggedin){
|
||||
.then((response) => {
|
||||
console.log('userLogin dispatch getToken response', response)
|
||||
|
||||
if (response.status === 200) {
|
||||
commit('setToken', response.data)
|
||||
dispatch('getUser').then(userdata => {
|
||||
console.log('User Loggedin')
|
||||
if (state.isAdmin) {
|
||||
@ -184,9 +184,11 @@ export default {
|
||||
}
|
||||
resolve()
|
||||
})
|
||||
}else{
|
||||
} else {
|
||||
commit('setLoginMessage', response.data.message)
|
||||
console.warn('Issue with getToken', response)
|
||||
console.log('user loggein failed')
|
||||
Promise.reject('user loggein failed')
|
||||
Promise.reject(new Error('user loggein failed'))
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
@ -200,23 +202,9 @@ export default {
|
||||
credentials,
|
||||
{
|
||||
validateStatus: function (status) {
|
||||
return status >= 200 && status < 500;
|
||||
return status >= 200 && status < 500
|
||||
}
|
||||
})
|
||||
.then((response) => {
|
||||
console.log('user REST getToken response', response)
|
||||
if(response.status === 200){
|
||||
commit('setToken', response.data)
|
||||
}else if(response.data.message){
|
||||
commit('setLoginMessage', response.data.message)
|
||||
}else{
|
||||
console.warn('Issue with getToken', response)
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.warn('Issue with getToken', error)
|
||||
Promise.reject(error)
|
||||
})
|
||||
},
|
||||
getUser ({ dispatch, commit, state }) {
|
||||
return new Promise((resolve, reject) => {
|
||||
@ -248,7 +236,7 @@ export default {
|
||||
getUserFlagColls ({ dispatch, commit, state }) {
|
||||
// flags
|
||||
// REST.get('/flagging_collection/1?_format=json')
|
||||
// .then(( data ) => {
|
||||
// .then((data) => {
|
||||
// console.log('TEST FLAG REST data', data)
|
||||
// })
|
||||
// .catch(error => {
|
||||
@ -267,11 +255,11 @@ export default {
|
||||
})
|
||||
},
|
||||
// https://drupal.stackexchange.com/questions/248539/cant-get-flagging-api-to-accept-post-request
|
||||
createFlagColl ({ dispatch, commit, state }, new_collection_name) {
|
||||
console.log('user createFlagColl', new_collection_name)
|
||||
createFlagColl ({ dispatch, commit, state }, newCollectionName) {
|
||||
console.log('user createFlagColl', newCollectionName)
|
||||
return new Promise((resolve, reject) => {
|
||||
const params = {
|
||||
name: new_collection_name
|
||||
name: newCollectionName
|
||||
}
|
||||
MA.post('materio_flag/create_user_flagging_collection', params)
|
||||
.then(({ data }) => {
|
||||
@ -321,7 +309,6 @@ export default {
|
||||
// reload the fulllist of flagcolleciton
|
||||
dispatch('getUserFlagColls').then(() => {
|
||||
if (state.flagcolls[collid].items.length) {
|
||||
|
||||
dispatch('loadMaterialsGQL', {
|
||||
ids: state.flagcolls[collid].items,
|
||||
gqlfragment: materiauGQL,
|
||||
@ -373,7 +360,6 @@ export default {
|
||||
// callBack: 'loadMaterialsCallBack',
|
||||
// callBackArgs: { collid: collid }
|
||||
// })
|
||||
|
||||
} else {
|
||||
// call the mutation without data to only trigger the FlagCollection component update
|
||||
console.log('committing setLoadedCollItems without args')
|
||||
@ -399,6 +385,7 @@ export default {
|
||||
.then(resp => {
|
||||
console.log('userLogout resp', resp)
|
||||
commit('setLoggedOut')
|
||||
// window.location.reload(true) ???
|
||||
})
|
||||
.catch(error => {
|
||||
console.warn('Issue with logout', error)
|
||||
|
Reference in New Issue
Block a user