From 0679fc260cd4cb3c6a825dacc578e80ac847d189 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Wed, 12 Feb 2014 17:33:42 +0100 Subject: [PATCH] Revert "Revert "Use switches on settings pane"" This reverts commit e5ae06afebda9cec79130bdef9157e17aec68344. --- assets/scripts/app/components.coffee | 16 +++++++++++++--- .../app/templates/components/travis-switch.hbs | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/assets/scripts/app/components.coffee b/assets/scripts/app/components.coffee index da423edd..09a177fb 100644 --- a/assets/scripts/app/components.coffee +++ b/assets/scripts/app/components.coffee @@ -1,9 +1,19 @@ Travis.TravisSwitchComponent = Ember.Component.extend tagName: 'a' 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: -> - @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) diff --git a/assets/scripts/app/templates/components/travis-switch.hbs b/assets/scripts/app/templates/components/travis-switch.hbs index e7b20837..18617602 100644 --- a/assets/scripts/app/templates/components/travis-switch.hbs +++ b/assets/scripts/app/templates/components/travis-switch.hbs @@ -1,4 +1,4 @@ -{{#if active}} +{{#if _active}} ON {{else}} OFF