js/controller/CardController.js   A
last analyzed

Complexity

Total Complexity 15
Complexity/F 1.36

Size

Lines of Code 62
Function Count 11

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 15
dl 0
loc 62
rs 10
c 0
b 0
f 0
cc 0
nc 4
mnd 1
bc 14
fnc 11
bpm 1.2727
cpm 1.3636
noi 10
1
2
3
/*
4
 * @copyright Copyright (c) 2016 Julius Härtl <[email protected]>
5
 *
6
 * @author Julius Härtl <[email protected]>
7
 *
8
 * @license GNU AGPL version 3 or any later version
9
 *  
10
 *  This program is free software: you can redistribute it and/or modify
11
 *  it under the terms of the GNU Affero General Public License as
12
 *  published by the Free Software Foundation, either version 3 of the
13
 *  License, or (at your option) any later version.
14
 *  
15
 *  This program is distributed in the hope that it will be useful,
16
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 *  GNU Affero General Public License for more details.
19
 *  
20
 *  You should have received a copy of the GNU Affero General Public License
21
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
 *  
23
 */
24
25
app.controller('CardController', function ($scope, $rootScope, $routeParams, $location, $stateParams, BoardService, CardService, StackService, StatusService) {
26
    $scope.sidebar = $rootScope.sidebar;
27
    $scope.status = {};
28
29
    $scope.cardservice = CardService;
30
    $scope.cardId = $stateParams.cardId;
31
32
    $scope.statusservice = StatusService.getInstance();
33
    $scope.boardservice = BoardService;
34
35
    $scope.statusservice.retainWaiting();
36
37
    CardService.fetchOne($scope.cardId).then(function(data) {
0 ignored issues
show
Unused Code introduced by
The parameter data is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
38
        $scope.statusservice.releaseWaiting();
39
        $scope.archived = CardService.getCurrent().archived;
40
    }, function(error) {
0 ignored issues
show
Unused Code introduced by
The parameter error is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
41
    });
42
43
    $scope.cardRenameShow = function() {
44
        if($scope.archived || !BoardService.canEdit())
45
            return false;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
46
        else {
47
            $scope.status.cardRename=true;
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
48
        }
49
    };
50
    $scope.cardEditDescriptionShow = function($event) {
51
        var node = $event.target.nodeName;
52
        console.log($event);
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
53
        console.log(BoardService);
54
        if($scope.card.archived || !$scope.boardservice.canEdit()) {
55
            console.log(node);
56
        } else {
57
            console.log("edit");
58
            $scope.status.cardEditDescription=true;
59
        }
60
        console.log($scope.status.canEditDescription);
61
    };
62
    // handle rename to update information on the board as well
63
    $scope.cardRename = function(card) {
64
        CardService.rename(card).then(function(data) {
0 ignored issues
show
Unused Code introduced by
The parameter data is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
65
            StackService.updateCard(card);
66
            $scope.status.renameCard = false;
67
        });
68
    };
69
    $scope.cardUpdate = function(card) {
0 ignored issues
show
Unused Code introduced by
The parameter card is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
70
        CardService.update(CardService.getCurrent()).then(function(data) {
0 ignored issues
show
Unused Code introduced by
The parameter data is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
71
            $scope.status.cardEditDescription = false;
72
            $('#card-description').find('.save-indicator').fadeIn(500).fadeOut(1000);
73
        });
74
    };
75
76
    $scope.labelAssign = function(element, model) {
0 ignored issues
show
Unused Code introduced by
The parameter model is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
77
        CardService.assignLabel($scope.cardId, element.id);
78
        var card = CardService.getCurrent();
79
        StackService.updateCard(card);
80
    };
81
    
82
    $scope.labelRemove = function(element, model) {
0 ignored issues
show
Unused Code introduced by
The parameter model is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
83
        CardService.removeLabel($scope.cardId, element.id)
84
    }
85
86
});
87