diff options
| author | jpl | 2017-04-07 12:17:47 +0200 | 
|---|---|---|
| committer | jpl | 2017-04-07 12:18:47 +0200 | 
| commit | a31103a83f25844d0d928d248313d86cedf7be5d (patch) | |
| tree | 65a60fdd4d888601a04b6c139406129fdd18e5fc | |
| parent | 700927525b24ecbbb730db468117838cfd2a1676 (diff) | |
| download | chouette-core-a31103a83f25844d0d928d248313d86cedf7be5d.tar.bz2 | |
Refs #3076: fix include/exclude dates in form for timetables#edit
| -rw-r--r-- | app/helpers/time_tables_helper.rb | 10 | ||||
| -rw-r--r-- | app/views/time_tables/_excluded_date_fields.html.slim | 20 | ||||
| -rw-r--r-- | app/views/time_tables/_form.html.slim | 8 | ||||
| -rw-r--r-- | app/views/time_tables/_show_time_table.html.slim | 43 | ||||
| -rw-r--r-- | app/views/time_tables/show.html.slim | 7 | 
5 files changed, 50 insertions, 38 deletions
| diff --git a/app/helpers/time_tables_helper.rb b/app/helpers/time_tables_helper.rb index 267c896bd..88dbda061 100644 --- a/app/helpers/time_tables_helper.rb +++ b/app/helpers/time_tables_helper.rb @@ -20,10 +20,10 @@ module TimeTablesHelper        :table_id            => "calendar-#{options[:year]}-#{"%02d" % options[:month]}",        :table_class         => 'calendar',        :month_name_class    => 'monthName', -      :other_month_class   => 'otherMonth', +      :other_month_class   => 'outsideMonth',        :day_name_class      => 'dayName',        :day_class           => 'day', -      :abbrev              => true, +      :abbrev              => false,        :first_day_of_week   => 0,        :accessible          => false,        :show_today          => true, @@ -69,7 +69,7 @@ module TimeTablesHelper      week_days.each do |wday|        cal << %(<th id="#{th_id(Date::DAYNAMES[wday], options[:table_id])}" scope="col">) -      cal << (options[:abbrev] ? %(<abbr title="#{day_names[wday]}">#{t("calendars.days.#{Date::DAYNAMES[wday].downcase}")}</abbr>) : day_names[wday]) +      cal << (options[:abbrev] ? %(<abbr title="#{day_names[wday]}">#{t("calendars.days.#{Date::DAYNAMES[wday].downcase}")}</abbr>) : t("calendars.days.#{Date::DAYNAMES[wday].downcase}"))        cal << %(</th>)      end @@ -86,7 +86,7 @@ module TimeTablesHelper        cell_attrs ||= {}        cell_attrs[:headers] = th_id(cur, options[:table_id])        cell_attrs[:class] ||= options[:day_class] -      cell_attrs[:class] += " weekendDay" if [0, 6].include?(cur.wday) +      cell_attrs[:class] += " weekend" if [0, 6].include?(cur.wday)        today = (Time.respond_to?(:zone) && !(zone = Time.zone).nil? ? zone.now.to_date : Date.today)        cell_attrs[:class] += " today" if (cur == today) and options[:show_today] @@ -139,7 +139,7 @@ module TimeTablesHelper      cell_attrs = {}      cell_attrs[:headers] = th_id(date, options[:table_id])      cell_attrs[:class] = options[:other_month_class] -    cell_attrs[:class] += " weekendDay" if weekend?(date) +    cell_attrs[:class] += " weekend" if weekend?(date)      cell_text = date.day      if options[:accessible] diff --git a/app/views/time_tables/_excluded_date_fields.html.slim b/app/views/time_tables/_excluded_date_fields.html.slim index 294d103fc..dba5bf952 100644 --- a/app/views/time_tables/_excluded_date_fields.html.slim +++ b/app/views/time_tables/_excluded_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 => false} -  = 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: false} +    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 f97e63d33..65c23231d 100644 --- a/app/views/time_tables/_form.html.slim +++ b/app/views/time_tables/_form.html.slim @@ -78,7 +78,7 @@            = render "date_fields",  f: p          .links.nested-linker -          = link_to_add_association t("time_tables.actions.add_date"), form, :dates, class: 'btn btn-outline-primary' +          = link_to_add_association t("time_tables.actions.add_date"), form, :dates, partial: 'date_fields', class: 'btn btn-outline-primary'      .col-lg-6.col-md-6.col-sm-12.col-xs-12        .subform @@ -90,11 +90,11 @@                    = @time_table.human_attribute_name("excluded_dates")              div -        = form.simple_fields_for :dates, @time_table.dates.to_a.select {|d| d.in_out == false}  do |p| -          = render "excluded_date_fields",  f: p +        = form.simple_fields_for :dates, @time_table.dates.to_a.select {|d| d.in_out == false}  do |q| +          = render "excluded_date_fields",  f: q          .links.nested-linker -          = link_to_add_association t("time_tables.actions.add_excluded_date"), form, :dates, class: 'btn btn-outline-primary' +          = link_to_add_association t("time_tables.actions.add_excluded_date"), form, :dates, partial: 'excluded_date_fields', class: 'btn btn-outline-primary'    = form.button :submit, t('actions.submit'), class: 'btn btn-default formSubmitr', form: 'timetable_form' diff --git a/app/views/time_tables/_show_time_table.html.slim b/app/views/time_tables/_show_time_table.html.slim index b1eeb690b..5688e9d08 100644 --- a/app/views/time_tables/_show_time_table.html.slim +++ b/app/views/time_tables/_show_time_table.html.slim @@ -1,22 +1,25 @@ -- (1..12).each do |month| -  .col-lg-2.col-md-3.col-sm-3.col-xs-6 -    = new_alt_calendar(year: @year, month: month, first_day_of_week: 1, calendar_title: "#{I18n.t("date.month_names")[month]} #{@year}") do |d| -      - if @time_table.excluded_date?(d) -        - [link_to(d.mday, edit_referential_time_table_path(@referential, @time_table) ), {class: "day excluded_date"}] -      - elsif @time_table.include_in_overlap_dates?(d) -        - [link_to(d.mday, edit_referential_time_table_path(@referential, @time_table) ), {class: "day overlaped_date"}] -      - elsif @time_table.include_in_dates?(d) -        - [link_to(d.mday, edit_referential_time_table_path(@referential, @time_table) ), {class: "day selected_date"}] -      - elsif @time_table.include_in_periods?(d) -        - [link_to(d.mday, edit_referential_time_table_path(@referential, @time_table) ), {class: "day selected_period"}] +.row +  - (1..12).each do |month| +    .col-lg-3.col-md-4.col-sm-4.col-xs-6 +      = new_alt_calendar(year: @year, month: month, first_day_of_week: 1, calendar_title: "#{I18n.t("date.month_names")[month]} #{@year}") do |d| +        - if @time_table.excluded_date?(d) +          - [link_to(d.mday, edit_referential_time_table_path(@referential, @time_table) ), {class: "day excluded_date"}] +        - elsif @time_table.include_in_overlap_dates?(d) +          - [link_to(d.mday, edit_referential_time_table_path(@referential, @time_table) ), {class: "day overlaped_date"}] +        - elsif @time_table.include_in_dates?(d) +          - [link_to(d.mday, edit_referential_time_table_path(@referential, @time_table) ), {class: "day selected_date"}] +        - elsif @time_table.include_in_periods?(d) +          - [link_to(d.mday, edit_referential_time_table_path(@referential, @time_table) ), {class: "day selected_period"}] -/ wip -- if @time_table.dates.where("in_out = true").present? -  h3.time_table_dates = @time_table.human_attribute_name("dates") -  .dates.content -    == render "time_tables/dates" +.row +  .col-lg-12 +    / wip +    - if @time_table.dates.where("in_out = true").present? +      h3.time_table_dates = @time_table.human_attribute_name("dates") +      .dates.content +        == render "time_tables/dates" -- if @time_table.dates.where("in_out = false").present? -  h3.time_table_dates = @time_table.human_attribute_name("excluded_dates") -  .excluded_dates.content -    == render "time_tables/excluded_dates" +    - if @time_table.dates.where("in_out = false").present? +      h3.time_table_dates = @time_table.human_attribute_name("excluded_dates") +      .excluded_dates.content +        == render "time_tables/excluded_dates" diff --git a/app/views/time_tables/show.html.slim b/app/views/time_tables/show.html.slim index 18604dab9..c37a01fa8 100644 --- a/app/views/time_tables/show.html.slim +++ b/app/views/time_tables/show.html.slim @@ -35,15 +35,14 @@              "Journées d'application pour les périodes ci-dessous" => %w(monday tuesday wednesday thursday friday saturday sunday).collect{ |d| content_tag(:span, t("calendars.days.#{d}"), class: "label label-default #{@time_table.send(d) ? '' : 'disabled'}") }.join.html_safe }      .row -      .col-lg-12 +      .col-lg-12.mb-sm          .pagination.pull-right -          = @year +          / = @year            .page_links              = link_to '', referential_time_table_path(@referential, @time_table, year: (@year - 1)), class: 'previous_page'              = link_to '', referential_time_table_path(@referential, @time_table, year: (@year + 1)), class: 'next_page' -    .row -      = render 'show_time_table' +    = render 'show_time_table'      .row        .col-lg-12 | 
