Skip to content
Browse files

Wire up both percentage gates.

  • Loading branch information...
1 parent 360dc85 commit 7b1f970af8ac0346c2c30ad97b82383e96fbca31 @jnunemaker committed Feb 18, 2013
View
43 lib/flipper/ui/assets/javascripts/application.coffee
@@ -163,28 +163,65 @@ class App.Gate.Boolean extends App.Gate
events:
'submit form': 'submit'
- 'change input[type=radio]': 'setValue'
constructor: ->
@name = 'boolean'
super
submit: (event) ->
event.preventDefault()
+ @gate.value = @input.is(':checked')
@gate.save()
- setValue: =>
- @gate.value = @input.is(':checked')
+class App.Gate.Group extends App.Gate
+ constructor: ->
+ @name = 'group'
+ super
+
+class App.Gate.Actor extends App.Gate
+ constructor: ->
+ @name = 'actor'
+ super
class App.Gate.PercentageOfActors extends App.Gate
+ elements:
+ 'input[type=text]': 'input'
+
+ events:
+ 'submit form': 'submit'
+
constructor: ->
@name = 'percentage_of_actors'
super
+ submit: (event) ->
+ event.preventDefault()
+ @gate.value = @input.val()
+ @gate.save()
+
+class App.Gate.PercentageOfRandom extends App.Gate
+ elements:
+ 'input[type=text]': 'input'
+
+ events:
+ 'submit form': 'submit'
+
+ constructor: ->
+ @name = 'percentage_of_random'
+ super
+
+ submit: (event) ->
+ event.preventDefault()
+ @gate.value = @input.val()
+ @gate.save()
+
class App.GateList extends Spine.Stack
controllers:
boolean: App.Gate.Boolean
+ group: App.Gate.Group
+ actor: App.Gate.Actor
percentage_of_actors: App.Gate.PercentageOfActors
+ percentage_of_random: App.Gate.PercentageOfRandom
jQuery ->
new App(el: $('#app'))
View
81 lib/flipper/ui/public/flipper/js/application.js
@@ -274,42 +274,104 @@
};
Boolean.prototype.events = {
- 'submit form': 'submit',
- 'change input[type=radio]': 'setValue'
+ 'submit form': 'submit'
};
function Boolean() {
- this.setValue = __bind(this.setValue, this);
this.name = 'boolean';
Boolean.__super__.constructor.apply(this, arguments);
}
Boolean.prototype.submit = function(event) {
event.preventDefault();
+ this.gate.value = this.input.is(':checked');
return this.gate.save();
};
- Boolean.prototype.setValue = function() {
- return this.gate.value = this.input.is(':checked');
- };
-
return Boolean;
})(App.Gate);
+ App.Gate.Group = (function(_super) {
+
+ __extends(Group, _super);
+
+ function Group() {
+ this.name = 'group';
+ Group.__super__.constructor.apply(this, arguments);
+ }
+
+ return Group;
+
+ })(App.Gate);
+
+ App.Gate.Actor = (function(_super) {
+
+ __extends(Actor, _super);
+
+ function Actor() {
+ this.name = 'actor';
+ Actor.__super__.constructor.apply(this, arguments);
+ }
+
+ return Actor;
+
+ })(App.Gate);
+
App.Gate.PercentageOfActors = (function(_super) {
__extends(PercentageOfActors, _super);
+ PercentageOfActors.prototype.elements = {
+ 'input[type=text]': 'input'
+ };
+
+ PercentageOfActors.prototype.events = {
+ 'submit form': 'submit'
+ };
+
function PercentageOfActors() {
this.name = 'percentage_of_actors';
PercentageOfActors.__super__.constructor.apply(this, arguments);
}
+ PercentageOfActors.prototype.submit = function(event) {
+ event.preventDefault();
+ this.gate.value = this.input.val();
+ return this.gate.save();
+ };
+
return PercentageOfActors;
})(App.Gate);
+ App.Gate.PercentageOfRandom = (function(_super) {
+
+ __extends(PercentageOfRandom, _super);
+
+ PercentageOfRandom.prototype.elements = {
+ 'input[type=text]': 'input'
+ };
+
+ PercentageOfRandom.prototype.events = {
+ 'submit form': 'submit'
+ };
+
+ function PercentageOfRandom() {
+ this.name = 'percentage_of_random';
+ PercentageOfRandom.__super__.constructor.apply(this, arguments);
+ }
+
+ PercentageOfRandom.prototype.submit = function(event) {
+ event.preventDefault();
+ this.gate.value = this.input.val();
+ return this.gate.save();
+ };
+
+ return PercentageOfRandom;
+
+ })(App.Gate);
+
App.GateList = (function(_super) {
__extends(GateList, _super);
@@ -320,7 +382,10 @@
GateList.prototype.controllers = {
boolean: App.Gate.Boolean,
- percentage_of_actors: App.Gate.PercentageOfActors
+ group: App.Gate.Group,
+ actor: App.Gate.Actor,
+ percentage_of_actors: App.Gate.PercentageOfActors,
+ percentage_of_random: App.Gate.PercentageOfRandom
};
return GateList;
View
35 lib/flipper/ui/views/layout.erb
@@ -51,7 +51,12 @@
<div class="tabs">
<ul>
<li><a href="#" data-tab="boolean">All On/All Off</a></li>
- <li><a href="#" data-tab="percentage_of_actors">Percentage Of Actors</a></li>
+ <li><a href="#" data-tab="group">Groups</a></li>
+ <li><a href="#" data-tab="actor">Actors</a></li>
+ <li><a href="#" data-tab="percentage_of_actors">
+ Percentage Of Actors</a></li>
+ <li><a href="#" data-tab="percentage_of_random">
+ Percentage Of Random</a></li>
</ul>
</div>
@@ -61,15 +66,39 @@
</script>
<script id="gate-boolean-template" type="text/x-handlebars-template">
- <form action="/flipper/features/{{feature_id}}" method="POST">
+ <form action="/flipper/features/{{feature_id}}/boolean" method="POST">
<input type="radio" name="value" value="true" {{#value}}checked="checked"{{/value}} /> On
<input type="radio" name="value" value="false" {{^value}}checked="checked"{{/value}} /> Off
<button>Save Settings</button>
</form>
</script>
+ <script id="gate-group-template" type="text/x-handlebars-template">
+ group
+ </script>
+
+ <script id="gate-actor-template" type="text/x-handlebars-template">
+ actor
+ </script>
+
<script id="gate-percentage-of-actors-template" type="text/x-handlebars-template">
- slider...
+ <form action="/flipper/features/{{feature_id}}/percentage_of_actors" method="POST">
+ <label>
+ Percentage
+ <input type="text" name="value" value="{{value}}" />
+ </label>
+ <button>Save Settings</button>
+ </form>
+ </script>
+
+ <script id="gate-percentage-of-random-template" type="text/x-handlebars-template">
+ <form action="/flipper/features/{{feature_id}}/percentage_of_random" method="POST">
+ <label>
+ Percentage
+ <input type="text" name="value" value="{{value}}" />
+ </label>
+ <button>Save Settings</button>
+ </form>
</script>
</body>

0 comments on commit 7b1f970

Please sign in to comment.
Something went wrong with that request. Please try again.