Commit Graph

10 Commits

Author SHA1 Message Date
taitus
bce1474527 Only render position field on table when cards rendered are not headers 2024-03-21 19:00:56 +01:00
taitus
e9a7731f49 Do not render "Number of colums" when create a sdg header card
Co-authored-by: Javi Martín <javim@elretirao.net>
2024-03-21 18:08:25 +01:00
Javi Martín
5c7d87f763 Open admin links in the same window
In the admin section, when clicking on a link that leads to a page in
the public area, sometimes the page was opened in the same window and
sometimes it would open in a new window, with no clear criteria
regarding when either scenario would take place.

This was really confusing, so now we're more consistent and open
(almost) every link in the same window. The main reason behind it is
simple: if we add `target: _blank`, people who want to open those links
in the same window can no longer do so, so we're taking control away
from them. However, if we don't add this attribute, people can choose
whether to open the link on the same tab or to open it on a new one,
since all browsers implement a method to do so.

More reasons behind this decision can be found in "Opening Links in New
Browser Windows and Tabs" [1].

We're keeping some exceptions, though:

* Opening the link to edit an investment on the same tab would result in
  losing all the investment filters already applied when searching for
  investments, so until we implement a way to keep these filters, we're
  also opening the link to edit an investment in a new tab
* For now, we're also opening links to download files in a new window;
  we'll deal with this case in the future

[1] https://www.nngroup.com/articles/new-browser-windows-and-tabs/
2023-10-24 16:31:39 +02:00
Javi Martín
dffe7966f6 Fix keyword arguments in action components calls
We were passing a hash of options instead of converting them to keyword
parameters, which resulted in warnings on Ruby 2.7:

```
app/components/admin/table_actions_component.html.erb:5: warning: Using
the last argument as keyword parameters is deprecated; maybe ** should
be added to the call

app/components/admin/table_actions_component.html.erb:9: warning: Using
the last argument as keyword parameters is deprecated; maybe ** should
be added to the call

app/components/admin/widget/cards/row_component.html.erb:20: warning:
Using the last argument as keyword parameters is deprecated; maybe **
should be added to the call

app/components/admin/widget/cards/table_component.html.erb:14: warning:
Using the last argument as keyword parameters is deprecated; maybe **
should be added to the call
```
2023-01-26 17:19:15 +01:00
Javi Martín
091abfc944 Use Active Storage to render attachments
This way we fix a bug we mentioned in commit 930bb753c which caused
links to documents to be broken when editing their title because the
title was used to generate the URL of the document.

Note we're still using Paperclip to render cached attachments because
this is the only case where we store files with just Paperclip and not
Active Storage.

With Active Storage, we render attachments just like any other resource,
using `polymorphic_path`. Paperclip included the `url` method in the
model; since the model doesn't have access to the request parameters
(like the host), this was inconvenient because it wasn't possible to
generate absolute URLs with Paperclip.

In order to simplify the code and make it similar to the way we used
Paperclip, we're adding a `variant` method accepting the name of a
variant and returning the variant.
2022-02-23 18:21:38 +01:00
Javi Martín
9cc0ad0ba9 Allow cards table actions to receive options
Just like we sometimes override options in the generic table actions
component, we're going to do the same thing with the cards table
actions.
2021-02-26 16:17:18 +01:00
Javi Martín
ba4b1a91e1 Allow using a different URL on widget card forms 2021-02-26 16:16:51 +01:00
Javi Martín
1e7517d1f6 Extract components to edit and add cards
This way we'll be able to reuse it in the SDG Management section while
reusing the `title` method to set the page title.
2021-01-14 17:38:01 +01:00
Javi Martín
1f6ca4980f Extract method in cards table component 2021-01-12 14:50:37 +01:00
Javi Martín
5148919c17 Remove duplication in cards tables
We were using the same code in two places, so we're extracting the code
into a component in order to share it.
2021-01-12 14:50:37 +01:00