Created
May 24, 2014 21:39
-
-
Save GLips/9cef62b8e79206b54a3f to your computer and use it in GitHub Desktop.
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
LW.StreamControlController = Ember.ObjectController.extend | |
sourceType: 'github' | |
sourceTypes: ['github', 'twitter'] | |
createNewSource: (-> | |
if @get('sourceType') | |
@clearNewSource() | |
sourceType = @get('sourceType') + '_source' | |
@set 'newParentSource', @store.createRecord('source', { stream: @get('model'), source_type: sourceType }) | |
@set 'newSource', @store.createRecord(sourceType, { parent: @get('newParentSource') }) | |
@get('newParentSource').set sourceType, @get('newSource') | |
).observes('sourceType') # This is changed by the dropdown detailed in the HTML below | |
# <div class="content"> | |
# <h2>Add a Source</h2> | |
# {{#unless creatingSource}} | |
# <div class="center"> | |
# <h4><a href="#" {{action 'new_source'}}>Create a new source</a></h4> | |
# </div> | |
# {{else}} | |
# <div class="content"> | |
# <label>Pull Content From</label> | |
# <!-- This is where you select the type of source you're creating, which generates a model called 'newSource' of the proper type --> | |
# {{view Ember.Select content=controller.sourceTypes value=controller.sourceType class="form-control"}} | |
# </div> | |
# <!-- This is where the magic happens, the view is designated by the new source you've selected under its 'createView' attribute --> | |
# {{view controller.newSource.createView model=controller.newSource viewName="sourceCreateView"}} | |
# <div class="center"> | |
# <button {{action 'save_new_source' this}} class="btn btn-lg btn-success">Create new source</button> | |
# <br> | |
# <a {{action 'cancel_new_source' this}} class="small">Cancel</a> | |
# </div> | |
# {{/unless}} | |
# </div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment