Skip to content

Commit

Permalink
Change price text input fields to number input fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksandar Petrushev committed Dec 22, 2021
1 parent 3fab47d commit 3999dd4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions app/views/spree/admin/prices/_variant_prices.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
<td class="panel-title"><%= variant.sku %></td>
<td><%= label_tag "vp[#{variant.id}][#{code}]", code %></td>
<td>
<%= text_field_tag "vp[#{variant.id}][#{code}][price]", (price && price.price ? price.display_amount.money : ''), class: 'form-control' %>
<%= number_field_tag "vp[#{variant.id}][#{code}][price]", (price && price.price ? price.display_amount.money : ''), step: 0.01, min: 0, class: 'form-control' %>
</td>
<td>
<%= text_field_tag "vp[#{variant.id}][#{code}][compare_at_price]", (price && price.compare_at_price ? price.display_compare_at_amount.money : ''), class: 'form-control' %>
<%= number_field_tag "vp[#{variant.id}][#{code}][compare_at_price]", (price && price.compare_at_price ? price.display_compare_at_amount.money : ''), step: 0.01, min: 0, class: 'form-control' %>
</td>
</tr>
<% end %>
Expand Down
8 changes: 4 additions & 4 deletions app/views/spree/admin/products/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
<div class="col-12 col-md-4" data-hook="admin_product_form_right">
<div data-hook="admin_product_form_price">
<%= f.field_container :price do %>
<%= f.label :price, raw(Spree.t(:master_price) + required_span_tag) %>
<%= f.label :price, raw(Spree.t(:price) + required_span_tag) %>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><%= currency_symbol(current_currency) %></span>
</div>
<%= f.text_field :price, value: number_to_currency(@product.amount_in(current_currency), unit: ''), class: 'form-control', disabled: (cannot? :update, @product.master.default_price) %>
<%= f.number_field :price, value: number_to_currency(@product.amount_in(current_currency), delimiter: '', unit: ''), step: 0.01, min: 0, class: 'form-control', required: :required, disabled: (cannot? :update, @product.master.default_price) %>
</div>
<%= f.error_message_on :price %>
<% end %>
Expand All @@ -48,7 +48,7 @@
<div class="input-group-prepend">
<span class="input-group-text"><%= currency_symbol(current_currency) %></span>
</div>
<%= f.text_field :compare_at_price, value: number_to_currency(@product.compare_at_amount_in(current_currency), unit: ''), class: 'form-control' %>
<%= f.number_field :compare_at_price, value: number_to_currency(@product.compare_at_amount_in(current_currency), delimiter: '', unit: ''), step: 0.01, min: 0, class: 'form-control' %>
</div>
<%= f.error_message_on :compare_at_price %>
<% end %>
Expand All @@ -57,7 +57,7 @@
<div data-hook="admin_product_form_cost_price" class="alpha two columns">
<%= f.field_container :cost_price do %>
<%= f.label :cost_price, Spree.t(:cost_price) %>
<%= f.text_field :cost_price, value: number_to_currency(@product.cost_price, unit: ''), class: 'form-control' %>
<%= f.number_field :cost_price, value: number_to_currency(@product.cost_price, delimiter: '', unit: ''), step: 0.01, min: 0, class: 'form-control' %>
<%= f.error_message_on :cost_price %>
<% end %>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/spree/admin/products/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<th scope="col"><%= Spree.t('admin.digitals.digital') %></th>
<th scope="col"><%= Spree.t(:status) %></th>
<th scope="col" class="text-center">
<%= sort_link @search, :master_default_price_amount, Spree.t(:master_price), {}, {title: 'admin_products_listing_price_title'} %>
<%= sort_link @search, :master_default_price_amount, Spree.t(:price), {}, {title: 'admin_products_listing_price_title'} %>
</th>
<th scope="col" data-hook="admin_products_index_header_actions" class="actions"></th>
</tr>
Expand Down
4 changes: 2 additions & 2 deletions app/views/spree/admin/products/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@

<div data-hook="new_product_price" class="col-12 col-md-4">
<%= f.field_container :price do %>
<%= f.label :price, raw(Spree.t(:master_price) + required_span_tag) %>
<%= f.label :price, raw(Spree.t(:price) + required_span_tag) %>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><%= currency_symbol(current_currency) %></span>
</div>
<%= f.text_field :price, value: number_to_currency(@product.price, unit: ''), class: 'form-control', required: :required %>
<%= f.number_field :price, value: number_to_currency(@product.price, delimiter: '', unit: ''), step: 0.01, min: 0, class: 'form-control', required: :required %>
</div>
<%= f.error_message_on :price %>
<% end %>
Expand Down

0 comments on commit 3999dd4

Please sign in to comment.