Skip to content

Commit

Permalink
Merge pull request #52 from erz-mba-fbi/develop
Browse files Browse the repository at this point in the history
v3.1.0
  • Loading branch information
schefbi authored Oct 8, 2019
2 parents a6d086a + 4ba0710 commit fc59b54
Show file tree
Hide file tree
Showing 25 changed files with 23,498 additions and 4,458 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# kursausschreibung 3.0.2

# kursausschreibung 3.1.0
=======
[![Build Status](https://travis-ci.org/erz-mba-fbi/kursausschreibung.svg?branch=master)](https://travis-ci.org/erz-mba-fbi/kursausschreibung)

## Prerequisites
Expand Down
7 changes: 7 additions & 0 deletions app/components/input/input-date.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import Component from '@ember/component';
import { dateGreaterNow} from 'kursausschreibung/framework/date-helpers';
import { formDanger } from 'kursausschreibung/helpers/form';

export default Component.extend({
change() {
if (this.field.id === 'Birthdate') {
formDanger(this.element.children[0],dateGreaterNow(this.element.children[0].value));
}
},
});
17 changes: 17 additions & 0 deletions app/components/input/input-string.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
import Component from '@ember/component';
import { getLocationFromZip, helperSocialSecurityNumber } from 'kursausschreibung/helpers/form';

export default Component.extend({
focusIn() {
if (this.field.id === 'Location') {
getLocationFromZip();
}
},
change() {
if (this.field.id === 'SocialSecurityNumber') {
helperSocialSecurityNumber(this.element.children[0]);
}

},
keyUp(){
if (this.field.id === 'SocialSecurityNumber') {
helperSocialSecurityNumber(this.element.children[0]);
}
}
});
2 changes: 1 addition & 1 deletion app/components/subscription-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default Component.extend({

subscribe(this.$('form'), this);
this.get('subscribe')();
}
}
}
});

Expand Down
22 changes: 22 additions & 0 deletions app/framework/date-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,20 @@ export function isInSubscriptionRange(event) {
now.getTime() < parse(event.SubscriptionTo).getTime();
}

/**
* return true when the DateFrom greater or equal
* to current date is. If DateFrom null then current date
* @param {object} event event to check
*/
export function eventStarted(event) {
let now = new Date();
if (event.DateFrom === null) {
return now.getTime() === now.getTime();
}
return parse(event.DateFrom).getTime() >= now.getTime();
}


/**
* combine a date and a time to a single date object
* this returns null when it fails
Expand Down Expand Up @@ -123,4 +137,12 @@ export function getYMD(dateString) {
*/
export function getDateTimeForIcs(dateString) {
return dateString.replace(new RegExp('-', 'g'), '/').replace(new RegExp('T', 'g'), ' ');
}

/**
* returns true if date > now
* @param {string} dateString YYYY-MM-DD
*/
export function dateGreaterNow(date){
return Date.parse(date) > Date.now() ? true : false;
}
3 changes: 2 additions & 1 deletion app/framework/ics-file.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions app/framework/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ let isGreen = createStatusCallback(settings.lampIsGreen, function (event) {
event.AllowSubscriptionInternetByStatus &&
event.TypeOfSubscription !== 1 &&
isInSubscriptionRange(event) &&
event.FreeSeats > 0 &&
(event.MaxParticipants - event.FreeSeats) < event.MinParticipants
((event.FreeSeats > 0) && ((event.MaxParticipants - event.FreeSeats) < event.MinParticipants) || event.EventTypeId === 1)
);
});

Expand Down
11 changes: 10 additions & 1 deletion app/framework/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import $ from 'jquery';
import { getEvents, getEvent, getLessons, getEventLocations, getEventTexts } from './api';
import { isGreen, isChartreuse, isYellow, isRed } from './status';
import ObjectProxy from '@ember/object/proxy';
import { formatDate, combineDate, isInSubscriptionRange, removeMinutes } from './date-helpers';
import { formatDate, combineDate, isInSubscriptionRange, removeMinutes, eventStarted } from './date-helpers';
import { all } from 'rsvp';
import settings from './settings';
import { getLanguage, getString } from './translate';
Expand Down Expand Up @@ -59,6 +59,14 @@ export function init() {
getEventTexts(language)
]).then(function ([events, lessons, eventLocations, eventTexts]) {

// remove null-values (temporary fix, see #50)
/*let removeNull = array => array.filter(element => element !== null);
events = removeNull(events);
lessons = removeNull(lessons);
eventLocations = removeNull(eventLocations);
eventTexts = removeNull(eventTexts);
*/
// filter events
events = filterEvents(events, language);

Expand Down Expand Up @@ -209,6 +217,7 @@ function filterEvents(events, language) {
(event.LanguageOfInstruction === 'Französisch' && language === 'en-US'));
}

events = events.filter(event => eventStarted(event));
return events;
}

Expand Down
Loading

0 comments on commit fc59b54

Please sign in to comment.