Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for #139 and #140 #141

Merged
merged 6 commits into from
Nov 16, 2020
Merged
Show file tree
Hide file tree
Changes from 4 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
25 changes: 20 additions & 5 deletions app/controllers/demonstrator/detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,36 @@ export default Ember.Controller.extend({
session: Ember.inject.service('session'),
classNames: ['demonstrator-group'],

noGroupToShow: false,

// TODO: move to models/eventTemplate.js when the Events attribute is filtered in the get call.
sortedEventsByCourseCode: Ember.computed('model', function () {
this.set("noGroupToShow", false);
return new RSVP.Promise((resolve, reject) => {
if (this.get('model.id')) {
this.get('store').query('event', {
filter: {
eventTemplateId: this.get('model.id')
}
}).then(events => {
let separatedEventsByCourseCode = {}
let eventDateByCourseCode = []
let separatedEventsByCourseCode = {};
let eventDateByCourseCode = [];

events.map(event => {
let date = event.get('date');
let dateString = moment(date).format("YYYY. MM. DD. hh:mm");

const courseCode = event.get('CourseCode');
if(!Object.keys(separatedEventsByCourseCode).includes(courseCode)) {
separatedEventsByCourseCode[courseCode] = [];
eventDateByCourseCode.push({ courseCode: courseCode, date: event.get('date')});
separatedEventsByCourseCode[courseCode] = {};
eventDateByCourseCode.push({ courseCode: courseCode, date: date});
}

if(!Object.keys(separatedEventsByCourseCode[courseCode]).includes(dateString)) {
separatedEventsByCourseCode[courseCode][dateString] = [];
}

separatedEventsByCourseCode[courseCode].push(event);
separatedEventsByCourseCode[courseCode][dateString].push(event);
return event;
});

Expand All @@ -40,13 +50,18 @@ export default Ember.Controller.extend({
finalEventsByCourseCode[sorted.courseCode] = separatedEventsByCourseCode[sorted.courseCode];
});

if(Object.keys(finalEventsByCourseCode).length === 0) {
this.set("noGroupToShow", true);
}

resolve(finalEventsByCourseCode);
}, err => {
console.error(err);
reject(err);
});
}
else {
this.set("noGroupToShow", true);
resolve({});
}
});
Expand Down
3 changes: 1 addition & 2 deletions app/styles/right.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
}

h3 {
padding-left: 0;
padding-bottom: 0;
padding: 0;
}

a, input, button {
Expand Down
5 changes: 1 addition & 4 deletions app/templates/components/demonstrator-group-data.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<hr />
<div class="text">
<span class="label">Csoport</span> {{await eventGroup}}
</div>
<hr style="border-top: dotted 0px gray;" />
<div class="text">
<span class="label">Labor helyszíne</span> {{await eventPlace}}
</div>
Expand Down
15 changes: 12 additions & 3 deletions app/templates/demonstrator/detail.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@
<a class="button no-margin-top" {{action 'generateSheet'}}>generálás</a>
<a class="button no-margin-top no-margin-left" {{action 'generateSheetSupplementary'}}>pót generálás</a>

{{#each-in (await sortedEventsByCourseCode) as |courseCode events|}}
{{demonstrator-group-data currentEventTemplate=model events=(await events) evaluateEvent=(action 'evaluateEvent')}}
{{/each-in}}
{{#each-in (await sortedEventsByCourseCode) as |courseCode eventsByDate|}}
<hr/>
<h3>{{courseCode}}</h3>
{{#each-in eventsByDate as |date events|}}
{{demonstrator-group-data currentEventTemplate=model events=(await events) evaluateEvent=(action 'evaluateEvent')}}
{{/each-in}}
{{/each-in}}

{{#if noGroupToShow}}
<hr/>
Nincs megjeleníthető laborcsoport.
{{/if}}