Skip to content

Commit

Permalink
Merge pull request #28 from erz-mba-fbi/develop
Browse files Browse the repository at this point in the history
Version 3.0.0
  • Loading branch information
schefbi authored May 3, 2019
2 parents 094f22f + 8bcd32b commit 8d841ee
Show file tree
Hide file tree
Showing 30 changed files with 5,123 additions and 3,162 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ deploy:
github-token: $GITHUB_TOKEN
keep-history: false
on:
branch: master
branch: develop
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018 erz-mba-fbi
Copyright (c) 2018-2019 erz-mba-fbi

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# kursausschreibung
# kursausschreibung 3.0.0

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

Expand Down Expand Up @@ -54,20 +54,20 @@ Make use of the many generators for code, try `ember help generate` for more det
* [ember inspector for firefox](https://addons.mozilla.org/en-US/firefox/addon/ember-inspector/)

## Documentation
Go to [Wiki](https://github.com/erz-mba-fbi/kursausschreibung/wiki)
Go to the [Wiki](https://github.com/erz-mba-fbi/kursausschreibung/wiki)

## Configuration (appconfig, settings, locale)

* **appconfig:** The basic configuration for the module must be stored in appconfig. Example: `apiUrl, webBaseUrl, oauthUrl, instanceId, clientId, applicationScope`
* **settings:** In this file you will find all settings for the module.
* **locale:** In the 'locale' folder you will find every translation for the module that does not come from Evento (e.g. labels, status, process...).

## Latest build
## Builds

You can download the latest build of the module here: [kursausschreibung.zip](https://erz-mba-fbi.github.io/kursausschreibung/kursausschreibung.zip). To use the module you first have to configure it.
You can download releases on the [releases page](https://github.com/erz-mba-fbi/kursausschreibung/releases) and the latest build of the module here: [kursausschreibung.zip](https://erz-mba-fbi.github.io/kursausschreibung/kursausschreibung.zip). To use the module you first have to configure it.

## Integration

For the integration into an html page you need a simple html configuration in header and body of the page in which you want to publish the module. Please see section `MODULE head configuration` and `MODULE MAIN APPLICATION` in `index.html`.

If you want to be sure that after authentication by the module the correct address is always used use `OPTION REDIRECT` in the `index.html`.
If you want to be sure that after authentication by the module the correct address is always used use `OPTION REDIRECT` in the `index.html`. Please put script element between head and body of masterpage (load faster).
10 changes: 9 additions & 1 deletion app/components/event-details-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@ import Component from '@ember/component';
import settings from 'kursausschreibung/framework/settings';
import { getString } from 'kursausschreibung/framework/translate';
import { camelize } from "@ember/string";
import { getIcsFileFromEvent } from "kursausschreibung/framework/ics-file";

export default Component.extend({
title: settings.eventDetailsTitle,
showEventText: settings.showEventText,

fields: settings.eventDetailsFields.map(key => ({
name: getString(camelize(key)), key
}))
})),

actions: {
getIcsFileFromEvent() {
getIcsFileFromEvent(this.event);
}
}

});
2 changes: 2 additions & 0 deletions app/components/status-lamp.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { getString } from 'kursausschreibung/framework/translate';

const statuses = {
green: { tooltip: getString('greenLamp'), className: 'lamp-green' },
chartreuse: { tooltip: getString('chartreuseLamp'), className: 'lamp-chartreuse' },
yellow: { tooltip: getString('yellowLamp'), className: 'lamp-yellow' },
red: { tooltip: getString('redLamp'), className: 'lamp-red' },
orange: { tooltip: getString('orangeLamp'), className: 'lamp-orange' }
Expand All @@ -27,5 +28,6 @@ export default Component.extend({

tagName: 'span',
attributeBindings: ['tooltip:data-uk-tooltip'],
classNames: ['status-lamp'],
classNameBindings: ['color']
});
40 changes: 40 additions & 0 deletions app/framework/ics-file.js

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

19 changes: 16 additions & 3 deletions app/framework/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,23 @@ function createStatusCallback(settingsValue, defaultImplementation) {

// see "Event Status Definition" in documentation
let isGreen = createStatusCallback(settings.lampIsGreen, function (event) {
return (event.AllowSubscriptionInternetByStatus &&
return (
event.AllowSubscriptionInternetByStatus &&
event.TypeOfSubscription !== 1 &&
isInSubscriptionRange(event) &&
event.FreeSeats > 0 &&
(event.MaxParticipants - event.FreeSeats) < event.MinParticipants
);
});

let isChartreuse = createStatusCallback(settings.lampIsChartreuse, function (event) {
return (
event.AllowSubscriptionInternetByStatus &&
event.TypeOfSubscription !== 1 &&
isInSubscriptionRange(event) &&
event.FreeSeats > 0);
event.FreeSeats > 0 &&
(event.MaxParticipants - event.FreeSeats) >= event.MinParticipants
);
});

let isYellow = createStatusCallback(settings.lampIsYellow, function (event) {
Expand All @@ -38,4 +51,4 @@ let isRed = createStatusCallback(settings.lampIsRed, function (event) {
);
});

export { isGreen, isYellow, isRed };
export { isGreen, isChartreuse, isYellow, isRed };
21 changes: 13 additions & 8 deletions app/framework/store.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { A } from '@ember/array';
import { underscore } from '@ember/string';
import EmberObject, { computed } from '@ember/object';
import $ from 'jquery';
import { getEvents, getEvent, getLessons, getEventLocations, getEventTexts } from './api';
import { isGreen, isYellow, isRed } from './status';
import { isGreen, isChartreuse, isYellow, isRed } from './status';
import ObjectProxy from '@ember/object/proxy';
import { formatDate, combineDate, isInSubscriptionRange, removeMinutes } from './date-helpers';
import { all } from 'rsvp';
Expand Down Expand Up @@ -172,7 +173,7 @@ function addLessonsToEvents(lessons) {
function filterEvents(events, language) {
// filter out events with undesired parameters

// backwards compatibility fallback for single hostId filter
// backwards compatibility fallback for single hostId filter
if (settings.hostIds instanceof Array) {
events = events.filter(event => settings.hostIds.indexOf(event.HostId) !== -1);
}
Expand All @@ -181,19 +182,19 @@ function filterEvents(events, language) {
if (settings.initialListFilters.hostIds instanceof Array) {
events = events.filter(event => settings.initialListFilters.hostIds.indexOf(event.HostId) !== -1);
}

if (settings.initialListFilters.eventCategoryIds instanceof Array) {
events = events.filter(event => settings.initialListFilters.eventCategoryIds.indexOf(event.EventCategoryId) !== -1);
}

if (settings.initialListFilters.eventLevelIds instanceof Array) {
events = events.filter(event => settings.initialListFilters.eventLevelIds.indexOf(event.EventLevelId) !== -1);
}

if (settings.initialListFilters.eventTypeIds instanceof Array) {
events = events.filter(event => settings.initialListFilters.eventTypeIds.indexOf(event.EventTypeId) !== -1);
}

if (settings.initialListFilters.statusIds instanceof Array) {
events = events.filter(event => settings.initialListFilters.statusIds.indexOf(event.StatusId) !== -1);
}
Expand Down Expand Up @@ -241,7 +242,7 @@ function putIntoAssocArrays(event) {

// area
let areaName = event.AreaOfEducation;
let areaKey = (event.areaKey = areaName.toLowerCase());
let areaKey = event.areaKey = underscore(areaName);

if (!eventsByArea.areas.hasOwnProperty(areaKey)) {
eventsByArea.areas[areaKey] = {
Expand All @@ -256,7 +257,7 @@ function putIntoAssocArrays(event) {

// category (in area)
let categoryName = event.EventCategory;
let categoryKey = (event.categoryKey = categoryName.toLowerCase());
let categoryKey = event.categoryKey = underscore(categoryName);

if (!eventsByArea.areas[areaKey].categories.hasOwnProperty(categoryKey)) {
eventsByArea.areas[areaKey].categories[categoryKey] = {
Expand All @@ -281,6 +282,10 @@ function createEmberObject(event) {
return 'green';
}

if (isChartreuse(this, isInSubscriptionRange)) {
return 'chartreuse';
}

if (isYellow(this, isInSubscriptionRange)) {
return 'yellow';

Expand Down
90 changes: 45 additions & 45 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,51 @@
</style>
{{content-for "head-footer"}}
</head>
<!-- OPTION REDIRECT -->
<script>
/**
* if you use "useAutoLogin": true (appconfig.js setting) it will in case of Authorization every time redirect to Parameter "moduleRedirectUrl".
* The redirect will execute only if no html element with id "kursausschreibung-root" on site available is.
*/
var url = window.location.href;
if (url.indexOf('?') > 0) {

var urlParameters = url.split('?');
var redirectURL = getParameterByName('moduleRedirectUrl')
if (urlParameters[1].indexOf("access_token") > -1 && !document.getElementById('kursausschreibung-root')) {
window.location = redirectURL + '?' + urlParameters[1];
}
}

/**
* get an URL-parameter
* taken from https://stackoverflow.com/q/901115#answer-901144
* @param {string} name the name of the parameter
* @param {string} url the URL (defaults to current URL)
*/
function getParameterByName(name, url) {

if (typeof url !== 'string') {
url = window.location.href;
}

name = name.replace(/[[\]]/g, '\\url');

var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)');
var results = regex.exec(url);

if (!results) {
return null;
}

if (!results[2]) {
return '';
}

return decodeURIComponent(results[2].replace(/\+/g, ' '));
}
</script>
<!-- OPTION REDIRECT -->
<body>
{{content-for "body"}}

Expand Down Expand Up @@ -103,49 +148,4 @@ <h1>by erz-mba-fbi</h1>
</div>
{{content-for "body-footer"}}
</body>
<!-- OPTION REDIRECT -->
<script>
/**
* if you use "useAutoLogin": true (appconfig.js setting) it will in case of Authorization every time redirect to Parameter "moduleRedirectUrl".
* The redirect will execute only if no html element with id "kursausschreibung-root" on site available is.
*/
var url = window.location.href;
if (url.indexOf('?') > 0) {

var urlParameters = url.split('?');
var redirectURL = getParameterByName('moduleRedirectUrl')
if (urlParameters[1].indexOf("access_token") > -1 && !document.getElementById('kursausschreibung-root')) {
window.location = redirectURL + '?' + urlParameters[1];
}
}

/**
* get an URL-parameter
* taken from https://stackoverflow.com/q/901115#answer-901144
* @param {string} name the name of the parameter
* @param {string} url the URL (defaults to current URL)
*/
function getParameterByName(name, url) {

if (typeof url !== 'string') {
url = window.location.href;
}

name = name.replace(/[[\]]/g, '\\url');

var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)');
var results = regex.exec(url);

if (!results) {
return null;
}

if (!results[2]) {
return '';
}

return decodeURIComponent(results[2].replace(/\+/g, ' '));
}
</script>
<!-- OPTION REDIRECT -->
</html>
3 changes: 2 additions & 1 deletion app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ const Router = EmberRouter.extend({

didTransition() {
this._super(...arguments);
rootElement.scrollIntoView();
rootElement.scrollIntoView({behavior:'smooth'});
}
});

Router.map(function () {
this.route('permalink', { path: '/uid/:event_id' });
this.route('list', { path: '/:area_of_education' }, function () {
this.route('category', { path: '/:category' }, function () {
this.route('event', { path: '/:event_id' }, function () {
Expand Down
4 changes: 4 additions & 0 deletions app/routes/list.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import Route from '@ember/routing/route';
import { underscore } from '@ember/string';
import uikit from 'uikit';

export default Route.extend({
model(params) {
let eventsByArea = this.modelFor('application');

// make sure old URLs still work
params.area_of_education = underscore(params.area_of_education);

// check if area of education exists
if (!eventsByArea.areas.hasOwnProperty(params.area_of_education)) {
this.replaceWith('/');
Expand Down
4 changes: 4 additions & 0 deletions app/routes/list/category.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import Route from '@ember/routing/route';
import { underscore } from '@ember/string';

export default Route.extend({
model(params) {
let categories = this.modelFor('list').categories;

// make sure old URLs still work
params.category = underscore(params.category);

// check if category exists
if (!(categories.hasOwnProperty(params.category))) {
this.replaceWith('list');
Expand Down
5 changes: 3 additions & 2 deletions app/routes/list/category/event.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import Route from '@ember/routing/route';
import { underscore } from '@ember/string';
import store from 'kursausschreibung/framework/store';

export default Route.extend({
model(params) {
let event = store.getEventById(params.event_id);

// check if event exists in area and category
let areaKey = this.paramsFor('list').area_of_education;
let categoryKey = this.paramsFor('list.category').category;
let areaKey = underscore(this.paramsFor('list').area_of_education);
let categoryKey = underscore(this.paramsFor('list.category').category);

if (
event === undefined ||
Expand Down
Loading

0 comments on commit 8d841ee

Please sign in to comment.