Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 74db519b

Přidáno uživatelem Jan Čarnogurský před téměř 4 roky(ů)

re #8119 - fix values functions bug, js refactoring

Zobrazit rozdíly:

src/main/webapp/WEB-INF/templates/assembly.html
92 92
                                    </div>
93 93
                                </td>
94 94

  
95
                                <select class="form-control hidden" th:id="'function-select-' + ${itemStat.index}"
96
                                        th:field="${configuration.parametersInConfiguration[__${itemStat.index}__].functions}"
97
                                        multiple>
95
                                <select class="form-control hidden" th:id="'tmp-function-select-' + ${itemStat.index}" multiple>
98 96
                                    <option th:each="function : ${parameterInConfiguration.parameter.functions}"
99 97
                                            th:text="${function.name}" th:value="${{function.id}}"></option>
100 98
                                </select>
src/main/webapp/js/assemblyScripts.js
4 4

  
5 5
$(document).ready(function() {
6 6

  
7
    // init handlers for position buttons
8
    initPositionButtons();
9

  
10
    // init actions
11
    initParameters();
12

  
13
    // spinner init
14
    initSpinnerToButtons();
15

  
16
    // generation init
17
    initTableGenerationButtons();
18

  
19
    // sort selected parameters
20
    initSelectedParameters();
21

  
22
    // set up tooltips
23
    initTooltips();
24

  
25
});
26

  
27
/**
28
 * Sets up functionality for position buttons (add/remove elements from position box), headlights
29
 */
30
function initPositionButtons() {
7 31
    // reaction for add/delete parameters from selected fields (row, column, value)
8 32
    $('.select-action-button').on('click', function () {
9 33
        // if input has headlight class (parameter is already added -> remove)
......
38 62

  
39 63
        validateCombination();
40 64
    });
41

  
42
    // init actions
43
    initParameters();
44

  
45
    // spinner init
46
    initSpinnerToButtons();
47

  
48
    // generation init
49
    initTableGenerationButtons();
50

  
51
    // sort selected parameters
52
    initSelectedParameters();
53

  
54
    // set up tooltips
55
    initTooltips();
56

  
57
});
65
}
58 66

  
59 67
/**
60 68
 * Remove value from all selected fields
......
90 98
 * @param hiddenValue
91 99
 */
92 100
function addParameter(index, parameterName, type, hiddenValue) {
101
    // basic set up for mapping element to dao object
93 102
    var row = document.createElement('tr');
94 103
    row.classList.add(type + '-parameter', 'parameter');
95 104

  
......
122 131

  
123 132
    var thirdTdBody;
124 133

  
125

  
134
    // for value copy hidden select
126 135
    if (type == VALUE)
127 136
    {
128
        thirdTdBody = $('#function-select-' + index).clone()[0];
137
        // get parameter select for functions
138
        thirdTdBody = $('#tmp-function-select-' + index).clone()[0];
139

  
140
        // set up id for select
141
        thirdTdBody.id = `parametersInConfiguration${index}.functions`;
142

  
143
        // set up name for select
144
        thirdTdBody.name = `parametersInConfiguration[${index}].functions`;
145

  
146
        // select first option
129 147
        thirdTdBody.selectedIndex = 0;
130 148

  
149
        // remove hidden class
131 150
        $(thirdTdBody).removeClass('hidden');
132 151
    }
152
    // for row and column add textfield
133 153
    else
134 154
    {
135 155
        var secondTd = document.createElement('td');
......
151 171

  
152 172
    row.appendChild(thirdTd);
153 173

  
174
    // append element to type wrapper
154 175
    $('#' + type + '-wrapper').append($(row));
155 176

  
177
    // reindex parameters order
156 178
    reindexOrder();
157 179

  
158 180
}
......
225 247
}
226 248

  
227 249
/**
228
 * Init base actions
250
 * Allow sort on parameters
229 251
 */
230 252
function initParameters()
231 253
{
232 254
    $('.sortable').sortable({
233 255
       stop: function () {
256
           // after change reindex parameters order
234 257
           reindexOrder();
235 258
       }
236 259
    });

Také k dispozici: Unified diff