diff options
| -rw-r--r-- | app/controllers/autocomplete_time_tables_controller.rb | 4 | ||||
| -rw-r--r-- | app/models/chouette/time_table.rb | 6 | ||||
| -rw-r--r-- | app/views/time_table_combinations/_form.html.slim | 2 |
3 files changed, 6 insertions, 6 deletions
diff --git a/app/controllers/autocomplete_time_tables_controller.rb b/app/controllers/autocomplete_time_tables_controller.rb index e977a28b0..e5d2b41ae 100644 --- a/app/controllers/autocomplete_time_tables_controller.rb +++ b/app/controllers/autocomplete_time_tables_controller.rb @@ -15,9 +15,9 @@ class AutocompleteTimeTablesController < InheritedResources::Base protected def select_time_tables - scope = referential.time_tables + scope = referential.time_tables.where("time_tables.id != ?", params[:source_id]) if params[:route_id] - scope = scope.joins(vehicle_journeys: :route).where( "routes.id IN (#{params[:route_id]})") + scope = scope.joins(vehicle_journeys: :route).where( "routes.id IN (#{params[:route_id]}) AND time_tables.id != #{params[:time_table_id]}") end scope end diff --git a/app/models/chouette/time_table.rb b/app/models/chouette/time_table.rb index 97d2e7556..3f56f6a1d 100644 --- a/app/models/chouette/time_table.rb +++ b/app/models/chouette/time_table.rb @@ -487,7 +487,7 @@ class Chouette::TimeTable < Chouette::TridentActiveRecord def merge!(another_tt) transaction do days = [].tap do |array| - array.push(*self.included_days_in_dates_and_periods, *another_tt.effective_days) + array.push(*self.effective_days, *another_tt.effective_days) array.uniq! end @@ -516,7 +516,7 @@ class Chouette::TimeTable < Chouette::TridentActiveRecord def intersect!(another_tt) transaction do days = [].tap do |array| - array.push(*self.included_days_in_dates_and_periods) + array.push(*self.effective_days) array.delete_if {|day| !another_tt.effective_days.include?(day) } array.uniq! end @@ -536,7 +536,7 @@ class Chouette::TimeTable < Chouette::TridentActiveRecord def disjoin!(another_tt) transaction do days = [].tap do |array| - array.push(*self.included_days_in_dates_and_periods) + array.push(*self.effective_days) array.delete_if {|day| another_tt.effective_days.include?(day) } array.uniq! end diff --git a/app/views/time_table_combinations/_form.html.slim b/app/views/time_table_combinations/_form.html.slim index b4f818828..581f00457 100644 --- a/app/views/time_table_combinations/_form.html.slim +++ b/app/views/time_table_combinations/_form.html.slim @@ -7,7 +7,7 @@ abbr title='Champ requis' * = f.input :combined_type, as: :boolean, checked_value: 'time_table', unchecked_value: 'calendar', required: false, label: content_tag(:span, t("time_table_combinations.combined_type.#{@combination.combined_type}"), class: 'switch-label', data: { checkedValue: 'Calendriers', uncheckedValue: 'Modèles de calendriers' }), wrapper_html: { class: 'col-sm-8 col-xs-7' } - = f.input :time_table_id, as: :select, input_html: {class: 'tt_combination_target', style: "width: 100%", data: { 'select2-ajax': 'true', 'select2ed-placeholder': 'Indiquez un calendrier...', term: 'comment_or_objectid_cont', url: referential_autocomplete_time_tables_path(@referential, format: :json)}}, wrapper_html: {class: @combination.combined_type != 'time_table' ? 'hidden' : ''} + = f.input :time_table_id, as: :select, input_html: {class: 'tt_combination_target', style: "width: 100%", data: { 'select2-ajax': 'true', 'select2ed-placeholder': 'Indiquez un calendrier...', term: 'comment_or_objectid_cont', url: referential_autocomplete_time_tables_path(@referential, format: :json, :source_id => @combination.source_id)}}, wrapper_html: {class: @combination.combined_type != 'time_table' ? 'hidden' : ''} = f.input :calendar_id, as: :select, input_html: { class: 'tt_combination_target', style: "width: 100%", data: { 'select2-ajax': 'true', 'select2ed-placeholder': 'Indiquez un modèle de calendrier...', term: 'name_cont', url: autocomplete_calendars_path}}, wrapper_html: {class: @combination.combined_type != 'calendar' ? 'hidden' : ''} |
