Skip to content

Commit

Permalink
Merge pull request #123 from bkd-mba-fbi/develop
Browse files Browse the repository at this point in the history
3.3.1
  • Loading branch information
schefbi authored Nov 16, 2021
2 parents 28c7887 + feef2e7 commit 3571257
Show file tree
Hide file tree
Showing 33 changed files with 250 additions and 315 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# kursausschreibung 3.3.0
# kursausschreibung 3.3.1
[![Build 🏭🚀](https://github.com/bkd-mba-fbi/kursausschreibung/actions/workflows/buildDeploy.yml/badge.svg)](https://github.com/bkd-mba-fbi/kursausschreibung/actions/workflows/buildDeploy.yml)
## Prerequisites

Expand Down
6 changes: 6 additions & 0 deletions app/components/input/input-checkbox.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import Component from '@ember/component';
import { vssDependency } from 'kursausschreibung/framework/form-helpers';

export default Component.extend({
change(){
let field = this.get('field');
let currentValue = document.getElementById('vss'+field.id).checked;
vssDependency(currentValue,field);
}
});
7 changes: 6 additions & 1 deletion app/components/input/input-date.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import Component from '@ember/component';
import { dateGreaterNow } from 'kursausschreibung/framework/date-helpers';
import { formFieldError } from 'kursausschreibung/framework/form-helpers';
import { formFieldError, vssDependency } from 'kursausschreibung/framework/form-helpers';

export default Component.extend({
change() {
if (this.field.id === 'Birthdate') {
formFieldError(this.element.children[0], dateGreaterNow(this.element.children[0].value));
}
},
focusOut() {
let field = this.get('field');
let currentValue = document.getElementById('vss'+field.id).value;
vssDependency(currentValue,field);
}
});
15 changes: 15 additions & 0 deletions app/components/input/input-dropdown.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
import Component from '@ember/component';
import { vssDependency } from 'kursausschreibung/framework/form-helpers';

export default Component.extend({
change(){
let field = this.get('field');
let currentValue = null;

document.getElementsByName(field.id).forEach(input => {
if(field.options.showAsRadioButtons) {
currentValue = input.checked ? input.value : currentValue;
} else {
currentValue = input.value;
}
});

vssDependency(currentValue,field);
}
});
6 changes: 5 additions & 1 deletion app/components/input/input-file.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Component from '@ember/component';
import { getString } from 'kursausschreibung/framework/translate';
import { removeFile } from 'kursausschreibung/framework/form-helpers';
import { removeFile, vssDependency } from 'kursausschreibung/framework/form-helpers';
import uikit from 'uikit';
import jQuery from 'jquery';

Expand Down Expand Up @@ -77,6 +77,10 @@ export default Component.extend({


uikit.notification({message: getString('UploadErfolgreich') + inputFile.name, pos: 'bottom-right', status:'success' });

let field = this.get('field');
vssDependency(inputFile,field);

}
},
actions: {
Expand Down
7 changes: 7 additions & 0 deletions app/components/input/input-freeform-dropdown.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Component from '@ember/component';
import { vssDependency } from 'kursausschreibung/framework/form-helpers';

export default Component.extend({
didInsertElement() {
Expand Down Expand Up @@ -27,5 +28,11 @@ export default Component.extend({
willDestroyElement() {
this.$('.typeahead').typeahead('destroy');
this._super(...arguments);
},

focusOut() {
let field = this.get('field');
let currentValue = document.getElementById('vss'+field.id).value;
vssDependency(currentValue,field);
}
});
6 changes: 6 additions & 0 deletions app/components/input/input-number.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import Component from '@ember/component';
import { vssDependency } from 'kursausschreibung/framework/form-helpers';

export default Component.extend({
focusOut() {
let field = this.get('field');
let currentValue = document.getElementById('vss'+field.id).value;
vssDependency(currentValue,field);
}
});
9 changes: 7 additions & 2 deletions app/components/input/input-string.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Component from '@ember/component';
import { helperSocialSecurityNumber } from 'kursausschreibung/framework/form-helpers';
import { helperSocialSecurityNumber, vssDependency } from 'kursausschreibung/framework/form-helpers';

export default Component.extend({
change() {
Expand All @@ -9,5 +9,10 @@ export default Component.extend({
},
keyUp() {
this.change();
}
},
focusOut() {
let field = this.get('field');
let currentValue = document.getElementById('vss'+field.id).value;
vssDependency(currentValue,field);
}
});
6 changes: 6 additions & 0 deletions app/components/input/input-textarea.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import Component from '@ember/component';
import { vssDependency } from 'kursausschreibung/framework/form-helpers';

export default Component.extend({
focusOut() {
let field = this.get('field');
let currentValue = document.getElementById('vss'+field.id).value;
vssDependency(currentValue,field);
}
});
26 changes: 20 additions & 6 deletions app/components/list-pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,28 @@ export default Component.extend({
return pages;
}),

filterCodes: computed('items', function () {
let filterCodes = this.get('items').filter(item => item.allfilterCodes instanceof Array);
return filterCodes.length === 0 ? null : filterCodes[0].allfilterCodes;
}),

itemsOnCurrentPage: computed('items', 'page', function () {
let page = this.get('page');
let filter = this.get('items').filter(item => item.codes instanceof Array);
return filter.length > 0 ? this.get('items') : this.get('items').slice(settings.itemsPerPage * (page - 1), settings.itemsPerPage * page);
})
}),

filterCodes: computed('items', function () {

let filterCodes = this.get('itemsOnCurrentPage').filter(item => item.allfilterCodes instanceof Array);
let eventfilterCodes = [];
filterCodes.forEach(event => {

let existsFilter = filterCodes[0].allfilterCodes.filter(filter => event.filter.indexOf(filter.id) > -1);

existsFilter.map(filter => {
if(eventfilterCodes.includes(filter) === false) {
eventfilterCodes.push(filter);
}
});

});

return eventfilterCodes.length === 1 ? null : eventfilterCodes;
}),
});
2 changes: 1 addition & 1 deletion app/components/subscription-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ function setProperties(data, element) {
// skip if there is no selection
if (text === '') return;

data[element.name] = text;
data[element.name] = element.name === 'StayPermit' ? parseInt(element.value) : text;
data[element.name + 'Id'] = parseInt(element.value);
return;
}
Expand Down
8 changes: 8 additions & 0 deletions app/framework/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@ export function getSubscriptionDetails(eventId) {
return get('Events/' + eventId + '/SubscriptionDetails');
}

/**
* get subscriptionDetailDependencies of an event
* @param {number} eventId the id of the event
*/
export function getSubscriptionDetailDependencies(eventId) {
return get('SubscriptionDetailDependencies/?idEvent=' + eventId);
}

/**
* get all eventTexts
* @param {string} cultureInfo 'de-CH' for german and 'en-US' for french
Expand Down
61 changes: 61 additions & 0 deletions app/framework/form-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,64 @@ function ean13checkNumber(number) {
}
return false;
}


/**
* Check if vssDependency available
* @param {string} formValue
* @param {object} field
*/
export function vssDependency(formValue,field) {

if(field.options.dependencyItems !== undefined) {

let hiddenClass = 'uk-hidden';

if (field.options.dependencyItems.length > 0) {

field.options.dependencyItems.forEach(element => {
let values = element.Values;
let operator = element.Operator;

let vssId = element.IdVss;
let hidden = document.getElementById('hidden'+vssId);
let requiredElement = document.getElementById('file'+vssId) === null ? document.getElementById('vss'+vssId) : document.getElementById('file'+vssId);

if(vssDependencyCheck(formValue,operator,values)) {
hidden.classList.remove(hiddenClass);
requiredElement.required = true;
} else {
hidden.classList.add(hiddenClass);
requiredElement.required = false;
}

});

}

}

}

/**
* Check if vssDependency true
* @param {string} formValue
* @param {number} operator
* @param {Array} values
*/
function vssDependencyCheck(formValue, operator, values) {

if(typeof formValue === 'boolean') {
formValue = formValue ? '1' : '0';
}

if (operator === 349) { //contains
return formValue.indexOf(values) > -1 ? true : false;
} else if (operator === 350) { //contains Not
return formValue.indexOf(values) === -1 ? true : false;
} else if (operator === 351) { //empty
return formValue === null || formValue === undefined || formValue.length === 0 ? true : false;
} else if (operator === 352) { //notEmpty
return formValue.length > 0 ? true : false; //formValue !== undefined ||
}
}
3 changes: 1 addition & 2 deletions app/framework/login-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ export function checkToken() {
if (accessToken !== null) {
// store token, refresh token and expiration
let refreshToken = getParameterByName('refresh_token');
let expire = parseInt(getParameterByName('expires_in'));
let tokenExpire = Date.now() + expire * 1000;
let tokenExpire = parseJWT(accessToken).exp * 1000;

setAccessToken(accessToken);
setRefreshToken(refreshToken);
Expand Down
7 changes: 5 additions & 2 deletions app/framework/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,12 @@ function addLessonsToEvents(lessons) {
return;
}
// add codes-array
eventsById[code.EventId].codes = [];
eventsById[code.EventId].codes.push(code);
if (eventsById[code.EventId].codes === undefined) {
eventsById[code.EventId].codes = [];
}

eventsById[code.EventId].codes.push(code);

// adds filter tag
let filter = eventsById[code.EventId].filter;
eventsById[code.EventId].filter = filter === undefined ? 'tag'+code.CodeId : filter + ' tag'+code.CodeId;
Expand Down
23 changes: 19 additions & 4 deletions app/framework/url-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,31 @@ export function setParameterByName(name,value, url) {
return url;
}

let params = decodeURI(url).split('?')[1];
let params = decodeURI(url).split('?');
let paramsLength = params.length;
params = params.length === 3 ? params[1] + '?' + params[2] : params[1];

if(params !== undefined) {

if(params.indexOf(name) >= 0) {
params = params.replace(name + '=' + getParameterByName(name,url), name +'='+ value);
} else {
params = params + '&' + name +'='+ value;
}
else {
let newParam = '&';
if (paramsLength > 2 && params.indexOf('?') > -1) {
newParam = '&';
} else if (paramsLength > 2 && params.indexOf('?') === -1) {
newParam = '?';
} else if (paramsLength === 2 && params.indexOf('#') > -1) {
newParam = '?';
}

params = params + newParam + name +'='+ value;
}

} else {
params = name +'='+ value;
}
window.location.href = encodeURI(url.split('?')[0] + '?' + params);

window.location.href = encodeURI(url.split('?')[0] + '?' + params);
}
37 changes: 32 additions & 5 deletions app/routes/list/category/event/subscribe.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { A } from '@ember/array';
import { get, set } from '@ember/object';
import Route from '@ember/routing/route';
import {
getDropDownItems, getSubscriptionDetails, getUserSettings,
getDropDownItems, getSubscriptionDetails, getSubscriptionDetailDependencies, getUserSettings,
SUBSCRIPTION_DETAIL_ALLOW_MULTIPLE_PEOPLE
} from 'kursausschreibung/framework/api';
import { autoCheckForLogin } from 'kursausschreibung/framework/login-helpers';
Expand All @@ -20,9 +20,12 @@ function loadDropdownItems(fields) {
.then(options => {

if(item.id === 'Nationality') {
options.forEach(element => {
element.Value = element.Value.split(':')[1].trim();
});
let setDefaultLand = options;
let defaultLand = options.findIndex(nationality => nationality.Key === 2008100);
setDefaultLand.splice(0,0,options[defaultLand]);
setDefaultLand.splice(0,0,options[defaultLand]);
}

if (item.options.options === undefined)
Expand Down Expand Up @@ -86,12 +89,34 @@ function getSubscriptionDetailFields(subscriptionDetails) {
options: detail.DropdownItems,
showAsRadioButtons: dataType === 'dropdown' ? detail.ShowAsRadioButtons : undefined,
tooltip: detail.Tooltip,
disabled: detail.readOnly
disabled: detail.readOnly,
hidden: '',
dependencyItems: []
}
};
});
}

function addSubscriptionDetailDependencies(subscriptionDetailDependencies,subscriptionDetails) {

subscriptionDetails.map(item => {

subscriptionDetailDependencies.find(dependency => {

if (dependency.IdVss === item.id){
item.options.hidden = 'uk-hidden';
item.options.required = false;
}
if (dependency.IdVssInfluencer === item.id) {
item.options.dependencyItems.push(dependency);
}
});
});

return subscriptionDetails;

}

function addTranslations(fields) {
fields.forEach(detail => {
if (detail.label === undefined)
Expand Down Expand Up @@ -138,8 +163,8 @@ export default Route.extend({

// make sure the session is still active
return autoCheckForLogin()
.then(() => Promise.all([getUserSettings(), getSubscriptionDetails(model.Id)]))
.then(([userSettings, subscriptionDetails]) => {
.then(() => Promise.all([getUserSettings(), getSubscriptionDetails(model.Id), getSubscriptionDetailDependencies(model.Id)]))
.then(([userSettings, subscriptionDetails, subscriptionDetailDependencies]) => {

// check if multiple people are allowed to subscribe at the same time
let allowMultiplePeople = false;
Expand All @@ -158,6 +183,8 @@ export default Route.extend({
set(model, 'userSettings', userSettings);
set(model, 'subscriptionDetailFields', getSubscriptionDetailFields(A(subscriptionDetails).sortBy('Sort')));

set(model, 'subscriptionDetailFields', addSubscriptionDetailDependencies(subscriptionDetailDependencies,getSubscriptionDetailFields(A(subscriptionDetails).sortBy('Sort'))) );

if (userSettings.isLoggedIn === false) {
let fields = getFormFields(settings, model.EventTypeId).addressFields;
let additionalPeopleFields = getFormFields(settings, model.EventTypeId).additionalPeopleFields;
Expand Down
Loading

0 comments on commit 3571257

Please sign in to comment.