1
0

Disallowed moving quantity into parent/child relationship if domains differ

Generalized quantity up/down/left/right actions into 'move'
This commit is contained in:
cryptogopher
2019-11-22 22:43:11 +01:00
parent 0820a90897
commit 8c073494e5
5 changed files with 36 additions and 58 deletions

View File

@@ -32,50 +32,19 @@
<%= q.name %>
</td>
<td class="order">
<% [:up, :down, :left, :right].each do |direction| %>
<%=
if q.left_sibling.present?
link_to '', up_quantity_path(q), {
if q.movable?(direction)
link_to '', move_quantity_path(q, direction), {
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"
class: "icon icon-move-#{direction}"
}
else
link_to '', '', {class: "icon"}
end
%>
<% end %>
</td>
<td class="domain"><%= q.domain %></td>
<td class="description"><%= q.description %></td>