diff --git a/app/components/explore/side-bar.js b/app/components/explore/side-bar.js index 7dec5728f40..3da9bc73451 100644 --- a/app/components/explore/side-bar.js +++ b/app/components/explore/side-bar.js @@ -1,155 +1,175 @@ import Component from '@ember/component'; import moment from 'moment'; -import { computed } from '@ember/object'; +import { computed, action } from '@ember/object'; import { not } from '@ember/object/computed'; import { getDateRanges } from 'open-event-frontend/utils/dictionary/filters'; -export default Component.extend({ +export default class extends Component { - classNames: ['ui', 'fluid', 'explore', 'vertical', 'menu'], + classNames = ['ui', 'fluid', 'explore', 'vertical', 'menu']; - customStartDate: moment().toISOString(), + customStartDate = moment().toISOString(); - customEndDate : null, - showFilters : false, + customEndDate = null; + showFilters = false; + isMapVisible = true; - hideClearFilters: computed('category', 'sub_category', 'event_type', 'startDate', 'endDate', 'location', 'ticket_type', 'cfs', function() { + @computed('category', 'sub_category', 'event_type', 'startDate', 'endDate', 'location', 'ticket_type', 'cfs') + get hideClearFilters() { return !(this.category || this.sub_category || this.event_type || this.startDate || this.endDate || this.location || this.ticket_type || this.cfs); - }), + } - showAllCategories: computed('category', 'sub_category', function() { + @computed('category', 'sub_category') + get showAllCategories() { return !this.category || !this.sub_category; + } - }), - showAllTypes: not('event_type'), - + showAllTypes = not('event_type'); - dateRanges: computed(function() { + @computed() + get dateRanges() { return getDateRanges.bind(this)(); - }), + } - showFiltersOnMobile: computed('device.isMobile', 'showFilters', function() { + @computed('device.isMobile', 'showFilters') + get showFiltersOnMobile() { return (!this.device.isMobile || this.showFilters); - }), - - actions: { - onLocationChangeHandler(lat, lng) { - this.setProperties({ - zoom: 17, - lat, - lng - }); - }, - selectCategory(category, subCategory) { - this.set('category', (category === this.category && !subCategory) ? null : category); - this.set('sub_category', (!subCategory || subCategory === this.sub_category) ? null : subCategory); - }, - - selectEventType(eventType) { - this.set('event_type', eventType === this.event_type ? null : eventType); - }, - - selectTicketType(ticketType) { - this.set('ticket_type', ticketType === this.ticket_type ? null : ticketType); - }, - - dateValidate(date) { - if (moment(date).isAfter(this.customEndDate)) { - this.set('customEndDate', date); - } + } - this.send('selectDateFilter', 'custom_dates'); - }, - - selectEventCfs(cfs) { - this.set('cfs', cfs === this.cfs ? null : cfs); - }, - - selectDateFilter(dateType) { - let newStartDate = null; - let newEndDate = null; - - if (dateType === this.dateType && dateType !== 'custom_dates') { - this.set('dateType', null); - } else { - this.set('dateType', dateType); - switch (dateType) { - case 'custom_dates': - newStartDate = this.customStartDate; - newEndDate = this.customEndDate; - break; - - case 'all_dates': - break; - - case 'today': - newStartDate = moment().toISOString(); - newEndDate = moment().toISOString(); - break; - - case 'tomorrow': - newStartDate = moment().add(1, 'day').toISOString(); - newEndDate = newStartDate; - break; - - case 'this_week': - newStartDate = moment().startOf('week').toISOString(); - newEndDate = moment().endOf('week').toISOString(); - break; - - case 'this_weekend': - newStartDate = moment().isoWeekday('Friday').toISOString(); - newEndDate = moment().isoWeekday('Sunday').toISOString(); - break; - - case 'next_week': - newStartDate = moment().isoWeekday('Monday').add(1, 'week').toISOString(); - newEndDate = moment().isoWeekday('Sunday').add(1, 'week').toISOString(); - break; - - case 'this_month': - newStartDate = moment().startOf('month').toISOString(); - newEndDate = moment().endOf('month').toISOString(); - break; - - default: - } - } + @action + onLocationChangeHandler(lat, lng) { + this.setProperties({ + zoom: 17, + lat, + lng + }); + } - this.set('startDate', newStartDate); - this.set('endDate', newEndDate); - }, - - onDateChange() { - this.send('selectDateFilter', 'custom_dates'); - }, - clearFilterCategory() { - this.setProperties({ - category : null, - sub_category : null - }); - - }, - clearFilterTypes() { - this.set('event_type', null); - }, - - clearFilters() { - this.setProperties({ - startDate : null, - endDate : null, - dateType : null, - category : null, - sub_category : null, - event_type : null, - location : null, - ticket_type : null, - cfs : null - }); - }, - - toggleFilters() { - this.set('showFilters', !this.showFilters); + @action + selectCategory(category, subCategory) { + this.set('category', (category === this.category && !subCategory) ? null : category); + this.set('sub_category', (!subCategory || subCategory === this.sub_category) ? null : subCategory); + } + + @action + selectEventType(eventType) { + this.set('event_type', eventType === this.event_type ? null : eventType); + } + + @action + selectTicketType(ticketType) { + this.set('ticket_type', ticketType === this.ticket_type ? null : ticketType); + } + + @action + dateValidate(date) { + if (moment(date).isAfter(this.customEndDate)) { + this.set('customEndDate', date); } + this.send('selectDateFilter', 'custom_dates'); + } + + @action + selectEventCfs(cfs) { + this.set('cfs', cfs === this.cfs ? null : cfs); + } + + @action + selectDateFilter(dateType) { + let newStartDate = null; + let newEndDate = null; + + if (dateType === this.dateType && dateType !== 'custom_dates') { + this.set('dateType', null); + } else { + this.set('dateType', dateType); + switch (dateType) { + case 'custom_dates': + newStartDate = this.customStartDate; + newEndDate = this.customEndDate; + break; + + case 'all_dates': + break; + + case 'today': + newStartDate = moment().toISOString(); + newEndDate = moment().toISOString(); + break; + + case 'tomorrow': + newStartDate = moment().add(1, 'day').toISOString(); + newEndDate = newStartDate; + break; + + case 'this_week': + newStartDate = moment().startOf('week').toISOString(); + newEndDate = moment().endOf('week').toISOString(); + break; + + case 'this_weekend': + newStartDate = moment().isoWeekday('Friday').toISOString(); + newEndDate = moment().isoWeekday('Sunday').toISOString(); + break; + + case 'next_week': + newStartDate = moment().isoWeekday('Monday').add(1, 'week').toISOString(); + newEndDate = moment().isoWeekday('Sunday').add(1, 'week').toISOString(); + break; + + case 'this_month': + newStartDate = moment().startOf('month').toISOString(); + newEndDate = moment().endOf('month').toISOString(); + break; + + default: + } + } + this.set('startDate', newStartDate); + this.set('endDate', newEndDate); + } + + @action + onDateChange() { + this.send('selectDateFilter', 'custom_dates'); + } + + @action + clearFilterCategory() { + this.setProperties({ + category : null, + sub_category : null + }); + + } + + @action + clearFilterTypes() { + this.set('event_type', null); + } + + @action + clearFilters() { + this.setProperties({ + startDate : null, + endDate : null, + dateType : null, + category : null, + sub_category : null, + event_type : null, + location : null, + ticket_type : null, + cfs : null + }); + } + + @action + toggleFilters() { + this.set('showFilters', !this.showFilters); + } + + @action + toggleMap() { + this.toggleProperty('isMapVisible'); } -}); +} diff --git a/app/templates/components/explore/side-bar.hbs b/app/templates/components/explore/side-bar.hbs index 61034cca136..6d1f9613fe0 100644 --- a/app/templates/components/explore/side-bar.hbs +++ b/app/templates/components/explore/side-bar.hbs @@ -1,8 +1,11 @@ -
+
{{#g-map markersFitMode='live' lat=37.7833 lng=-122.4167 zoom=2 address=location class='google-maps' as |context|}} {{g-map-address-marker context address=location onLocationChange=(action 'onLocationChangeHandler')}} {{/g-map}}
+{{#if device.isMobile}} +
{{if (not isMapVisible) 'Show' 'Hide'}} Map
+{{/if}}
{{widgets/forms/places-autocomplete