Skip to content

Instantly share code, notes, and snippets.

@marcusleemitchell
Created March 8, 2010 16:37
Show Gist options
  • Save marcusleemitchell/325327 to your computer and use it in GitHub Desktop.
Save marcusleemitchell/325327 to your computer and use it in GitHub Desktop.
/** MODELS **/
/** VIEW **/
MidasEvolvedSprout.OperationNodeView = SC.View.extend(SCUI.Cleanup, LinkIt.NodeView,
/** @scope MidasEvolvedSprout.OperatorNodeView.prototype */ {
classNames: ['operation-node-view'],
layout: { top:0, left:0, width:300, height:100 },
displayProperties: ['content', 'isSelected'],
content: null,
render: function(context) {
sc_super();
if(this.get('isSelected')){
context.addClass('selected');
this.get('content')._linksDidChange();
}
if(this.get('content').get('isStartPoint')) context.addClass('start-point');
if(this.get('content').get('isEndPoint')) context.addClass('end-point');
},
_listStateFunctions: function() {
return SC.Binding.transform(function(value, binding) {
var ret = value.toArray();
ret.push({ guid: '0', name: "".loc() });
return ret;
}).from('MidasEvolvedSprout.stateFunctionController.content');
},
createChildViews: function(){
var childViews = [];
var content = this.get('content');
if(SC.none(content)) return;
// This is the content of the view
var contentView = this.createChildView(
SC.SelectFieldView.extend({
layout: { centerX:0, height:20, left:5, width:250, top:5 },
objectsBinding: this._listStateFunctions(),
nameKey: 'name',
valueKey: 'guid',
valueBinding: SC.binding('.content.action_function_id', this),
isEnabledBinding: 'MidasEvolvedSprout.stateFunctionController.isEditable'
})
);
childViews.push(contentView);
var stateFunctionParametersView = this.createChildView(
SC.CollectionView.extend({
classNames: ['state-function-parameters', 'show-overflow'],
layout: { top:30 },
exampleView: MidasEvolvedSprout.StateFunctionParameterView,
contentBinding: '.parentView.content.actionFunction.stateFunctionParameters',
layoutForContentIndex: function(contentIndex) {
content = this.get('content');
parameterCount = content.get('length');
return { left:5, top:(contentIndex*30), right:5, height:30 }
}
})
);
childViews.push(stateFunctionParametersView);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment