strated to displaying falgcollection on the left of results
This commit is contained in:
@ -138,7 +138,6 @@ export default {
|
||||
this.loadingFlag = false;
|
||||
})
|
||||
}else{
|
||||
|
||||
this.flag({uuid: this.item.uuid, collid: collid})
|
||||
.then(data => {
|
||||
console.log("onFlagActionCard then", data);
|
||||
|
@ -0,0 +1,49 @@
|
||||
<template lang="html">
|
||||
<div
|
||||
:id="id"
|
||||
:class="{opened: isopened}"
|
||||
>
|
||||
<FlagCollection v-if='openedCollid' :collection='flagcolls[openedCollid]'/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapState, mapActions } from 'vuex'
|
||||
|
||||
import { MA } from 'vuejs/api/ma-axios'
|
||||
import router from 'vuejs/route'
|
||||
|
||||
import FlagCollection from 'vuejs/components/User/FlagCollection'
|
||||
|
||||
export default {
|
||||
router,
|
||||
props:['id'],
|
||||
data() {
|
||||
return {
|
||||
// isOpened: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState({
|
||||
flagcolls: state => state.User.flagcolls,
|
||||
openedCollid: state => state.User.openedCollid
|
||||
}),
|
||||
isopened () {
|
||||
return this.openedCollid
|
||||
}
|
||||
},
|
||||
beforeMount() {
|
||||
|
||||
},
|
||||
methods: {
|
||||
|
||||
},
|
||||
components: {
|
||||
FlagCollection
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
</style>
|
@ -0,0 +1,60 @@
|
||||
<template>
|
||||
<section class="flag-collection">
|
||||
<h3>{{collection.name}}</h3>
|
||||
<ul v-if="loadedItems">
|
||||
<li
|
||||
v-for="item in loadedItems"
|
||||
:key="item.id"
|
||||
>{{item.attributes.title}}</li>
|
||||
</ul>
|
||||
<span v-else class="loading">Loading</span>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapState, mapActions } from 'vuex'
|
||||
|
||||
export default {
|
||||
name: "FlagCollection",
|
||||
props: ['collection'],
|
||||
data: () => ({
|
||||
loadedItems: false
|
||||
}),
|
||||
computed: {
|
||||
...mapState({
|
||||
flagcolls: state => state.User.flagcolls
|
||||
// openedCollid: state => state.User.openedCollid
|
||||
})
|
||||
},
|
||||
// watch: {
|
||||
// flagcolls (newv, oldv) {
|
||||
// console.log('watching flagcolls');
|
||||
// if( typeof this.flagcolls[this.collection.id].loadedItems !== 'undefined' ) {
|
||||
// this.loadedItems = this.flagcolls[this.collection.id].loadedItems
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
created() {
|
||||
this.unsubscribe = this.$store.subscribe((mutation, state) => {
|
||||
if (mutation.type === 'User/setLoadedCollItems') {
|
||||
this.loadedItems = state.User.flagcolls[this.collection.id].loadedItems
|
||||
}
|
||||
});
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.unsubscribe()
|
||||
},
|
||||
// beforeMount () {
|
||||
// if (typeof this.flagcolls[collection.id].loadedItems === 'undefined') {
|
||||
// this.
|
||||
// }
|
||||
// },
|
||||
// methods: {
|
||||
// ...mapActions({
|
||||
// loadFlagCollItems: 'User/loadFlagCollItems'
|
||||
// })
|
||||
// }
|
||||
}
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
@ -4,8 +4,11 @@
|
||||
class="mdi mdi-folder-outline"
|
||||
>My folders</h2>
|
||||
<ul>
|
||||
<li v-if="flagcolls" v-for="coll in flagcolls" :key="coll.id">
|
||||
<h5>{{ coll.name }} ({{ coll.items.length }})</h5>
|
||||
<li v-if="flagcolls" v-for="coll in flagcolls" :key="coll.id">
|
||||
<h5
|
||||
:flagcollid="coll.id"
|
||||
@click.prevent="onOpenFlagColl"
|
||||
>{{ coll.name }} ({{ coll.items.length }})</h5>
|
||||
<div class="actions">
|
||||
<span
|
||||
class="delete-btn mdi"
|
||||
@ -64,7 +67,8 @@ export default {
|
||||
methods: {
|
||||
...mapActions({
|
||||
createFlagColl: 'User/createFlagColl',
|
||||
deleteFlagColl: 'User/deleteFlagColl'
|
||||
deleteFlagColl: 'User/deleteFlagColl',
|
||||
openFlagColl: 'User/openFlagColl'
|
||||
}),
|
||||
onCreateFlagColl () {
|
||||
console.log("UserFlags onCreateFlagColl", this.new_folder_name)
|
||||
@ -77,7 +81,7 @@ export default {
|
||||
})
|
||||
},
|
||||
onDeleteFlagColl (e) {
|
||||
let flagcollid = e.target.getAttribute('flagcollid');
|
||||
const flagcollid = e.target.getAttribute('flagcollid');
|
||||
console.log("UserFlags onDeleteFlagColl", flagcollid);
|
||||
this.is_deleting_folder = flagcollid;
|
||||
this.deleteFlagColl(flagcollid)
|
||||
@ -85,6 +89,14 @@ export default {
|
||||
// console.log("onDeleteFlagColl then", data);
|
||||
this.is_deleting_folder = false;
|
||||
})
|
||||
},
|
||||
onOpenFlagColl (e) {
|
||||
const flagcollid = e.target.getAttribute('flagcollid');
|
||||
console.log("UserFlags onDeleteFlagColl", flagcollid);
|
||||
this.openFlagColl(flagcollid)
|
||||
.then(() => {
|
||||
// console.log("onDeleteFlagColl then", data);
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ Vue.use(VueRouter)
|
||||
// const languages = ['en', 'fr'];
|
||||
// console.log('path aliases', (() => languages.map(l => `/${l}/base`))() );
|
||||
|
||||
let basePath = drupalSettings.path.baseUrl + drupalSettings.path.pathPrefix;
|
||||
const basePath = drupalSettings.path.baseUrl + drupalSettings.path.pathPrefix
|
||||
|
||||
const routes = [
|
||||
{
|
||||
@ -32,11 +32,11 @@ const routes = [
|
||||
// }
|
||||
},
|
||||
{
|
||||
name:'base',
|
||||
name: 'base',
|
||||
path: `${basePath}base`,
|
||||
// path: `/base`,
|
||||
// alias: (() => languages.map(l => `/${l}/base`))(),
|
||||
component: Base,
|
||||
component: Base
|
||||
// components: {
|
||||
// 'base': Base
|
||||
// }
|
||||
@ -53,20 +53,20 @@ const routes = [
|
||||
// ]
|
||||
// }
|
||||
{
|
||||
name:'blabla',
|
||||
name: 'blabla',
|
||||
path: `${basePath}blabla`,
|
||||
component: Blabla
|
||||
},
|
||||
{
|
||||
name:'article',
|
||||
name: 'article',
|
||||
path: `${basePath}blabla/:alias`,
|
||||
component: Article,
|
||||
component: Article
|
||||
// meta: { uuid:null }
|
||||
},
|
||||
{
|
||||
name:'showrooms',
|
||||
name: 'showrooms',
|
||||
path: `${basePath}showrooms`,
|
||||
component: Showrooms,
|
||||
component: Showrooms
|
||||
// meta: { uuid:null }
|
||||
},
|
||||
// {
|
||||
@ -77,7 +77,7 @@ const routes = [
|
||||
// }
|
||||
// },
|
||||
{
|
||||
name:'pricing',
|
||||
name: 'pricing',
|
||||
path: `${basePath}pricing`,
|
||||
component: Pricing
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { REST } from 'vuejs/api/rest-axios'
|
||||
// import { JSONAPI } from 'vuejs/api/json-axios';
|
||||
import { JSONAPI } from 'vuejs/api/json-axios'
|
||||
import { MA } from 'vuejs/api/ma-axios'
|
||||
import qs from 'querystring-es3'
|
||||
|
||||
@ -18,7 +18,8 @@ export default {
|
||||
isAdherent: false,
|
||||
canSearch: false,
|
||||
roles: [],
|
||||
flagcolls: false
|
||||
flagcolls: false,
|
||||
openedCollid: null
|
||||
},
|
||||
|
||||
// getters
|
||||
@ -84,6 +85,13 @@ export default {
|
||||
setFlagColls (state, flagcolls) {
|
||||
console.log('User setFlagColls', flagcolls)
|
||||
state.flagcolls = flagcolls
|
||||
},
|
||||
openFlagColl (state, collid) {
|
||||
state.openedCollid = collid
|
||||
},
|
||||
setLoadedCollItems (state, data) {
|
||||
console.log('setLoadedCollItems', data)
|
||||
state.flagcolls[data.collid].loadedItems = data.items
|
||||
}
|
||||
},
|
||||
|
||||
@ -262,6 +270,39 @@ export default {
|
||||
})
|
||||
})
|
||||
},
|
||||
openFlagColl ({ commit, dispatch }, collid) {
|
||||
console.log('user openFlagColl', collid)
|
||||
commit('openFlagColl', collid)
|
||||
dispatch('loadFlagCollItems', collid)
|
||||
},
|
||||
loadFlagCollItems ({ commit, state }, collid) {
|
||||
console.log('loadFlagCollItems', state.flagcolls[collid].items_uuids)
|
||||
const params = {
|
||||
'filter[uuids-groupe][group][conjunction]': 'OR'
|
||||
}
|
||||
const uuids = state.flagcolls[collid].items_uuids
|
||||
// console.log('uuids', uuids)
|
||||
for (let i = 0; i < uuids.length; i++) {
|
||||
let uuid = uuids[i]
|
||||
// console.log('uuid', uuid)
|
||||
params[`filter[${uuid}][condition][path]`] = 'id'
|
||||
params[`filter[${uuid}][condition][value]`] = uuid
|
||||
params[`filter[${uuid}][condition][operator]`] = '='
|
||||
params[`filter[${uuid}][condition][memberOf]`] = 'uuids-groupe'
|
||||
}
|
||||
console.log('search JSONAPI params', params);
|
||||
const q = qs.stringify(params)
|
||||
return JSONAPI.get('node/materiau?' + q)
|
||||
.then(({ data }) => {
|
||||
console.log('user loadFlagCollItems data', data)
|
||||
// dispatch('parseItems', { data: data.data, uuids: uuids })
|
||||
commit('setLoadedCollItems', {collid: collid, items: data.data})
|
||||
})
|
||||
.catch((error) => {
|
||||
console.warn('Issue with loadFlagCollItems', error)
|
||||
Promise.reject(error)
|
||||
})
|
||||
},
|
||||
userLogout ({ commit, state }) {
|
||||
const credentials = qs.stringify({
|
||||
token: state.csrf_token
|
||||
|
Reference in New Issue
Block a user