diff options
| -rw-r--r-- | app/controllers/time_table_combinations_controller.rb | 23 | ||||
| -rw-r--r-- | app/views/time_table_combinations/_combine.html.erb | 2 | ||||
| -rw-r--r-- | app/views/time_table_combinations/new.js.erb | 4 | ||||
| -rw-r--r-- | app/views/time_tables/show.html.erb | 2 | 
4 files changed, 25 insertions, 6 deletions
| diff --git a/app/controllers/time_table_combinations_controller.rb b/app/controllers/time_table_combinations_controller.rb index baaf90fec..32a3dcab9 100644 --- a/app/controllers/time_table_combinations_controller.rb +++ b/app/controllers/time_table_combinations_controller.rb @@ -1,24 +1,39 @@  class TimeTableCombinationsController < ChouetteController -  respond_to :js, :only => [:create] +  respond_to :js, :only => [:new,:create]    belongs_to :referential do      belongs_to :time_table, :parent_class => Chouette::TimeTable     end +  after_filter :clean_flash + +  def clean_flash +    # only run this in case it's an Ajax request. +    return unless request.xhr? +    flash.discard +  end + +  def new +    @time_table_combination = TimeTableCombination.new(:source_id => parent.id) +    render :action => :new +  end +    def create      @time_table_combination = TimeTableCombination.new( params[:time_table_combination].merge( :source_id => parent.id)) -    #@time_table = parent      @year = params[:year] ? params[:year].to_i : Date.today.cwyear      if @time_table_combination.valid?        begin          @time_table = @time_table_combination.combine          flash[:notice] = t('time_table_combinations.success')          render "create_success" -      rescue Exception=> e -        Rails.logger.error "Error: #{e}" +        rescue => e +          Rails.logger.error( "TimeTableCombination error, @time_table_combination=#{@time_table_combination.inspect}") +          Rails.logger.error( e.inspect)          flash[:error] = t('time_table_combinations.failure')          render "create_failure"        end +    else  +      render "create_failure"      end    end diff --git a/app/views/time_table_combinations/_combine.html.erb b/app/views/time_table_combinations/_combine.html.erb index 85fc5ab26..27b5f056f 100644 --- a/app/views/time_table_combinations/_combine.html.erb +++ b/app/views/time_table_combinations/_combine.html.erb @@ -1,4 +1,4 @@ -<div id="combine_form" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> +<div id="modal_combine" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">    <div class="modal-dialog">      <div class="modal-content">        <div class="modal-header"> diff --git a/app/views/time_table_combinations/new.js.erb b/app/views/time_table_combinations/new.js.erb new file mode 100644 index 000000000..ea98d9aaf --- /dev/null +++ b/app/views/time_table_combinations/new.js.erb @@ -0,0 +1,4 @@ +var combine_form_partial = '<%= j render "time_table_combinations/combine_form" %> '; +$('#new_time_table_combination').replaceWith(combine_form_partial); + + diff --git a/app/views/time_tables/show.html.erb b/app/views/time_tables/show.html.erb index e02d96a58..7e9a5aa62 100644 --- a/app/views/time_tables/show.html.erb +++ b/app/views/time_tables/show.html.erb @@ -12,7 +12,7 @@    <li><%= link_to t('time_tables.actions.edit'), edit_referential_time_table_path(@referential, @time_table), :class => "edit" %></li>    <li><%= link_to t('time_tables.actions.destroy'), referential_time_table_path(@referential, @time_table), :method => :delete, :data => {:confirm =>  t('time_tables.actions.destroy_confirm')}, :class => "remove" %></li>    <li><font color="green"><i class="fa fa-files-o fa-fw"></i></font><%= link_to t('time_tables.actions.duplicate'), duplicate_referential_time_table_path(@referential, @time_table), :class => "with_fa" %></li> -  <li><font color="#D98F3B"><i class="fa fa-cogs fa-fw"></i></font><%= link_to t('time_tables.actions.combine'), '#combine_form', 'data-toggle' => 'modal', :class => "with_fa"%></li> +  <li><font color="#D98F3B"><i class="fa fa-cogs fa-fw"></i></font><%= link_to t('time_tables.actions.combine'), new_referential_time_table_time_table_combination_path(@referential, @time_table), {:remote => true, 'data-toggle' =>  "modal", 'data-target' => '#modal_combine', :class => "with_fa"} %></li>  </ul> | 
