From 8b5830a33f6a08eead47a76bfed6687773fe1e88 Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Thu, 8 Sep 2016 09:31:10 +0200 Subject: [PATCH] Fixing initial color in color selector --- .../color-selector/color-selector.controller.coffee | 9 ++++----- .../color-selector/color-selector.directive.coffee | 5 +++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/modules/components/color-selector/color-selector.controller.coffee b/app/modules/components/color-selector/color-selector.controller.coffee index fc1214d0..c30d9729 100644 --- a/app/modules/components/color-selector/color-selector.controller.coffee +++ b/app/modules/components/color-selector/color-selector.controller.coffee @@ -24,13 +24,12 @@ getDefaulColorList = taiga.getDefaulColorList class ColorSelectorController constructor: () -> @.colorList = getDefaulColorList() - - if @.initColor - @.color = @.initColor - @.displayColorList = false - resetColor: () -> + setColor: (color) -> + @.color = @.initColor + + resetColor: () -> if @.isRequired and not @.color @.color = @.initColor diff --git a/app/modules/components/color-selector/color-selector.directive.coffee b/app/modules/components/color-selector/color-selector.directive.coffee index 817d2e9b..fb091711 100644 --- a/app/modules/components/color-selector/color-selector.directive.coffee +++ b/app/modules/components/color-selector/color-selector.directive.coffee @@ -17,6 +17,8 @@ # File: color-selector.directive.coffee ### +bindOnce = @.taiga.bindOnce + ColorSelectorDirective = ($timeout) -> link = (scope, el, attrs, ctrl) -> # Animation @@ -42,6 +44,9 @@ ColorSelectorDirective = ($timeout) -> .mouseenter(cancel) .mouseleave(close) + bindOnce scope, 'vm.initColor', (color) -> + ctrl.setColor(color) + return { link: link, templateUrl:"components/color-selector/color-selector.html",