Skip to content

Commit

Permalink
updates dependencies and fixes property modified twice in a single re…
Browse files Browse the repository at this point in the history
…nder deprecations
  • Loading branch information
jelhan committed Aug 1, 2017
1 parent b517f0d commit 632c36e
Show file tree
Hide file tree
Showing 40 changed files with 2,251 additions and 1,563 deletions.
14 changes: 14 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
root: true,
parserOptions: {
ecmaVersion: 2017,
sourceType: 'module'
},
extends: 'eslint:recommended',
env: {
browser: true,
es6: true
},
rules: {
}
};
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.
# See https://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist
Expand All @@ -18,4 +18,10 @@
/coverage/*
/libpeerconnection.log
npm-debug.log*
yarn-error.log
testem.log

# ember-try
.node_modules.ember-try/
bower.json.ember-try
package.json.ember-try
32 changes: 0 additions & 32 deletions .jshintrc

This file was deleted.

22 changes: 6 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,16 @@ sudo: false

cache:
yarn: true
directories:
- travis_phantomjs

addons:
apt:
sources:
- sourceline: 'deb https://dl.yarnpkg.com/debian/ stable main'
key_url: 'https://dl.yarnpkg.com/debian/pubkey.gpg'
packages:
- yarn

before_install:
# update node
- nvm install 6
# update phantomjs
- export PATH=$PWD/travis_phantomjs/phantomjs-2.1.1-linux-x86_64/bin:$PATH; if [ $(phantomjs --version) != '2.1.1' ]; then rm -rf $PWD/travis_phantomjs; mkdir -p $PWD/travis_phantomjs && wget https://assets.membergetmember.co/software/phantomjs-2.1.1-linux-x86_64.tar.bz2 -O $PWD/travis_phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2 && tar -xvf $PWD/travis_phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2 -C $PWD/travis_phantomjs; fi

- if $TEST_EMBER || $TEST_SAUCHE; then curl -o- -L https://yarnpkg.com/install.sh | bash; fi
- if $TEST_EMBER || $TEST_SAUCHE; then export PATH=$HOME/.yarn/bin:$PATH; fi
- if $TEST_EMBER; then yarn global add phantomjs-prebuilt; fi
- if $TEST_EMBER; then phantomjs --version; fi
install:
- if $TEST_EMBER || $TEST_SAUCE; then yarn global add bower; fi
- if $TEST_EMBER || $TEST_SAUCE; then yarn install; fi
- if $TEST_EMBER || $TEST_SAUCE; then yarn global add bower; fi
- if $TEST_EMBER || $TEST_SAUCE; then yarn install --no-interactive; fi
- if $TEST_EMBER || $TEST_SAUCE; then bower install; fi
# install non development composer requirements for api
- if $TEST_EMBER || $TEST_SAUCE; then cd api/ && composer install --no-dev && cd ..; fi
Expand Down
2 changes: 0 additions & 2 deletions app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ const { Application } = Ember;

let App;

Ember.MODEL_FACTORY_INJECTIONS = true;

App = Application.extend({
modulePrefix: config.modulePrefix,
podModulePrefix: config.podModulePrefix,
Expand Down
7 changes: 5 additions & 2 deletions app/components/create-options-datetime.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ from 'ember-cp-validations';
import { groupBy } from 'ember-array-computed-macros';
import Form from 'ember-bootstrap/components/bs-form';

const { computed, Component, inject, isEmpty, isPresent, observer } = Ember;
const { computed, Component, inject, isArray, isEmpty, isPresent, observer } = Ember;
const { filter, mapBy, readOnly } = computed;

let modelValidations = buildValidations({
Expand Down Expand Up @@ -147,7 +147,10 @@ export default Component.extend(modelValidations, {
return childView instanceof Form;
});
}),
formElements: readOnly('form.childFormElements'),
formElements: computed('form.childFormElements', function() {
let formElements = this.get('form.childFormElements');
return isArray(formElements) ? formElements : [];
}),
daysValidationState: computed('formElements.@each.validation', function() {
return this.get('formElements').reduce(function(daysValidationState, item) {
const day = item.get('model.day');
Expand Down
31 changes: 17 additions & 14 deletions app/components/create-options-text.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Ember from 'ember';
import BsForm from 'ember-bootstrap/components/bs-form';
import { anyBy } from 'ember-array-computed-macros';

const { Component, computed, inject, observer, on } = Ember;
const { Component, computed, inject, observer, on, run } = Ember;

export default Component.extend({
actions: {
Expand Down Expand Up @@ -49,21 +49,24 @@ export default Component.extend({
this.set('form', this.nearestOfType(BsForm));
}),

labelValidationClass: computed('anyElementHasFeedback', 'anyElementIsInvalid', 'everyElementIsValid', function() {
if (!this.get('anyElementHasFeedback')) {
return 'label-has-no-validation';
}

if (this.get('anyElementIsInvalid')) {
return 'label-has-error';
}
labelValidationClass: 'label-has-no-validation',
updateLabelValidationClass: observer('anyElementHasFeedback', 'anyElementIsInvalid', 'everyElementIsValid', function() {
run.scheduleOnce('sync', () => {
let validationClass;

if (this.get('everyElementIsValid')) {
return 'label-has-success';
}
if (!this.get('anyElementHasFeedback')) {
validationClass = 'label-has-no-validation';
} else if (this.get('anyElementIsInvalid')) {
validationClass = 'label-has-error';
} else if (this.get('everyElementIsValid')) {
validationClass = 'label-has-success';
} else {
validationClass = 'label-has-no-validation';
}

return 'label-has-no-validation';
}),
this.set('labelValidationClass', validationClass);
});
}).on('init'),

classNameBindings: ['labelValidationClass'],

Expand Down
146 changes: 78 additions & 68 deletions app/controllers/poll.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import moment from 'moment';
/* global jstz */

const {
ArrayProxy,
computed,
Controller,
getOwner,
Expand All @@ -13,6 +14,69 @@ const {
observer
} = Ember;

const dateObject = EmberObject.extend({
i18n: inject.service(),
init() {
// retrive locale on init to setup observers
this.get('i18n.locale');
},
date: computed('dateString', 'i18n.locale', function() {
let value = this.get('dateString');
let date;

if (isEmpty(value)) {
return null;
}

date = moment(value);

if (
this.get('hasTime') &&
!this.get('useLocalTimezone')
) {
date.tz(this.get('timezone'));
}

return date;
}),
formatted: computed('date', 'hasTime', 'timezone', 'useLocaleTImezone', function() {
let date = this.get('date');

if (!moment.isMoment(date)) {
return '';
}

if (
this.get('hasTime') &&
!this.get('useLocaleTimezone') &&
isPresent(this.get('timezone'))
) {
date.tz(this.get('timezone'));
}

return this.get('hasTime') ? date.format('LLLL') : date.format(
moment.localeData()
.longDateFormat('LLLL')
.replace(
moment.localeData().longDateFormat('LT'), '')
.trim()
);
}),
formattedTime: computed('date', function() {
let date = this.get('title');

if (!moment.isMoment(date)) {
return '';
}

return date.format('LT');
}),
hasTime: computed('dateString', function() {
return moment(this.get('dateString'), 'YYYY-MM-DD', true).isValid() === false;
}),
title: computed.readOnly('date')
});

export default Controller.extend({
actions: {
linkAction(type) {
Expand Down Expand Up @@ -75,7 +139,7 @@ export default Controller.extend({
let count = 0;
let lastDate = null;
datetimes.forEach(function(el) {
let date = moment(el.title)
let date = moment(el.get('date'))
.hour(0)
.minute(0)
.seconds(0)
Expand Down Expand Up @@ -114,75 +178,21 @@ export default Controller.extend({
/*
* handles options if they are dates
*/
dates: computed('model.options.[]', 'useLocalTimezone', function() {
let timezone = false;
let dates = [];
const dateObject = EmberObject.extend({
i18n: inject.service(),
init() {
// retrive locale to setup observers
this.get('i18n.locale');
},
formatted: computed('title', 'i18n.locale', function() {
const date = this.get('title');
const locale = this.get('i18n.locale');

// locale is stored on date, we have to override it if it has changed since creation
if (date.locale() !== locale) {
date.locale(this.get('i18n.locale'));
}

return this.get('hasTime') ? date.format('LLLL') : date.format(
moment.localeData()
.longDateFormat('LLLL')
.replace(
moment.localeData().longDateFormat('LT'), '')
.trim()
);
}),
formattedTime: computed('title', 'i18n.locale', function() {
const date = this.get('title');
const locale = this.get('i18n.locale');

// locale is stored on date, we have to override it if it has changed since creation
if (date.locale() !== locale) {
date.locale(this.get('i18n.locale'));
}

return date.format('LT');
})
});

// if poll type is find a date
// we return an empty array
if (!this.get('model.isFindADate')) {
return [];
}

// if poll has dates with times we have to care about timezone
// but since user timezone is default we only have to set timezone
// if timezone poll got created in should be used
if (
this.get('hasTimes') &&
!this.get('useLocalTimezone')
) {
timezone = this.get('model.timezone');
}

const owner = getOwner(this);
dates = this.get('model.options').map((option) => {
const date = moment(option.get('title'));
const hasTime = moment(option.get('title'), 'YYYY-MM-DD', true).isValid() === false;
if (timezone && hasTime) {
date.tz(timezone);
dates: computed('model.options', 'model.timezone', 'useLocalTimezone', function() {
let owner = getOwner(this);
let timezone = this.get('model.timezone');
let useLocalTimezone = this.get('useLocalTimezone');

return ArrayProxy.create({
content: this.get('model.options'),
objectAtContent(idx) {
return dateObject.create(owner.ownerInjection(), {
dateString: this.get('content').objectAt(idx).get('title'),
timezone,
useLocalTimezone
});
}
return dateObject.create(owner.ownerInjection(), {
title: date,
hasTime
});
});

return dates;
}),

flashMessages: inject.service(),
Expand Down
12 changes: 6 additions & 6 deletions app/controllers/poll/participation.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export default Controller.extend(Validations, {

selections: computed('pollController.model.options', 'pollController.dates', function() {
let options;
const isFindADate = this.get('isFindADate');
let isFindADate = this.get('isFindADate');
let lastDate;

if (this.get('isFindADate')) {
Expand All @@ -195,14 +195,14 @@ export default Controller.extend(Validations, {

// format label
if (isFindADate) {
if (option.hasTime && lastDate && option.title.format('YYYY-MM-DD') === lastDate.format('YYYY-MM-DD')) {
if (option.get('hasTime') && lastDate && option.get('date').format('YYYY-MM-DD') === lastDate.format('YYYY-MM-DD')) {
// do not repeat dates for different times
labelValue = option.title;
labelValue = option.get('date');
labelFormat = 'time';
} else {
labelValue = option.title;
labelFormat = option.hasTime ? 'day-with-time' : 'day';
lastDate = option.title;
labelValue = option.get('date');
labelFormat = option.get('hasTime') ? 'day-with-time' : 'day';
lastDate = option.get('date');
}
} else {
labelValue = option.get('title');
Expand Down
Loading

0 comments on commit 632c36e

Please sign in to comment.