diff --git a/app/assets/images/pictograms/close-circle-outline.svg b/app/assets/images/pictograms/close-circle-outline.svg new file mode 100644 index 0000000..bc755e1 --- /dev/null +++ b/app/assets/images/pictograms/close-circle-outline.svg @@ -0,0 +1 @@ + diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 70c60a5..4832335 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -88,7 +88,6 @@ module ApplicationHelper image_element_to(:link, name, image, options, html_options) end - private def image_element_to(type, name, image = nil, options = nil, html_options = {}) @@ -126,7 +125,7 @@ module ApplicationHelper end end if exponent != 1 - result += "10#{exponent-1}" + result += "10% d" % [exponent-1] end result.html_safe end diff --git a/app/views/units/_form.html.erb b/app/views/units/_form.html.erb index 52a255f..217c54c 100644 --- a/app/views/units/_form.html.erb +++ b/app/views/units/_form.html.erb @@ -1,26 +1,24 @@ -
> -

<%= t ".heading_new_unit" %>

+<%= fields_for unit do |form| %> + + <%= form.text_field :symbol, form: :unit_form, required: true, autofocus: true, size: 10, + autocomplete: "off" %> + + + <%= form.text_field :name, form: :unit_form, size: 25, autocomplete: "off" %> + + + <% unless unit.base.nil? %> + <%= form.number_field :multiplier, form: :unit_form, step: "any", size: 10, + autocomplete: "off" %> + <% end %> + - <%= labelled_form_for @unit, - url: project_units_path(@project), - html: {id: 'unit-add-form', name: 'unit-add-form'} do |f| %> - - <%= render partial: 'units/form', locals: {f: f} %> - <%= submit_tag l(:button_create) %> - <%= link_to l(:button_cancel), "#", onclick: '$("#add-unit").hide(); return false;' %> - <% end %> -
-
- -<%= error_messages_for @unit %> - -
-
-
-

<%= f.text_field :shortname, required: true, size: 20 %>

-
-
-

<%= f.text_field :name, size: 60 %>

-
-
-
+ + <%= form.submit unit.persisted? ? t(:update) : t(:add), form: :unit_form %> + <%= image_link_to t(:cancel), "close-circle-outline", units_path, class: 'dangerous', + onclick: 'this.closest("tr").replaceChildren(); + document.querySelector("a#add_unit").style.visibility = "visible"; + return false;' %> + + +<% end %> diff --git a/app/views/units/index.html.erb b/app/views/units/index.html.erb index 445f2e9..2f6b24d 100644 --- a/app/views/units/index.html.erb +++ b/app/views/units/index.html.erb @@ -1,10 +1,13 @@
<% if current_user.at_least(:active) %> - <%= image_link_to t(".add_unit"), "plus-outline", new_unit_path %> + <%= turbo_frame_tag target: dom_id(Unit.new) do %> + <%= image_link_to t('.add_unit'), 'plus-outline', new_unit_path, id: :add_unit, + onclick: 'this.style.visibility = "hidden";' %> + <% end %> <% end %>
-<%#= turbo_frame_tag 'unit_form' %> +<%= turbo_frame_tag 'unit_form_frame' %> @@ -18,6 +21,8 @@ + + <% Unit.each_with_level(@units) do |unit, level| %>