From 2ae03c9852922ff23ce79910ce499bfb8c7644e6 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Tue, 19 Mar 2024 11:19:53 +0100 Subject: thing: improved the UX on the form MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The "target" field is not autocompleted unless users explicitely change its value themselves. The autocompletion is built from the authors last name combo plus the year (which is rather naive, but effective for most cases). Moreover, some fields have been moved and the "access" field will only appear if "url" is set. Signed-off-by: Miquel Sabaté Solà --- app/views/things/_form.html.erb | 48 +++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 23 deletions(-) (limited to 'app/views') diff --git a/app/views/things/_form.html.erb b/app/views/things/_form.html.erb index 4aa3dc7..11d2230 100644 --- a/app/views/things/_form.html.erb +++ b/app/views/things/_form.html.erb @@ -1,7 +1,7 @@ <%= form_with(model: thing) do |form| %> <%= render "layouts/errors", model: thing %> -
+
<%= form.label :title %> <%= form.text_field :title, autofocus: true, autocapitalize: 'on', required: true %> @@ -9,7 +9,7 @@
<%= form.label :authors %> - <%= form.text_field :authors, autocapitalize: 'words', required: true %> + <%= form.text_field :authors, autocapitalize: 'words', "data-action": "thing#authorsUpdate", required: true %> <%= form.check_box :editors %> <%= form.label :editors %>
@@ -19,11 +19,6 @@ <%= form.text_field :note, autocapitalize: 'on' %>
-
- <%= form.label :target %> - <%= form.text_field :target, autocapitalize: 'on', required: true %> -
-
<%= form.label :publisher %> <%= form.text_field :publisher, autocapitalize: 'on' %> @@ -31,25 +26,12 @@
<%= form.label :year %> - <%= form.number_field :year %> + <%= form.number_field :year, "data-action": "thing#yearUpdate" %>
- <%= form.label :address %> - <%= form.text_field :address, autocapitalize: 'on' %> -
- -
- <%= form.label :url do %> - <%= I18n.t('activerecord.attributes.thing.url') %> - - <% end %> - <%= form.text_field :url, "data-action": "thing#updateLink" %> -
- -
- <%= form.label :access %> - <%= form.date_field :access %> + <%= form.label :target %> + <%= form.text_field :target, autocapitalize: 'on', "data-action": "thing#cancel", "data-thing-target": "identifier", required: true %>
@@ -67,6 +49,26 @@ <%= form.number_field :rate, min: 0, max: 10, required: true %>
+
+ <%= form.label :address %> + <%= form.text_field :address, autocapitalize: 'on' %> +
+ +
+ <%= form.label :url do %> + <%= I18n.t('activerecord.attributes.thing.url') %> + + <% end %> + <%= form.text_field :url, "data-action": "thing#updateLink" %> +
+ +
+
+ <%= form.label :access %> + <%= form.date_field :access %> +
+
+
<%= form.label :status %> <%= form.select :status, options_for_select(Thing.statuses.map { |k, _| [I18n.t("things.status.#{k}"), k] }.sort, thing.status) %> -- cgit v1.2.3