Use switches on settings pane

This commit is contained in:
Piotr Sarnacki 2014-01-21 18:46:36 +01:00
parent d41d6de175
commit 357b176f93
4 changed files with 21 additions and 19 deletions

View File

@ -1,9 +1,19 @@
Travis.TravisSwitchComponent = Ember.Component.extend Travis.TravisSwitchComponent = Ember.Component.extend
tagName: 'a' tagName: 'a'
classNames: ['travis-switch'] classNames: ['travis-switch']
classNameBindings: ['active'] classNameBindings: ['_active:active']
activeBinding: 'target.active' # TODO: how to handle overriding properties to
# avoid naming it _action?
_active: (->
@get('target.active') || @get('active')
).property('target.active', 'active')
click: -> click: ->
@sendAction('action', @get('target')) if target = @get('target')
@set('target.active', !@get('target.active'))
else
@set('active', !@get('active'))
# allow for bindings to propagate
Ember.run.next this, ->
@sendAction('action', target)

View File

@ -54,7 +54,7 @@ Travis.RepoSettingsController = Em.ObjectController.extend
tab: Ember.computed.alias('controllers.repoSettingsTab.model.tab') tab: Ember.computed.alias('controllers.repoSettingsTab.model.tab')
settings: Ember.computed.alias('model.settings') settings: Ember.computed.alias('model.settings')
submit: -> save: ->
@set('saving', true) @set('saving', true)
self = this self = this
@get('model').saveSettings(@get('settings')).then -> @get('model').saveSettings(@get('settings')).then ->

View File

@ -1,4 +1,4 @@
{{#if active}} {{#if _active}}
ON ON
{{else}} {{else}}
OFF OFF

View File

@ -5,26 +5,18 @@
{{#travis-tab "general" "General Settings"}} {{#travis-tab "general" "General Settings"}}
{{#settings-form}} {{#settings-form}}
<p> <p>
{{settings-input checked=builds_only_with_travis_yml type="checkbox" id="builds-only-with-travis-yml"}} {{travis-switch action="save" active=settings.builds_only_with_travis_yml}}
<label for="builds-only-with-travis-yml">Build only commits with .travis.yml file</label> Build only commits with .travis.yml file
</p> </p>
<p> <p>
{{settings-input checked=build_pushes type="checkbox" id="build-pushes"}} {{travis-switch action="save" active=settings.build_pushes}}
<label for="build-pushes">Build pushes</label> Build pushes
</p> </p>
<p> <p>
{{settings-input checked=build_pull_requests type="checkbox" id="build-pull-requests"}} {{travis-switch action="save" active=settings.build_pull_requests}}
<label for="build-pull-requests">Build pull requests</label> Build pull requests
</p>
<p>
{{#if saving}}
<span class="saving">Saving</span>
{{else}}
<button type="submit">Save</button>
{{/if}}
</p> </p>
{{/settings-form}} {{/settings-form}}
{{/travis-tab}} {{/travis-tab}}