Revize 5d599617
Přidáno uživatelem Jakub Vašta před téměř 5 roky(ů)
website/public/js/zcu-heatmap.js | ||
---|---|---|
222 | 222 |
|
223 | 223 |
function updateAvailableDataSets(available) { |
224 | 224 |
|
225 |
var options = ''; |
|
226 |
|
|
227 |
Object.entries(available).forEach(([key, value]) => { |
|
228 |
options += '<option value="' + value + '">' + key + '</option>\n'; |
|
225 |
var isOptionEnabled = true; |
|
226 |
$("#type > option").each(function() { |
|
227 |
if((this.value in available) == false) { |
|
228 |
$(this).prop('disabled', true) |
|
229 |
$(this).prop('selected', false) |
|
230 |
} |
|
231 |
else { |
|
232 |
$(this).prop('disabled', false) |
|
233 |
if (isOptionEnabled) { |
|
234 |
$(this).prop('selected', true) |
|
235 |
} |
|
236 |
isOptionEnabled = false; |
|
237 |
} |
|
229 | 238 |
}); |
230 | 239 |
|
231 |
if (options === '') { |
|
232 |
$('#submit-btn').prop('disabled', true); |
|
233 |
} |
|
234 |
else { |
|
235 |
$('#submit-btn').prop('disabled', false); |
|
236 |
} |
|
240 |
$('#submit-btn').prop('disabled', isOptionEnabled); |
|
237 | 241 |
|
238 |
$('#type').empty().append(options); |
|
239 |
|
|
240 | 242 |
} |
website/src/Form/DataSetType.php | ||
---|---|---|
22 | 22 |
} |
23 | 23 |
|
24 | 24 |
public function buildForm(FormBuilderInterface $builder, array $options) { |
25 |
$selectTypeData = null == $options['data']->getDate() ? |
|
26 |
Utils::prepareDatasetsNames($this->manager->getAvailableCollections()) : |
|
27 |
$this->manager->getAvailableCollectionsByDay($options['data']->getDate()); |
|
28 |
|
|
29 | 25 |
$builder |
30 | 26 |
->add('date', TextType::class) |
31 | 27 |
->add('time', ChoiceType::class, [ |
... | ... | |
57 | 53 |
], |
58 | 54 |
]) |
59 | 55 |
->add('type', ChoiceType::class, [ |
60 |
'choices' => $selectTypeData,
|
|
56 |
'choices' => Utils::prepareDatasetsNames($this->manager->getAvailableCollections()),
|
|
61 | 57 |
]) |
62 | 58 |
->add('submit', SubmitType::class); |
63 | 59 |
} |
website/templates/heatmap.html.twig | ||
---|---|---|
156 | 156 |
<script src="{{ asset('js/zcu-heatmap.js') }}"></script> |
157 | 157 |
<script> |
158 | 158 |
initMap(); |
159 |
checkDataSetsAvailability("{{ path('available') }}") |
|
159 | 160 |
{% if submitted %} |
160 | 161 |
loadCurrentTimeHeatmap("{{ path('opendata') }}"); |
161 | 162 |
{% endif %} |
Také k dispozici: Unified diff
Re #8080
+ data set type select box change - options are disabled not removed