Forked from dnatochy/controllers.application.js
Last active
February 22, 2019 07:20
-
-
Save charlesfeng/365f2d47d3e690c152fa2fc23179bc10 to your computer and use it in GitHub Desktop.
TestingEmberObjects
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import Apk from '../models/apk'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
init(){ | |
var object = { | |
category: 'Crazy', | |
status: 'LIVE', | |
deviceCompatibility: ['P5', 'P61'] | |
}; | |
this.set('apk', Apk.objectToEmber(object)); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
var Apk = Ember.Object.extend({ | |
}); | |
const constants = { | |
hardware: { | |
P61: 'P61', | |
P5: 'P5', | |
P61B: 'P61B' | |
} | |
}; | |
const hardwareLabels = { | |
P61: 'POYNT_SMART_TERMINAL_V1', | |
P61B: 'POYNT_SMART_TERMINAL_V2', | |
P5: 'POYNT5' | |
}; | |
Apk.reopenClass({ | |
objectToEmber: function (object) { | |
console.log(object); | |
object.deviceCompatibility = Ember.ArrayProxy.create({ | |
content: Object.keys(constants.hardware).map(function (model) { | |
return Ember.Object.create({ | |
model: model, | |
selected: (object.deviceCompatibility || []).indexOf(model) !== -1 | |
}); | |
}) | |
}); | |
console.log(object.deviceCompatibility); | |
return Apk.create(object); | |
}, | |
emberToObject: function (version, ){ | |
var object = version.getProperties( | |
'category', | |
'status' | |
); | |
return object; | |
} | |
}); | |
export default Apk; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.15.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
"ember": "3.4.3", | |
"ember-template-compiler": "3.4.3", | |
"ember-testing": "3.4.3" | |
}, | |
"addons": { | |
"ember-data": "3.4.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment