Skip to content

Commit

Permalink
Merge branch 'development' of https://github.com/fossasia/open-event-…
Browse files Browse the repository at this point in the history
…frontend into development
  • Loading branch information
maze-runnar committed Aug 8, 2021
2 parents fadde90 + c2cf84e commit c843d1a
Show file tree
Hide file tree
Showing 37 changed files with 879 additions and 557 deletions.
7 changes: 7 additions & 0 deletions app/components/event-card.js
Expand Up @@ -3,6 +3,7 @@ import { classNames } from '@ember-decorators/component';
import { action, computed } from '@ember/object';
import Component from '@ember/component';
import { forOwn } from 'lodash-es';
import moment from 'moment';
import { pascalCase } from 'open-event-frontend/utils/string';

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

@computed
get isPastEvent() {
const currentTime = moment.tz(this.event.timezone);
return this.event.endsAt < currentTime;
}

@action
selectCategory(category, subCategory) {
this.set('category', (category === this.category && !subCategory) ? null : category);
Expand Down
4 changes: 2 additions & 2 deletions app/components/explore/side-bar.js
Expand Up @@ -19,9 +19,9 @@ export default class SideBar extends Component {
@tracked suggestions = [];
isMapVisible = true;

@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')
@computed('category', 'sub_category', 'event_type', 'startDate', 'endDate', 'location', 'ticket_type', 'cfs', 'is_online', 'is_location', 'is_mixed', 'has_logo', 'has_image', 'is_past')
get hideDefaultFilters() {
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);
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);
}

@computed('model')
Expand Down
24 changes: 18 additions & 6 deletions app/components/forms/events/view/videoroom-form.js
Expand Up @@ -259,6 +259,9 @@ export default class VideoroomForm extends Component.extend(FormMixin) {
this.data.stream.extra.bbb_options.endCurrentMeeting = this.showUpdateOptions ? this.endCurrentMeeting : false;
await this.data.stream.save();
const saveModerators = this.data.stream.moderators.toArray().map(moderator => {
if (moderator.id) {
return moderator;
}
return moderator.save();
});
const deleteModerators = this.deletedModerators.map(moderator => {
Expand Down Expand Up @@ -291,20 +294,29 @@ export default class VideoroomForm extends Component.extend(FormMixin) {
this.onValid(() => {
const existingEmails = this.data.stream.moderators.map(moderator => moderator.email);
if (!existingEmails.includes(this.moderatorEmail)) {
const moderator = this.store.createRecord('video-stream-moderator', {
email : this.moderatorEmail,
videoStream : this.data.stream
});
this.data.stream.moderators.pushObject(moderator);
const existingModerator = this.deletedModerators.filter(moderator => moderator.email === this.moderatorEmail);
if (existingModerator.length === 0) {
const newModerator = this.store.createRecord('video-stream-moderator', {
email : this.moderatorEmail,
videoStream : this.data.stream
});
this.data.stream.moderators.pushObject(newModerator);
} else {
const moderator = this.store.peekRecord('video-stream-moderator', existingModerator[0].id);
this.data.stream.moderators.pushObject(moderator);
}
}
this.deletedModerators = this.deletedModerators.filter(moderator => moderator.email !== this.moderatorEmail);
this.moderatorEmail = '';
});
}

@action
deleteModerator(moderator) {
this.deletedModerators.push(moderator);
this.data.stream.moderators.removeObject(moderator);
if (moderator.id) {
this.deletedModerators.push(moderator);
}
}

async loadRecordings() {
Expand Down
67 changes: 63 additions & 4 deletions app/components/forms/group/group-events-form.js
@@ -1,40 +1,91 @@

import Component from '@ember/component';
import { action, computed } from '@ember/object';
import { tracked } from '@glimmer/tracking';
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';
import { all } from 'rsvp';

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

@service errorHandler;

@tracked eventToBeUpdate = [];
@tracked unsavedEvents = [];
@tracked savedEvents = [];

@action
addEvent(event) {
const eventIds = this.eventToBeUpdate.map(evnt => evnt.identifier);
if (this.savedEvents.includes(event.id) && eventIds.includes(event.id)) {
event.isAnnounced = true;
this.eventToBeUpdate = this.eventToBeUpdate.filter(event => event.identifier === event.id);
} else {
event.isAnnounced = false;
this.eventToBeUpdate.push(event);
}
this.group.events.pushObject(event);
}

@action
removeEvent(event) {
if (event.isAnnounced) {
event.isAnnounced = false;
this.eventToBeUpdate.push(event);
}
this.group.events.removeObject(event);
}

@action
async announceEvent(event) {
this.set('isLoading', true);
try {
const heading = this.l10n.t('Do you want to announce the event') + ' "' + event.name + '" ' + this.l10n.t('to all group members now') + '?';
const options = {
denyText : 'Cancel',
denyColor : 'red',
approveText : 'Yes',
approveColor : 'green'
};
await this.confirm.prompt(heading, options);
} catch {
this.set('isLoading', false);
return;
}
this.loader.load(`/groups/${this.group.id}/events/${event.identifier}/announce`)
.then(() => {
event.isAnnounced = true;
this.notify.success(this.l10n.t('Event has been announced.'), {
id: 'event_announce'
});
})
.catch(() => {
this.notify.error(this.l10n.t('Oops something went wrong. Please try again.'), {
id: 'event_announce'
});
})
.finally(() => {
this.set('isLoading', false);
});
}

@computed('events.[]', 'group.events.[]')
get remainingEvents() {
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();
return sortBy(this.remainingEvents.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();
return sortBy(this.remainingEvents.toArray().filter(event => { return moment(event.endsAt) > moment()}), ['startsAt']).reverse();
}

@action
Expand All @@ -48,13 +99,17 @@ export default class GroupEventsForm extends Component.extend(FormMixin) {
event.preventDefault();
this.onValid(async() => {
try {
this.loading = true;
this.set('isLoading', true);
/* For the first save throws an error -> field may not be null, as social links are added in group-settings-form
Hence, passing an empty array. */
if (!this.group.socialLinks) {
this.group.socialLinks = [];
}
await this.group.save();
const updatedEvents = this.eventToBeUpdate.map(event => {
return event.save();
});
await all([...updatedEvents]);
this.notify.success(this.l10n.t('Your group has been saved'),
{
id: 'group_save'
Expand All @@ -64,8 +119,12 @@ export default class GroupEventsForm extends Component.extend(FormMixin) {
console.error('Error while saving group', e);
this.errorHandler.handle(e);
} finally {
this.loading = false;
this.set('isLoading', false);
}
});
}

didInsertElement() {
this.set('savedEvents', [...this.groupEvents.toArray().map(event => event.identifier)]);
}
}
19 changes: 12 additions & 7 deletions app/components/forms/session-speaker-form.js
Expand Up @@ -461,7 +461,6 @@ export default Component.extend(FormMixin, {
}
return speakerInvite.save();
});
this.deletedSpeakerInvites.filter(speakerInvite => (speakerInvite.id === null));
const deleteSpeakerInvites = this.deletedSpeakerInvites.map(speakerInvite => {
return speakerInvite.destroyRecord();
});
Expand Down Expand Up @@ -494,12 +493,18 @@ export default Component.extend(FormMixin, {
const existingEmails = this.data.session.speakerInvites.filter(speakerInvite => speakerInvite.status === 'pending');
existingEmails.map(speakerInvite => speakerInvite.email);
if (!existingEmails.includes(this.speakerInviteEmail)) {
const speakerInvite = this.store.createRecord('speaker-invite', {
email : this.speakerInviteEmail,
session : this.data.session,
event : this.data.event
});
this.data.session.speakerInvites.pushObject(speakerInvite);
const existingSpeakerInvite = this.deletedSpeakerInvites.filter(speakerInvite => speakerInvite.email === this.speakerInviteEmail);
if (existingSpeakerInvite.length === 0) {
const newSpeakerInvite = this.store.createRecord('speaker-invite', {
email : this.speakerInviteEmail,
session : this.data.session,
event : this.data.event
});
this.data.session.speakerInvites.pushObject(newSpeakerInvite);
} else {
const speakerInvite = this.store.peekRecord('speaker-invite', existingSpeakerInvite[0].id);
this.data.session.speakerInvites.pushObject(speakerInvite);
}
}
this.deletedSpeakerInvites = this.deletedSpeakerInvites.filter(speakerInvite => speakerInvite.email !== this.speakerInviteEmail);
this.speakerInviteEmail = '';
Expand Down
14 changes: 14 additions & 0 deletions app/components/group-nav.js
@@ -0,0 +1,14 @@
import classic from 'ember-classic-decorator';
import Component from '@ember/component';
import { action } from '@ember/object';
import { tagName } from '@ember-decorators/component';

@classic
@tagName('')
export default class GroupNav extends Component {
@action
refreshRoute() {
this.refresh();
}
}

2 changes: 1 addition & 1 deletion app/controllers/application.js
Expand Up @@ -56,7 +56,7 @@ export default class ApplicationController extends Controller {

@action
search() {
this.transitionToRoute('explore', { queryParams: { event_name: this.event_name } });
this.transitionToRoute('explore.events', { queryParams: { name: this.event_name } });
this.event_name = null;
}

Expand Down
10 changes: 5 additions & 5 deletions app/controllers/explore.js → app/controllers/explore/events.js
Expand Up @@ -4,8 +4,8 @@ import Controller from '@ember/controller';

@classic
export default class ExploreController extends Controller {
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'];
event_name = null;
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'];
name = null;
is_online = null;
is_location = null;
is_mixed = null;
Expand All @@ -29,8 +29,8 @@ export default class ExploreController extends Controller {

@action
clearFilter(filterType) {
if (filterType === 'event_name') {
this.set('event_name', null);
if (filterType === 'name') {
this.set('name', null);
}
if (filterType === 'is_online') {
this.set('is_online', null);
Expand Down Expand Up @@ -79,7 +79,7 @@ export default class ExploreController extends Controller {
@action
clearAllFilters() {
this.setProperties({
event_name : null,
name : null,
category : null,
sub_category : null,
event_type : null,
Expand Down
23 changes: 23 additions & 0 deletions app/controllers/explore/groups.js
@@ -0,0 +1,23 @@
import classic from 'ember-classic-decorator';
import { action } from '@ember/object';
import Controller from '@ember/controller';

@classic
export default class ExploreController extends Controller {
queryParams = ['name'];
name = null;

@action
clearFilter(filterType) {
if (filterType === 'name') {
this.set('name', null);
}
}

@action
clearAllFilters() {
this.setProperties({
name: null
});
}
}
1 change: 1 addition & 0 deletions app/models/event.js
Expand Up @@ -54,6 +54,7 @@ export default class Event extends ModelBase.extend(CustomPrimaryKeyMixin, {
isChatEnabled : attr('boolean', { defaultValue: false }),
isBillingInfoMandatory : attr('boolean', { defaultValue: false }),
isDocumentEnabled : attr('boolean', { defaultValue: false }),
isAnnounced : attr('boolean', { defaultValue: false }),

isTaxEnabled : attr('boolean', { defaultValue: false }),
canPayByPaypal : attr('boolean', { defaultValue: false }),
Expand Down
5 changes: 4 additions & 1 deletion app/router.js
Expand Up @@ -175,7 +175,10 @@ Router.map(function() {
});
});
});
this.route('explore');
this.route('explore', function() {
this.route('events');
this.route('groups');
});
this.route('groups', function() {
this.route('list');
this.route('create');
Expand Down

0 comments on commit c843d1a

Please sign in to comment.