| Age | Commit message (Collapse) | Author | 
 | 
 | 
 | 
 | 
 | 
af83/5817-referential-vehicle-journeys-index--fix-StopArea-kind-a
5817 referential vehicle journeys index  fix stop area kind a
 | 
 | 
The other migration for this in
`db/migrate/20180126134944_add_kind_to_stop_areas.rb` didn't handle
`kind IS NULL`. Since all the `kind`s were initialised to NULL when the
column was created, the `where` query didn't select any stop areas
because it was looking for those with some varchar value, and thus it
wasn't able to update any.
This ensures our existing records all have a `kind` in case we end up
using the field in a template at some point and our old data bugs out.
Refs #5817
 | 
 | 
This reverts commit c2bc391ee91cac70e726d188be97dd2323df0df2.
Thanks to 76abdbd66c16e6e1233685a5fa28a42cba5580d9, this temporary fix
can be reverted. We don't actually need `kind` selected here, it was
only added to appease the auto-initialisation of `kind` in `StopArea`.
Now that we don't set a default value for `kind` on initialisation, we
can remove it from this `select`.
 | 
 | 
We were getting this error on `ReferentialVehicleJourneys#index`:
    Feb  1 17:48:32 chouette-dev rails/chouette[18900]: Started GET "/referentials/9/vehicle_journeys" for 172.28.10.14 at 2018-02-01 17:48:32 +0100
    Feb  1 17:48:32 chouette-dev rails/chouette[18900]: Processing by ReferentialVehicleJourneysController#index as HTML
    Feb  1 17:48:32 chouette-dev rails/chouette[18900]: Parameters: {"referential_id"=>"9"}
    Feb  1 17:48:32 chouette-dev rails/chouette[18900]: locale set to :fr
    Feb  1 17:48:32 chouette-dev rails/chouette[18900]: Rendered referential_vehicle_journeys/_filters.html.slim (37.0ms)
    Feb  1 17:48:32 chouette-dev rails/chouette[18900]: Rendered referential_vehicle_journeys/index.html.slim within layouts/application (54.3ms)
    Feb  1 17:48:32 chouette-dev rails/chouette[18900]: Completed 500 Internal Server Error in 73ms (ActiveRecord: 10.4ms)
    Feb  1 17:48:32 chouette-dev rails/chouette[18900]: ActionView::Template::Error (missing attribute: kind):#012    23:         = f.input :published_journey_name_lteq, label: false, wrapper_html: { class: 'w45'}#012    24:     .form-group.togglable#012    25:       = f.label Chouette::StopArea.model_name.human.pluralize, required: false, class: 'control-label'#012    26:       = f.input :stop_area_ids, collection: @all_stop_areas.select(:id, :name).order(name: :asc), checked: params[:q] && params[:q][:stop_area_ids], as: :check_boxes, label: false, label_method: lambda{|l| ("<span>" + l.name + "</span>").html_safe}, required: false, wrapper_html: { class: 'checkbox_list'}, multiple: true#012    27:     .form-group.togglable#012    28:       = f.label Chouette::VehicleJourney.human_attribute_name(:purchase_window), class: 'control-label'#012    29:       .filter_menu#012  app/models/chouette/stop_area.rb:51:in `block in <class:StopArea>'#012  app/views/referential_vehicle_journeys/_filters.html.slim:26:in `block in _app_views_referential_vehicle_journeys__filters_html_slim__692539656386688985_47285414929500'#012  app/views/referential_vehicle_journeys/_filters.html.slim:1:in `_app_views_referential_vehicle_journeys__filters_html_slim__692539656386688985_47285414929500'#012  app/views/referential_vehicle_journeys/index.html.slim:9:in `_app_views_referential_vehicle_journeys_index_html_slim___336434325333090796_47285419865660'
    Feb  1 17:48:32 chouette-dev rails/chouette[18900]: Processing by ErrorsController#server_error as HTML
    Feb  1 17:48:32 chouette-dev rails/chouette[18900]: Parameters: {"referential_id"=>"9"}
    Feb  1 17:48:32 chouette-dev rails/chouette[18900]: locale set to :fr
or, this one locally which is easier to read:
    ActiveModel::MissingAttributeError in ReferentialVehicleJourneys#index
    Showing .../stif-boiv/app/views/referential_vehicle_journeys/_filters.html.slim where line #44 raised:
    missing attribute: kind
    Extracted source (around line #51):
        after_initialize do
    >     self.kind ||= :commercial
        end
        def self.nullable_attributes
    Trace of template inclusion: app/views/referential_vehicle_journeys/index.html.slim
    Rails.root: .../stif-boiv
    Application Trace | Framework Trace | Full Trace
    app/models/chouette/stop_area.rb:51:in `block in <class:StopArea>'
    app/views/referential_vehicle_journeys/_filters.html.slim:44:in `block in _app_views_referential_vehicle_journeys__filters_html_slim___131528464712770693_70134715599760'
    app/views/referential_vehicle_journeys/_filters.html.slim:1:in `_app_views_referential_vehicle_journeys__filters_html_slim___131528464712770693_70134715599760'
    app/views/referential_vehicle_journeys/index.html.slim:9:in `_app_views_referential_vehicle_journeys_index_html_slim__3124451149445015007_70134715309040'
This is because on `ReferentialVehicleJourneys#index`, the StopArea
filter makes this query:
    @all_stop_areas.select(:id, :name).order(name: :asc)
Alban added a temporary fix for the release in
c2bc391ee91cac70e726d188be97dd2323df0df2.
After a discussion with Luc, he said we only want the initial value on
the `#new` form, and we decided to take this out of the model and put it
in the form template instead.
Here, when a new `StopArea` is created, `:commercial` will be pre-filled
in the `kind` field by default. On the `#edit` page, it should show the
existing value of `kind` but not permit editing.
Refs #5817
 | 
 | 
 | 
 | 
5417 Update parents checksum when children are created or updated
 | 
 | 
 | 
 | 
5835 Timetables inherit application days from calendars
 | 
 | 
5832 fix filter by stopareas on vjs index
 | 
 | 
5825 Fix info window behaviour on VJs editor
 | 
 | 
5844 Add missing translation
 | 
 | 
 | 
 | 
 | 
 | 
5830 Fix RouteDecorator's duplicate action
 | 
 | 
3542 referential overview
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
Still missing:
- Pagination
- Filters
 | 
 | 
 | 
 | 
 | 
 | 
By default a value was always set on the "Line" filter, yielding
misleading results.
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
5798 Show return journeys on the journeys' editor.
 | 
 | 
5576 vehicle journeys  filter by line
 | 
 | 
5758 Add localized names to StopAreas
 | 
 | 
 | 
 | 
5796 Add some legroom in the JourneyPatterns editor
 | 
 | 
 | 
 | 
 | 
 | 
Johan recommended using an `IN` query to only get the lines in the
current scope. I assumed I'd be covered by the schema and how only the
lines for the current referential are in the schema, but this is
probably a more reasonable way to get associated lines.
Refs #5576
 | 
 | 
I went with this custom filter because I couldn't get it to work with a
symbol-based filter in the template. But Johan suggested trying it and I
guess it works. Not sure what I was doing that didn't work before.
Refs #5576
 | 
 | 
When the text of the current selection was very long, it could extend to
the end of the input, the farthest right:
    +-------------------+
    | Long text is long |
    +-------------------+
The problem is that the arrow indicating you can click on the input to
bring up a drop-down list of options would cover the "g" in "long" in
the above example (well, not exactly because of proportional width
characters, but you get the idea).
Fix the overlap by overriding Bootstrap Select2's style from
app/assets/stylesheets/vendor/select2-bootstrap.css:306-309, which looks
like this:
    .select2-container--bootstrap .select2-selection--single .select2-selection__rendered {
      color: #555555;
      padding: 0;
    }
Obviously, the padding is wrong. We need some right padding to give room
for the arrow. What are you thinking Bootstrap Select2?
Refs #5576
 | 
 | 
Pre-fill this box with the value from `params[:q]` so users can see
their selected line after filtering.
For some reason Select2 wants to keep it selected even after clicking
"Effacer". Not sure what that's about, but the HTML `<select>` clearly
doesn't have a `selected` attribute/option.
Refs #5576
 |