Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Traces: Migrate list to bootstrap #3036

Closed
wants to merge 2 commits into from

Conversation

tordans
Copy link
Contributor

@tordans tordans commented Jan 3, 2021

Changes:

  • switch from tables to bootstrap media since it makes the spacing around the image easier and also its not a table in a semantic way
  • remove the unless in #index since it is covered by the if-size>0 above

refactor the list

  • reorder elements
  • make the pending-image a blank square and move the pending notice to the first line
  • move the actions to the right and use the previous title-text as link-text since those explain a lot better what the links actually do (I thought "edit" would edit the trace-db-entry, not open the map-editor)
  • remove the two translations that are not used anymore from en.yml
  • use if-present for tags-link-list since its easier to read
  • use the same styling for the trace description as on the changeset description (italic text)

I will wait for a first review of this.

Still to do:

  • Check specs
  • Add translations for the two new strings (hint about how to this is welcome)

Screenshots

BEFORE
traces-before

AFTER

traces-after

AFTER / PENDING
traces-pending

- switch from tables to bootstrap media since it makes the spacing around the image easier and also its not a table in a semantic way
- remove the unless in #index since it is covered by the if-size>0 above

refactor the list
- reorder elements
- make the pending-image a blank square and move the pending notice to the first line
- hide both actions if trace is pending
- move the actions to the right and use the previous title-text as link-text since those explain a lot better what the links actually do (I thought "edit" would edit the trace-db-entry, not open the map-editor)
- remove the two translations that are not used anymore from en.yml
- use if-present for tags-link-list since its easier to read
- use the same styling for the trace description as on the changeset description (italic text)
Solving linter messages.

```
4 error(s) were found in ERB files
Linting 154 files with 12 linters...

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
In file: app/views/traces/_trace.html.erb:1

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
In file: app/views/traces/_trace.html.erb:1

Layout/CaseIndentation: Indent `when` as deep as `case`.
In file: app/views/traces/_trace.html.erb:30

Layout/EndAlignment: `end` at 4, 24 is not aligned with `case` at 1, 23.
In file: app/views/traces/_trace.html.erb:32
```
<% if trace.tags.present? %>
<%= t ".in" %>
<%= safe_join(trace.tags.collect { |tag| link_to_tag tag.tag }, ", ") %>
<% end %>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bit here looks like a Lego-style translation, as it translates the text word by word. Obviously I can't tell if that's causing some issue for any of the ~97 languages we support.

Typically you would define one locale string that includes multiple variables and let the translators figure out what the proper text would be in their language.

Copy link
Contributor Author

@tordans tordans Jan 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I try not to touch the output – translations and things like this join – in all my PRs since my focus is on refactoring the html/css to bootstrap and while doing this moving the elements to a – in my opinion – better place in the view. I hope this will make it easier to merge since I expect less discussion about the right wording and less re-translating needs to be done.

If we where to change this specific translation, I would vote for changing the meaning of "in" to something like "categorised with" or "tagged with". The "in" term does not make much sense IMO, since the tags are not the main "folder" where the traces are "in", nor are the tags the main navigation element on the traces page.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that's a separate issue and should be addressed (if there is indeed a problem) in a separate PR.

Copy link
Collaborator

@gravitystorm gravitystorm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall I like parts of this PR, e.g. removing the ... and making the link text clearer. But I'm not convinced by the list vs tables - not yet, but still a possibility!

<% end %>
<% end %>

<div class="media-body">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The media component has been removed from bootstrap 5. See twbs/bootstrap#28265. So to avoid having to refactor this soon, we should avoid using it now.

<% else %>
<span class="text-danger"><%= t ".pending" %></span>
<% end %>
<li class="media mb-1 p-2 <%= cycle("", " bg-light") %>">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I count 10 different uses of margin and padding utilities - seems a bit high? If there is any way to reduce them, that would make the layout more robust to future changes. In particular, I can't see any system behind choosing different sizes e.g. -1, -2 etc.

<% else %>
<span class="text-danger"><%= t ".pending" %></span>
<% end %>
<li class="media mb-1 p-2 <%= cycle("", " bg-light") %>">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We recently moved away from cycle in templates, although this is less intrusive than what we had previously. See 5fdada2 for the change.

This proposes changing the colour for the stripes, which makes it inconsistent with the other striped tables/lists e.g. messages.

Is there a different way to achieve this? Or alternatively, does writing more CSS to support attempting to stripe a list suggest that we should be sticking with a table?

<img src="<%= url_for :controller => "traces", :action => "icon", :id => trace.id, :display_name => trace.user.display_name %>" alt="" class="img-thumbnail mr-3" />
</a>
<% else %>
<div style="width: 60px; height: 60px" class="img-thumbnail bg-white mr-3"></div>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think our CSP allows inline styling like this. But if we're making empty divs a specific width and height, to push other content around, then we should be looking at using a grid or table instead.


<div class="media-body">
<% if trace.inserted %>
<p class="float-right">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if floating is the right approach here, but I haven't investigated alternatives like grid.

... <%= time_ago_in_words(trace.timestamp, :scope => :'datetime.distance_in_words_ago') %></span>
<%= link_to_if trace.inserted?, t(".map"), { :controller => "site", :action => "index", :mlat => trace.latitude, :mlon => trace.longitude, :anchor => "map=14/#{trace.latitude}/#{trace.longitude}" }, { :title => t(".view_map") } %> /
<%= link_to t(".edit"), { :controller => "site", :action => "edit", :gpx => trace.id }, { :title => t(".edit_map") } %>
<% badge_class = trace.visibility.in?("public", "identifiable") ? "success" : "danger" %>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be in?(Array) i.e. trace.visibility.in?(["public", "identifiable"]) (note added [ ])

@gravitystorm gravitystorm added the changes requested Changes are needed before the PR will be merged or reviewed again label Jan 6, 2021
gravitystorm added a commit to gravitystorm/openstreetmap-website that referenced this pull request Mar 17, 2021
gravitystorm added a commit to gravitystorm/openstreetmap-website that referenced this pull request Mar 17, 2021
@gravitystorm
Copy link
Collaborator

I've refactored this based on the review notes, and opened a new PR at #3139

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changes requested Changes are needed before the PR will be merged or reviewed again
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants