fix build issue by updating ember-moment

This commit is contained in:
jelhan 2017-07-25 16:10:55 +02:00
parent dcef728690
commit 364147f4b6
6 changed files with 873 additions and 67 deletions

View file

@ -182,12 +182,6 @@ export default Controller.extend(Validations, {
let options;
const isFindADate = this.get('isFindADate');
let lastDate;
const dateFormat = moment.localeData()
.longDateFormat('LLLL')
.replace(
moment.localeData().longDateFormat('LT'), '')
.trim();
const dateTimeFormat = 'LLLL';
if (this.get('isFindADate')) {
options = this.get('pollController.dates');
@ -204,15 +198,15 @@ export default Controller.extend(Validations, {
if (option.hasTime && lastDate && option.title.format('YYYY-MM-DD') === lastDate.format('YYYY-MM-DD')) {
// do not repeat dates for different times
labelValue = option.title;
labelFormat = 'LT';
labelFormat = 'time';
} else {
labelValue = option.title;
labelFormat = option.hasTime ? dateTimeFormat : dateFormat;
labelFormat = option.hasTime ? 'day-with-time' : 'day';
lastDate = option.title;
}
} else {
labelValue = option.get('title');
labelFormat = false;
labelFormat = 'plain';
}
// https://github.com/offirgolan/ember-cp-validations#basic-usage---objects
@ -234,11 +228,35 @@ export default Controller.extend(Validations, {
// changes https://github.com/stefanpenner/ember-moment/issues/108
// but that should be the way to go
label: computed('i18n.locale', function() {
if (this.get('labelFormat') === false) {
let labelFormat = this.get('labelFormat');
if (labelFormat === 'plain') {
return this.get('labelValue');
} else {
return this.get('labelValue').locale(this.get('i18n.locale')).format(this.get('labelFormat'));
}
let currentLocale = this.get('i18n.locale');
let momentFormat;
switch (labelFormat) {
case 'time':
momentFormat = 'LT';
break;
case 'day-with-time':
momentFormat = 'LLLL';
break;
case 'day':
momentFormat = moment.localeData(currentLocale)
.longDateFormat('LLLL')
.replace(moment.localeData(currentLocale).longDateFormat('LT'), '')
.trim();
break;
}
return this.get('labelValue')
.locale(currentLocale)
.format(momentFormat);
}),
labelFormat,
labelValue,

View file

@ -35,7 +35,7 @@ module.exports = function(environment) {
moment: {
includeLocales: ['de', 'es'],
includeTimezone: '2010-2020'
includeTimezone: 'subset'
},
i18n: {

View file

@ -48,7 +48,7 @@
"ember-cli-inject-live-reload": "^1.4.1",
"ember-cli-jshint": "^1.0.4",
"ember-cli-less": "^1.5.3",
"ember-cli-moment-shim": "0.7.1",
"ember-cli-moment-shim": "3.3.3",
"ember-cli-page-object": "1.7.0",
"ember-cli-pretender": "^0.6.0",
"ember-cli-qunit": "^2.1.0",
@ -65,7 +65,7 @@
"ember-i18n-cp-validations": "^3.0.2",
"ember-load-initializers": "^0.5.1",
"ember-math-helpers": "^2.0.2",
"ember-moment": "^6.1.0",
"ember-moment": "7.3.1",
"ember-object-at-helper": "0.1.0",
"ember-page-title": "^3.0.6",
"ember-radio-buttons": "^4.0.1",

View file

@ -9,7 +9,6 @@ import moment from 'moment';
const { run } = Ember;
let application, server;
let dateString;
module('Acceptance | view evaluation', {
beforeEach() {
@ -19,11 +18,6 @@ module('Acceptance | view evaluation', {
application.__container__.lookup('adapter:application').__proto__.namespace = '';
server = new Pretender();
dateString = moment.localeData()
.longDateFormat('LLLL')
.replace(
moment.localeData().longDateFormat('LT'), '')
.trim();
},
afterEach() {
server.shutdown();
@ -139,7 +133,7 @@ test('evaluation is correct for FindADate', function(assert) {
);
assert.equal(
find('.best-options strong').text().trim(),
moment('2016-01-01').format(dateString),
'Friday, January 1, 2016',
'options are evaluated correctly'
);
assert.equal(

View file

@ -72,15 +72,11 @@ test('view a poll with dates', function(assert) {
});
visit(`/poll/${id}?encryptionKey=${encryptionKey}`).then(function() {
const dayFormat = moment.localeData().longDateFormat('LLLL')
.replace(
moment.localeData().longDateFormat('LT'), '')
.trim();
assert.deepEqual(
pageParticipation.options().labels,
[
moment('2015-12-12').format(dayFormat),
moment('2016-01-01').format(dayFormat)
'Saturday, December 12, 2015',
'Friday, January 1, 2016'
]
);
});
@ -111,11 +107,11 @@ test('view a poll with dates and times', function(assert) {
pageParticipation.options().labels,
[
// full date
moment.tz('2015-12-12T11:11:00.000Z', timezone).format('LLLL'),
moment.tz('2015-12-12T11:11:00.000Z', timezone).locale('en').format('LLLL'),
// only time cause day is repeated
moment.tz('2015-12-12T13:13:00.000Z', timezone).format('LT'),
moment.tz('2015-12-12T13:13:00.000Z', timezone).locale('en').format('LT'),
// full date cause day changed
moment.tz('2016-01-01T11:11:00.000Z', timezone).format('LLLL')
moment.tz('2016-01-01T11:11:00.000Z', timezone).locale('en').format('LLLL')
]
);
});
@ -160,8 +156,8 @@ test('view a poll while timezone differs from the one poll got created in and ch
assert.deepEqual(
pageParticipation.options().labels,
[
moment.tz('2015-12-12T11:11:00.000Z', timezoneLocal).format('LLLL'),
moment.tz('2016-01-01T11:11:00.000Z', timezoneLocal).format('LLLL')
moment.tz('2015-12-12T11:11:00.000Z', timezoneLocal).locale('en').format('LLLL'),
moment.tz('2016-01-01T11:11:00.000Z', timezoneLocal).locale('en').format('LLLL')
]
);
@ -216,8 +212,8 @@ test('view a poll while timezone differs from the one poll got created in and ch
assert.deepEqual(
pageParticipation.options().labels,
[
moment.tz('2015-12-12T11:11:00.000Z', timezonePoll).format('LLLL'),
moment.tz('2016-01-01T11:11:00.000Z', timezonePoll).format('LLLL')
moment.tz('2015-12-12T11:11:00.000Z', timezonePoll).locale('en').format('LLLL'),
moment.tz('2016-01-01T11:11:00.000Z', timezonePoll).locale('en').format('LLLL')
]
);

862
yarn.lock

File diff suppressed because it is too large Load diff