updates ember, ember data and ember data model fragments and fixes some container deprecation
This commit is contained in:
parent
c8fbc62d8c
commit
1400b71417
15 changed files with 156 additions and 122 deletions
|
@ -1,6 +1,6 @@
|
|||
import Ember from 'ember';
|
||||
import Resolver from 'ember/resolver';
|
||||
import loadInitializers from 'ember/load-initializers';
|
||||
import Resolver from './resolver';
|
||||
import loadInitializers from 'ember-load-initializers';
|
||||
import config from './config/environment';
|
||||
|
||||
const { Application } = Ember;
|
||||
|
|
|
@ -4,7 +4,7 @@ import {
|
|||
}
|
||||
from 'ember-cp-validations';
|
||||
|
||||
const { computed, Controller, Object: EmberObject, inject } = Ember;
|
||||
const { computed, Controller, getOwner, Object: EmberObject, inject } = Ember;
|
||||
|
||||
const Validations = buildValidations({
|
||||
pollType: [
|
||||
|
@ -45,18 +45,16 @@ export default Controller.extend(Validations, {
|
|||
pollType: computed.alias('model.pollType'),
|
||||
|
||||
pollTypes: computed('', function() {
|
||||
const container = this.get('container');
|
||||
const owner = getOwner(this);
|
||||
|
||||
return [
|
||||
TranslateableObject.create({
|
||||
TranslateableObject.create(owner.ownerInjection(), {
|
||||
id: 'FindADate',
|
||||
labelTranslation: 'pollTypes.findADate.label',
|
||||
container
|
||||
labelTranslation: 'pollTypes.findADate.label'
|
||||
}),
|
||||
TranslateableObject.create({
|
||||
TranslateableObject.create(owner.ownerInjection(), {
|
||||
id: 'MakeAPoll',
|
||||
labelTranslation: 'pollTypes.makeAPoll.label',
|
||||
container
|
||||
labelTranslation: 'pollTypes.makeAPoll.label'
|
||||
})
|
||||
];
|
||||
})
|
||||
|
|
|
@ -6,7 +6,16 @@ from 'ember-cp-validations';
|
|||
import moment from 'moment';
|
||||
/* global jstz */
|
||||
|
||||
const { computed, Controller, copy, inject, isEmpty, Object: EmberObject, observer } = Ember;
|
||||
const {
|
||||
computed,
|
||||
Controller,
|
||||
copy,
|
||||
getOwner,
|
||||
inject,
|
||||
isEmpty,
|
||||
Object: EmberObject,
|
||||
observer
|
||||
} = Ember;
|
||||
|
||||
const Validations = buildValidations({
|
||||
anonymousUser: validator('presence', {
|
||||
|
@ -65,10 +74,10 @@ export default Controller.extend(Validations, {
|
|||
answerType: computed.alias('model.answerType'),
|
||||
|
||||
answerTypes: computed('', function() {
|
||||
const container = this.get('container');
|
||||
const owner = getOwner(this);
|
||||
|
||||
return [
|
||||
TranslateableObject.create({
|
||||
TranslateableObject.create(owner.ownerInjection(), {
|
||||
id: 'YesNo',
|
||||
labelTranslation: 'answerTypes.yesNo.label',
|
||||
answers: [
|
||||
|
@ -82,10 +91,9 @@ export default Controller.extend(Validations, {
|
|||
labelTranslation: 'answerTypes.no.label',
|
||||
icon: 'glyphicon glyphicon-thumbs-down'
|
||||
})
|
||||
],
|
||||
container
|
||||
]
|
||||
}),
|
||||
TranslateableObject.create({
|
||||
TranslateableObject.create(owner.ownerInjection(), {
|
||||
id: 'YesNoMaybe',
|
||||
labelTranslation: 'answerTypes.yesNoMaybe.label',
|
||||
answers: [
|
||||
|
@ -104,14 +112,12 @@ export default Controller.extend(Validations, {
|
|||
labelTranslation: 'answerTypes.no.label',
|
||||
icon: 'glyphicon glyphicon-thumbs-down'
|
||||
})
|
||||
],
|
||||
container
|
||||
]
|
||||
}),
|
||||
TranslateableObject.create({
|
||||
TranslateableObject.create(owner.ownerInjection(), {
|
||||
id: 'FreeText',
|
||||
labelTranslation: 'answerTypes.freeText.label',
|
||||
answers: [],
|
||||
container
|
||||
answers: []
|
||||
})
|
||||
];
|
||||
}),
|
||||
|
@ -119,38 +125,32 @@ export default Controller.extend(Validations, {
|
|||
expirationDuration: 'P3M',
|
||||
|
||||
expirationDurations: computed('', function() {
|
||||
const container = this.get('container');
|
||||
const owner = getOwner(this);
|
||||
|
||||
return [
|
||||
TranslateableObject.create({
|
||||
TranslateableObject.create(owner.ownerInjection(), {
|
||||
id: 'P7D',
|
||||
labelTranslation: 'create.settings.expirationDurations.P7D',
|
||||
container
|
||||
labelTranslation: 'create.settings.expirationDurations.P7D'
|
||||
}),
|
||||
TranslateableObject.create({
|
||||
TranslateableObject.create(owner.ownerInjection(), {
|
||||
id: 'P1M',
|
||||
labelTranslation: 'create.settings.expirationDurations.P1M',
|
||||
container
|
||||
labelTranslation: 'create.settings.expirationDurations.P1M'
|
||||
}),
|
||||
TranslateableObject.create({
|
||||
TranslateableObject.create(owner.ownerInjection(), {
|
||||
id: 'P3M',
|
||||
labelTranslation: 'create.settings.expirationDurations.P3M',
|
||||
container
|
||||
labelTranslation: 'create.settings.expirationDurations.P3M'
|
||||
}),
|
||||
TranslateableObject.create({
|
||||
TranslateableObject.create(owner.ownerInjection(), {
|
||||
id: 'P6M',
|
||||
labelTranslation: 'create.settings.expirationDurations.P6M',
|
||||
container
|
||||
labelTranslation: 'create.settings.expirationDurations.P6M'
|
||||
}),
|
||||
TranslateableObject.create({
|
||||
TranslateableObject.create(owner.ownerInjection(), {
|
||||
id: 'P1Y',
|
||||
labelTranslation: 'create.settings.expirationDurations.P1Y',
|
||||
container
|
||||
labelTranslation: 'create.settings.expirationDurations.P1Y'
|
||||
}),
|
||||
TranslateableObject.create({
|
||||
TranslateableObject.create(owner.ownerInjection(), {
|
||||
id: '',
|
||||
labelTranslation: 'create.settings.expirationDurations.never',
|
||||
container
|
||||
labelTranslation: 'create.settings.expirationDurations.never'
|
||||
})
|
||||
];
|
||||
}),
|
||||
|
|
|
@ -2,7 +2,16 @@ import Ember from 'ember';
|
|||
import moment from 'moment';
|
||||
/* global jstz */
|
||||
|
||||
const { computed, Controller, inject, isEmpty, isPresent, Object: EmberObject, observer } = Ember;
|
||||
const {
|
||||
computed,
|
||||
Controller,
|
||||
getOwner,
|
||||
inject,
|
||||
isEmpty,
|
||||
isPresent,
|
||||
Object: EmberObject,
|
||||
observer
|
||||
} = Ember;
|
||||
|
||||
export default Controller.extend({
|
||||
actions: {
|
||||
|
@ -47,8 +56,8 @@ export default Controller.extend({
|
|||
i18n: inject.service(),
|
||||
value: null
|
||||
});
|
||||
// need to inject container into dateGroupObject to support service injection
|
||||
const container = this.get('container');
|
||||
// need to inject owner into dateGroupObject to support service injection
|
||||
const owner = getOwner(this);
|
||||
let dateGroups = [];
|
||||
|
||||
let count = 0;
|
||||
|
@ -69,10 +78,9 @@ export default Controller.extend({
|
|||
} else {
|
||||
// push last values;
|
||||
dateGroups.pushObject(
|
||||
dateGroupObject.create({
|
||||
dateGroupObject.create(owner.ownerInjection(), {
|
||||
'value': lastDate,
|
||||
'colspan': count,
|
||||
container
|
||||
'colspan': count
|
||||
})
|
||||
);
|
||||
|
||||
|
@ -82,10 +90,9 @@ export default Controller.extend({
|
|||
}
|
||||
});
|
||||
dateGroups.pushObject(
|
||||
dateGroupObject.create({
|
||||
dateGroupObject.create(owner.ownerInjection(), {
|
||||
'value': lastDate,
|
||||
'colspan': count,
|
||||
container
|
||||
'colspan': count
|
||||
})
|
||||
);
|
||||
|
||||
|
@ -150,18 +157,16 @@ export default Controller.extend({
|
|||
timezone = this.get('model.timezone');
|
||||
}
|
||||
|
||||
const container = this.get('container');
|
||||
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);
|
||||
}
|
||||
return dateObject.create({
|
||||
return dateObject.create(owner.ownerInjection(), {
|
||||
title: date,
|
||||
hasTime,
|
||||
// inject container otherwise we could not inject i18n service
|
||||
container
|
||||
hasTime
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -5,7 +5,14 @@ import {
|
|||
from 'ember-cp-validations';
|
||||
import moment from 'moment';
|
||||
|
||||
const { computed, Controller, inject, isEmpty, Object: EmberObject } = Ember;
|
||||
const {
|
||||
computed,
|
||||
Controller,
|
||||
getOwner,
|
||||
inject,
|
||||
isEmpty,
|
||||
Object: EmberObject
|
||||
} = Ember;
|
||||
|
||||
const validCollection = function(collection) {
|
||||
// return false if any object in collection is inValid
|
||||
|
@ -146,7 +153,7 @@ export default Controller.extend(Validations, {
|
|||
|
||||
possibleAnswers: computed('pollController.model.answers', function() {
|
||||
return this.get('pollController.model.answers').map((answer) => {
|
||||
const container = this.get('container');
|
||||
const owner = getOwner(this);
|
||||
|
||||
const AnswerObject = EmberObject.extend({
|
||||
icon: answer.get('icon'),
|
||||
|
@ -154,8 +161,7 @@ export default Controller.extend(Validations, {
|
|||
});
|
||||
|
||||
if (!isEmpty(answer.get('labelTranslation'))) {
|
||||
return AnswerObject.extend({
|
||||
container,
|
||||
return AnswerObject.extend(owner.ownerInjection(), {
|
||||
i18n: inject.service(),
|
||||
label: computed('i18n.locale', function() {
|
||||
return this.get('i18n').t(this.get('labelTranslation'));
|
||||
|
@ -212,10 +218,8 @@ export default Controller.extend(Validations, {
|
|||
// https://github.com/offirgolan/ember-cp-validations#basic-usage---objects
|
||||
// To lookup validators, container access is required which can cause an issue with Object creation
|
||||
// if the object is statically imported. The current fix for this is as follows.
|
||||
const container = this.get('container');
|
||||
return EmberObject.extend(SelectionValidations, {
|
||||
container,
|
||||
|
||||
const owner = getOwner(this);
|
||||
return EmberObject.extend(owner.ownerInjection(), SelectionValidations, {
|
||||
// forceAnswer and isFreeText must be included in model
|
||||
// cause otherwise validations can't depend on it
|
||||
forceAnswer: this.get('forceAnswer'),
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
import DS from 'ember-data';
|
||||
/* global MF */
|
||||
import Fragment from 'model-fragments/fragment';
|
||||
|
||||
export default MF.Fragment.extend({
|
||||
type: DS.attr('string'),
|
||||
label: DS.attr('string'),
|
||||
labelTranslation: DS.attr('string'),
|
||||
icon: DS.attr('string')
|
||||
const { attr } = DS;
|
||||
|
||||
export default Fragment.extend({
|
||||
type: attr('string'),
|
||||
label: attr('string'),
|
||||
labelTranslation: attr('string'),
|
||||
icon: attr('string')
|
||||
});
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
import DS from 'ember-data';
|
||||
import Ember from 'ember';
|
||||
import moment from 'moment';
|
||||
import Fragment from 'model-fragments/fragment';
|
||||
import { fragmentOwner } from 'model-fragments/attributes';
|
||||
import {
|
||||
validator, buildValidations
|
||||
}
|
||||
from 'ember-cp-validations';
|
||||
/* global MF */
|
||||
|
||||
const { assert, computed, isEmpty } = Ember;
|
||||
const { attr } = DS;
|
||||
const { assert, computed, inject, isEmpty } = Ember;
|
||||
|
||||
const Validations = buildValidations({
|
||||
title: [
|
||||
|
@ -53,9 +55,9 @@ const Validations = buildValidations({
|
|||
]
|
||||
});
|
||||
|
||||
export default MF.Fragment.extend(Validations, {
|
||||
poll: MF.fragmentOwner(),
|
||||
title: DS.attr('string'),
|
||||
export default Fragment.extend(Validations, {
|
||||
poll: fragmentOwner(),
|
||||
title: attr('string'),
|
||||
|
||||
date: computed('title', function() {
|
||||
const allowedFormats = [
|
||||
|
@ -153,7 +155,7 @@ export default MF.Fragment.extend(Validations, {
|
|||
}
|
||||
}),
|
||||
|
||||
i18n: Ember.inject.service(),
|
||||
i18n: inject.service(),
|
||||
init() {
|
||||
this.get('i18n.locale');
|
||||
}
|
||||
|
|
|
@ -1,55 +1,63 @@
|
|||
import DS from 'ember-data';
|
||||
import Ember from 'ember';
|
||||
/* global MF */
|
||||
import DS from 'ember-data';
|
||||
import {
|
||||
fragmentArray
|
||||
} from 'model-fragments/attributes';
|
||||
|
||||
export default DS.Model.extend({
|
||||
const {
|
||||
attr,
|
||||
hasMany,
|
||||
Model
|
||||
} = DS;
|
||||
|
||||
export default Model.extend({
|
||||
/*
|
||||
* relationships
|
||||
*/
|
||||
users: DS.hasMany('user', { async: false }),
|
||||
users: hasMany('user', { async: false }),
|
||||
|
||||
/*
|
||||
* properties
|
||||
*/
|
||||
// Is participation without user name possibile?
|
||||
anonymousUser: DS.attr('boolean'),
|
||||
anonymousUser: attr('boolean'),
|
||||
|
||||
// array of possible answers
|
||||
answers: MF.fragmentArray('answer'),
|
||||
answers: fragmentArray('answer'),
|
||||
|
||||
// YesNo, YesNoMaybe or Freetext
|
||||
answerType: DS.attr('string'),
|
||||
answerType: attr('string'),
|
||||
|
||||
// ISO-8601 combined date and time string in UTC
|
||||
creationDate: DS.attr('date'),
|
||||
creationDate: attr('date'),
|
||||
|
||||
// polls description
|
||||
description: DS.attr('string', {
|
||||
description: attr('string', {
|
||||
defaultValue: ''
|
||||
}),
|
||||
|
||||
// ISO 8601 date + time string in UTC
|
||||
expirationDate: DS.attr('string', {
|
||||
expirationDate: attr('string', {
|
||||
includePlainOnCreate: 'serverExpirationDate'
|
||||
}),
|
||||
|
||||
// Must all options been answered?
|
||||
forceAnswer: DS.attr('boolean'),
|
||||
forceAnswer: attr('boolean'),
|
||||
|
||||
// array of polls options
|
||||
options: MF.fragmentArray('option'),
|
||||
options: fragmentArray('option'),
|
||||
|
||||
// FindADate or MakeAPoll
|
||||
pollType: DS.attr('string'),
|
||||
pollType: attr('string'),
|
||||
|
||||
// timezone poll got created in (like "Europe/Berlin")
|
||||
timezone: DS.attr('string'),
|
||||
timezone: attr('string'),
|
||||
|
||||
// polls title
|
||||
title: DS.attr('string'),
|
||||
title: attr('string'),
|
||||
|
||||
// Croodle version poll got created with
|
||||
version: DS.attr('string', {
|
||||
version: attr('string', {
|
||||
encrypted: false
|
||||
}),
|
||||
|
||||
|
|
|
@ -1,27 +1,35 @@
|
|||
import DS from 'ember-data';
|
||||
/* global MF */
|
||||
import {
|
||||
fragmentArray
|
||||
} from 'model-fragments/attributes';
|
||||
|
||||
export default DS.Model.extend({
|
||||
const {
|
||||
attr,
|
||||
belongsTo,
|
||||
Model
|
||||
} = DS;
|
||||
|
||||
export default Model.extend({
|
||||
/*
|
||||
* relationship
|
||||
*/
|
||||
poll: DS.belongsTo('poll'),
|
||||
poll: belongsTo('poll'),
|
||||
|
||||
/*
|
||||
* properties
|
||||
*/
|
||||
// ISO 8601 date + time string
|
||||
creationDate: DS.attr('date'),
|
||||
creationDate: attr('date'),
|
||||
|
||||
// user name
|
||||
name: DS.attr('string'),
|
||||
name: attr('string'),
|
||||
|
||||
// array of users selections
|
||||
// must be in same order as options property of poll
|
||||
selections: MF.fragmentArray('selection'),
|
||||
selections: fragmentArray('selection'),
|
||||
|
||||
// Croodle version user got created with
|
||||
version: DS.attr('string', {
|
||||
version: attr('string', {
|
||||
encrypted: false
|
||||
})
|
||||
});
|
||||
|
|
3
app/resolver.js
Normal file
3
app/resolver.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
import Resolver from 'ember-resolver';
|
||||
|
||||
export default Resolver;
|
16
bower.json
16
bower.json
|
@ -1,17 +1,10 @@
|
|||
{
|
||||
"name": "croodle",
|
||||
"dependencies": {
|
||||
"ember": "1.13.13",
|
||||
"ember-cli-shims": "0.0.6",
|
||||
"ember-cli-test-loader": "0.2.1",
|
||||
"ember-data": "1.13.15",
|
||||
"ember-load-initializers": "0.1.7",
|
||||
"ember-qunit": "0.4.16",
|
||||
"ember": "~2.4.1",
|
||||
"ember-cli-shims": "0.1.0",
|
||||
"ember-cli-test-loader": "0.2.2",
|
||||
"ember-qunit-notifications": "0.1.0",
|
||||
"ember-resolver": "~0.1.20",
|
||||
"jquery": "^1.11.3",
|
||||
"loader.js": "ember-cli/loader.js#3.4.0",
|
||||
"qunit": "~1.20.0",
|
||||
"sjcl": "~1.0.0",
|
||||
"bootstrap": "~3.3.5",
|
||||
"bootstrap-datepicker": "~1.4.0",
|
||||
|
@ -25,8 +18,5 @@
|
|||
"chartjs": "1.0.2",
|
||||
"Chart.StackedBar.js": "jelhan/Chart.StackedBar.js#3a81baa3a191cd3ff14a8249bf86e388bc650640",
|
||||
"ceibo": "1.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ember-data-model-fragments": "1.13.1"
|
||||
}
|
||||
}
|
||||
|
|
19
package.json
19
package.json
|
@ -28,46 +28,47 @@
|
|||
"ember-array-computed-macros": "martndemus/ember-array-computed-macros#3fde9023336d227aa6009060b40b4de77d8b1a9b",
|
||||
"ember-bootstrap": "^0.8.0",
|
||||
"ember-bootstrap-cp-validations": "^0.2.0",
|
||||
"ember-cli": "1.13.13",
|
||||
"ember-cli": "2.4.2",
|
||||
"ember-cli-acceptance-test-helpers": "0.4.0",
|
||||
"ember-cli-app-version": "^2.0.0",
|
||||
"ember-cli-app-version": "^1.0.0",
|
||||
"ember-cli-babel": "^5.1.5",
|
||||
"ember-cli-bootstrap-datepicker": "^0.5.5",
|
||||
"ember-cli-browser-navigation-button-test-helper": "0.0.1",
|
||||
"ember-cli-build-info": "^0.2.0",
|
||||
"ember-cli-chart": "jelhan/ember-cli-chart#87cc4f125ce69e22197c992206cca700edc70267",
|
||||
"ember-cli-content-security-policy": "0.4.0",
|
||||
"ember-cli-dependency-checker": "^1.1.0",
|
||||
"ember-cli-dependency-checker": "^1.2.0",
|
||||
"ember-cli-htmlbars": "^1.0.1",
|
||||
"ember-cli-htmlbars-inline-precompile": "^0.3.1",
|
||||
"ember-cli-ic-ajax": "0.2.4",
|
||||
"ember-cli-inject-live-reload": "^1.3.1",
|
||||
"ember-cli-less": "^1.5.3",
|
||||
"ember-cli-moment-shim": "0.7.1",
|
||||
"ember-cli-page-object": "1.1.0",
|
||||
"ember-cli-pretender": "^0.6.0",
|
||||
"ember-cli-qunit": "^1.0.4",
|
||||
"ember-cli-qunit": "^1.2.1",
|
||||
"ember-cli-release": "0.2.8",
|
||||
"ember-cli-sauce": "^1.6.0",
|
||||
"ember-cli-sri": "^2.0.0",
|
||||
"ember-cli-sri": "^2.1.0",
|
||||
"ember-cli-uglify": "^1.2.0",
|
||||
"ember-cp-validations": "^2.9.3",
|
||||
"ember-data": "^1.13.15",
|
||||
"ember-data-model-fragments": "^1.13.3",
|
||||
"ember-data": "^2.4.0",
|
||||
"ember-data-model-fragments": "2.3.2",
|
||||
"ember-disable-proxy-controllers": "^1.0.1",
|
||||
"ember-export-application-global": "^1.0.4",
|
||||
"ember-get-helper": "^1.1.0",
|
||||
"ember-i18n": "4.1.4",
|
||||
"ember-i18n-cp-validations": "^2.5.0",
|
||||
"ember-load-initializers": "^0.5.0",
|
||||
"ember-math-helpers": "^1.2.1",
|
||||
"ember-moment": "^6.1.0",
|
||||
"ember-object-at-helper": "0.1.0",
|
||||
"ember-radio-buttons": "^4.0.1",
|
||||
"ember-resolver": "^2.0.3",
|
||||
"ember-simple-select": "^0.6.0",
|
||||
"ember-suave": "^4.0.0",
|
||||
"ember-truth-helpers": "^1.2.0",
|
||||
"express": "^4.8.5",
|
||||
"glob": "^5.0.3",
|
||||
"loader.js": "^4.0.0",
|
||||
"node-phpcgi": "^0.3.5"
|
||||
}
|
||||
}
|
||||
|
|
13
testem.js
Normal file
13
testem.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
/*jshint node:true*/
|
||||
module.exports = {
|
||||
"framework": "qunit",
|
||||
"test_page": "tests/index.html?hidepassed",
|
||||
"disable_watching": true,
|
||||
"launch_in_ci": [
|
||||
"PhantomJS"
|
||||
],
|
||||
"launch_in_dev": [
|
||||
"PhantomJS",
|
||||
"Chrome"
|
||||
]
|
||||
};
|
|
@ -13,11 +13,11 @@ export default function(name, options = {}) {
|
|||
},
|
||||
|
||||
afterEach() {
|
||||
destroyApp(this.application);
|
||||
|
||||
if (options.afterEach) {
|
||||
options.afterEach.apply(this, arguments);
|
||||
}
|
||||
|
||||
destroyApp(this.application);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import Resolver from 'ember/resolver';
|
||||
import Resolver from '../../resolver';
|
||||
import config from '../../config/environment';
|
||||
|
||||
const resolver = Resolver.create();
|
||||
|
|
Loading…
Reference in a new issue