Skip to content

Instantly share code, notes, and snippets.

@bj-mcduck
Last active August 29, 2015 14:00
Show Gist options
  • Save bj-mcduck/11104247 to your computer and use it in GitHub Desktop.
Save bj-mcduck/11104247 to your computer and use it in GitHub Desktop.
.form-group
%label.control-label.col-sm-2
Name
.col-sm-10
= hb 'input type="text" value=symbol.name class="form-control input-group-large"'
.form-group
%label.control-label.col-sm-2
Category
.col-sm-10
= hb 'view Ember.Select content=categories optionValuePath="content.id" optionLabelPath="content.name" value=symbol.parent_id class="form-control" prompt="None"'
.form-group
%label.control-label.col-sm-2
Description
.col-sm-10
= hb 'textarea value=symbol.description class="form-control input-group-large"'
.form-group
%label.control-label.col-sm-2
Image
.col-sm-10
= hb 'textarea value=symbol.description class="form-control input-group-large"'
.form-group
.col-sm-10
%btn.btn.btn-primary{ _action: 'save' }
WooTtSave
%btn.btn.btn-primary{ _action: 'cancel' }
WotCancel
DreamSymbolForm = Ember.Component.extend
symbol: null
save: null
cancel: null
delete: null
saveText: 'Save'
cancelText: 'Cancel'
actions:
cancel: ->
@sendAction 'cancel'
save: ->
@sendAction 'save'
App.DreamSymbolsEditController = Ember.ObjectController.extend
value: (->
@get('model.parent.id')
).property 'model.parent.id'
categories: (->
controller = @
@store.all('dream_symbol').map (symbol)->
{ id: parseInt( symbol.get('id'), 10 ), name: symbol.get('name') } if symbol.get('id') != controller.get('model.id')
).property '[email protected]'
actions:
cancel: ->
@currentModel.rollback()
@transitionToRoute 'dream_symbols.show', @currentModel
save: ->
route = @
@currentModel.save().then (symbol)->
route.transitionToRoute 'dream_symbols.show', symbol
delete: ->
@get('model').deleteRecord()
@get('model').save()
@transitionTo 'dream_symbols.index'
test: ->
console.log 'TESTS TEST TEST'
{{ dream-symbol-form symbol=model categories=categories value=value save="test" cancel='test' }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment