Added Quantity ordering
Some table columns made unwrappable
This commit is contained in:
parent
2176ef77f3
commit
745d6de42b
@ -1,6 +1,6 @@
|
|||||||
class QuantitiesController < ApplicationController
|
class QuantitiesController < ApplicationController
|
||||||
before_action :find_project_by_project_id, only: [:index, :create]
|
before_action :find_project_by_project_id, only: [:index, :create]
|
||||||
before_action :find_quantity, only: [:destroy, :toggle]
|
before_action :find_quantity, only: [:destroy, :toggle, :up, :down, :left, :right]
|
||||||
before_action :authorize
|
before_action :authorize
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@ -31,6 +31,26 @@ class QuantitiesController < ApplicationController
|
|||||||
redirect_to project_quantities_url(@project)
|
redirect_to project_quantities_url(@project)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def up
|
||||||
|
@quantity.move_left if @quantity.left_sibling.present?
|
||||||
|
redirect_to project_quantities_url(@project)
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
@quantity.move_right if @quantity.right_sibling.present?
|
||||||
|
redirect_to project_quantities_url(@project)
|
||||||
|
end
|
||||||
|
|
||||||
|
def left
|
||||||
|
@quantity.move_to_right_of(@quantity.parent) if @quantity.parent.present?
|
||||||
|
redirect_to project_quantities_url(@project)
|
||||||
|
end
|
||||||
|
|
||||||
|
def right
|
||||||
|
@quantity.move_to_child_of(@quantity.left_sibling) if @quantity.left_sibling.present?
|
||||||
|
redirect_to project_quantities_url(@project)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def quantity_params
|
def quantity_params
|
||||||
|
@ -27,10 +27,11 @@
|
|||||||
<table class="list">
|
<table class="list">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th><%= l(:field_order) %></th>
|
||||||
<th><%= l(:field_name) %></th>
|
<th><%= l(:field_name) %></th>
|
||||||
<th><%= l(:field_domain) %></th>
|
<th><%= l(:field_domain) %></th>
|
||||||
<th><%= l(:field_description) %></th>
|
<th><%= l(:field_description) %></th>
|
||||||
<th style="width:15%"><%= l(:field_action) %></th>
|
<th><%= l(:field_action) %></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -42,11 +43,44 @@
|
|||||||
quantity_class += " primary" if q.primary
|
quantity_class += " primary" if q.primary
|
||||||
%>
|
%>
|
||||||
<tr id="quantity-<%= q.id %>" class="<%= quantity_class %>">
|
<tr id="quantity-<%= q.id %>" class="<%= quantity_class %>">
|
||||||
|
<td class="order">
|
||||||
|
<%=
|
||||||
|
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
|
||||||
|
%>
|
||||||
|
</td>
|
||||||
<td class="name"><span><%= q.name %></span></td>
|
<td class="name"><span><%= q.name %></span></td>
|
||||||
<td class="domain"><%= q.domain %></td>
|
<td class="domain"><%= q.domain %></td>
|
||||||
<td class="description"><%= q.description %></td>
|
<td class="description"><%= q.description %></td>
|
||||||
<td class="action">
|
<td class="action">
|
||||||
<%= link_to l(:button_toggle), toggle_quantity_path(q),
|
<%= link_to l(:button_primary), toggle_quantity_path(q),
|
||||||
{method: :post, class: "icon #{q.primary ? "icon-fav" : "icon-fav-off"}"} %>
|
{method: :post, class: "icon #{q.primary ? "icon-fav" : "icon-fav-off"}"} %>
|
||||||
<%= delete_link quantity_path(q), data: {} %>
|
<%= delete_link quantity_path(q), data: {} %>
|
||||||
</td>
|
</td>
|
||||||
|
BIN
assets/images/1leftarrow.png
Normal file
BIN
assets/images/1leftarrow.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 254 B |
BIN
assets/images/1rightarrow.png
Normal file
BIN
assets/images/1rightarrow.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 255 B |
@ -1,3 +1,8 @@
|
|||||||
table.list tr.quantity.primary td.name {font-weight: bold;}
|
table.list tr.quantity.primary td.name {font-weight: bold;}
|
||||||
table.list td.action,
|
table.list td.action,
|
||||||
table.list td.value {text-align: right;}
|
table.list td.value {text-align: right;}
|
||||||
|
table.list td.action,
|
||||||
|
table.list td.name {white-space: nowrap;}
|
||||||
|
|
||||||
|
.icon-move-left { background-image: url(../images/1leftarrow.png); }
|
||||||
|
.icon-move-right { background-image: url(../images/1rightarrow.png); }
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# English strings go here for Rails i18n
|
# English strings go here for Rails i18n
|
||||||
en:
|
en:
|
||||||
body_trackers_menu_caption: 'Body trackers'
|
body_trackers_menu_caption: 'Body trackers'
|
||||||
|
field_order: 'Order'
|
||||||
field_action: 'Action'
|
field_action: 'Action'
|
||||||
field_reference: 'Reference'
|
field_reference: 'Reference'
|
||||||
field_group: 'Group'
|
field_group: 'Group'
|
||||||
@ -10,7 +11,7 @@ en:
|
|||||||
field_domain: 'Domain'
|
field_domain: 'Domain'
|
||||||
field_parent_quantity: 'Parent'
|
field_parent_quantity: 'Parent'
|
||||||
field_shortname: 'Short name'
|
field_shortname: 'Short name'
|
||||||
button_toggle: 'Toggle'
|
button_primary: 'Primary'
|
||||||
activerecord:
|
activerecord:
|
||||||
errors:
|
errors:
|
||||||
models:
|
models:
|
||||||
|
@ -13,6 +13,7 @@ resources :projects do
|
|||||||
resources :sources, :only => [:index, :create, :destroy]
|
resources :sources, :only => [:index, :create, :destroy]
|
||||||
resources :quantities, :only => [:index, :create, :destroy] do
|
resources :quantities, :only => [:index, :create, :destroy] do
|
||||||
post 'toggle', on: :member
|
post 'toggle', on: :member
|
||||||
|
post 'up', 'down', 'left', 'right', on: :member
|
||||||
end
|
end
|
||||||
resources :units, :only => [:index, :create, :destroy]
|
resources :units, :only => [:index, :create, :destroy]
|
||||||
end
|
end
|
||||||
|
2
init.rb
2
init.rb
@ -24,7 +24,7 @@ Redmine::Plugin.register :body_tracking do
|
|||||||
:body_trackers => [:defaults],
|
:body_trackers => [:defaults],
|
||||||
:ingredients => [:create, :destroy, :import],
|
:ingredients => [:create, :destroy, :import],
|
||||||
:sources => [:create, :destroy],
|
:sources => [:create, :destroy],
|
||||||
:quantities => [:create, :destroy, :toggle],
|
:quantities => [:create, :destroy, :toggle, :up, :down, :left, :right],
|
||||||
:units => [:create, :destroy],
|
:units => [:create, :destroy],
|
||||||
}, require: :loggedin
|
}, require: :loggedin
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user