Skip to content

Commit 16c8ccf

Browse files
Merge branch 'development' into sorting-of-sales
2 parents 8d2577e + c2cf84e commit 16c8ccf

File tree

26 files changed

+798
-511
lines changed

26 files changed

+798
-511
lines changed

app/components/event-card.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { classNames } from '@ember-decorators/component';
33
import { action, computed } from '@ember/object';
44
import Component from '@ember/component';
55
import { forOwn } from 'lodash-es';
6+
import moment from 'moment';
67
import { pascalCase } from 'open-event-frontend/utils/string';
78

89
@classic
@@ -29,6 +30,12 @@ export default class EventCard extends Component {
2930
return this.isWide ? 'thirteen wide computer ten wide tablet sixteen wide mobile column ' + (!this.device.isMobile && 'rounded-l-none') : 'event fluid';
3031
}
3132

33+
@computed
34+
get isPastEvent() {
35+
const currentTime = moment.tz(this.event.timezone);
36+
return this.event.endsAt < currentTime;
37+
}
38+
3239
@action
3340
selectCategory(category, subCategory) {
3441
this.set('category', (category === this.category && !subCategory) ? null : category);

app/components/explore/side-bar.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ export default class SideBar extends Component {
1919
@tracked suggestions = [];
2020
isMapVisible = true;
2121

22-
@computed('category', 'sub_category', 'event_type', 'startDate', 'endDate', 'location', 'ticket_type', 'cfs', 'event_name', 'is_online', 'is_location', 'is_mixed', 'has_logo', 'has_image', 'is_past')
22+
@computed('category', 'sub_category', 'event_type', 'startDate', 'endDate', 'location', 'ticket_type', 'cfs', 'is_online', 'is_location', 'is_mixed', 'has_logo', 'has_image', 'is_past')
2323
get hideDefaultFilters() {
24-
return !(this.category || this.sub_category || this.event_type || this.startDate || this.endDate || this.location || this.ticket_type || this.cfs || this.event_name || this.is_online || this.is_location || this.is_mixed || this.has_logo || this.has_image || this.is_past);
24+
return !(this.category || this.sub_category || this.event_type || this.startDate || this.endDate || this.location || this.ticket_type || this.cfs || this.is_online || this.is_location || this.is_mixed || this.has_logo || this.has_image || this.is_past);
2525
}
2626

2727
@computed('model')

app/components/forms/group/group-events-form.js

Lines changed: 63 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,91 @@
11

22
import Component from '@ember/component';
33
import { action, computed } from '@ember/object';
4+
import { tracked } from '@glimmer/tracking';
45
import { inject as service } from '@ember/service';
56
import classic from 'ember-classic-decorator';
67
import FormMixin from 'open-event-frontend/mixins/form';
78
import moment from 'moment';
89
import { sortBy } from 'lodash-es';
10+
import { all } from 'rsvp';
911

1012
@classic
1113
export default class GroupEventsForm extends Component.extend(FormMixin) {
1214

1315
@service errorHandler;
1416

17+
@tracked eventToBeUpdate = [];
18+
@tracked unsavedEvents = [];
19+
@tracked savedEvents = [];
20+
1521
@action
1622
addEvent(event) {
23+
const eventIds = this.eventToBeUpdate.map(evnt => evnt.identifier);
24+
if (this.savedEvents.includes(event.id) && eventIds.includes(event.id)) {
25+
event.isAnnounced = true;
26+
this.eventToBeUpdate = this.eventToBeUpdate.filter(event => event.identifier === event.id);
27+
} else {
28+
event.isAnnounced = false;
29+
this.eventToBeUpdate.push(event);
30+
}
1731
this.group.events.pushObject(event);
1832
}
1933

2034
@action
2135
removeEvent(event) {
36+
if (event.isAnnounced) {
37+
event.isAnnounced = false;
38+
this.eventToBeUpdate.push(event);
39+
}
2240
this.group.events.removeObject(event);
2341
}
2442

43+
@action
44+
async announceEvent(event) {
45+
this.set('isLoading', true);
46+
try {
47+
const heading = this.l10n.t('Do you want to announce the event') + ' "' + event.name + '" ' + this.l10n.t('to all group members now') + '?';
48+
const options = {
49+
denyText : 'Cancel',
50+
denyColor : 'red',
51+
approveText : 'Yes',
52+
approveColor : 'green'
53+
};
54+
await this.confirm.prompt(heading, options);
55+
} catch {
56+
this.set('isLoading', false);
57+
return;
58+
}
59+
this.loader.load(`/groups/${this.group.id}/events/${event.identifier}/announce`)
60+
.then(() => {
61+
event.isAnnounced = true;
62+
this.notify.success(this.l10n.t('Event has been announced.'), {
63+
id: 'event_announce'
64+
});
65+
})
66+
.catch(() => {
67+
this.notify.error(this.l10n.t('Oops something went wrong. Please try again.'), {
68+
id: 'event_announce'
69+
});
70+
})
71+
.finally(() => {
72+
this.set('isLoading', false);
73+
});
74+
}
75+
2576
@computed('events.[]', 'group.events.[]')
2677
get remainingEvents() {
2778
return sortBy(this.events.toArray().filter(event => !this.group.events.toArray().includes(event)), ['startsAt']).reverse();
2879
}
2980

3081
@computed('events.[]', 'group.events.[]')
3182
get pastEvents() {
32-
return sortBy(this.events.toArray().filter(event => { return moment(event.endsAt) < moment()}), ['startsAt']).reverse();
83+
return sortBy(this.remainingEvents.toArray().filter(event => { return moment(event.endsAt) < moment()}), ['startsAt']).reverse();
3384
}
3485

3586
@computed('events.[]', 'group.events.[]')
3687
get upcomingEvents() {
37-
return sortBy(this.events.toArray().filter(event => { return moment(event.endsAt) > moment()}), ['startsAt']).reverse();
88+
return sortBy(this.remainingEvents.toArray().filter(event => { return moment(event.endsAt) > moment()}), ['startsAt']).reverse();
3889
}
3990

4091
@action
@@ -48,13 +99,17 @@ export default class GroupEventsForm extends Component.extend(FormMixin) {
4899
event.preventDefault();
49100
this.onValid(async() => {
50101
try {
51-
this.loading = true;
102+
this.set('isLoading', true);
52103
/* For the first save throws an error -> field may not be null, as social links are added in group-settings-form
53104
Hence, passing an empty array. */
54105
if (!this.group.socialLinks) {
55106
this.group.socialLinks = [];
56107
}
57108
await this.group.save();
109+
const updatedEvents = this.eventToBeUpdate.map(event => {
110+
return event.save();
111+
});
112+
await all([...updatedEvents]);
58113
this.notify.success(this.l10n.t('Your group has been saved'),
59114
{
60115
id: 'group_save'
@@ -64,8 +119,12 @@ export default class GroupEventsForm extends Component.extend(FormMixin) {
64119
console.error('Error while saving group', e);
65120
this.errorHandler.handle(e);
66121
} finally {
67-
this.loading = false;
122+
this.set('isLoading', false);
68123
}
69124
});
70125
}
126+
127+
didInsertElement() {
128+
this.set('savedEvents', [...this.groupEvents.toArray().map(event => event.identifier)]);
129+
}
71130
}

app/components/group-nav.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import classic from 'ember-classic-decorator';
2+
import Component from '@ember/component';
3+
import { action } from '@ember/object';
4+
import { tagName } from '@ember-decorators/component';
5+
6+
@classic
7+
@tagName('')
8+
export default class GroupNav extends Component {
9+
@action
10+
refreshRoute() {
11+
this.refresh();
12+
}
13+
}
14+

app/controllers/application.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export default class ApplicationController extends Controller {
5656

5757
@action
5858
search() {
59-
this.transitionToRoute('explore', { queryParams: { event_name: this.event_name } });
59+
this.transitionToRoute('explore.events', { queryParams: { name: this.event_name } });
6060
this.event_name = null;
6161
}
6262

app/controllers/explore.js renamed to app/controllers/explore/events.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import Controller from '@ember/controller';
44

55
@classic
66
export default class ExploreController extends Controller {
7-
queryParams = ['category', 'sub_category', 'event_type', 'start_date', 'end_date', 'location', 'ticket_type', 'cfs', 'event_name', 'is_online', 'is_location', 'is_mixed', 'has_logo', 'has_image', 'is_past'];
8-
event_name = null;
7+
queryParams = ['category', 'sub_category', 'event_type', 'start_date', 'end_date', 'location', 'ticket_type', 'cfs', 'name', 'is_online', 'is_location', 'is_mixed', 'has_logo', 'has_image', 'is_past'];
8+
name = null;
99
is_online = null;
1010
is_location = null;
1111
is_mixed = null;
@@ -29,8 +29,8 @@ export default class ExploreController extends Controller {
2929

3030
@action
3131
clearFilter(filterType) {
32-
if (filterType === 'event_name') {
33-
this.set('event_name', null);
32+
if (filterType === 'name') {
33+
this.set('name', null);
3434
}
3535
if (filterType === 'is_online') {
3636
this.set('is_online', null);
@@ -79,7 +79,7 @@ export default class ExploreController extends Controller {
7979
@action
8080
clearAllFilters() {
8181
this.setProperties({
82-
event_name : null,
82+
name : null,
8383
category : null,
8484
sub_category : null,
8585
event_type : null,

app/controllers/explore/groups.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import classic from 'ember-classic-decorator';
2+
import { action } from '@ember/object';
3+
import Controller from '@ember/controller';
4+
5+
@classic
6+
export default class ExploreController extends Controller {
7+
queryParams = ['name'];
8+
name = null;
9+
10+
@action
11+
clearFilter(filterType) {
12+
if (filterType === 'name') {
13+
this.set('name', null);
14+
}
15+
}
16+
17+
@action
18+
clearAllFilters() {
19+
this.setProperties({
20+
name: null
21+
});
22+
}
23+
}

app/models/event.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export default class Event extends ModelBase.extend(CustomPrimaryKeyMixin, {
5454
isChatEnabled : attr('boolean', { defaultValue: false }),
5555
isBillingInfoMandatory : attr('boolean', { defaultValue: false }),
5656
isDocumentEnabled : attr('boolean', { defaultValue: false }),
57+
isAnnounced : attr('boolean', { defaultValue: false }),
5758

5859
isTaxEnabled : attr('boolean', { defaultValue: false }),
5960
canPayByPaypal : attr('boolean', { defaultValue: false }),

app/router.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,10 @@ Router.map(function() {
175175
});
176176
});
177177
});
178-
this.route('explore');
178+
this.route('explore', function() {
179+
this.route('events');
180+
this.route('groups');
181+
});
179182
this.route('groups', function() {
180183
this.route('list');
181184
this.route('create');

0 commit comments

Comments
 (0)