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) { if (places) {
wherePlace.name = places.split(',') wherePlace.name = places.split(',')
} }
console.log(wherePlace.name)
const events = await Event.findAll({ const events = await Event.findAll({
order: [['start_datetime', 'ASC']], order: [['start_datetime', 'ASC']],
where: { start_datetime: { [Sequelize.Op.gte]: yesterday } }, where: { start_datetime: { [Sequelize.Op.gte]: yesterday } },

View file

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

View file

@ -10,6 +10,7 @@
import { mapState, mapActions } from 'vuex' import { mapState, mapActions } from 'vuex'
import filters from '@/filters' import filters from '@/filters'
import moment from 'moment' import moment from 'moment'
import { intersection } from 'lodash'
export default { export default {
name: 'Calendar', name: 'Calendar',
@ -58,7 +59,21 @@ export default {
} }
}, },
computed: { 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 () { attributes () {
return [ return [
{ key: 'todaly', dates: new Date(), { key: 'todaly', dates: new Date(),
@ -67,7 +82,7 @@ export default {
}, },
popover: {label: this.$t('Today')} 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' b-card(bg-variant='dark' text-variant='white'
@click='$router.push("/event/" + event.id)' @click='$router.push("/event/" + event.id)'
:img-src='imgPath') :img-src='imgPath')
h4 {{event.title}} h5 {{event.title}}
div <v-icon name='clock'/> {{event.start_datetime|datetime}} 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}} span(v-b-popover.hover="event.place && event.place.address || ''") <v-icon name='map-marker-alt'/> {{event.place.name}}
br 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') 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}} small.float-right {{event.start_datetime|short_datetime}}
h5.mb-1 {{event.title}} h5.mb-1 {{event.title}}
small.mb-1 {{event.description}}
b-badge.float-right.ml-1(v-for='tag in event.tags') {{tag.tag}} 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}} small.float-right(v-b-popover.hover='event.place.address') {{event.place.name}}
Calendar(v-else) Calendar(v-else)

View file

@ -19,7 +19,7 @@
div div
b-badge.mr-1(@click="removeSelected(sel)" b-badge.mr-1(@click="removeSelected(sel)"
v-for="sel in selectedLabel" 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.groupMenu(v-show='showDropdown')
b-list-group-item(:key="$index" v-for="(item, $index) in matched" 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) { addSearchTag (state, tag) {
if (!state.filters.tags.find(t => t === tag.tag)) { if (!state.filters.tags.find(t => t === tag.tag)) {
state.filters.tags.push(tag.tag) state.filters.tags.push(tag.tag)
} else {
state.filters.tags = state.filters.tags.filter(t => t !== tag.tag)
} }
}, },
setSearchTags (state, tags) { setSearchTags (state, tags) {