Skip to content

Commit

Permalink
Refactor public event display page to use new API
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinavk96 authored and niranjan94 committed Jul 3, 2017
1 parent be7b1ca commit d9e5369
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 25 deletions.
2 changes: 1 addition & 1 deletion app/components/event-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default Component.extend({
classNames: ['column'],

tags: computed('event.type', 'event.topic', 'event.subTopic', function() {
const tagsOriginal = this.get('event').getProperties('type', 'topic', 'subTopic');
const tagsOriginal = this.getProperties('event.topic.name', 'event.type.name', 'event.subTopic.name');
let tags = [];
forOwn(tagsOriginal, value => {
if (value && value.trim() !== '') {
Expand Down
20 changes: 10 additions & 10 deletions app/controllers/index.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import Ember from 'ember';
import moment from 'moment';

const { Controller, computed } = Ember;

export default Controller.extend({

callForSpeakersEvents: computed('model.[]', function() {
return this.get('model').filter(event => {
const callForPapers = event.get('callForPapers');
if (callForPapers === null || !callForPapers.get('startDate') || !callForPapers.get('timezone') || !callForPapers.get('endDate')) {
return false;
}
const startDateTime = moment.tz(callForPapers.get('startDate'), callForPapers.get('timezone'));
const endDateTime = moment.tz(callForPapers.get('endDate'), callForPapers.get('timezone'));
return moment().isBetween(startDateTime, endDateTime);
});
// return this.get('model').filter(event => {
// const callForPapers = event.get('speakersCall');
// // console.log(callForPapers);
// if (!callForPapers|| !callForPapers.get('startDate') || !callForPapers.get('timezone') || !callForPapers.get('endDate')) {
// return false;
// }
// const startDateTime = moment.tz(callForPapers.get('startDate'), callForPapers.get('timezone'));
// const endDateTime = moment.tz(callForPapers.get('endDate'), callForPapers.get('timezone'));
// return moment().isBetween(startDateTime, endDateTime);
// });
}),

actions: {
Expand Down
8 changes: 6 additions & 2 deletions app/models/discount-code.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ export default Model.extend({
createdAt : attr('date'),

tickets : hasMany('ticket'),
event : belongsTo('event'), // The event that this discount code belongs to [Form (2)]
events : hasMany('event') // The events that this discount code has been applied to [Form (1)]
event : belongsTo('event', {
inverse: 'discountCodes'
}), // The event that this discount code belongs to [Form (2)]
events: hasMany('event', {
inverse: 'discountCode'
}) // The events that this discount code has been applied to [Form (1)]
});

16 changes: 15 additions & 1 deletion app/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@ const { Route } = Ember;

export default Route.extend({
model() {
return this.store.query('event', { end_time_gt: moment.utc().format('YYYY-MM-DDTHH:mm:ss'), state: 'Published' });
return this.store.query('event', {
include : 'event_topic,event_sub_topic,event_type',
filter : [
{
name : 'starts_at',
op : 'ge',
val : moment().toISOString()
},
{
name : 'state',
op : 'eq',
val : 'Published'
}
]
});
}
});
2 changes: 1 addition & 1 deletion app/serializers/event-topic.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import ApplicationSerializer from 'open-event-frontend/serializers/application';

export default ApplicationSerializer.extend({
attrs: {
subTopics: 'eventSubTopics'
subTopics: 'event-sub-topics'
}
});
13 changes: 6 additions & 7 deletions app/serializers/event.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import ApplicationSerializer from 'open-event-frontend/serializers/application';

export default ApplicationSerializer.extend({
primaryKey : 'identifier',
attrs : {
type : 'eventType',
topic : 'eventTopic',
subTopic : 'eventSubTopic',
copyright : 'eventCopyright',
externalEventUrl : 'eventUrl'
attrs: {
type : 'event-type',
topic : 'event-topic',
subTopic : 'event-sub-topic',
copyright : 'event-copyright',
externalEventUrl : 'event-url'
}
});
6 changes: 3 additions & 3 deletions app/templates/components/event-card.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
{{#unless device.isMobile}}
<div class="ui card three wide computer six wide tablet column">
<a class="image" href="{{href-to 'public' event.identifier}}">
{{widgets/safe-image src=(if event.large event.large event.placeholderUrl)}}
{{widgets/safe-image src=(if event.originalImageUrl event.originalImageUrl event.originalImageUrl)}}
</a>
</div>
{{/unless}}
{{/if}}
<div class="ui card {{unless isWide 'event fluid' 'thirteen wide computer ten wide tablet sixteen wide mobile column'}}">
{{#unless isWide}}
<a class="image" href="{{href-to 'public' event.identifier}}">
{{widgets/safe-image src=(if event.large event.large event.placeholderUrl)}}
{{widgets/safe-image src=(if event.originalImageUrl event.originalImageUrl event.originalImageUr)}}
</a>
{{/unless}}
<a class="main content" href="{{href-to 'public' event.identifier}}">
Expand All @@ -20,7 +20,7 @@
{{/smart-overflow}}
<div class="meta">
<span class="date">
{{moment-format event.startTime 'ddd, MMM DD HH:mm A'}}
{{moment-format event.startsAt 'ddd, MMM DD HH:mm A'}}
</span>
</div>
{{#smart-overflow class='description'}}
Expand Down

0 comments on commit d9e5369

Please sign in to comment.