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 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
6 changes: 5 additions & 1 deletion app/controllers/demonstrator.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import Ember from 'ember';
import moment from 'moment';

export default Ember.Controller.extend({
subMenu: Ember.computed('model', 'model.[]', function() {
return this.get('model').map(eventTemplate => ({
let subMenu = this.get('model').map(eventTemplate => ({
id: eventTemplate.get('id'),
route: 'demonstrator.detail',
description: eventTemplate.get('name')
}));
return subMenu.sort((lhs, rhs) => {
return lhs.description - rhs.description;
});
})
});
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
5 changes: 3 additions & 2 deletions app/controllers/student.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Ember from 'ember';
import moment from 'moment';
import RSVP from 'rsvp';

export default Ember.Controller.extend({
Expand All @@ -25,9 +26,9 @@ export default Ember.Controller.extend({
promises.push(promise);
});
RSVP.Promise.all(promises).then(() => {
// sort menupoints by key
// sort menupoints by date
const sorted = subMenuKeys.sort((lhs, rhs) => {
return lhs.event.get('date') - rhs.event.get('date');
return moment(lhs.event.get('date')).diff(rhs.event.get('date'));
});
// select the first menu that has not been graded yet.
this.set('currentView', null);
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}}