1
0

Added quantity edit form

Changed quantity long text field width setting
This commit is contained in:
cryptogopher
2019-11-24 01:26:35 +01:00
parent 8c073494e5
commit fdfedf3bc9
9 changed files with 116 additions and 81 deletions

View File

@@ -9,8 +9,9 @@
</div>
<% end %>
<p><%= f.text_field :name, size: 25, required: true %></p>
<p><%= f.text_field :description, size: 200 %></p>
<p><%= f.text_field :formula, size: 200, placeholder: t('.formula_placeholder') %></p>
<p><%= f.text_field :description, style: "width: 100%;" %></p>
<p><%= f.text_field :formula, placeholder: t('.formula_placeholder'),
style: "width: 100%;" %></p>
<p><%= f.check_box :primary %></p>
</div>

View File

@@ -0,0 +1,81 @@
<%= render :partial => 'quantities/filters',
:locals => {:url => filter_project_quantities_path(@project)} %>
<% if @quantities.any? { |q| q.persisted? } %>
<table class="list">
<thead>
<tr>
<th><%= l(:field_name) %></th>
<th><%= l(:field_order) %></th>
<th><%= l(:field_domain) %></th>
<th><%= l(:field_description) %></th>
<th><%= l(:field_action) %></th>
</tr>
</thead>
<tbody>
<% Quantity.each_with_level(@quantities) do |q, level| %>
<%
next if q.new_record?
quantity_class = "quantity"
quantity_class += " project idnt idnt-#{level+1}"
quantity_class += " primary" if q.primary
%>
<tr id="quantity-<%= q.id %>" class="<%= quantity_class %>">
<td class="name">
<%= link_to '', toggle_quantity_path(q), {
remote: true,
method: :post,
class: "icon #{q.primary ? "icon-fav" : "icon-fav-off"}"
}
%>
<%= q.name %>
</td>
<td class="order">
<% [: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 %>
</td>
<td class="domain"><%= q.domain %></td>
<td class="description"><%= q.description %></td>
<td class="action">
<%=
link_to l(:button_edit), edit_quantity_path(q), {
remote: true,
class: "icon icon-edit"
}
%>
<%= delete_link quantity_path(q), {remote: true, data: {}} %>
</td>
</tr>
<% next unless (action_name == "edit") && (q == @quantity) %>
<tr>
<td class="form" colspan="6">
<div id="edit-quantity">
<%= 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 %>
</div>
</td>
</tr>
<% end %>
</tbody>
</table>
<% else %>
<p class="nodata"><%= l(:label_no_data) %></p>
<% end %>

View File

@@ -1,60 +0,0 @@
<%= render :partial => 'quantities/filters',
:locals => {:url => filter_project_quantities_path(@project)} %>
<% if @quantities.any? { |q| q.persisted? } %>
<table class="list">
<thead>
<tr>
<th><%= l(:field_name) %></th>
<th><%= l(:field_order) %></th>
<th><%= l(:field_domain) %></th>
<th><%= l(:field_description) %></th>
<th><%= l(:field_action) %></th>
</tr>
</thead>
<tbody>
<% Quantity.each_with_level(@quantities) do |q, level| %>
<%
next if q.new_record?
quantity_class = "quantity"
quantity_class += " project idnt idnt-#{level+1}"
quantity_class += " primary" if q.primary
quantity_class += " anchor" if @anchor == q.id
%>
<tr id="quantity-<%= q.id %>" class="<%= quantity_class %>">
<td class="name">
<%= link_to '', toggle_quantity_path(q), {
remote: true,
method: :post,
class: "icon #{q.primary ? "icon-fav" : "icon-fav-off"}"
}
%>
<%= q.name %>
</td>
<td class="order">
<% [: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 %>
</td>
<td class="domain"><%= q.domain %></td>
<td class="description"><%= q.description %></td>
<td class="action">
<%= delete_link quantity_path(q), {remote: true, data: {}} %>
</td>
</tr>
<% end %>
</tbody>
</table>
<% else %>
<p class="nodata"><%= l(:label_no_data) %></p>
<% end %>

View File

@@ -5,7 +5,7 @@
<div class="contextual">
<% if User.current.allowed_to?(:manage_common, @project) %>
<%= link_to t(".link_new_quantity"), '#', :class => 'icon icon-add',
:onclick => '$("#add-quantity").show(); $("#quantity_name").focus(); return false;' %>
:onclick => '$("#add-quantity").toggle(); $("#quantity_name").focus(); return false;' %>
<% end %>
</div>
@@ -24,5 +24,5 @@
<h2><%= t ".heading" %></h2>
<div id='quantities'>
<%= render :partial => 'quantities/list' %>
<%= render :partial => 'quantities/index' %>
</div>

View File

@@ -1,3 +1,3 @@
$('div[id^=flash_]').remove();
$('#content').prepend('<%= escape_javascript(render_flash_messages) %>');
$('#quantities').html('<%= escape_javascript(render :partial => 'quantities/list') %>');
$('#quantities').html('<%= escape_javascript(render :partial => 'quantities/index') %>');