Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/helpers/spree/admin/base_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,10 @@ def product_wysiwyg_editor_enabled?
def taxon_wysiwyg_editor_enabled?
Spree::Backend::Config[:taxon_wysiwyg_editor_enabled]
end

def number_validation_pattern
'^[0-9]*([.,][0-9]*)*$'
end
end
end
end
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' %>
<%= text_field_tag "vp[#{variant.id}][#{code}][price]", (price && price.price ? price.display_amount.money : ''), class: 'form-control', pattern: number_validation_pattern %>
</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' %>
<%= text_field_tag "vp[#{variant.id}][#{code}][compare_at_price]", (price && price.compare_at_price ? price.display_compare_at_amount.money : ''), class: 'form-control', pattern: number_validation_pattern %>
</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.text_field :price, value: number_to_currency(@product.amount_in(current_currency), unit: ''), class: 'form-control', disabled: (cannot? :update, @product.master.default_price), pattern: number_validation_pattern %>
</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.text_field :compare_at_price, value: number_to_currency(@product.compare_at_amount_in(current_currency), unit: ''), class: 'form-control', pattern: number_validation_pattern %>
</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.text_field :cost_price, value: number_to_currency(@product.cost_price, unit: ''), class: 'form-control', pattern: number_validation_pattern %>
<%= f.error_message_on :cost_price %>
<% end %>
</div>
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.text_field :price, value: number_to_currency(@product.price, unit: ''), class: 'form-control', required: :required, pattern: number_validation_pattern %>
</div>
<%= f.error_message_on :price %>
<% end %>
Expand Down