diff --git a/app/app.js b/app/app.js index 639da3b..570bcc4 100644 --- a/app/app.js +++ b/app/app.js @@ -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; diff --git a/app/controllers/create/index.js b/app/controllers/create/index.js index 9bfdb80..64d5ce0 100644 --- a/app/controllers/create/index.js +++ b/app/controllers/create/index.js @@ -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' }) ]; }) diff --git a/app/controllers/create/settings.js b/app/controllers/create/settings.js index 18b8888..53ba87b 100644 --- a/app/controllers/create/settings.js +++ b/app/controllers/create/settings.js @@ -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' }) ]; }), diff --git a/app/controllers/poll.js b/app/controllers/poll.js index 86eebaa..aa1eb11 100644 --- a/app/controllers/poll.js +++ b/app/controllers/poll.js @@ -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 }); }); diff --git a/app/controllers/poll/participation.js b/app/controllers/poll/participation.js index d3fd2e4..862af8c 100644 --- a/app/controllers/poll/participation.js +++ b/app/controllers/poll/participation.js @@ -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'), diff --git a/app/models/answer.js b/app/models/answer.js index ed91873..1f58d43 100644 --- a/app/models/answer.js +++ b/app/models/answer.js @@ -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') }); diff --git a/app/models/option.js b/app/models/option.js index 143cbac..02f02e3 100644 --- a/app/models/option.js +++ b/app/models/option.js @@ -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'); } diff --git a/app/models/poll.js b/app/models/poll.js index 9a96774..ee0c253 100644 --- a/app/models/poll.js +++ b/app/models/poll.js @@ -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 }), diff --git a/app/models/user.js b/app/models/user.js index fd6826b..4edc059 100644 --- a/app/models/user.js +++ b/app/models/user.js @@ -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 }) }); diff --git a/app/resolver.js b/app/resolver.js new file mode 100644 index 0000000..2fb563d --- /dev/null +++ b/app/resolver.js @@ -0,0 +1,3 @@ +import Resolver from 'ember-resolver'; + +export default Resolver; diff --git a/bower.json b/bower.json index a20276c..a146f0f 100644 --- a/bower.json +++ b/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" } } diff --git a/package.json b/package.json index 44f3647..2648420 100644 --- a/package.json +++ b/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" } } diff --git a/testem.js b/testem.js new file mode 100644 index 0000000..26044b2 --- /dev/null +++ b/testem.js @@ -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" + ] +}; diff --git a/tests/helpers/module-for-acceptance.js b/tests/helpers/module-for-acceptance.js index ed23003..8c8b74e 100644 --- a/tests/helpers/module-for-acceptance.js +++ b/tests/helpers/module-for-acceptance.js @@ -13,11 +13,11 @@ export default function(name, options = {}) { }, afterEach() { - destroyApp(this.application); - if (options.afterEach) { options.afterEach.apply(this, arguments); } + + destroyApp(this.application); } }); } diff --git a/tests/helpers/resolver.js b/tests/helpers/resolver.js index ebfb4e4..b208d38 100644 --- a/tests/helpers/resolver.js +++ b/tests/helpers/resolver.js @@ -1,4 +1,4 @@ -import Resolver from 'ember/resolver'; +import Resolver from '../../resolver'; import config from '../../config/environment'; const resolver = Resolver.create();