Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 2aabf54e

Přidáno uživatelem Petr Urban před téměř 3 roky(ů)

#41 Created new .js function which takes care of "middle option" --> indeterminate, when not all checkboxes are selected. Removed checkbox Select All from footer and added it to header.

Zobrazit rozdíly:

src/main/webapp/WEB-INF/templates/index.html
47 47
            <div class="col">
48 48
                <!-- Table for selecting projects -->
49 49
                <table th:if="${not #lists.isEmpty(query.projects)}" class="table">
50
                    <thead>
51

  
52
                    </thead>
50
                    <thead></thead>
53 51
                    <tbody>
54
                    <tr th:each="project : ${query.projects}">
55
                        <td><a th:text="${project.name}" th:href="@{'/projects/' + ${project.id}}" class="anchor-table"></a></td>
56
                        <td style="text-align: center">
57
                            <input checked type="checkbox" class="form-check-input" name="selectedProjects"
58
                                   th:value="${project.id}" th:id="@{project_} + ${project.id}">
59
                        </td>
60
                    </tr>
61
                    </tbody>
62
                    <tfoot>
52

  
63 53
                    <tr>
64 54
                        <td style="border-bottom: none !important; text-align: right !important;">
65 55
                            Select All
66 56
                        </td>
67 57
                        <td style="border-bottom: none; !important">
68
<!--                            <label class="form-check-label" for="select_all_projects">Select All</label>-->
58
                            <!--<label class="form-check-label" for="select_all_projects">Select All</label>-->
69 59
                            <input checked type="checkbox" class="form-check-input add-label" id="select_all_projects"
70 60
                                   onclick="checkAllProjects(this)">
71 61
                        </td>
72 62
                    </tr>
73
                    </tfoot>
63

  
64
                    <tr th:each="project : ${query.projects}">
65
                        <td><a th:text="${project.name}" th:href="@{'/projects/' + ${project.id}}" class="anchor-table"></a></td>
66
                        <td style="text-align: center">
67
                            <input checked type="checkbox" class="form-check-input" name="selectedProjects"
68
                                   th:value="${project.id}" th:id="@{project_} + ${project.id}"
69
                            onclick="projectCheckboxesAllIndeterminate(this, 0)">
70
                        </td>
71
                    </tr>
72
                    </tbody>
73
                    <tfoot></tfoot>
74 74
                </table>
75 75
                <div th:unless="${not #lists.isEmpty(query.projects)}" class="alert alert-danger" role="alert">
76 76
                    There are no projects to analyze!
......
84 84
                    
85 85
                    </thead>
86 86
                    <tbody>
87
                    <tr th:each="antiPattern : ${query.antiPatterns}">
88
                        <td><a th:text="${antiPattern.printName}" th:href="@{'/anti-patterns/' + ${antiPattern.id}}" class="anchor-table"></a></td>
89
                        <td style="text-align: center">
90
                            <input checked type="checkbox" class="form-check-input" name="selectedAntiPatterns"
91
                                   th:value="${antiPattern.id}" th:id="@{anti-pattern_} + ${antiPattern.id}">
92
                        </td>
93
                    </tr>
94
                    </tbody>
95
                    <tfoot>
96 87
                    <tr>
97 88
                        <td style="border-bottom: none !important; text-align: right !important;">
98 89
                            Select All
99 90
                        </td>
100 91
                        <td style="border-bottom: none !important; text-align: center !important;">
101
<!--                            <label class="form-check-label" for="select_all_anti_patterns">Select All</label>-->
92
                            <!--                            <label class="form-check-label" for="select_all_anti_patterns">Select All</label>-->
102 93
                            <input checked type="checkbox" class="form-check-input add-label" id="select_all_anti_patterns"
103 94
                                   onclick="checkAllAntiPatterns(this)">
104 95
                        </td>
105 96
                    </tr>
106
                    </tfoot>
97
                    <tr th:each="antiPattern : ${query.antiPatterns}">
98
                        <td><a th:text="${antiPattern.printName}" th:href="@{'/anti-patterns/' + ${antiPattern.id}}" class="anchor-table"></a></td>
99
                        <td style="text-align: center">
100
                            <input checked type="checkbox" class="form-check-input" name="selectedAntiPatterns"
101
                                   th:value="${antiPattern.id}" th:id="@{anti-pattern_} + ${antiPattern.id}"
102
                                   onclick="projectCheckboxesAllIndeterminate(this, 1)">
103
                        </td>
104
                    </tr>
105
                    </tbody>
106
                    <tfoot></tfoot>
107 107
                </table>
108 108
                <div th:unless="${not #lists.isEmpty(query.antiPatterns)}" class="alert alert-danger" role="alert">
109 109
                    There are no anti-patterns to detect!
src/main/webapp/resources/js/core.js
1
function projectCheckboxesAllIndeterminate(checkbox, selectPattern) {
2

  
3
    var globalCheckboxPattern = "";
4
    var checkboxPattern = "";
5

  
6
    if (selectPattern == 0) {
7
        globalCheckboxPattern = '*[id^="select_all_projects"]';
8
        checkboxPattern = '*[id^="project_"]';
9
    } else {
10
        globalCheckboxPattern = '*[id^="select_all_anti_patterns"]';
11
        checkboxPattern = '*[id^="anti-pattern_"]';
12
    }
13

  
14
    var projectCheckboxes = document.querySelectorAll(checkboxPattern);
15
    var checkedCounter = 0;
16

  
17
    for (let i = 0; i < projectCheckboxes.length; i++) {
18
            if(projectCheckboxes[i].checked) {
19
                checkedCounter++;
20
            }
21
     }
22
        var projectSelectAllCheckbox = document.querySelector(globalCheckboxPattern);
23

  
24
        if (checkedCounter <= 0) {
25
            projectSelectAllCheckbox.indeterminate = false;
26
            projectSelectAllCheckbox.checked = false;
27
        } else if (checkedCounter < projectCheckboxes.length) {
28
            projectSelectAllCheckbox.indeterminate = true;
29
        } else {
30
            projectSelectAllCheckbox.indeterminate = false;
31
            projectSelectAllCheckbox.checked = true;
32
        }
33

  
34
}
35

  
1 36
// script to popover
2 37
$(document).ready(function () {
3 38
    $('[data-toggle="popover"]').popover();
......
18 53
    for (i = 0; i < antiPatterns.length; i++) {
19 54
        antiPatterns[i].checked = !!checkBox.checked;
20 55
    }
56
    antiPatternsChecked = true;
21 57
}
22 58

  
23 59
function showProgressBar() {

Také k dispozici: Unified diff