diff options
| author | Robert | 2017-07-27 12:11:29 +0200 |
|---|---|---|
| committer | Robert | 2017-07-27 12:11:29 +0200 |
| commit | 60ae8866d6d4c55bc064a2a83c1a1ffa87894202 (patch) | |
| tree | 39b0601a1ea043903de3952e585a930f7e231d43 /app/controllers | |
| parent | 3fb343af351bfa4691ed3c7eb0930d9bb8d0d7ac (diff) | |
| parent | 870f75c2411a8a46c15a0766713df9a3611f2eaf (diff) | |
| download | chouette-core-60ae8866d6d4c55bc064a2a83c1a1ffa87894202.tar.bz2 | |
Merge branch 'master' into 1726-WorkbenchImport-for-multi-Netex-import
Diffstat (limited to 'app/controllers')
| -rw-r--r-- | app/controllers/referentials_controller.rb | 4 | ||||
| -rw-r--r-- | app/controllers/routing_constraint_zones_controller.rb | 31 | ||||
| -rw-r--r-- | app/controllers/time_tables_controller.rb | 5 | ||||
| -rw-r--r-- | app/controllers/workbenches_controller.rb | 1 |
4 files changed, 30 insertions, 11 deletions
diff --git a/app/controllers/referentials_controller.rb b/app/controllers/referentials_controller.rb index 838c46168..afd376092 100644 --- a/app/controllers/referentials_controller.rb +++ b/app/controllers/referentials_controller.rb @@ -9,7 +9,7 @@ class ReferentialsController < BreadcrumbController def new if params[:from] source_referential = Referential.find(params[:from]) - @referential = Referential.new_from(source_referential, organisation: current_organisation) + @referential = Referential.new_from(source_referential) end new! do @@ -118,7 +118,7 @@ class ReferentialsController < BreadcrumbController end def create_resource(referential) - referential.organisation = current_organisation unless referential.created_from + referential.organisation = current_organisation referential.ready = true super end diff --git a/app/controllers/routing_constraint_zones_controller.rb b/app/controllers/routing_constraint_zones_controller.rb index 6c3cb8a29..6541eb492 100644 --- a/app/controllers/routing_constraint_zones_controller.rb +++ b/app/controllers/routing_constraint_zones_controller.rb @@ -58,23 +58,40 @@ class RoutingConstraintZonesController < ChouetteController @q = current_referential.routing_constraint_zones.search(params[:q]) @routing_constraint_zones ||= begin - if sort_column && sort_direction - routing_constraint_zones = @q.result(distinct: true).order(sort_column + ' ' + sort_direction) - else - routing_constraint_zones = @q.result(distinct: true).order(:name) - end - routing_constraint_zones = routing_constraint_zones.paginate(page: params[:page], per_page: 10) + routing_constraint_zones = sort_collection + routing_constraint_zones = routing_constraint_zones.paginate( + page: params[:page], + per_page: 10 + ) end end private def sort_column - (Chouette::RoutingConstraintZone.column_names).include?(params[:sort]) ? params[:sort] : 'name' + ( + Chouette::RoutingConstraintZone.column_names + + [ + 'stop_points_count', + 'route' + ] + ).include?(params[:sort]) ? params[:sort] : 'name' end def sort_direction %w[asc desc].include?(params[:direction]) ? params[:direction] : 'asc' end + def sort_collection + sort_by = sort_column + + if sort_by == 'stop_points_count' + @q.result.order_by_stop_points_count(sort_direction) + elsif sort_by == 'route' + @q.result.order_by_route_name(sort_direction) + else + @q.result.order(sort_column + ' ' + sort_direction) + end + end + def routing_constraint_zone_params params.require(:routing_constraint_zone).permit( :name, diff --git a/app/controllers/time_tables_controller.rb b/app/controllers/time_tables_controller.rb index edeb5a32f..0054963c9 100644 --- a/app/controllers/time_tables_controller.rb +++ b/app/controllers/time_tables_controller.rb @@ -35,7 +35,7 @@ class TimeTablesController < ChouetteController def create tt_params = time_table_params - if tt_params[:calendar_id] + if tt_params[:calendar_id] && tt_params[:calendar_id] != "" %i(monday tuesday wednesday thursday friday saturday sunday).map { |d| tt_params[d] = true } calendar = Calendar.find(tt_params[:calendar_id]) tt_params[:calendar_id] = nil if tt_params.has_key?(:dates_attributes) || tt_params.has_key?(:periods_attributes) @@ -115,7 +115,8 @@ class TimeTablesController < ChouetteController end def tags - @tags = ActsAsTaggableOn::Tag.where("tags.name = ?", "%#{params[:tag]}%") + # @tags = ActsAsTaggableOn::Tag.where("tags.name = ?", "%#{params[:tag]}%") + @tags = Chouette::TimeTable.tags_on(:tags) respond_to do |format| format.json { render :json => @tags.map{|t| {:id => t.id, :name => t.name }} } end diff --git a/app/controllers/workbenches_controller.rb b/app/controllers/workbenches_controller.rb index 171db6a07..19af28a98 100644 --- a/app/controllers/workbenches_controller.rb +++ b/app/controllers/workbenches_controller.rb @@ -7,6 +7,7 @@ class WorkbenchesController < BreadcrumbController def index # Only display Wb with selected name, according to #4108 @workbench = current_organisation.workbenches.find_by(name: "Gestion de l'offre") + @referentials = @workbench.all_referentials @calendars = Calendar.where('organisation_id = ? OR shared = ?', current_organisation.id, true) end |
