Code coverage report for src\components\filters\filters.js

# all files / src/components/filters/ filters.js

60.34% Statements 35/58
0% Branches 0/14
40% Functions 6/15
60.34% Lines 35/58

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    1281×
    1×

    1×

    1×
    2×

    2×

    2×

    2×

    2×

    2×

    2×

    2×

    2×

    2×

    2×

    2×

    2×

    2×

    2×

    2×

    1×
    1×

    1×
    7×

    1×
    4×

    1×

    1×

    1×

    1×

    1×

    1×

    1×
    1×

    1×

     (function component(ng) {
      ng.module('components')
        .component('exFilters', {
          templateUrl: './components/filters/filters.html',
          controller: filtersCtrl,
          controllerAs: 'vm',
          bindToController: true,
          bindings: {
            selectFilters: '@',
            state: '@'
          }
        });

      filtersCtrl.$inject = ['checkedButton', 'showMenu', '$scope'];

      function filtersCtrl(checkedButton, showMenu, $scope) {
          var vm = this;

          vm.states = [
            {value: "In work", check: false},
            {value: "Pending", check: false},
            {value: "Planing", check: false},
            {value: "done", check: false}
          ];

          vm.stateText = 'State:';

          vm.id = ['#labelId', '#labelState', '#labelContainer',
            '#labelVehicle', '#labelDocNumber', '#labelDateFrom', '#labelDateTo'];

          vm.selectFilters = {};

          vm.clear = clear;

          vm.search = search;

          vm.setEstimateEnd = setEstimateEnd;

          vm.groupEvent = groupEvent;

          vm.multichecked = checkedButton.setMultichecked;

          vm.setSelectFilters = setSelectFilters;

          vm.show = showMenu.showMenu;

          vm.showLabel = showLabel;

          vm.checkState = checkState;

          vm.changeView =changeView;

          $scope.$watch(function() {
            return checkedButton.check;
          }, function(newVal) {
            newVal == undefined ? vm.check = true : vm.check = newVal;
          });

          function clear() {
            vm.selectFilters = {};

            vm.id.forEach(function(element) {
              ng.element(document.querySelector(element)).css('display', 'none');
            }, this);

            vm.states.forEach(function(element) {
              element.check = false;
            }, this);

            vm.stateText = 'State:';
          }

          function search() {
            vm.stateText != 'State:' ? vm.selectFilters.state = vm.stateText.split(', ') : vm.selectFilters.state = '';

            console.log(vm.selectFilters);
          }

          function setEstimateEnd() {
            console.log("set estimate end");
          }

          function groupEvent() {
            console.log("group event");
          }

          function showLabel(id, value) {
            if (value != null && value != '') {
              ng.element(document.querySelector(id)).css('display', 'block');
            } else {
              ng.element(document.querySelector(id)).css('display', 'none');
            }
          }

          function checkState() {
            id = '#labelState';
            vm.stateText = 'State:';

            ng.element(document.querySelector(id)).css('display', 'none');

            vm.states.forEach(function(element) {
              if (element.check == true) {
                if (vm.stateText == 'State:') {
                  vm.stateText = element.value;
                  ng.element(document.querySelector(id)).css('display', 'block');
                } else {
                  vm.stateText += ', ' + element.value;
                }
              }
            }, this);
          }

          function setSelectFilters(selectFilters) {
            vm.selectFilters = selectFilters;
          }

          function changeView() {
            if (ng.element(document.querySelector('table3')).css('display') == 'block') {
              ng.element(document.querySelector('table3')).css('display', 'none');
              ng.element(document.querySelector('table2')).css('display', 'block');
            } else {
              ng.element(document.querySelector('table3')).css('display', 'block');
              ng.element(document.querySelector('table2')).css('display', 'none');
            }
          }
      }
    })(angular);