Project

General

Profile

Patch #32523 » 32523-v3.patch

Yuichi HARADA, 2024-09-12 04:47

View differences:

app/assets/javascripts/application.js
185 185
  if (!filterOptions) return;
186 186
  var operators = operatorByType[filterOptions['type']];
187 187
  var filterValues = filterOptions['values'];
188
  var i, select;
188
  var select;
189 189

  
190 190
  var tr = $('<div class="filter">').attr('id', 'tr_'+fieldId).html(
191 191
    '<div class="field"><input checked="checked" id="cb_'+fieldId+'" name="f[]" value="'+field+'" type="checkbox"><label for="cb_'+fieldId+'"> '+filterOptions['name']+'</label></div>' +
......
195 195
  filterTable.append(tr);
196 196

  
197 197
  select = tr.find('.operator select');
198
  for (i = 0; i < operators.length; i++) {
199
    var option = $('<option>').val(operators[i]).text(operatorLabels[operators[i]]);
200
    if (operators[i] == operator) { option.prop('selected', true); }
198
  operators.forEach(function(op) {
199
    var option = $('<option>').val(op).text(operatorLabels[op]);
200
    if (op == operator) { option.prop('selected', true); }
201 201
    select.append(option);
202
  }
202
  });
203 203
  select.change(function(){ toggleOperator(field); });
204 204

  
205 205
  switch (filterOptions['type']) {
......
215 215
    );
216 216
    select = tr.find('.values select');
217 217
    if (values.length > 1) { select.attr('multiple', true); }
218
    for (i = 0; i < filterValues.length; i++) {
219
      var filterValue = filterValues[i];
218
    filterValues.forEach(function(filterValue) {
220 219
      var option = $('<option>');
221 220
      if ($.isArray(filterValue)) {
222 221
        option.val(filterValue[1]).text(filterValue[0]);
......
231 230
        if ($.inArray(filterValue, values) > -1) {option.prop('selected', true);}
232 231
      }
233 232
      select.append(option);
234
    }
233
    });
235 234
    break;
236 235
  case "date":
237 236
  case "date_past":
......
259 258
    );
260 259
    $('#values_'+fieldId).val(values[0]);
261 260
    select = tr.find('.values select');
262
    for (i = 0; i < filterValues.length; i++) {
263
      var filterValue = filterValues[i];
261
    filterValues.forEach(function(filterValue) {
264 262
      var option = $('<option>');
265 263
      option.val(filterValue[1]).text(filterValue[0]);
266 264
      if (values[0] == filterValue[1]) { option.prop('selected', true); }
267 265
      select.append(option);
268
    }
266
    });
269 267
    break;
270 268
  case "integer":
271 269
  case "float":
(5-5/5)