Commit Graph

37 Commits

Author SHA1 Message Date
Javi Martín
f8d06bcaf2 Move management investments search partial to a component
We're also moving it to the `management` subfolder, since it's only used
in the budget investments management.
2024-11-08 15:03:55 +01:00
Javi Martín
b9e137619a Simplify the way we provide the title in most cases
This is consistent with the way we're providing the main class.

Note we're still setting the title using a block in more complex cases.
2024-03-23 00:35:47 +01:00
Javi Martín
f1105140ae Remove duplicate <main> tags in management views
There can only be one <main> tag in a document, and we've already got a
<main> tag in the management layout.
2024-03-23 00:33:41 +01:00
Javi Martín
629e208e9d Add and apply ArgumentAlignment rubocop rule
We're choosing the default `with_first_argument` style because it's the
one we use the most.
2023-08-18 14:56:16 +02:00
Senén Rodero Rodríguez
96f584c4f7 Allow printing investments from any budget in the management interface 2023-02-03 12:18:13 +01:00
Senén Rodero Rodríguez
569138cbae Extract view into component 2023-01-16 13:36:31 +01:00
Javi Martín
e54b6b3d97 Increase investments width in management section
I'm not sure whether it now looks worse on extra large screens, but I'm
positive it looks much better on medium and large screens, particularly
when investments have images.
2021-11-09 01:36:19 +01:00
decabeza
823cc37ce8 Update styles and layout for new budget investment form 2021-07-09 14:25:24 +02:00
decabeza
a851048d56 Allow users to remove their support on investments
Note we don't cast negative votes when users remove their support. That
way we provide compatibility for institutions who have implemented real
negative votes (in case there are / will be any), and we also keep the
database meaningful: it's not that users downvoted something; they
simply removed their upvote.

Co-Authored-By: Javi Martín <javim@elretirao.net>
Co-Authored-By: Julian Nicolas Herrero <microweb10@gmail.com>
2021-06-14 14:46:54 +02:00
Javi Martín
758cdaf8d7 Extract controllers to support investments
Since we're going to add an action to remove supports, having a separate
controller makes things easier.

Note there was a strange piece of code which assumed users were not
verified if they couldn't vote investments. Now the code is also
strange, since it assumes users are not verified if they can't create
votes. We might need to revisit these conditions if our logic changes in
the future.
2021-06-14 14:42:03 +02:00
Javi Martín
0214184b2d Remove investment supports query optimizations
In the previous commit I mentioned:

> If I'm right, the `investment_votes` instance variable only exists to
> avoid several database queries to get whether the current user has
> supported each of the investments.
>
> However, that doesn't make much sense when only one investment is
> shown.

Now let's discuss the case when there are several investments, like in
the investments index:

* There are 10 investments per page by default
* Each query takes less than a millisecond
* We still make a query per investment to check whether the current user
  voted in a different group
* AFAIK, there have been no performance tests showing these
  optimizations make the request to the investments index significantly
  faster
* These optimizations make the code way more complex than it is without
  them

Considering all these points, I'm removing the optimizations. I'm fine
with adding `includes` calls to preload records and avoid N+1 queries
even if there are no performance tests showing they make the application
faster because the effect on the code complexity is negligible. But
that's not the case here.

Note we're using `defined?` instead of the `||=` operator because the
`||=` operator will not serve its purpose when the result of the
operation returns `false`.
2021-06-14 14:41:57 +02:00
Javi Martín
5fab843184 Simplify managing investment votes
If I'm right, the `investment_votes` instance variable only exists to
avoid several database queries to get whether the current user has
supported each of the investments.

However, that doesn't make much sense when only one investment is shown.
In this case, the number of queries stays the same, and so we can
simplify the code by rendering the component with an optional parameter.
2021-06-14 14:41:51 +02:00
Javi Martín
d5f4313f59 Simplify getting URL to support an investment
We're also changing the method name to `vote_path` in order to be
consistent with the way Rails uses `_path` for relative URLs.
2021-06-14 14:38:34 +02:00
Javi Martín
014d29b991 Extract method to get a budget phase title 2021-03-09 16:37:47 +01:00
Javi Martín
f864156b21 Add and apply ClosingErbTagIndent ERB Lint rule
Note this rule does still allow us to add new lines after opening tags;
it just makes sure that if we do, we also add it in closing tags.
Likewise, if we don't add it in the opening tag, it forces us not to add
it in the closing tag either.

I don't have a strong preference about either style; in these cases I've
chosen the latter because it seemed more common in our code.
2021-02-05 17:39:42 +01:00
Javi Martín
749428d93f Replace content_tag with new tag builder syntax
One of the main advantages of this syntax is we can now omit the content
parameter when it's empty.
2020-04-27 19:26:37 +02:00
Javi Martín
911fe4e481 Simplify calls to render partial
We're also adding a bit of consistency, since most of our calls to
partial rendering omit the `partial` and `locals` keys.
2019-09-04 15:00:36 +02:00
Javi Martín
3e4e65ead7 Use double quotes inside ERB
We were using single quotes inside ERB code when that code was inside
HTML double quotes.
2019-03-25 14:58:54 +01:00
Julian Herrero
0e0462368b Use double quotes in app/views/management 2019-03-19 12:16:50 +01:00
decabeza
b43945ad33 Removes custom content on management and devise views 2018-07-30 17:58:13 +02:00
decabeza
2e8fe65b3d Cleans and improves management views layout 2018-07-02 17:41:39 +02:00
rgarcia
01ef439053 Display only current budget to Managers printing investments
In the specs, some investment were missing a heading_id, thus creating
another unexpected budget

By explicitly setting the heading_id we can control better which
budgets are created in each test
2018-01-15 22:02:04 +01:00
kikito
e0c0b18757 Sets partial locals correctly in use and management views 2016-12-16 18:01:20 +01:00
kikito
2a9957cea0 Extracts budget investment form to partial 2016-12-15 19:36:13 +01:00
kikito
869f7b39d6 fixes i18n 2016-12-08 11:49:13 +01:00
kikito
748fd8becf Makes all tests pass in bi management 2016-12-07 19:16:37 +01:00
kikito
b3be1633af Fixes all management bi issues except filtering by geozone 2016-12-07 16:35:27 +01:00
kikito
2760e751e7 fixes several specs 2016-12-06 20:09:17 +01:00
kikito
7afa12fa4e Adds dom_ids to views 2016-12-06 20:09:04 +01:00
kikito
e793a0d8e1 Adapts management::budget_investments to new budgets 2016-12-06 18:05:58 +01:00
kikito
0564392964 Introduces management budgets 2016-12-06 18:02:25 +01:00
kikito
8ef479bf31 Changes routes to use budgets resource instead of namespace 2016-12-06 18:01:37 +01:00
kikito
882565aeca Adds more controller variables and uses them in investment controller 2016-12-05 17:35:40 +01:00
kikito
c64c88da43 Fixes typo 2016-12-05 11:13:57 +01:00
kikito
6aab9f5253 renames _investment to _investment_show 2016-12-02 19:32:56 +01:00
kikito
c1f62dd317 Reimplements several bi views 2016-12-02 19:23:46 +01:00
kikito
83d254adae Moves views from one folder to another 2016-12-02 19:19:22 +01:00