Skip to content

Commit

Permalink
Fixes #1363, clear article price on new article form
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Altmann committed Mar 13, 2015
1 parent 3795310 commit dc40ce1
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
3 changes: 2 additions & 1 deletion app/views/articles/_form.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@
/ You should have received a copy of the GNU Affero General Public License
/ along with Fairmondo. If not, see <http://www.gnu.org/licenses/>.
/
- edit_form = false unless local_assigns.has_key?(:edit_form)

.article-form.Accordion.Accordion--activated.Accordion--scrollToActive
= render "articles/form/article_template_select"
= semantic_form_for resource, html: {multipart: true, class: 'js-visual-submit js-category-add'}, builder: ::Fairtastic::FormBuilder do |f|
= f.semantic_errors
= render "articles/form/common_inputs", f: f
= render "articles/form/common_inputs", f: f, edit_form: edit_form
/ validity checked in policy
= f.hidden_field :original_id
= f.input_step :double_check, :prefix => false do
Expand Down
2 changes: 1 addition & 1 deletion app/views/articles/edit.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
/ along with Fairmondo. If not, see <http://www.gnu.org/licenses/>.
/
h1= t('article.titles.edit')
= render 'form'
= render "form", edit_form: true
7 changes: 6 additions & 1 deletion app/views/articles/form/_common_inputs.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
/ along with Fairmondo. If not, see <http://www.gnu.org/licenses/>.
/
/ Lieferzeit, preise? (auch le), DELETE CHROME PASSWORD
- edit_form = false unless local_assigns.has_key?(:edit_form)

= f.input_step :title_and_categories, default_step: true do
= f.inputs do
.Accordion-step
Expand All @@ -45,7 +47,10 @@
.Accordion-step
= f.input :quantity, tooltip: true, input_html: { class: 'JS-enforce-input-constraints' }
.Accordion-step
= f.input :price, tooltip: true, input_html: { value: number_with_precision(f.object.price, precision: 2), class: 'JS-remote-validate-blur' }, required: true
= f.input :price, tooltip: true, required: true,
input_html: { value: (edit_form ? number_with_precision(f.object.price, precision: 2) : ""),
placeholder: "0,00",
class: "JS-remote-validate-blur" }
- if current_user.is_a?(LegalEntity)
.Accordion-step
= f.input :basic_price, tooltip: true, input_html: { value: number_with_precision(f.object.basic_price, precision: 2) }
Expand Down
4 changes: 2 additions & 2 deletions app/views/articles/new.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
/ You should have received a copy of the GNU Affero General Public License
/ along with Fairmondo. If not, see <http://www.gnu.org/licenses/>.
/
h1= t('article.titles.new')
h1= t("article.titles.new")
- if current_user.is_a?(PrivateUser)
p= tinycms_content "article-introduction-private"
- elsif current_user.is_a?(LegalEntity)
p= tinycms_content "article-introduction-legal"
= render 'form'
= render "form", edit_form: params[:edit_as_new] ? true : false
2 changes: 2 additions & 0 deletions test/features/articles_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ def fill_form_with_valid_article
choose "article_condition_new"
end

fill_in I18n.t('formtastic.labels.article.price'), with: '5,00'

if @user.is_a? LegalEntity
fill_in I18n.t('formtastic.labels.article.basic_price'), with: '99,99'
select I18n.t("enumerize.article.basic_price_amount.kilogram"), from: I18n.t('formtastic.labels.article.basic_price_amount')
Expand Down

0 comments on commit dc40ce1

Please sign in to comment.