Last active
August 29, 2015 14:00
-
-
Save csprocket777/ec02f90c8705e3263cc5 to your computer and use it in GitHub Desktop.
Hack solution to updating Ember.Select with computed property created using defineProperty()
This file contains 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
export default Ember.View.extend({ | |
didInsertElement: function(){ | |
var self = this; | |
setTimeout(function(){ | |
self.get('controller.model').fixBindingsHack(); | |
}, 100); | |
} | |
}); |
This file contains 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 BaseModel from "appkit/models/base-model"; | |
export default BaseModel.extend({ | |
title: DS.attr('string'), | |
order: DS.attr('number'), | |
active: DS.attr('boolean'), | |
step_type: DS.attr('number'), | |
step_type_label: DS.attr('string'), | |
model_name: DS.attr('string'), | |
record_workflow_segment_step_params: DS.hasMany('record-workflow-segment-step-param', {inverse: 'record_workflow_segment_step'}), | |
record_workflow_segment: DS.belongsTo('record-workflow-segment', {inverse:'record_workflow_segment_steps'}), | |
dynamicPropertiesList: Ember.A([]), | |
setupExistingParams: function(){ | |
Ember.defineProperty(this, 'record_phase', Ember.computed('record_workflow_segment_step_params.[]', function(key, value){ | |
if( this.get('step_type').toString() !== "1" ){ | |
return undefined; | |
} | |
var param = this.get('record_workflow_segment_step_params').findBy('name', 'record_phase'); | |
if( !Ember.isNone( value ) && param ) | |
{ | |
param.set('value', value); | |
} | |
if( !Ember.isBlank(param.get("model_name")) ) | |
{ | |
return Ember.isNone(param.get('value')) ? null: this.store.find( param.get('model_name'), param.get('value') ); | |
}else{ | |
return param ? param.get('value').toString(): null; | |
} | |
}).property()); | |
this.get('dynamicPropertiesList').pushObject('record_phase'); | |
this.set('dynamicPropertiesExist', true); | |
}.on('didLoad'), | |
dynamicPropertiesExist: false, | |
fixBindingsHack: function(){ | |
this.get('dynamicPropertiesList').forEach(function(item){ | |
if( !Ember.isBlank( this.get(item) ) ) | |
{ | |
var tmp = this.get(item); | |
this.set(item, "1000000000000"); | |
this.set(item, tmp); | |
} | |
tmp = null; | |
}, this); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment