Skip to content

Commit

Permalink
Merge pull request #107 from bkd-mba-fbi/develop
Browse files Browse the repository at this point in the history
Lyss 3.3.0
  • Loading branch information
schefbi authored Sep 23, 2021
2 parents e4076f7 + 27c371a commit fff4f09
Show file tree
Hide file tree
Showing 38 changed files with 2,442 additions and 1,244 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/buildDeploy.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@

name: 🏭Build 🚀Deploy

on:
push:
branches: [ develop ]
branches: [ master ]
pull_request:
branches: [ master ]

Expand All @@ -18,6 +19,7 @@ jobs:

steps:
- uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
Expand All @@ -27,10 +29,10 @@ jobs:
- name: Build 🏭
run: |
npm install
- npm run build
- cp LICENSE README.md dist
- (cd dist; zip --move --recurse-paths kursausschreibung.zip *)
- mv README.md dist
npm run build
cp LICENSE README.md dist
(cd dist; zip --move --recurse-paths kursausschreibung.zip *)
mv README.md dist
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@4.1.4
Expand Down
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-2019 bkd-mba-fbi
Copyright (c) 2018-2021 bkd-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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# kursausschreibung 3.2.0
# kursausschreibung 3.3.0
[![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
1 change: 1 addition & 0 deletions app/components/event-list-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { camelize } from "@ember/string";

export default Component.extend({
tagName: 'li',
classNames: 'jsfilter',

title: settings.eventListTitle,

Expand Down
26 changes: 22 additions & 4 deletions app/components/event-list-search.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,47 @@
import Component from '@ember/component';
import { oneWay } from '@ember/object/computed';
import { observer } from '@ember/object';
import { setParameterByName, getParameterByName } from 'kursausschreibung/framework/url-helpers';

// tests if a query matches a value
function match(value, query) {

if (typeof value === 'object' && value !== null) {
value = Object.values(value).join('|');
}

return (
typeof value === 'string' &&
value.toLowerCase().indexOf(query) !== -1
);
}

export default Component.extend({
query: '',

query: getParameterByName('search'),
// update the filtered events when the events change
eventsChanged: observer('events', function () {
this.send('queryChanged');
}),

willRender() {
this.send('queryChanged');
},

filteredEvents: oneWay('events'),

keyUp(){
setParameterByName('search',this.get('query'));
},

actions: {
queryChanged() {
let query = this.get('query').toLowerCase();
clearSearch() {
this.set('query','');
setParameterByName('search','');
},

queryChanged() {
let query = this.get('query');
query = query === null ? '' : query.toLowerCase();
// don't filter the events when the query is empty
if (query === '') {
this.set('filteredEvents', this.get('events'));
Expand Down
31 changes: 31 additions & 0 deletions app/components/event-list.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,40 @@
import Component from '@ember/component';
import {getParameterByName, setParameterByName} from 'kursausschreibung/framework/url-helpers';

function filterParam(getParam) {
let filters = document.getElementsByClassName('filter-tag');
let activeClass = 'uk-active';


if(getParam) {
let filterValue = getParameterByName('filter');

for (let item of filters) {
document.getElementById(item.id).classList.remove(activeClass);
if(item.id.indexOf('tag'+filterValue) >= 0) {
document.getElementById(item.id).classList.add(activeClass);
}
}
} else {
for (let item of filters) {
if(item.className.indexOf(activeClass) >= 0) {
setParameterByName('filter',item.id.substring(3,item.id.length));
}
}
}

}

export default Component.extend({
actions: {
queryChanged(query) {
this.get('queryChanged')(query);
}
},
didRender() {
filterParam(true);
},
click() {
filterParam(false);
}
});
132 changes: 132 additions & 0 deletions app/components/input/input-file.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
import Component from '@ember/component';
import { getString } from 'kursausschreibung/framework/translate';
import { removeFile } from 'kursausschreibung/framework/form-helpers';
import uikit from 'uikit';
import jQuery from 'jquery';

function getInputFile(fieldId) {
let elementIdFile = getElementIdFile(fieldId);
return document.getElementById(elementIdFile).files[0];
}

function getElementIdFile(fieldId) {
return 'file' + fieldId;
}

export default Component.extend({
change() {

let elementIdFile = getElementIdFile(this.field.id);
let inputFile = getInputFile(this.field.id);
inputFile.imgDev = null;
let maxFileSizeMB = (this.get('field.maxFileSize') / (1024 * 1024)).toFixed(2);

if (inputFile.size > this.get('field.maxFileSize') && maxFileSizeMB !== '0.00') {
uikit.modal.alert(getString('FileSizeTooBig') + maxFileSizeMB + 'MB');
removeFile(elementIdFile);
}
else if (this.get('field.acceptFileType').indexOf(inputFile.type) === -1 || inputFile.type === "") {
uikit.modal.alert(getString('FileTypeNotAccept') + this.get('field.acceptFileType'));
removeFile(elementIdFile);
}
else {

this.set('field.fileLabelBevorFileChoose', this.get('field.fileTypeLabel'));
this.set('field.fileTypeLabel', inputFile.name);
this.set('field.fileObject', inputFile);

let buttonClass = document.getElementById('fileBt' + this.field.id);
buttonClass.classList.remove('required');
let buttonClassDel = document.getElementById('fileBtDel' + this.field.id);
buttonClassDel.classList.remove('uk-hidden');

const reader = new FileReader();
let data;

// Note: reading file is async
reader.onload = () => {
data = reader.result;
this.set('field.fileObject.data', data);

};

if (inputFile) {
reader.readAsDataURL(inputFile);
}

if(this.get('field.acceptFileType') === 'image/jpeg') {

let fieldId = this.field.id;
let buttonClassUpload = document.getElementById('fileBtUpload' + fieldId);
buttonClassUpload.classList.remove('uk-hidden');

let imgField = document.getElementById('img'+ fieldId);
imgField.classList.remove('uk-hidden');


var basic = jQuery('#img'+ this.field.id).croppie({
viewport: { width: 296, height: 396 },
boundary: { width: 350, height: 450 },
});

basic.croppie('bind', {
url: URL.createObjectURL(inputFile)
});

}


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

deleteFile() {
let fieldId = this.field.id;
let elementIdFile = getElementIdFile(fieldId);
let buttonClassDel = document.getElementById('fileBtDel' + fieldId);
buttonClassDel.classList.add('uk-hidden');
let imgClassDel = document.getElementById('img' + fieldId);
imgClassDel.classList.add('uk-hidden');
let imgClassUp = document.getElementById('fileBtUpload' + fieldId);
imgClassUp.classList.add('uk-hidden');
let imgFielDev = document.getElementById('imgDev' + fieldId);
imgFielDev.classList.add('uk-hidden');
removeFile(elementIdFile);
this.set('field.fileTypeLabel', this.get('field.fileLabelBevorFileChoose'));

jQuery('#img'+ this.field.id).croppie('destroy');

},
uploadImage(){
let fieldId = this.field.id;
//on button click
let basic = jQuery('#img'+ fieldId);
let inputFile = getInputFile(fieldId);
basic.croppie('result', {
type: 'base64',
format: 'jpeg'
}).then(function(base64) {
// html is div (overflow hidden)
// with img positioned inside.
inputFile.imgDev = base64;

let imgFielDev = document.getElementById('imgDev' + fieldId);
imgFielDev.src = base64;
imgFielDev.classList.remove('uk-hidden');
let imgClassUp = document.getElementById('fileBtUpload' + fieldId);
imgClassUp.classList.add('uk-hidden');
let imgClassDel = document.getElementById('img' + fieldId);
imgClassDel.classList.add('uk-hidden');

jQuery('#img'+ fieldId).croppie('destroy');

});



}

}

});
12 changes: 9 additions & 3 deletions app/components/list-pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ let n = 2;

export default Component.extend({
lastPage: computed('items', function () {
return Math.ceil(this.get('items').length / settings.itemsPerPage);
let filter = this.get('items').filter(item => item.codes instanceof Array);
return filter.length > 0 ? 1 : Math.ceil(this.get('items').length / settings.itemsPerPage);
}),

isFirstPage: computed('page', function () {
Expand Down Expand Up @@ -58,9 +59,14 @@ 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');

return this.get('items').slice(settings.itemsPerPage * (page - 1), settings.itemsPerPage * 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);
})
});
15 changes: 8 additions & 7 deletions app/components/status-lamp.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { observer } from '@ember/object';
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' }
green: { tooltip: getString('greenLamp'), className: 'lamp-green', icon: 'pencil' },
chartreuse: { tooltip: getString('chartreuseLamp'), className: 'lamp-chartreuse', icon: 'check' },
yellow: { tooltip: getString('yellowLamp'), className: 'lamp-yellow', icon: 'clock' },
red: { tooltip: getString('redLamp'), className: 'lamp-red', icon: 'close' },
orange: { tooltip: getString('orangeLamp'), className: 'lamp-orange', icon: 'ban' }
};

export default Component.extend({
Expand All @@ -23,11 +23,12 @@ export default Component.extend({
if (status !== undefined) {
this.set('tooltip', status.tooltip);
this.set('color', status.className);
this.set('icon', status.icon);
}
}),

tagName: 'span',
attributeBindings: ['tooltip:data-uk-tooltip'],
classNames: ['status-lamp'],
attributeBindings: ['tooltip:data-uk-tooltip',"icon:uk-icon"],
classNames: ['status-lamp','icon-lamp'],
classNameBindings: ['color']
});
20 changes: 19 additions & 1 deletion app/components/subscription-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ function subscribe($form, self) {

if (element.type === 'checkbox')
value = element.checked ? 'Ja' : 'Nein';
else if (element.type === 'file')
value = element.files[0] !== undefined ? element.files[0].name :null;
else if (element.value !== '' && element.dataset.type === 'date')
value = getDMY(element.value); // this is the required format for subscriptionDetails
else if ((element.value !== '' && element.type !== 'radio') || element.checked)
Expand All @@ -94,6 +96,14 @@ function subscribe($form, self) {
subscriptionData.SubscriptionDetails.push({ VssId: vssId, Value: value });
});

//made a array of Files for upload to server
let subscriptionFiles = [];
for (const [key, value] of Object.entries(assocSubscriptionData)) {
if (value instanceof Object) {
subscriptionFiles.push({IdVss: key, fileAsBase64: value.imgDev === null ? value.data : value.imgDev, name: value.name, size: value.size, type: value.type});
}
}

// values for dataToSubmit
let personId = userSettings.IdPerson, tableData = {}, addressData, companyAddressData, additionalPeople;

Expand Down Expand Up @@ -145,7 +155,7 @@ function subscribe($form, self) {
// save the data to submit
setDataToSubmit({
personId, eventId, useCompanyAddress, addressData, companyAddressData, subscriptionData,
additionalPeople, tableData
additionalPeople, tableData, subscriptionFiles
});
}

Expand Down Expand Up @@ -191,6 +201,11 @@ function setProperties(data, element) {
return;
}

if (element.type === 'file') {
data[element.name] = element.files[0] !== undefined ? element.files[0] : null;
return;
}

data[element.name] = element.value === '' ? null : element.value;
}

Expand All @@ -212,6 +227,9 @@ function getTableData(fields, data) {
// localize dates
if (field.dataType === 'date')
value = formatDate(value, 'LL');

if (field.dataType === 'file')
value = value.name;

return { label, value };
}).filter(field => field !== null);
Expand Down
Loading

0 comments on commit fff4f09

Please sign in to comment.