[openstreetmap/openstreetmap-website] WIP: simple_form (#2655)

Andy Allan notifications at github.com
Thu Jun 11 10:30:27 UTC 2020


Refs #2654 

This is a draft implementation of using `simple_form` and Bootstrap. I might split this PR into stages, e.g. a separate PR for refactoring the existing CSS, and I haven't finished noodling around to find any remaining forms that I broke.

In the meantime, you can see how simple_form work for the trace upload form:

```
<%= simple_form_for @trace, :url => { :action => "create" }, :html => { :multipart => true } do |f| %>
  <%= f.error_notification %>
  <%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %>
  <%= f.input :gpx_file, :as => :file, required: true %>
  <%= f.input :description %>
  <%= f.input :tagstring %>
  <%= f.input :visibility, :collection => [:private, :public, :trackable, :identifiable],
                           :include_blank => false,
                           :hint => link_to(t(".visibility_help"), t(".visibility_help_url")) %>
  <%= f.button :submit %>
  <%= link_to t(".help"), t(".help_url"), :class => "btn btn-link" %>
<% end %>
```

So for example, `f.input` takes care of checking the i18n for hints, checks the model for errors, looks up labels, and adds all those elements automatically.
You can view, comment on, or merge this pull request online at:

  https://github.com/openstreetmap/openstreetmap-website/pull/2655

-- Commit Summary --

  * Add simple_form gem
  * Rubocop autofix for initializers
  * Refactor away from global form control styling
  * Customise simple_form_bootstrap defaults
  * Merge simple_form translations into the main en.yml form
  * Remove the red colour override, and use the bootstrap default
  * Refactor the trace forms to use simple_form and bootstrap

-- File Changes --

    M .rubocop.yml (1)
    M Gemfile (1)
    M Gemfile.lock (4)
    M app/assets/stylesheets/common.scss (413)
    M app/assets/stylesheets/parameters.scss (1)
    M app/views/browse/changeset.html.erb (6)
    M app/views/browse/new_note.html.erb (2)
    M app/views/browse/note.html.erb (4)
    M app/views/diary_entries/show.html.erb (2)
    M app/views/friendships/make_friend.html.erb (2)
    M app/views/friendships/remove_friend.html.erb (2)
    M app/views/issues/_comments.html.erb (2)
    M app/views/issues/index.html.erb (2)
    M app/views/layouts/_search.html.erb (2)
    M app/views/oauth_clients/edit.html.erb (2)
    M app/views/oauth_clients/index.html.erb (2)
    M app/views/oauth_clients/show.html.erb (2)
    M app/views/redactions/edit.html.erb (2)
    M app/views/redactions/new.html.erb (2)
    M app/views/site/export.html.erb (2)
    M app/views/traces/edit.html.erb (59)
    M app/views/traces/new.html.erb (39)
    M app/views/traces/show.html.erb (8)
    M app/views/user_blocks/edit.html.erb (2)
    M app/views/user_blocks/new.html.erb (2)
    M app/views/user_blocks/revoke.html.erb (2)
    M app/views/users/confirm.html.erb (2)
    M app/views/users/confirm_email.html.erb (2)
    M app/views/users/logout.html.erb (2)
    A config/initializers/simple_form.rb (177)
    A config/initializers/simple_form_bootstrap.rb (433)
    M config/locales/en.yml (28)
    A lib/templates/erb/scaffold/_form.html.erb (15)

-- Patch Links --

https://github.com/openstreetmap/openstreetmap-website/pull/2655.patch
https://github.com/openstreetmap/openstreetmap-website/pull/2655.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/2655
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20200611/93a3a7ea/attachment-0001.htm>


More information about the rails-dev mailing list