-MainController = ($scope, resource, $timeout) ->
+MainController = ($scope, resource, $timeout, $routeParams) ->
     resource.getUser("me").then (result) ->
         $scope.user = result
 
+    $scope.addTripButton = ()->
+        $scope.showTripDialog = true
+
+    $scope.closeTripButton = ()->
+        $scope.showTripDialog = false
+
     $scope.addTaskButton = ()->
         $scope.showTaskDialog = true
 
     $scope.closeTaskButton = ()->
         $scope.showTaskDialog = false
 
-    $scope.addTripButton = ()->
-        $scope.showTripDialog = true
-
-    $scope.closeTripButton = ()->
-        $scope.showTripDialog = false
-
     $scope.addCardButton = ()->
-        $scope.showCardForm = true
+        if $routeParams.taskId
+            $scope.showCardForm = true
+        else
+            $scope.$emit("flash", {"type":"error", "message": "No tiene seleccionada ninguna tarea"})
 
     $scope.closeCardButton = ()->
         $scope.showCardForm = false

    return

module = angular.module("mrfogg.controllers.main", [])
module.controller("MainController", ["$scope","resource", "$timeout", MainController])
module.controller("ContainerController", ["$scope", ContainerController])
module.controller("UserListController", ["$scope", "$rootScope", "resource", UserListController])
module.controller("TooltipController", ["$scope", "$document", TooltipController])

        $scope.flashMessage = data.message

        hideFlash = ()->
            $scope.isFlashWarnVisible = false
            $scope.isFlashErrorVisible = false
            $scope.isFlashSuccessVisible = false
