1
|
|
|
var handleTimePeriodEndTodayCheckboxChange = function () { |
2
|
|
|
var $timePeriodEndToday = $('#timePeriod_end_today'); |
3
|
|
|
var isChecked = $timePeriodEndToday.get(0).checked; |
4
|
|
|
|
5
|
|
|
if (!isChecked) { |
6
|
|
|
var now = new Date(); |
7
|
|
|
|
8
|
|
|
$('#odiseo_sylius_report_dataFetcherConfiguration_timePeriod_end_year').val(now.getFullYear()); |
9
|
|
|
$('#odiseo_sylius_report_dataFetcherConfiguration_timePeriod_end_month').val(now.getMonth() + 1); |
10
|
|
|
$('#odiseo_sylius_report_dataFetcherConfiguration_timePeriod_end_day').val(now.getDate()); |
11
|
|
|
} |
12
|
|
|
|
13
|
|
|
$timePeriodEndToday.closest('.field').find('select').prop('disabled', isChecked); |
14
|
|
|
}; |
15
|
|
|
|
16
|
|
|
var setupAutocomplete = function () { |
17
|
|
|
$('.sylius-autocomplete').each(function(idx, el) { |
18
|
|
|
var element = $(el); |
19
|
|
|
var criteriaName = element |
20
|
|
|
.data('criteria-name'); |
21
|
|
|
var choiceName = element |
22
|
|
|
.data('choice-name'); |
23
|
|
|
var choiceValue = element |
24
|
|
|
.data('choice-value'); |
25
|
|
|
var autocompleteValue = element |
26
|
|
|
.find('input.autocomplete') |
27
|
|
|
.val(); |
28
|
|
|
var loadForEditUrl = element |
29
|
|
|
.data('load-edit-url'); |
30
|
|
|
|
31
|
|
|
element |
32
|
|
|
.dropdown({ |
33
|
|
|
delay: { |
34
|
|
|
search: 250 |
35
|
|
|
}, |
36
|
|
|
minCharacters: 3, |
37
|
|
|
forceSelection: false, |
38
|
|
|
apiSettings: { |
39
|
|
|
dataType: 'JSON', |
40
|
|
|
cache: false, |
41
|
|
|
beforeSend: function beforeSend(settings) { |
42
|
|
|
/* eslint-disable-next-line no-param-reassign */ |
43
|
|
|
settings.data[criteriaName] = settings.urlData.query; |
44
|
|
|
|
45
|
|
|
return settings; |
46
|
|
|
}, |
47
|
|
|
onResponse: function onResponse(response) { |
48
|
|
|
return { |
49
|
|
|
success: true, |
50
|
|
|
results: response.map(function (item) { |
51
|
|
|
return { |
52
|
|
|
name: item[choiceName], |
53
|
|
|
value: item[choiceValue] |
54
|
|
|
}; |
55
|
|
|
}) |
56
|
|
|
}; |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
}); |
60
|
|
|
|
61
|
|
|
if (autocompleteValue.split(',') |
62
|
|
|
.filter(String).length > 0) { |
63
|
|
|
var menuElement = element |
64
|
|
|
.find('div.menu'); |
65
|
|
|
|
66
|
|
|
menuElement.api({ |
67
|
|
|
on: 'now', |
68
|
|
|
method: 'GET', |
69
|
|
|
url: loadForEditUrl, |
70
|
|
|
beforeSend: function beforeSend(settings) { |
71
|
|
|
/* eslint-disable-next-line no-param-reassign */ |
72
|
|
|
settings.data[choiceValue] = autocompleteValue.split(',') |
73
|
|
|
.filter(String); |
74
|
|
|
|
75
|
|
|
return settings; |
76
|
|
|
}, |
77
|
|
|
onSuccess: function onSuccess(response) { |
78
|
|
|
response.forEach(function (item) { |
79
|
|
|
menuElement.append($('<div class="item" data-value="' + item[choiceValue] + '">' + item[choiceName] + '</div>')); |
80
|
|
|
}); |
81
|
|
|
} |
82
|
|
|
}); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
window.setTimeout(function () { |
86
|
|
|
element |
87
|
|
|
.dropdown('set selected', element |
88
|
|
|
.find('input.autocomplete') |
89
|
|
|
.val() |
90
|
|
|
.split(',') |
91
|
|
|
.filter(String)); |
92
|
|
|
}, 5000); |
93
|
|
|
}); |
94
|
|
|
}; |
95
|
|
|
|
96
|
|
|
var setupForms = function () { |
97
|
|
|
$('#odiseo_sylius_report_dataFetcher_configuration .ui.toggle.checkbox').checkbox(); |
98
|
|
|
$('#odiseo_sylius_report_dataFetcher_configuration .ui.dropdown').dropdown(); |
99
|
|
|
|
100
|
|
|
setupAutocomplete(); |
101
|
|
|
}; |
102
|
|
|
|
103
|
|
|
(function ($) { |
104
|
|
|
'use strict'; |
105
|
|
|
|
106
|
|
|
$(document).ready(function() |
107
|
|
|
{ |
108
|
|
|
setupForms(); |
109
|
|
|
handleTimePeriodEndTodayCheckboxChange(); |
110
|
|
|
|
111
|
|
|
$('#odiseo_sylius_report_renderer').handlePrototypes({ |
112
|
|
|
'prototypePrefix': 'odiseo_sylius_report_renderer_renderers', |
113
|
|
|
'containerSelector': '#odiseo_sylius_report_renderer_configuration' |
114
|
|
|
}); |
115
|
|
|
$('#odiseo_sylius_report_dataFetcher').handlePrototypes({ |
116
|
|
|
'prototypePrefix': 'odiseo_sylius_report_dataFetcher_dataFetchers', |
117
|
|
|
'containerSelector': '#odiseo_sylius_report_dataFetcher_configuration' |
118
|
|
|
}); |
119
|
|
|
$('#odiseo_sylius_report_dataFetcher').on('change', function (e) { |
|
|
|
|
120
|
|
|
handleTimePeriodEndTodayCheckboxChange(); |
121
|
|
|
setupForms(); |
122
|
|
|
}); |
123
|
|
|
$('#timePeriod_end_today').on('change', function () { |
124
|
|
|
handleTimePeriodEndTodayCheckboxChange(); |
125
|
|
|
}) |
126
|
|
|
}); |
127
|
|
|
})( jQuery ); |
This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.