From 3415f54cbaaf23518548fed45d40c83a14e2e05b Mon Sep 17 00:00:00 2001 From: Vit Brunner Date: Sat, 11 Oct 2014 10:31:36 +0200 Subject: [PATCH] More status flipping restrictions --- source/documents/scripts/controllers.js.coffee | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/documents/scripts/controllers.js.coffee b/source/documents/scripts/controllers.js.coffee index afe8a9b..7893080 100644 --- a/source/documents/scripts/controllers.js.coffee +++ b/source/documents/scripts/controllers.js.coffee @@ -14,6 +14,9 @@ angular.module("sideBySide.controllers", []) .controller "ComparisonController", [ '$scope', 'poems', 'transformer' ($scope, poems, transformer) -> + min = 1 + max = 5 + $scope.$watch () -> poems.getActive().length , () -> @@ -30,8 +33,11 @@ angular.module("sideBySide.controllers", []) $scope.all = poems.all $scope.switchActive = (poem) -> - if (not poem.meta.Active || poems.getActive().length > 1) + length = poems.getActive().length + active = poem.meta.Active + if ((length > min or not active) and (length < max or active)) poem.meta.Active = not poem.meta.Active + # TODO else notification $scope.flipPick = () -> $scope.pick = not $scope.pick