Permalink
Browse files

Merge pull request #1381 from leider/master

Fix bug for english in edit activity
  • Loading branch information...
leider committed Dec 2, 2018
2 parents dad9dcf + 89f0c01 commit 29f50e7546d3536fdb6130f290ce1bf0f0ff4c32
@@ -1,7 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Middleware" type="mocha-javascript-test-runner" factoryName="Mocha">
<node-interpreter>$usr-local-bin$/node</node-interpreter>
<node-options />
<node-options>--icu-data-dir=node_modules/full-icu</node-options>
<working-directory>$PROJECT_DIR$</working-directory>
<pass-parent-env>true</pass-parent-env>
<envs>
@@ -18,6 +18,6 @@
<ConfigurationWrapper RunnerId="MochaDebugRunner" />
<ConfigurationWrapper RunnerId="RunnerForMochaJavaScript" />
<ConfigurationWrapper RunnerId="debuggableProgram" />
<method />
<method v="2" />
</configuration>
</component>
@@ -73,6 +73,7 @@ module.exports = function (grunt) {
src: ['node_modules/bootstrap-colorpicker/dist/js/bootstrap-colorpicker.min.*',
'node_modules/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js',
'node_modules/bootstrap-datepicker/dist/locales/bootstrap-datepicker.de.min.js',
'node_modules/bootstrap-datepicker/dist/locales/bootstrap-datepicker.en-GB.min.js',
'node_modules/simple-timepicker/dist/simple-timepicker.min.js',
'node_modules/guillotine/js/jquery.guillotine.min.js'
],
@@ -8,9 +8,9 @@ var contentsOfAlphanumeric = 'Only numbers, characters, dashes and underscores a
var nicknameIsNotAvailable = 'This nickname is not available.';
var contentsOfNickname = 'Nickname must only contain letters, numbers and underscores.';
var emailAlreadyTaken = 'This email address is already registered. Did you already create a profile?';
var datepicker_lang = 'en';
var datepicker_lang = 'en-GB';
var datepicker_format = 'dd/mm/yyyy';
var fc_lang = 'en-gb';
var fc_lang = 'en-GB';
var tableLangUrl = '';
var help = 'Help';
var selectTshirtSize = 'Please select a t-shirt size.';
@@ -13,7 +13,7 @@ function toUtc(dateString, timeString) {
}

if (dateString && timeString) {
var dateArray = dateString.split('.').map(stringToInt);
var dateArray = dateString.split(/[.|/]/).map(stringToInt);
var timeArray = timeString.split(':').map(stringToInt);
if (dateArray.length === 3 && timeArray.length === 2) {
return new Date(Date.UTC(dateArray[2], dateArray[1] - 1, dateArray[0], timeArray[0], timeArray[1]));
@@ -19,6 +19,11 @@ class Activity {
this.state.resources = {};
this.state.resources[standardName] = {_registeredMembers: [], _registrationOpen: true};
}
const start = (this.state.startUnix && !isNaN(this.state.startUnix)) ? DateTime.fromMillis(this.state.startUnix * 1000) : DateTime.local();
this.state.startDate = start.set({milliseconds: 0, seconds: 0}).setZone(fieldHelpers.defaultTimezone()).toJSDate();

const end = (this.state.endUnix && !isNaN(this.state.endUnix)) ? DateTime.fromMillis(this.state.endUnix * 1000) : DateTime.local();
this.state.startDate = end.set({milliseconds: 0, seconds: 0}).setZone(fieldHelpers.defaultTimezone()).toJSDate();
}

id() {
@@ -222,14 +227,6 @@ class Activity {
return this.endDateTime().ordinal !== this.startDateTime().ordinal;
}

startDate() {
return new Date(this.startUnix() * 1000);
}

endDate() {
return new Date(this.endUnix() * 1000);
}

startDateTime() {
return DateTime.fromMillis(this.startUnix() * 1000).setZone(fieldHelpers.defaultTimezone());
}
@@ -11,7 +11,7 @@ function activityAsICal(activity) {
event.setDescription(activity.description().replace(/\r\n/g, '\n'));
event.addProperty('LOCATION', activity.location().replace(/\r\n/g, '\n'));
event.addProperty('URL', misc.toFullQualifiedUrl('activities', encodeURIComponent(activity.url())));
event.setDate(activity.startDate(), activity.endDate());
event.setDate(activity.startDateTime().toJSDate(), activity.endDateTime().toJSDate());
return event;
}

@@ -10,11 +10,10 @@ block content

block scripts
+map(activity.location())
script $('#location').change(function() {showLocation($('#location').val())})
script $('#location').change(function () {showLocation($('#location').val())})
script(src='/clientscripts/bootstrap-datepicker.min.js')
script(src='/clientscripts/simple-timepicker.min.js')
if language === 'de'
script(src='/clientscripts/bootstrap-datepicker.de.min.js')
script(src='/clientscripts/bootstrap-datepicker.' + language + '.min.js')
script(src='/clientscripts/activityDateModel.js')
script(src='/clientscripts/activityform-dateAdapter.js')
script(src='/clientscripts/check-activityform.js')
@@ -5,7 +5,7 @@ const conf = require('simple-configure');
const misc = conf.get('beans').get('misc');

// adding additional languages to builtin Intl
if (!require('intl-locales-supported')(['de', 'en-gb'])) {
if (!require('intl-locales-supported')(['de', 'en-GB'])) {
// `Intl` exists, but it doesn't have the data we need, so load the
// polyfill and replace the constructors we need with the polyfill's.
const IntlPolyfill = require('intl');
@@ -70,10 +70,10 @@ module.exports = {
validator.check(activityInput.assignedGroup, 'Gruppe ist ein Pflichtfeld.').notEmpty();
nonEmptyResourceLimits.forEach(limit => validator.check(limit, 'Die Ressourcenbeschränkungen dürfen nur aus Ziffern bestehen.').isInt());

const startUnix = fieldHelpers.parseToUnixUsingDefaultTimezone(activityInput.startDate, activityInput.startTime);
const endUnix = fieldHelpers.parseToUnixUsingDefaultTimezone(activityInput.endDate, activityInput.endTime);
const start = fieldHelpers.parseToDateTimeUsingDefaultTimezone(activityInput.startDate, activityInput.startTime);
const end = fieldHelpers.parseToDateTimeUsingDefaultTimezone(activityInput.endDate, activityInput.endTime);

if (startUnix >= endUnix) {
if (start >= end) {
validator.error('Start muss vor Ende liegen.');
}

@@ -1,4 +1,6 @@
'use strict';

const {DateTime} = require('luxon');
const Member = require('simple-configure').get('beans').get('member');

module.exports = function accessrights(req, res, next) {
@@ -35,7 +37,7 @@ module.exports = function accessrights(req, res, next) {
},

canDeleteActivity: function canDeleteActivity(activity) {
return this.isSuperuser() || (activity.owner() === this.memberId() && activity.startDate() > new Date());
return this.isSuperuser() || (activity.owner() === this.memberId() && activity.startDateTime() > DateTime.local());
},

canCreateGroup: function canCreateGroup() {
@@ -76,7 +76,7 @@ app.get('/test', (req, res) => {
});

app.get('/language/:isoCode', (req, res) => {
req.session.language = req.params.isoCode.substring(0, 2);
req.session.language = req.params.isoCode;
res.redirect(req.query.currentUrl);
});

@@ -235,13 +235,13 @@ describe('formatNumberWithCurrentLocale', () => {
});

it('formats for "en"', () => {
const res = {locals: {language: 'en-gb'}};
const res = {locals: {language: 'en-GB'}};
const result = fieldHelpers.formatNumberWithCurrentLocale(res, 22);
expect(result).to.equal('22.00');
});

it('formats "undefined"', () => {
const res = {locals: {language: 'en-gb'}};
const res = {locals: {language: 'en-GB'}};
const result = fieldHelpers.formatNumberWithCurrentLocale(res, undefined);
expect(result).to.equal('0.00');
});
@@ -53,7 +53,7 @@ mixin loginMenu(forInline)
| &nbsp;#{t('general.feedback')}
li: include ../version
if language === 'de'
+languageEntry(forInline, 'en-gb', 'switch to English', 'United-Kingdom.png')
+languageEntry(forInline, 'en-GB', 'switch to English', 'United-Kingdom.png')
else
+languageEntry(forInline, 'de', 'auf Deutsch umschalten', 'Germany.png')

0 comments on commit 29f50e7

Please sign in to comment.