|
@@ -3,6 +3,8 @@ import { REST } from 'vuejs/api/rest-axios'
|
|
import { MA } from 'vuejs/api/ma-axios'
|
|
import { MA } from 'vuejs/api/ma-axios'
|
|
import qs from 'querystring-es3'
|
|
import qs from 'querystring-es3'
|
|
|
|
|
|
|
|
+import materiauGQL from 'vuejs/api/gql/materiauflaglist.fragment.gql'
|
|
|
|
+
|
|
export default {
|
|
export default {
|
|
namespaced: true,
|
|
namespaced: true,
|
|
|
|
|
|
@@ -238,12 +240,12 @@ export default {
|
|
})
|
|
})
|
|
})
|
|
})
|
|
},
|
|
},
|
|
- flagUnflag ({ dispatch, commit, state }, { action, uuid, collid }) {
|
|
|
|
- console.log('user flagUnflag', action, uuid, collid)
|
|
|
|
|
|
+ flagUnflag ({ dispatch, commit, state }, { action, id, collid }) {
|
|
|
|
+ console.log('user flagUnflag', action, id, collid)
|
|
return new Promise((resolve, reject) => {
|
|
return new Promise((resolve, reject) => {
|
|
const params = {
|
|
const params = {
|
|
flagid: state.flagcolls[collid].flag_id,
|
|
flagid: state.flagcolls[collid].flag_id,
|
|
- uuid: uuid,
|
|
|
|
|
|
+ id: id,
|
|
flagcollid: collid
|
|
flagcollid: collid
|
|
}
|
|
}
|
|
return MA.post(`materio_flag/${action}`, params)
|
|
return MA.post(`materio_flag/${action}`, params)
|
|
@@ -251,15 +253,25 @@ export default {
|
|
console.log('user MA flag', data)
|
|
console.log('user MA flag', data)
|
|
// reload the fulllist of flagcolleciton
|
|
// reload the fulllist of flagcolleciton
|
|
dispatch('getUserFlagColls').then(() => {
|
|
dispatch('getUserFlagColls').then(() => {
|
|
- if (state.flagcolls[collid].items_uuids.length) {
|
|
|
|
- dispatch('loadMaterials', {
|
|
|
|
- uuids: state.flagcolls[collid].items_uuids,
|
|
|
|
- imgStyle: ['card_medium_half'],
|
|
|
|
|
|
+ if (state.flagcolls[collid].items.length) {
|
|
|
|
+
|
|
|
|
+ dispatch('loadMaterialsGQL', {
|
|
|
|
+ ids: state.flagcolls[collid].items,
|
|
|
|
+ gqlfragment: materiauGQL,
|
|
callBack: 'loadMaterialsCallBack',
|
|
callBack: 'loadMaterialsCallBack',
|
|
callBackArgs: { collid: collid }
|
|
callBackArgs: { collid: collid }
|
|
}).then(() => {
|
|
}).then(() => {
|
|
resolve()
|
|
resolve()
|
|
})
|
|
})
|
|
|
|
+
|
|
|
|
+ // dispatch('loadMaterials', {
|
|
|
|
+ // uuids: state.flagcolls[collid].items_uuids,
|
|
|
|
+ // imgStyle: ['card_medium_half'],
|
|
|
|
+ // callBack: 'loadMaterialsCallBack',
|
|
|
|
+ // callBackArgs: { collid: collid }
|
|
|
|
+ // }).then(() => {
|
|
|
|
+ // resolve()
|
|
|
|
+ // })
|
|
} else {
|
|
} else {
|
|
commit('setLoadedCollItems', { collid: collid, items: [] })
|
|
commit('setLoadedCollItems', { collid: collid, items: [] })
|
|
resolve()
|
|
resolve()
|
|
@@ -274,18 +286,27 @@ export default {
|
|
openFlagColl ({ commit, dispatch, state }, collid) {
|
|
openFlagColl ({ commit, dispatch, state }, collid) {
|
|
console.log('user openFlagColl', collid)
|
|
console.log('user openFlagColl', collid)
|
|
commit('openFlagColl', collid)
|
|
commit('openFlagColl', collid)
|
|
- if (state.flagcolls[collid].items_uuids.length) {
|
|
|
|
|
|
+ if (state.flagcolls[collid].items.length) {
|
|
if (typeof state.flagcollsLoadedItems[collid] === 'undefined') {
|
|
if (typeof state.flagcollsLoadedItems[collid] === 'undefined') {
|
|
- console.log('loading flagcoll items')
|
|
|
|
|
|
+ console.log('loading flagcoll items', state.flagcolls[collid])
|
|
// if no loadedItems, load them
|
|
// if no loadedItems, load them
|
|
// loadMaterials is on mixins
|
|
// loadMaterials is on mixins
|
|
// https://github.com/huybuidac/vuex-extensions
|
|
// https://github.com/huybuidac/vuex-extensions
|
|
- dispatch('loadMaterials', {
|
|
|
|
- uuids: state.flagcolls[collid].items_uuids,
|
|
|
|
- imgStyle: ['card_medium_half'],
|
|
|
|
|
|
+
|
|
|
|
+ dispatch('loadMaterialsGQL', {
|
|
|
|
+ ids: state.flagcolls[collid].items,
|
|
|
|
+ gqlfragment: materiauGQL,
|
|
callBack: 'loadMaterialsCallBack',
|
|
callBack: 'loadMaterialsCallBack',
|
|
callBackArgs: { collid: collid }
|
|
callBackArgs: { collid: collid }
|
|
})
|
|
})
|
|
|
|
+
|
|
|
|
+ // dispatch('loadMaterials', {
|
|
|
|
+ // uuids: state.flagcolls[collid].items_uuids,
|
|
|
|
+ // imgStyle: ['card_medium_half'],
|
|
|
|
+ // callBack: 'loadMaterialsCallBack',
|
|
|
|
+ // callBackArgs: { collid: collid }
|
|
|
|
+ // })
|
|
|
|
+
|
|
} else {
|
|
} else {
|
|
// call the mutation without data to only trigger the FlagCollection component update
|
|
// call the mutation without data to only trigger the FlagCollection component update
|
|
console.log('committing setLoadedCollItems without args')
|
|
console.log('committing setLoadedCollItems without args')
|