Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion app/components/forms/group/group-events-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { action, computed } from '@ember/object';
import { inject as service } from '@ember/service';
import classic from 'ember-classic-decorator';
import FormMixin from 'open-event-frontend/mixins/form';
import moment from 'moment';
import { sortBy } from 'lodash-es';

@classic
export default class GroupEventsForm extends Component.extend(FormMixin) {
Expand Down Expand Up @@ -41,7 +43,17 @@ export default class GroupEventsForm extends Component.extend(FormMixin) {

@computed('events.[]', 'group.events.[]')
get remainingEvents() {
return this.events.toArray().filter(event => !this.group.events.toArray().includes(event));
return sortBy(this.events.toArray().filter(event => !this.group.events.toArray().includes(event)), ['startsAt']).reverse();
}

@computed('events.[]', 'group.events.[]')
get pastEvents() {
return sortBy(this.events.toArray().filter(event => { return moment(event.endsAt) < moment()}), ['startsAt']).reverse();
}

@computed('events.[]', 'group.events.[]')
get upcomingEvents() {
return sortBy(this.events.toArray().filter(event => { return moment(event.endsAt) > moment()}), ['startsAt']).reverse();
}

@action
Expand Down
15 changes: 14 additions & 1 deletion app/components/forms/group/group-view.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
import Component from '@ember/component';
import { action } from '@ember/object';
import { computed, action } from '@ember/object';
import classic from 'ember-classic-decorator';
import FormMixin from 'open-event-frontend/mixins/form';
import moment from 'moment';
import { sortBy } from 'lodash-es';

@classic
export default class GroupView extends Component.extend(FormMixin) {

@computed('events.[]', 'group.events.[]')
get pastEvents() {
return sortBy(this.group.events.toArray().filter(event => { return moment(event.endsAt) < moment()}), ['startsAt']).reverse();
}

@computed('events.[]', 'group.events.[]')
get upcomingEvents() {
return sortBy(this.group.events.toArray().filter(event => { return moment(event.endsAt) > moment()}), ['startsAt']).reverse();
}

@action
shareEvent() {}
}
13 changes: 10 additions & 3 deletions app/templates/components/forms/group/group-events-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,19 @@
</div>
{{/if}}
</div>

<div class="mb-4">
{{#if this.remainingEvents}}
<h2 class="main-heading mb-4">{{t 'All Events'}}</h2>
<div class="ui hidden divider"></div>
<h2 class="main-heading">{{t 'Upcoming Events'}}</h2>
<div class="ui stackable three column grid">
{{#each this.upcomingEvents as |event|}}
<EventCard @event={{event}} @shareEvent={{action "shareEvent"}} @addToGroup={{true}} @addEvent={{action "addEvent"}}/>
{{/each}}
</div>
<div class="ui hidden divider"></div>
<h2 class="main-heading">{{t 'Past Events'}}</h2>
<div class="ui stackable three column grid">
{{#each this.remainingEvents as |event|}}
{{#each this.pastEvents as |event|}}
<EventCard @event={{event}} @shareEvent={{action "shareEvent"}} @addToGroup={{true}} @addEvent={{action "addEvent"}}/>
{{/each}}
</div>
Expand Down
21 changes: 16 additions & 5 deletions app/templates/components/forms/group/group-view.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,22 @@
{{/if}}
{{/each}}
</div>
<div class="ui stackable three column grid">
{{#each @group.events as |event|}}
<EventCard @event={{event}} @shareEvent={{action "shareEvent"}} @removeFromGroup={{false}} />
{{/each}}
</div>
{{#if this.upcomingEvents}}
<h2 class="main-heading mb-4">{{t 'Upcoming Events'}}</h2>
<div class="ui stackable three column grid">
{{#each this.upcomingEvents as |event|}}
<EventCard @event={{event}} @shareEvent={{action "shareEvent"}} />
{{/each}}
</div>
{{/if}}
{{#if this.pastEvents}}
<h2 class="main-heading mb-4">{{t 'Past Events'}}</h2>
<div class="ui stackable three column grid">
{{#each this.pastEvents as |event|}}
<EventCard @event={{event}} @shareEvent={{action "shareEvent"}} />
{{/each}}
</div>
{{/if}}
{{/if}}
</div>
</div>