diff options
| author | jpl | 2017-04-04 14:59:34 +0200 |
|---|---|---|
| committer | jpl | 2017-04-04 14:59:41 +0200 |
| commit | 043e813ce3c13be2611d20d5e084f2add79afb59 (patch) | |
| tree | f4c44138d86f89ffa84a461403cf8031f2ccaefc | |
| parent | 4bb68cf4748fae774cad7ef6c1e71e91e72a1af6 (diff) | |
| download | chouette-core-043e813ce3c13be2611d20d5e084f2add79afb59.tar.bz2 | |
Refs #2892: starting integration update on timetables#edit
| -rw-r--r-- | app/views/time_tables/_date_fields.html.slim | 20 | ||||
| -rw-r--r-- | app/views/time_tables/_form.html.slim | 93 | ||||
| -rw-r--r-- | app/views/time_tables/_period_fields.html.slim | 25 | ||||
| -rw-r--r-- | app/views/time_tables/edit.html.slim | 13 | ||||
| -rw-r--r-- | spec/features/time_tables_spec.rb | 4 | ||||
| -rw-r--r-- | spec/views/time_tables/edit.html.erb_spec.rb | 6 |
6 files changed, 87 insertions, 74 deletions
diff --git a/app/views/time_tables/_date_fields.html.slim b/app/views/time_tables/_date_fields.html.slim index f17fcaa2c..e9b0c15ba 100644 --- a/app/views/time_tables/_date_fields.html.slim +++ b/app/views/time_tables/_date_fields.html.slim @@ -1,5 +1,15 @@ -= f.inputs class: 'nested-fields date' do - = f.label @time_table.human_attribute_name("date"), class: 'col-md-1' - = f.input :date, as: :date_picker, :label => false, :input_html => { class: 'form-control col-md-3' } - = f.input :in_out, as: :hidden, :input_html => {:value => true} - = link_to_remove_association t('actions.destroy'), f, class: "col-md-3"
\ No newline at end of file +.nested-fields + - if f.object.errors.has_key? :base + .row + .col-lg-12 + .alert.alert-danger + - f.object.errors[:base].each do |message| + p.small = message + + .wrapper + div + / = f.label @time_table.human_attribute_name("date"), class: 'col-md-1' + = f.input :date, as: :date, label: false, wrapper_html: { class: 'date' } + = f.input :in_out, as: :hidden, :input_html => {:value => true} + div + = link_to_remove_association '', f, class: 'fa fa-trash', data: { confirm: 'Etes-vous sûr(e) ?' }, title: t('actions.delete') diff --git a/app/views/time_tables/_form.html.slim b/app/views/time_tables/_form.html.slim index 8652f7cb5..94af1bd01 100644 --- a/app/views/time_tables/_form.html.slim +++ b/app/views/time_tables/_form.html.slim @@ -1,17 +1,21 @@ -= semantic_form_for [@referential, @time_table] do |form| - = form.inputs do - = form.input :comment, :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.time_table.comment")} - = form.input :version - = form.input :tag_search, as: :tags, :input_html => { :id => "tag_search",:placeholder => t("formtastic.placeholders.time_table.tag_search") } - = form.input :tag_list, as: :hidden, :input_html => { :id => "tag_list" } - = form.input :objectid, :required => !@time_table.new_record?, :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.time_table.objectid")} - - if @time_table.new_record? - = form.input :calendar, as: :select, collection: current_organisation.calendars += simple_form_for [@referential, @time_table], html: {class: 'form-horizontal', id: 'timetable_form'}, wrapper: :horizontal_form do |form| + + .row + .col-lg-12 + = form.input :comment, :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.time_table.comment")} + = form.input :version + = form.input :tag_search, as: :select, :input_html => { :id => "tag_search",:placeholder => t("formtastic.placeholders.time_table.tag_search") } + = form.input :tag_list, as: :hidden, :input_html => { :id => "tag_list" } + = form.input :objectid, :required => !@time_table.new_record?, :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.time_table.objectid")} + - if @time_table.new_record? + = form.input :calendar, as: :select, collection: current_organisation.calendars + + .separator + + .row + .col-lg-12 + h3 = @time_table.human_attribute_name('periods') - h3.time_table_periods = @time_table.human_attribute_name("periods") - - #periods_content - = form.inputs class: 'day_type' do label.day_type_label = @time_table.human_attribute_name("day_types") = form.input :monday, as: :boolean, class: "others" = form.input :tuesday, as: :boolean @@ -21,53 +25,34 @@ = form.input :saturday, as: :boolean = form.input :sunday, as: :boolean - #periods - = form.semantic_fields_for :periods do |p| - == render "period_fields", :f => p - - = link_to_add_association t("time_tables.actions.add_period"), form, :periods , :"data-association-insertion-method" => "append", :"data-association-insertion-node" => "div#periods" - - h3.time_table_dates = @time_table.human_attribute_name("dates") - - #dates_content - #dates - = form.semantic_fields_for :dates, @time_table.dates.to_a.select {|d| d.in_out == true} do |p| - == render "date_fields", :f => p - - = link_to_add_association t("time_tables.actions.add_date"), form, :dates, :"data-association-insertion-method" => "append", :"partial" => "date_fields", :"data-association-insertion-node" => "div#dates" + .row + .col-lg-12 + = form.simple_fields_for :periods do |p| + = render "period_fields", f: p - h3.time_table_dates = @time_table.human_attribute_name("excluded_dates") + = link_to_add_association t("time_tables.actions.add_period"), form, :periods, class: 'btn btn-outline-primary' - #excluded_dates_content - #excluded_dates - = form.semantic_fields_for :dates, @time_table.dates.to_a.select {|d| d.in_out == false} do |p| - == render "excluded_date_fields", :f => p + .separator + + .row + .col-lg-12 + h3 = @time_table.human_attribute_name('dates') - = link_to_add_association t("time_tables.actions.add_excluded_date"), form, :dates, :"data-association-insertion-method" => "append", :"partial" => "excluded_date_fields", :"data-association-insertion-node" => "div#excluded_dates" + = form.simple_fields_for :dates, @time_table.dates.to_a.select {|d| d.in_out == true} do |p| + = render "date_fields", f: p - = form.actions do - = form.action :submit, as: :button - = form.action :cancel, as: :link + = link_to_add_association t("time_tables.actions.add_date"), form, :dates, class: 'btn btn-outline-primary' -= javascript_tag "var items = #{ @time_table.tag_list.to_a };" + .separator + + .row + .col-lg-12 + h3 = @time_table.human_attribute_name("excluded_dates") -javascript: - $("#tag_search").tagsManager({ - prefilled: items, - output: '#tag_list', - tagsContainer: '#tagsContainer' - }); + = form.simple_fields_for :dates, @time_table.dates.to_a.select {|d| d.in_out == false} do |p| + = render "excluded_date_fields", f: p - var time_tables_tag_list = new Bloodhound({ - datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'), - queryTokenizer: Bloodhound.tokenizers.whitespace, - remote: "#{tags_referential_time_tables_path(@referential, format: 'json')}?tag=%QUERY", - }); + = link_to_add_association t("time_tables.actions.add_excluded_date"), form, :dates, class: 'btn btn-outline-primary' - time_tables_tag_list.initialize(); - $("#tag_search").typeahead(null, { - name: 'time_tables_tag_list', - displayKey: 'name', - source: time_tables_tag_list.ttAdapter() - }); + = form.button :submit, t('actions.submit'), class: 'btn btn-default formSubmitr', form: 'timetable_form' diff --git a/app/views/time_tables/_period_fields.html.slim b/app/views/time_tables/_period_fields.html.slim index cefa68df5..d6f97a731 100644 --- a/app/views/time_tables/_period_fields.html.slim +++ b/app/views/time_tables/_period_fields.html.slim @@ -1,8 +1,17 @@ -= f.inputs class: 'nested-fields period' do - = f.label @time_table.human_attribute_name("period_start"), class: "col-md-1" - = f.input :period_start, as: :date_picker, :label => false, :input_html => { class: 'form-control col-md-3' } - - = f.label @time_table.human_attribute_name("period_end"), class: "col-md-1" - = f.input :period_end, as: :date_picker, :label => false, :input_html => { class: 'form-control col-md-3' } - - = link_to_remove_association t('actions.destroy'), f, class: "col-md-2"
\ No newline at end of file +.nested-fields + - if f.object.errors.has_key? :base + .row + .col-lg-12 + .alert.alert-danger + - f.object.errors[:base].each do |message| + p.small = message + + .wrapper + div + / = f.label @time_table.human_attribute_name("period_start") + = f.input :period_start, as: :date, label: false, wrapper_html: { class: 'date' } + div + / = f.label @time_table.human_attribute_name("period_end") + = f.input :period_end, as: :date, label: false, wrapper_html: { class: 'date' } + div + = link_to_remove_association '', f, class: 'fa fa-trash', data: { confirm: 'Etes-vous sûr(e) ?' }, title: t('actions.delete') diff --git a/app/views/time_tables/edit.html.slim b/app/views/time_tables/edit.html.slim index 1746b48c7..4f7cab845 100644 --- a/app/views/time_tables/edit.html.slim +++ b/app/views/time_tables/edit.html.slim @@ -1,3 +1,12 @@ -= title_tag t('time_tables.edit.title', :time_table => @time_table.comment) +/ PageHeader += pageheader 'map-marker', + @time_table.comment, + '', + '' -== render 'form'
\ No newline at end of file +/ PageContent +.page_content + .container-fluid + .row + .col-lg-8.col-lg-offset-2.col-md-8.col-md-offset-2.col-sm-10.col-sm-offset-1 + == render 'form' diff --git a/spec/features/time_tables_spec.rb b/spec/features/time_tables_spec.rb index 8e0b62c89..975160979 100644 --- a/spec/features/time_tables_spec.rb +++ b/spec/features/time_tables_spec.rb @@ -126,7 +126,7 @@ describe "TimeTables", :type => :feature do click_link "Ajouter un calendrier" fill_in "Nom", :with => "TimeTable 1" fill_in "Identifiant Neptune", :with => "test:Timetable:1" - click_button("Créer calendrier") + click_button("Valider") expect(page).to have_content("TimeTable 1") end end @@ -136,7 +136,7 @@ describe "TimeTables", :type => :feature do visit referential_time_table_path(referential, subject) click_link "Editer ce calendrier" fill_in "Nom", :with => "TimeTable Modified" - click_button("Editer calendrier") + click_button("Valider") expect(page).to have_content("TimeTable Modified") end end diff --git a/spec/views/time_tables/edit.html.erb_spec.rb b/spec/views/time_tables/edit.html.erb_spec.rb index 18c5d6d85..35d360042 100644 --- a/spec/views/time_tables/edit.html.erb_spec.rb +++ b/spec/views/time_tables/edit.html.erb_spec.rb @@ -5,9 +5,9 @@ describe "/time_tables/edit", :type => :view do let!(:time_table) { assign(:time_table, create(:time_table) ) } describe "test" do - it "should render h2 with the group comment" do - render - expect(rendered).to have_selector("h2", :text => Regexp.new(time_table.comment)) + it "should render h1 with the group comment" do + render + expect(rendered).to have_selector("h1", :text => Regexp.new(time_table.comment)) end end |
