diff --git a/app/controllers/quantities_controller.rb b/app/controllers/quantities_controller.rb index 443df62..c401f29 100644 --- a/app/controllers/quantities_controller.rb +++ b/app/controllers/quantities_controller.rb @@ -1,7 +1,7 @@ class QuantitiesController < ApplicationController before_action :init_session_filters before_action :find_project_by_project_id, only: [:index, :create, :filter] - before_action :find_quantity, only: [:destroy, :toggle, :move] + before_action :find_quantity, only: [:edit, :update, :destroy, :toggle, :move] before_action :authorize def index @@ -21,6 +21,17 @@ class QuantitiesController < ApplicationController end end + def filter + session[:q_filters] = params[:filters] + prepare_quantities + render :toggle + end + + def edit + prepare_quantities + render :toggle + end + def destroy if @quantity.destroy flash[:notice] = 'Deleted quantity' @@ -34,12 +45,6 @@ class QuantitiesController < ApplicationController prepare_quantities end - def filter - session[:q_filters] = params[:filters] - prepare_quantities - render :toggle - end - def move direction = params[:direction].to_sym case direction diff --git a/app/views/quantities/_form.html.erb b/app/views/quantities/_form.html.erb index f2351dc..6a2c54c 100644 --- a/app/views/quantities/_form.html.erb +++ b/app/views/quantities/_form.html.erb @@ -9,8 +9,9 @@ <% end %>
<%= f.text_field :name, size: 25, required: true %>
-<%= f.text_field :description, size: 200 %>
-<%= f.text_field :formula, size: 200, placeholder: t('.formula_placeholder') %>
+<%= f.text_field :description, style: "width: 100%;" %>
+<%= f.text_field :formula, placeholder: t('.formula_placeholder'), + style: "width: 100%;" %>
<%= f.check_box :primary %>
diff --git a/app/views/quantities/_index.html.erb b/app/views/quantities/_index.html.erb new file mode 100644 index 0000000..ad3f448 --- /dev/null +++ b/app/views/quantities/_index.html.erb @@ -0,0 +1,81 @@ +<%= render :partial => 'quantities/filters', + :locals => {:url => filter_project_quantities_path(@project)} %> + +<% if @quantities.any? { |q| q.persisted? } %> +<%= l(:field_name) %> | +<%= l(:field_order) %> | +<%= l(:field_domain) %> | +<%= l(:field_description) %> | +<%= l(:field_action) %> | +|
---|---|---|---|---|---|
+ <%= link_to '', toggle_quantity_path(q), { + remote: true, + method: :post, + class: "icon #{q.primary ? "icon-fav" : "icon-fav-off"}" + } + %> + <%= q.name %> + | ++ <% [:up, :down, :left, :right].each do |direction| %> + <%= + if q.movable?(direction) + link_to '', move_quantity_path(q, direction), { + remote: true, + method: :post, + class: "icon icon-move-#{direction}" + } + else + link_to '', '', {class: "icon"} + end + %> + <% end %> + | +<%= q.domain %> | +<%= q.description %> | ++ <%= + link_to l(:button_edit), edit_quantity_path(q), { + remote: true, + class: "icon icon-edit" + } + %> + <%= delete_link quantity_path(q), {remote: true, data: {}} %> + | +|
+
+ <%= labelled_form_for @quantity, url: quantity_path(@quantity), method: :patch,
+ remote: true, html: {id: 'quantity-edit-form'} do |f| %>
+
+ <%= render :partial => 'quantities/form', :locals => { :f => f } %>
+ <%= submit_tag l(:button_save) %>
+ <%=
+ link_to l(:button_cancel), "#", :onclick => '$("#edit-quantity").hide()'
+ %>
+ <% end %>
+
+ |
+
<%= l(:label_no_data) %>
+<% end %> diff --git a/app/views/quantities/_list.html.erb b/app/views/quantities/_list.html.erb deleted file mode 100644 index 160d583..0000000 --- a/app/views/quantities/_list.html.erb +++ /dev/null @@ -1,60 +0,0 @@ -<%= render :partial => 'quantities/filters', - :locals => {:url => filter_project_quantities_path(@project)} %> - -<% if @quantities.any? { |q| q.persisted? } %> -<%= l(:field_name) %> | -<%= l(:field_order) %> | -<%= l(:field_domain) %> | -<%= l(:field_description) %> | -<%= l(:field_action) %> | -
---|---|---|---|---|
- <%= link_to '', toggle_quantity_path(q), { - remote: true, - method: :post, - class: "icon #{q.primary ? "icon-fav" : "icon-fav-off"}" - } - %> - <%= q.name %> - | -- <% [:up, :down, :left, :right].each do |direction| %> - <%= - if q.movable?(direction) - link_to '', move_quantity_path(q, direction), { - remote: true, - method: :post, - class: "icon icon-move-#{direction}" - } - else - link_to '', '', {class: "icon"} - end - %> - <% end %> - | -<%= q.domain %> | -<%= q.description %> | -- <%= delete_link quantity_path(q), {remote: true, data: {}} %> - | -
<%= l(:label_no_data) %>
-<% end %> diff --git a/app/views/quantities/index.html.erb b/app/views/quantities/index.html.erb index 372f627..18448df 100644 --- a/app/views/quantities/index.html.erb +++ b/app/views/quantities/index.html.erb @@ -5,7 +5,7 @@