Hide title field for primary progress bars

These bars don't have a title.
This commit is contained in:
Javi Martín
2019-01-04 16:26:35 +01:00
committed by decabeza
parent c5d32c5ab9
commit dfdf0b0636
2 changed files with 18 additions and 0 deletions

View File

@@ -28,9 +28,22 @@ App.Forms =
input: -> input: ->
$("[name='#{this.name}']").val($(this).val()) $("[name='#{this.name}']").val($(this).val())
hideOrShowFieldsAfterSelection: ->
$("[name='progress_bar[kind]']").on
change: ->
title_field = $("[name^='progress_bar'][name$='[title]']").parent()
if this.value == "primary"
title_field.addClass("hide")
else
title_field.removeClass("hide")
$("[name='progress_bar[kind]']").change()
initialize: -> initialize: ->
App.Forms.disableEnter() App.Forms.disableEnter()
App.Forms.submitOnChange() App.Forms.submitOnChange()
App.Forms.toggleLink() App.Forms.toggleLink()
App.Forms.synchronizeInputs() App.Forms.synchronizeInputs()
App.Forms.hideOrShowFieldsAfterSelection()
false false

View File

@@ -34,6 +34,8 @@ shared_examples "progressable" do |factory_name, path_name|
select "Primary", from: "Type" select "Primary", from: "Type"
expect(page).not_to have_field "Title"
fill_in "Current progress", with: 43 fill_in "Current progress", with: 43
click_button "Create Progress bar" click_button "Create Progress bar"
@@ -65,6 +67,9 @@ shared_examples "progressable" do |factory_name, path_name|
visit path visit path
within("#progress_bar_#{bar.id}") { click_link "Edit" } within("#progress_bar_#{bar.id}") { click_link "Edit" }
expect(page).to have_field "Current progress"
expect(page).not_to have_field "Title"
fill_in "Current progress", with: 44 fill_in "Current progress", with: 44
click_button "Update Progress bar" click_button "Update Progress bar"