diff --git a/app/controllers/quantities_controller.rb b/app/controllers/quantities_controller.rb index 4bba6fb..953a43e 100644 --- a/app/controllers/quantities_controller.rb +++ b/app/controllers/quantities_controller.rb @@ -28,27 +28,31 @@ class QuantitiesController < ApplicationController def toggle @quantity.update(primary: !@quantity.primary) - redirect_to project_quantities_url(@project) + @quantities = @project.quantities end def up @quantity.move_left if @quantity.left_sibling.present? - redirect_to project_quantities_url(@project) + @quantities = @project.quantities + render :toggle end def down @quantity.move_right if @quantity.right_sibling.present? - redirect_to project_quantities_url(@project) + @quantities = @project.quantities + render :toggle end def left @quantity.move_to_right_of(@quantity.parent) if @quantity.parent.present? - redirect_to project_quantities_url(@project) + @quantities = @project.quantities + render :toggle end def right @quantity.move_to_child_of(@quantity.left_sibling) if @quantity.left_sibling.present? - redirect_to project_quantities_url(@project) + @quantities = @project.quantities + render :toggle end private diff --git a/app/views/quantities/_list.html.erb b/app/views/quantities/_list.html.erb new file mode 100644 index 0000000..7cb0ea8 --- /dev/null +++ b/app/views/quantities/_list.html.erb @@ -0,0 +1,86 @@ +<% if @quantities.many? %> +
<%= 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 %> + | ++ <%= + if q.left_sibling.present? + link_to '', up_quantity_path(q), { + remote: true, + method: :post, + class: "icon icon-move-up" + } + else + link_to '', '', {class: "icon"} + end + %> + <%= + if q.right_sibling.present? + link_to '', down_quantity_path(q), { + remote: true, + method: :post, + class: "icon icon-move-down" + } + else + link_to '', '', {class: "icon"} + end + %> + <%= + if q.parent.present? + link_to '', left_quantity_path(q), { + remote: true, + method: :post, + class: "icon icon-move-left" + } + else + link_to '', '', {class: "icon"} + end + %> + <%= + if q.left_sibling.present? + link_to '', right_quantity_path(q), { + remote: true, + method: :post, + class: "icon icon-move-right" + } + else + link_to '', '', {class: "icon"} + end + %> + | +<%= q.domain %> | +<%= q.description %> | +<%= delete_link quantity_path(q), data: {} %> | +
<%= l(:label_no_data) %>
+<% end %> diff --git a/app/views/quantities/index.html.erb b/app/views/quantities/index.html.erb index a627436..91f0868 100644 --- a/app/views/quantities/index.html.erb +++ b/app/views/quantities/index.html.erb @@ -23,71 +23,6 @@<%= l(:field_name) %> | -<%= l(:field_order) %> | -<%= l(:field_domain) %> | -<%= l(:field_description) %> | -<%= l(:field_action) %> | -
---|---|---|---|---|
- <%= link_to '', toggle_quantity_path(q), - {method: :post, class: "icon #{q.primary ? "icon-fav" : "icon-fav-off"}"} %> - <%= q.name %> - | -- <%= - if q.left_sibling.present? - link_to '', up_quantity_path(q), {method: :post, class: "icon icon-move-up"} - else - link_to '', '', {class: "icon"} - end - %> - <%= - if q.right_sibling.present? - link_to '', down_quantity_path(q), - {method: :post, class: "icon icon-move-down"} - else - link_to '', '', {class: "icon"} - end - %> - <%= - if q.parent.present? - link_to '', left_quantity_path(q), - {method: :post, class: "icon icon-move-left"} - else - link_to '', '', {class: "icon"} - end - %> - <%= - if q.left_sibling.present? - link_to '', right_quantity_path(q), - {method: :post, class: "icon icon-move-right"} - else - link_to '', '', {class: "icon"} - end - %> - | -<%= q.domain %> | -<%= q.description %> | -<%= delete_link quantity_path(q), data: {} %> | -
<%= l(:label_no_data) %>
-<% end %> +