diff options
| author | Teddy Wing | 2018-04-19 13:59:41 +0200 |
|---|---|---|
| committer | Johan Van Ryseghem | 2018-04-26 09:16:15 +0200 |
| commit | e5215f229e3dfa5d84a43bcf75e2edf8c99667a3 (patch) | |
| tree | f4d18422ecbcda411e7382eff94fea677ce4f606 /app/javascript | |
| parent | 37cef4eca7eec2dbfc4be10334c787ce207b466e (diff) | |
| download | chouette-core-e5215f229e3dfa5d84a43bcf75e2edf8c99667a3.tar.bz2 | |
ReferentialVehicleJourneys: Show selected line in drop-down
Previously we weren't showing the currently-selected line filter in the
drop-down label.
If a line is selected, get its ID and name and use those to pre-fill the
select.
Using Select2's `initSelection` option to configure this instead of
putting `selected: ` in the Rails field definition. That would have
looked like this:
collection: [[@filtered_line.name, @filtered_line.id]],
selected: params[:q] && params[:q][:route_line_id_eq],
But doing it that way wasn't possible because this is an AJAX-populated
Select2.
Since we already have a way to use `initSelection`, this was the
quickest and easiest way to go, but apparently Select2 v4.0 deprecated
this option, instead doing it with a data adapter. Couldn't really be
bothered right now to figure out how to set that up as it seemed like a
lot of work for not much payoff right now. Also, I was a little
disappointed in Select2's docs regarding this. From what I understood,
it looks like you basically need to create your own custom data adapter
to do this, which sounds like a pain, and I'm not sure if I would have
to mess with the rest of our existing Select2 configuration setup in
order to integrate that.
Refs #5889
Diffstat (limited to 'app/javascript')
0 files changed, 0 insertions, 0 deletions
