Revize b3c57a7c
Přidáno uživatelem Jan Čarnogurský před téměř 5 roky(ů)
src/main/webapp/WEB-INF/templates/assembly.html | ||
---|---|---|
262 | 262 |
<script type="text/javascript"> |
263 | 263 |
$("select").selectpicker(); |
264 | 264 |
</script> |
265 |
<script> |
|
266 |
$(document).ready(function() { |
|
267 |
|
|
268 |
$('.select-action-button').on('click', function () { |
|
269 |
if ($(this).hasClass('select-action-headlight')) |
|
270 |
{ |
|
271 |
$(this).removeClass('select-action-headlight'); |
|
272 |
removeParameter(getParameterTitle($(this)), getParameterType($(this))); |
|
273 |
} |
|
274 |
else |
|
275 |
{ |
|
276 |
$(this).closest('.select-action-buttons').find('.select-action-button').removeClass('select-action-headlight'); |
|
277 |
|
|
278 |
removeFromAll(getParameterTitle($(this))); |
|
279 |
|
|
280 |
$(this).addClass('select-action-headlight'); |
|
281 |
|
|
282 |
addParameter(getParameterIndex($(this)), |
|
283 |
getParameterTitle($(this)), |
|
284 |
getParameterType($(this)), |
|
285 |
getParameterHiddenValue($(this))); |
|
286 |
|
|
287 |
initParameters(); |
|
288 |
} |
|
289 |
}); |
|
290 |
|
|
291 |
initParameters(); |
|
292 |
|
|
293 |
}); |
|
294 |
|
|
295 |
function removeFromAll(title) { |
|
296 |
$rows = $('.selected-input-container'); |
|
297 |
|
|
298 |
$rows.each(function () { |
|
299 |
$(this).find('.parameter-name').each(function () { |
|
300 |
if ($(this).text() == title) |
|
301 |
{ |
|
302 |
$(this).closest('.parameter').remove(); |
|
303 |
} |
|
304 |
}) |
|
305 |
}); |
|
306 |
} |
|
307 |
|
|
308 |
function getParameterIndex(button) { |
|
309 |
return $(button).closest('.parameter-row').find('.parameterIndex').val(); |
|
310 |
} |
|
311 |
|
|
312 |
function addParameter(index, parameterName, type, hiddenValue) { |
|
313 |
var row = document.createElement('tr'); |
|
314 |
row.classList.add(type + '-parameter', 'parameter'); |
|
315 |
|
|
316 |
let hiddenInput = document.createElement('input'); |
|
317 |
hiddenInput.type = 'hidden'; |
|
318 |
hiddenInput.id = `parametersInConfiguration${index}.location.id`; |
|
319 |
hiddenInput.name = `parametersInConfiguration[${index}].location.id`; |
|
320 |
hiddenInput.value = hiddenValue; |
|
321 |
|
|
322 |
row.appendChild(hiddenInput); |
|
323 |
|
|
324 |
var firstTd = document.createElement('td'); |
|
325 |
|
|
326 |
var firstTdBody = document.createElement('span'); |
|
327 |
firstTdBody.classList.add('parameter-name'); |
|
328 |
firstTdBody.innerHTML = parameterName; |
|
329 |
|
|
330 |
firstTd.appendChild(firstTdBody); |
|
331 |
|
|
332 |
row.appendChild(firstTd); |
|
333 |
|
|
334 |
var thirdTd = document.createElement('td'); |
|
335 |
|
|
336 |
var thirdTdBody; |
|
337 |
|
|
338 |
|
|
339 |
if (type == 'value') |
|
340 |
{ |
|
341 |
thirdTdBody = $('#function-select-' + index).clone()[0]; |
|
342 |
|
|
343 |
$(thirdTdBody).removeClass('hidden'); |
|
344 |
} |
|
345 |
else |
|
346 |
{ |
|
347 |
var secondTd = document.createElement('td'); |
|
348 |
|
|
349 |
var secondTdBody = document.createElement('input'); |
|
350 |
secondTdBody.type = 'text'; |
|
351 |
secondTdBody.classList.add('form-control', 'select-filter-input-name'); |
|
352 |
secondTdBody.name = `parametersInConfiguration[${index}].columnName`; |
|
353 |
|
|
354 |
secondTd.appendChild(secondTdBody); |
|
355 |
|
|
356 |
row.appendChild(secondTd); |
|
357 |
|
|
358 |
thirdTdBody = document.createElement('span'); |
|
359 |
thirdTdBody.innerHTML = "<i class=\"fas fa-sort\"></i>"; |
|
360 |
} |
|
361 |
|
|
362 |
thirdTd.appendChild(thirdTdBody); |
|
363 |
|
|
364 |
row.appendChild(thirdTd); |
|
365 |
|
|
366 |
$('#' + type + '-wrapper').append($(row)); |
|
367 |
|
|
368 |
} |
|
369 |
|
|
370 |
function removeParameter(title, parameterClass) { |
|
371 |
$rows = $('.' + parameterClass + '-parameter'); |
|
372 |
|
|
373 |
$rows.each(function () { |
|
374 |
$(this).find('.parameter-name').each(function () { |
|
375 |
if ($(this).text() == title) |
|
376 |
{ |
|
377 |
$(this).closest('.' + parameterClass + '-parameter').remove(); |
|
378 |
} |
|
379 |
}) |
|
380 |
}); |
|
381 |
} |
|
382 |
|
|
383 |
function getParameterType(context) { |
|
384 |
if ($(context).hasClass('column-button')) |
|
385 |
{ |
|
386 |
return 'column'; |
|
387 |
} |
|
388 |
else if ($(context).hasClass('row-button')) |
|
389 |
{ |
|
390 |
return 'row'; |
|
391 |
} |
|
392 |
else if ($(context).hasClass('value-button')) |
|
393 |
{ |
|
394 |
return 'value'; |
|
395 |
} |
|
396 |
} |
|
397 |
|
|
398 |
function getParameterHiddenValue(context) { |
|
399 |
if ($(context).hasClass('column-button')) |
|
400 |
{ |
|
401 |
return 1; |
|
402 |
} |
|
403 |
else if ($(context).hasClass('row-button')) |
|
404 |
{ |
|
405 |
return 2; |
|
406 |
} |
|
407 |
else if ($(context).hasClass('value-button')) |
|
408 |
{ |
|
409 |
return 3; |
|
410 |
} |
|
411 |
} |
|
412 |
|
|
413 |
function getParameterTitle(context) { |
|
414 |
return $(context).closest('.parameter-row').find('.parameter-name').text(); |
|
415 |
} |
|
416 |
|
|
417 |
|
|
418 |
function initParameters() |
|
419 |
{ |
|
420 |
$('.sortable').sortable(); |
|
421 |
$("select").selectpicker('refresh'); |
|
422 |
} |
|
423 |
|
|
424 |
|
|
425 |
</script> |
|
265 |
<script ype="text/javascript" src="js/assemblyScripts.js"></script> |
Také k dispozici: Unified diff
re #7970 added confirmation before assembly delete. Srcipts moved from templates to separated files