diff options
| author | Alban Peignier | 2015-05-26 11:04:12 +0200 |
|---|---|---|
| committer | Alban Peignier | 2015-05-26 11:04:18 +0200 |
| commit | d55aa475e49102c4ee65fa2770fd58e094cba991 (patch) | |
| tree | 85bfdb17a8745348966fae671ad4441399b71d5a | |
| parent | 5e54f602bb927e6c3a1a165e4aa9eb594c348c0e (diff) | |
| download | chouette-core-d55aa475e49102c4ee65fa2770fd58e094cba991.tar.bz2 | |
Remove disabled attribute on stop_area_id input. Simplify javascript in routes/form partial
| -rw-r--r-- | app/views/routes/_form.html.erb | 20 | ||||
| -rw-r--r-- | app/views/routes/_stop_point_fields.html.erb | 10 |
2 files changed, 12 insertions, 18 deletions
diff --git a/app/views/routes/_form.html.erb b/app/views/routes/_form.html.erb index 2aa9dd8b7..d642efe88 100644 --- a/app/views/routes/_form.html.erb +++ b/app/views/routes/_form.html.erb @@ -10,14 +10,14 @@ <%= form.input :objectid, :required => !@route.new_record?, :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.route.objectid")} %> <% end %> <div id="stop_points"> - <%= form.semantic_fields_for :stop_points, :include_id => false, :label => "TOTO" do |p| %> - <%= render "stop_point_fields", :f => p, :test1 => "oiuoiu" %> + <%= form.semantic_fields_for :stop_points, :include_id => false do |p| %> + <%= render "stop_point_fields", :f => p %> <% end %> - <div class="links"> + <div class="links"> <%= link_to_add_association t("routes.actions.add_stop_point"), form, :stop_points, :class => 'add_stop_point add' %> <br/> - <%= link_to t('routes.actions.new_stop_point'), new_referential_stop_area_path(@referential), {:class => "add", :target => "_blank"} %> - </div> + <%= link_to t('routes.actions.new_stop_point'), new_referential_stop_area_path(@referential), {:class => "add", :target => "_blank"} %> + </div> </div> <%= form.actions do %> @@ -38,8 +38,6 @@ $(document).ready( function() { var write_stop_point_ids = function(){ $('#stop_points input[type="hidden"][class~="stop_point_id"]').each(function(index,element) { - - // soit le parent a la classe added_stop_point if ( $(element).hasClass("added_stop_point") ){ $(this).attr("value", ""); @@ -50,11 +48,8 @@ $(document).ready( function() { } var empty_stop_point_ids = function() { - while(stop_point_ids.length > 0) { - stop_point_ids.pop(); - } - $('#stop_points input[type="hidden"][class="stop_point_id"]').map(function() { - stop_point_ids.push( $(this).val()); + stop_point_ids = $.map($('#stop_points input[type="hidden"][class="stop_point_id"]'), function(element, index) { + return $(element).val(); }); // console.log( "before-remove"); // console.log( stop_point_ids); @@ -104,4 +99,3 @@ $(document).ready( function() { </script> - diff --git a/app/views/routes/_stop_point_fields.html.erb b/app/views/routes/_stop_point_fields.html.erb index d90444b03..73ac69152 100644 --- a/app/views/routes/_stop_point_fields.html.erb +++ b/app/views/routes/_stop_point_fields.html.erb @@ -3,17 +3,17 @@ <div class="col-md-1 resize"> <%= link_to_remove_association "<i class='fa fa-trash-o'></i>".html_safe, f %> <span class="handle" alt="<%= t('stop_points.index.move') %>" title="<%= t('stop_points.index.move') %>" ><i class='fa fa-arrows'></i></span> - </div> + </div> <div class="col-md-11"> <% if f.object.stop_area.nil? || f.object.new_record? %> <%= f.input :id, :as => :hidden, :input_html => { :class => "stop_point_id added_stop_point", :value => "" } %> <%= f.input :position, :as => :hidden, :input_html => { :class => "position" } %> - <%= f.input :stop_area_id, :label => false, :as => :search_stop_area, :json => referential_autocomplete_stop_areas_path(@referential, :format => :json)+"?filter=physical", :hint_text => t('search_hint'), :no_result_text => t('no_result_text'),:searching_text => t('searching_term'), :tokenLimit => 1, :input_html => { :class => "new_stop_point stop_area_id", :"data-pre" => Rabl::Renderer.new('autocomplete_stop_areas/index', [f.object.stop_area].compact, :view_path => 'app/views', :format => :json, :scope => self ).render } %> + <%= f.input :stop_area_id, :label => false, :as => :search_stop_area, :json => referential_autocomplete_stop_areas_path(@referential, :format => :json)+"?filter=physical", :hint_text => t('search_hint'), :no_result_text => t('no_result_text'),:searching_text => t('searching_term'), :tokenLimit => 1, :input_html => { :class => "new_stop_point stop_area_id", :"data-pre" => Rabl::Renderer.new('autocomplete_stop_areas/index', [f.object.stop_area].compact, :view_path => 'app/views', :format => :json, :scope => self ).render } %> <% else %> <%= f.input :id, :as => :hidden, :input_html => { :class => "stop_point_id" } %> <%= f.input :position, :as => :hidden, :input_html => { :class => "position" } %> - <%= f.input :stop_area_id, :label => false, :as => :search_stop_area, :json => referential_autocomplete_stop_areas_path(@referential, :format => :json)+"?filter=physical", :hint_text => t('search_hint'), :no_result_text => t('no_result_text'),:searching_text => t('searching_term'), :tokenLimit => 1, :disabled => true, :input_html => { :class => "stop_area_id", :"data-pre" => Rabl::Renderer.new('autocomplete_stop_areas/index', [f.object.stop_area].compact, :view_path => 'app/views', :format => :json, :scope => self ).render } %> + <%= f.input :stop_area_id, :label => false, :as => :search_stop_area, :json => referential_autocomplete_stop_areas_path(@referential, :format => :json)+"?filter=physical", :hint_text => t('search_hint'), :no_result_text => t('no_result_text'),:searching_text => t('searching_term'), :tokenLimit => 1, :input_html => { :class => "stop_area_id", :"data-pre" => Rabl::Renderer.new('autocomplete_stop_areas/index', [f.object.stop_area].compact, :view_path => 'app/views', :format => :json, :scope => self ).render } %> + <% end %> + </div> <% end %> - </div> - <% end %> </div> |
