Commit Graph

40 Commits

Author SHA1 Message Date
Javi Martín
b51aa31e6a Use HTML beautifier to indent ERB files
We had inconsistent indentation in many places. Now we're fixing them
and adding a linter to our CI so we don't accidentally introduce
inconsistent indentations again.
2025-03-07 16:31:08 +01:00
Javi Martín
251a5fb6e9 Default to delete method for the destroy action
This is consistent with what Rails does.
2024-04-17 23:38:41 +02:00
Javi Martín
5876738369 Ask confirmation to delete drafts and questions
This is similar to what we do in almost every other page of the admin
section.
2024-04-17 16:44:10 +02:00
Javi Martín
ecad046a99 Use buttons to destroy drafts and questions
As mentioned in commits 5311daadf and bb958daf0, using links combined
with JavaScript to generate POST (or, in this case, DELETE) requests to
the server has a few issues.
2024-04-17 16:44:09 +02: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
decabeza
800027728a Add description to legislation questions 2023-02-22 00:52:51 +01:00
decabeza
cd99f2a5eb Replace legislation question textarea to text field 2023-02-22 00:52:51 +01:00
Javi Martín
1632540984 Remove redundant placeholders in forms
Using placeholders having similar (or identical) text as already present
as a label has a few issues.

First, it's a distraction. Reading the same information twice is
useless, requires an extra effort, and might even frustrate users.

Second, if users start typing before reading the placeholder and see it
disappear, they might think they're missing relevant information,
delete what they typed, and read the placeholder. That will get them
nowhere.

Finally, we display placeholders using a text offering very low contrast
against the background, so users don't think the placeholder is an
actual value entered in the field. Using such low contrast makes the
text hard to read, particularly for users with visual impairments.

So we're removing these placeholders.

This commit only deals with placeholder texts with similar (or
identical) texts as the label text. There might be other places where we
should replace placeholder texts with labels, but that's a different
topic.
2021-06-23 19:52:45 +02:00
Javi Martín
cfc60b5de4 Warn for changes just in markdown editor
This is the reason why this feature was implemented in the first
place: it's easy to open the editor, make some changes, close it, and
continue without realizing the changes have not been saved.

In the rest of the forms, this functionality is quite lacking. For
starters, some forms warn if there are unsaved changes, while some forms
don't, which is highly inconsistent and disorients users.

Furthermore, we were having problems with this feature after upgrading
Turbolinks, particularly in forms using CKEditor. In these cases, a lot
of hacking needs to be done in order to make this feature work properly,
since CKEditor adds some formatting automatically, and if this is done
after the form is serialized, we'll get some unexpected behavior. On the
other hand, comparing the value of a textarea against its `defaultValue`
property will work on every edge case, including using the browser's
back button or reloading the page.

Finally, users are used to the way web forms work, and aren't used to be
asked for confirmation when they change their mind and decide to leave
the page without saving the changes. Asking them for confirmation will
be annoying in most cases. Besides that, if they accidentally leave the
page, they can use the browser's back button and they'll recover the
unsaved changes.

It's true this won't happen it they accidentally close the browser's
window, but our WatchFormChanges functionality didn't work in this case
either. Using the "beforeunload" event adds more problems than it
solves, since it doesn't support custom messages (or, to be more
precise, modern browsers ignore custom messages), and it doesn't get
along with turbolinks.

Co-Authored-By: Senén Rodero Rodríguez <senenrodero@gmail.com>
2020-08-05 14:10:22 +02:00
Javi Martín
fa070f326e Remove unnecessary content_tag calls
We're usually using HTML tags in views instead.
2020-04-27 19:26:37 +02:00
Javi Martín
8ff728ee83 Use the shared partial to render errors
We were using it most of the time, but in some places we still had
duplicated code.
2019-10-25 15:15:47 +02:00
Javi Martín
6fa67b5e53 Use active record translations for labels
This way we can simplify the way we generate form fields. In some cases,
we also use the human attribute in table headers, which IMHO makes
sense.

I haven't moved all of them: for example, sometimes a label is
different depending on whether it's shown to administrators, valuators,
or users. And I haven't touched the ones related to devise, since I
wasn't sure about possible side effects.

Note I've also removed placeholders when they had the same text as their
labels, since they weren't helpful. On the contrary, the added redundant
text to the form, potentially distracting users.
2019-10-07 01:56:23 +02:00
Javi Martín
f9ed186909 Add rubocop spacing rules
We were following these rules in most places; we just didn't define them
anywhere.
2019-09-10 21:04:56 +02:00
Javi Martín
c62da726b8 Apply SpaceAroundErbTag ERB Lint rule 2019-09-10 20:02:15 +02:00
taitus
0602a38742 Fix Style: Display Titles without highlight 2019-07-01 15:03:48 +02:00
taitus
c9eaeffaf2 Align admin legislation questions form fields with new translations interface 2019-07-01 14:49:44 +02:00
Senén Rodero Rodríguez
146c09adb7 Update references to new translation interface 2019-07-01 14:49:43 +02:00
Julian Herrero
7b4b4b716c Use double quotes in app/views/admin/legislation 2019-03-19 12:16:50 +01:00
Javi Martín
9105ac3a69 Prefix classes used in JavaScript with "js-"
The same way it's done in the rest of the application.
2018-10-22 16:36:18 +02:00
Javi Martín
dbea577062 Follow naming conventions for HTML classes and IDs
We use underscores for IDs and hyphens for classes.
2018-10-22 16:36:18 +02:00
Javi Martín
5511a3a194 Fix "Add option" link position
The new options were being added inside the `.column` div, when they
needed to be added before it.
2018-10-22 16:36:17 +02:00
Javi Martín
21cf39d5ed Fix alignment in last translatable fields
When we grouped the fields together, the last one turned into a
`last-child`, which foundation automatically aligns to the right.

The markdown editor also needed to be tweaked a little bit.
2018-10-22 16:36:17 +02:00
Javi Martín
f70ef3ff2f Fix question options translations not being saved
If we enabled the locale and then added an option, the "add option" link
added the partial which was generated before enabling the translation,
and so it generated a field where the translation was disabled.

Enabling the translation after inserting each field solves the issue.
2018-10-22 15:46:24 +02:00
Javi Martín
85701bd754 Update legislation questions translatable fields 2018-10-22 15:46:24 +02:00
Marko Lovic
06347062dd Make Legislation Questions translatable 2018-09-19 14:54:24 +02:00
decabeza
f8707a73cd Unifies styles and views for admin legislation processes 2018-07-31 12:50:48 +02:00
decabeza
28234b333f Improves legislation questions form 2018-06-08 18:32:12 +02:00
decabeza
0b235d69d4 adds consistency for back links 2017-07-26 18:18:30 +02:00
decabeza
02055bd09a hides legislation empty tables, improves table styles 2017-05-24 13:34:37 +02:00
decabeza
5364ec106a fixes headings structure on legislation admin 2017-05-24 13:04:19 +02:00
decabeza
28e17b870c unifies styles and html code 2017-05-24 13:03:25 +02:00
Amaia Castro
536784ee04 Merge pull request #72 from medialab-prado/back-improvements
Back improvements
2017-01-19 10:27:12 +01:00
Fernando Blat
6560e77554 Ask for confirmation when changing the page and
the forms watched do have changes
2017-01-18 13:37:11 +01:00
Fernando Blat
1537dd41da Add forms placeholders 2017-01-18 11:46:19 +01:00
Amaia Castro
39633dce67 Fix back links in admin 2017-01-04 12:39:09 +01:00
Amaia Castro
ab12ffe98f Titles for legislation admin pages 2016-12-30 12:03:11 +01:00
Amaia Castro
4c309b5243 Refactor css classes 2016-12-30 11:22:28 +01:00
Amaia Castro
0cd2b62e2c Integrate admin html and css from sandbox 2016-12-30 11:00:34 +01:00
Amaia Castro
a6ceab6d73 Answer legislation questions 2016-12-27 19:49:03 +01:00
Amaia Castro
d25d6c178c Legislation Questions model and basic admin 2016-12-20 18:52:43 +01:00