diff options
| author | Marc Florisson | 2014-08-20 22:23:48 +0200 |
|---|---|---|
| committer | Marc Florisson | 2014-08-20 22:23:48 +0200 |
| commit | 008432840b80e4fa3a1bc4e0410d604e74d0e0e4 (patch) | |
| tree | 64f4bdfa7fda46430d1cfc0857ace7fe23291f00 | |
| parent | b6d1c06128a67878ca5430dff005eaabb026307b (diff) | |
| download | chouette-core-008432840b80e4fa3a1bc4e0410d604e74d0e0e4.tar.bz2 | |
refactor vehicle translate with modal dialog.
| -rw-r--r-- | app/controllers/vehicle_translations_controller.rb | 19 | ||||
| -rw-r--r-- | app/views/time_table_combinations/_combine.html.erb | 1 | ||||
| -rw-r--r-- | app/views/vehicle_journeys/show.html.erb | 16 | ||||
| -rw-r--r-- | app/views/vehicle_translations/_translate_form.html.erb | 15 | ||||
| -rw-r--r-- | app/views/vehicle_translations/new.js.erb | 4 |
5 files changed, 46 insertions, 9 deletions
diff --git a/app/controllers/vehicle_translations_controller.rb b/app/controllers/vehicle_translations_controller.rb index af54001ae..0eeb450b8 100644 --- a/app/controllers/vehicle_translations_controller.rb +++ b/app/controllers/vehicle_translations_controller.rb @@ -1,5 +1,5 @@ class VehicleTranslationsController < ChouetteController - respond_to :html, :only => [:create] + respond_to :js, :only => [:new, :create] belongs_to :referential do belongs_to :line, :parent_class => Chouette::Line do @@ -9,16 +9,21 @@ class VehicleTranslationsController < ChouetteController end end + def new + @vehicle_translation = VehicleTranslation.new( :vehicle_journey_id => parent.id) + flash[:notice] = "mokmlklmk" + render :action => :new + end + def create begin - translation = VehicleTranslation.new( params[:vehicle_translation].merge( :vehicle_journey_id => parent.id)) - translation.translate - flash[:notice] = t('vehicle_translations.success', :count => translation.count) + @vehicle_translation = VehicleTranslation.new( params[:vehicle_translation].merge( :vehicle_journey_id => parent.id)) + @vehicle_translation.translate + flash[:notice] = t('vehicle_translations.success', :count => @vehicle_translation.count) rescue flash[:alert] = t('vehicle_translations.failure') end - redirect_to referential_line_route_vehicle_journeys_path(@referential, @line, @route) - + render :action => :new end - + end diff --git a/app/views/time_table_combinations/_combine.html.erb b/app/views/time_table_combinations/_combine.html.erb index 3257cf812..a83d109a1 100644 --- a/app/views/time_table_combinations/_combine.html.erb +++ b/app/views/time_table_combinations/_combine.html.erb @@ -5,7 +5,6 @@ <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button> <h4 class="modal-title" id="myModalLabel"><%= t('time_tables.show.combine_form') %></h4> </div> - <% @time_table_combination.clean %> <%= render "time_table_combinations/combine_form" %> </div> diff --git a/app/views/vehicle_journeys/show.html.erb b/app/views/vehicle_journeys/show.html.erb index 01f44c7b0..f1438e72d 100644 --- a/app/views/vehicle_journeys/show.html.erb +++ b/app/views/vehicle_journeys/show.html.erb @@ -1,5 +1,17 @@ <%= title_tag vehicle_title(@vehicle_journey) %> +<div id="modal_translation" 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"> + <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button> + <h4 class="modal-title" id="myModalLabel"><%= t('.translation_form') %></h4> + <p id="translate_form"></p> + </div> + </div> + </div> +</div> + <div class="vehicle_journey"> <div class="summary"> <p> @@ -93,17 +105,19 @@ <%= paginated_content @vehicle_journey.time_tables, "time_table" %> </div> + <% content_for :sidebar do %> <ul class="actions"> <li><%= link_to t('vehicle_journeys.actions.edit'), edit_referential_line_route_vehicle_journey_path(@referential, @line, @route, @vehicle_journey), :class => "edit" %></li> <li><%= link_to t('vehicle_journeys.actions.destroy'), referential_line_route_vehicle_journey_path(@referential, @line, @route, @vehicle_journey), :method => :delete, :data => {:confirm => t('vehicle_journeys.actions.destroy_confirm')}, :class => "remove" %></li> </ul> + <li><%= link_to t('.translation_form'), new_referential_line_route_vehicle_journey_vehicle_translation_path(@referential, @line, @route, @vehicle_journey), {:remote => true, 'data-toggle' => "modal", 'data-target' => '#modal_translation'} %></li> <% unless @vehicle_journey.vehicle_journey_at_stops.empty? || @vehicle_journey.vehicle_journey_at_stops.any? { |vjas| vjas.departure_time.nil? } %> <h4><%= t('.translation_form') %></h4> <div id="compact_form" > <%= semantic_form_for [@referential, @line, @route, @vehicle_journey, VehicleTranslation.new] do |form| %> - <%= form.inputs do %> + <%= form.inputs do %> <%= form.input :duration %> <%= form.input :count %> <% end %> diff --git a/app/views/vehicle_translations/_translate_form.html.erb b/app/views/vehicle_translations/_translate_form.html.erb new file mode 100644 index 000000000..479332606 --- /dev/null +++ b/app/views/vehicle_translations/_translate_form.html.erb @@ -0,0 +1,15 @@ +<%= semantic_form_for [@referential, @line, @route, @vehicle_journey, @vehicle_translation], :remote => true, :html => {:id => "translate_form"} do |form| %> +<div class="modal-body"> + <%= render "shared/flash_messages" %> + <%= form.inputs do %> + <%= form.input :duration %> + <%= form.input :count %> + <% end %> +</div> +<div class="modal-footer"> + <%= form.actions do %> + <%= form.action :submit, :as => :button, :label => t('.validation') %> + <% end %> +<% end %> +</div> + diff --git a/app/views/vehicle_translations/new.js.erb b/app/views/vehicle_translations/new.js.erb new file mode 100644 index 000000000..0c7869fb6 --- /dev/null +++ b/app/views/vehicle_translations/new.js.erb @@ -0,0 +1,4 @@ +var modal_translation_content = '<%= escape_javascript( render "vehicle_translations/translate_form") %> '; +$('#translate_form').html(modal_translation_content); + + |
