This commit is contained in:
lesion 2019-03-02 00:02:13 +01:00
parent b50a9a250c
commit f3dab2d315
7 changed files with 44 additions and 31 deletions

View file

@ -19,7 +19,6 @@ const exportController = {
if (places) {
wherePlace.name = places.split(',')
}
console.log(wherePlace.name)
const events = await Event.findAll({
order: [['start_datetime', 'ASC']],
where: { start_datetime: { [Sequelize.Op.gte]: yesterday } },

View file

@ -6,7 +6,6 @@
b-collapse#nav_collapse(is-nav)
b-navbar-nav.ml-auto(v-if='logged')
b-nav-item(to='/new_event') <v-icon color='lightgreen' name='plus'/> {{$t('Add Event')}}
b-nav-item(@click='search=!search') <v-icon color='lightgreen' name='search'/> {{$t('Search')}}
b-nav-item(to='/settings') <v-icon color='orange' name='cog'/> {{$t('Settings')}}
b-nav-item(v-if='user.is_admin' to='/admin') <v-icon color='lightblue' name='tools'/> {{$t('Admin')}}
b-nav-item(variant='danger' @click='logout') <v-icon color='red' name='sign-out-alt'/> {{$t('Logout')}}
@ -15,24 +14,29 @@
b-nav-item(to='/register') {{$t('Register')}}
b-nav-item(to='/login') {{$t('Login')}}
transition(name='toggle')
b-navbar#search(v-if='search' type='dark' variant="dark" toggleable='lg')
b-navbar-nav
b-nav-form
typeahead.ml-1(v-model='filters_places'
textField='name' valueField='name'
updateOnMatchOnly
:data='places' multiple placeholder='Luogo')
b-nav-form
typeahead.ml-1(v-model='filters_tags'
updateOnMatchOnly
textField='tag' valueField='tag'
:data='tags' multiple placeholder='Tags')
b-navbar-nav.ml-auto(variant='dark')
b-nav-item(to='/export/feed' href='#') <v-icon color='orange' name='rss'/> feed
b-nav-item(to='/export/ics') <v-icon color='orange' name='calendar'/> cal
b-nav-item(to='/export/email') <v-icon color='orange' name='envelope'/> mail
b-nav-item(to='/export/embed') <v-icon color='orange' name='code'/> embed
b-nav-item(to='/export/print') <v-icon color='orange' name='print'/> print
b-navbar#search(type='dark' variant="dark" toggleable='lg')
b-navbar-toggle(target='nav_search')
v-icon(name='search')
b-collapse#nav_search(is-nav)
<template slot="button-content"><em>User</em></template>
b-navbar-nav
b-nav-form
typeahead.ml-1.mt-1(v-model='filters_places'
textField='name' valueField='name'
updateOnMatchOnly
:data='places' multiple placeholder='Luogo')
b-nav-form
typeahead.ml-1.mt-1(v-model='filters_tags'
updateOnMatchOnly
textField='tag' valueField='tag'
:data='tags' multiple placeholder='Tags')
b-navbar-nav.ml-auto(variant='dark')
b-nav-item(to='/export/feed' href='#') <v-icon color='orange' name='rss'/> feed
b-nav-item(to='/export/ics') <v-icon color='orange' name='calendar'/> cal
b-nav-item(to='/export/email') <v-icon color='orange' name='envelope'/> mail
b-nav-item(to='/export/embed') <v-icon color='orange' name='code'/> embed
b-nav-item(to='/export/print') <v-icon color='orange' name='print'/> print
Home
transition(name="fade" mode="out-in")
router-view(name='modal')
@ -54,20 +58,14 @@ export default {
mounted () {
this.updateMeta()
},
data () {
return {search: false}
},
components: { Register, Login, Home, Settings, newEvent, eventDetail },
computed: {
...mapState(['logged', 'user', 'filters', 'tags', 'places']),
filters_tags: {
set (value) {
console.log('dentro set ', value)
this.setSearchTags(value)
},
get () {
console.log('dentro get')
console.log(this.filters)
return this.filters.tags
}
},

View file

@ -10,6 +10,7 @@
import { mapState, mapActions } from 'vuex'
import filters from '@/filters'
import moment from 'moment'
import { intersection } from 'lodash'
export default {
name: 'Calendar',
@ -58,7 +59,21 @@ export default {
}
},
computed: {
...mapState(['events', 'tags']),
filteredEvents () {
if (!this.filters.tags.length && !this.filters.places.length) return this.events
return this.events.filter(e => {
if (this.filters.tags.length) {
const m = intersection(e.tags.map(t => t.tag), this.filters.tags)
if (m.length>0) return true
}
if (this.filters.places.length) {
if (this.filters.places.find(p => p === e.place.name))
return true
}
return 0
})
},
...mapState(['events', 'tags', 'filters']),
attributes () {
return [
{ key: 'todaly', dates: new Date(),
@ -67,7 +82,7 @@ export default {
},
popover: {label: this.$t('Today')}
},
...this.events.map(this.eventToAttribute)
...this.filteredEvents.map(this.eventToAttribute)
]
}
}

View file

@ -2,7 +2,7 @@
b-card(bg-variant='dark' text-variant='white'
@click='$router.push("/event/" + event.id)'
:img-src='imgPath')
h4 {{event.title}}
h5 {{event.title}}
div <v-icon name='clock'/> {{event.start_datetime|datetime}}
span(v-b-popover.hover="event.place && event.place.address || ''") <v-icon name='map-marker-alt'/> {{event.place.name}}
br

View file

@ -29,7 +29,6 @@
img(v-if='event.image_path' slot="aside" :src="imgPath(event)" alt="Media Aside" style='max-height: 60px')
small.float-right {{event.start_datetime|short_datetime}}
h5.mb-1 {{event.title}}
small.mb-1 {{event.description}}
b-badge.float-right.ml-1(v-for='tag in event.tags') {{tag.tag}}
small.float-right(v-b-popover.hover='event.place.address') {{event.place.name}}
Calendar(v-else)

View file

@ -19,7 +19,7 @@
div
b-badge.mr-1(@click="removeSelected(sel)"
v-for="sel in selectedLabel"
:key="sel") {{sel}}
:key="sel") <v-icon color='orange' name='times' /> {{sel}}
b-list-group.groupMenu(v-show='showDropdown')
b-list-group-item(:key="$index" v-for="(item, $index) in matched"

View file

@ -62,6 +62,8 @@ export default new Vuex.Store({
addSearchTag (state, tag) {
if (!state.filters.tags.find(t => t === tag.tag)) {
state.filters.tags.push(tag.tag)
} else {
state.filters.tags = state.filters.tags.filter(t => t !== tag.tag)
}
},
setSearchTags (state, tags) {