aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjpl2016-11-03 11:22:06 +0100
committerThomas Haddad2016-11-08 18:15:11 +0100
commit77adefca8011e9ab8198537fc5b08c270a68ddb2 (patch)
tree2f9b91da514cf2a2234f53bcd51cb56ed193eb4f
parent825152f5d74ab91c79adaadbd337585da4c82be8 (diff)
downloadchouette-core-77adefca8011e9ab8198537fc5b08c270a68ddb2.tar.bz2
rebuilding route edit form with simpleform
-rw-r--r--app/views/routes/_form.html.slim122
-rw-r--r--app/views/routes/_stop_point_fields.html.slim21
-rw-r--r--app/views/routes/edit.html.slim4
3 files changed, 37 insertions, 110 deletions
diff --git a/app/views/routes/_form.html.slim b/app/views/routes/_form.html.slim
index 754ecfc06..78d07c3d1 100644
--- a/app/views/routes/_form.html.slim
+++ b/app/views/routes/_form.html.slim
@@ -1,96 +1,36 @@
-= semantic_form_for [@referential, @line, @route] do |form|
- = form.inputs do
- = form.input :name
- = form.input :published_name
- = form.input :number
- = form.input :comment
- = form.input :opposite_route, as: :select, :collection => @line.routes.select { |r| r.id != @route.id }
- = form.input :direction_code, as: :select, :collection => Chouette::Route.directions, :include_blank => false, :member_label => Proc.new { |mode| t("directions.label.#{mode}") }
- = form.input :wayback_code, as: :select, :collection => Chouette::Route.waybacks, :include_blank => false, :member_label => Proc.new { |mode| t("waybacks.label.#{mode}") }
- = form.input :objectid, :required => !@route.new_record?, :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.route.objectid")}
+= simple_form_for [@referential, @line, @route] do |f|
+ .row
+ .col-lg-4.col-md-4.col-sm-4.col-xs-4
+ = f.input :name
+ .col-lg-4.col-md-4.col-sm-4.col-xs-4
+ = f.input :published_name
+ .col-lg-4.col-md-4.col-sm-4.col-xs-4
+ = f.input :number
+
+ .row
+ .col-lg-5.col-md-5.col-sm-5.col-xs-5
+ = f.input :comment
+ .col-lg-7.col-md-7.col-sm-7.col-xs-7
+ = f.input :opposite_route, collection: @line.routes.select { |r| r.id != @route.id }
+
+ .row
+ .col-lg-4.col-md-4.col-sm-4.col-xs-4
+ = f.input :direction_code, collection: Chouette::Route.directions, include_blank: false, member_label: Proc.new { |mode| t("directions.label.#{mode}") }
+ .col-lg-4.col-md-4.col-sm-4.col-xs-4
+ = f.input :wayback_code, collection: Chouette::Route.waybacks, include_blank: false, member_label: Proc.new { |mode| t("waybacks.label.#{mode}") }
+ .col-lg-4.col-md-4.col-sm-4.col-xs-4
+ = f.input :objectid, required: !@route.new_record?, input_html: { title: t("formtastic.titles#{format_restriction_for_locales(@referential)}.route.objectid") }
+
+ .row
+ .col-lg-12.col-md-12.col-sm-12.col-xs-12
+ = f.simple_fields_for :stop_points do |point|
+ = render 'stop_point_fields', f: point
- #stop_points
- .list-group
- = form.semantic_fields_for :stop_points, :include_id => false do |p|
- = render 'test', f: p
+ .row
+ .col-lg-12.col-md-12.col-sm-12.col-xs-12.text-right
+ = link_to 'Annuler', :back, class: 'btn btn-link'
+ = f.button :submit, class: 'btn btn-danger'
- .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' }
-
- = form.actions do
- = form.action :submit, as: :button
- = form.action :cancel, as: :link
// TEST ES6
= javascript_include_tag 'es6_browserified/test.js'
-
-// OLD JS
-/ javascript:
-/ $(document).ready(function() {
-/ var stop_point_ids = [];
-/
-/ var order_position = function() {
-/ $('#stop_points input[type="hidden"][id$="position"]').each(function(index) {
-/ $(this).val(index);
-/ });
-/ };
-/
-/ 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", "");
-/ } else {
-/ $(this).attr("value", stop_point_ids.shift());
-/ }
-/ });
-/ }
-/
-/ var empty_stop_point_ids = function() {
-/ 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);
-/ };
-/
-/ $('#stop_points').sortable({
-/ axis: 'y',
-/ dropOnEmpty: false,
-/ handle: '.handle',
-/ cursor: 'crosshair',
-/ items: '.stop_point',
-/ opacity: 0.4,
-/ scroll: true,
-/ start: function( event, ui ) {
-/ empty_stop_point_ids();
-/ },
-/ update: function( event, ui ) {
-/ write_stop_point_ids();
-/ order_position();
-/ }
-/ });
-/
-/ $('#stop_points').bind("cocoon:after-insert", function(event, insertedItem) {
-/ var new_stop_count = $('div.nested-fields.stop_point').size();
-/ var cocoonId = insertedItem.find("input.new_stop_point").attr("id").match( /route_stop_points_attributes_(\d+)_stop_area_id/)[1];
-/ insertedItem.find('input').each( function(index,e){
-/ var old = $(e).attr("name");
-/ if (old!=undefined) {
-/ $(e).attr("name", old.replace( cocoonId, new_stop_count - 1));
-/ }
-/ });
-/
-/ //console.log( "cocoonId="+cocoonId+", new_stop_count="+new_stop_count);
-/ order_position();
-/ });
-/
-/ $('#stop_points').on("cocoon:before-remove", empty_stop_point_ids);
-/
-/ $('#stop_points').on("cocoon:after-remove", function() {
-/ write_stop_point_ids();
-/ order_position();
-/ });
-/ });
diff --git a/app/views/routes/_stop_point_fields.html.slim b/app/views/routes/_stop_point_fields.html.slim
index 5c086d324..922b400eb 100644
--- a/app/views/routes/_stop_point_fields.html.slim
+++ b/app/views/routes/_stop_point_fields.html.slim
@@ -1,19 +1,4 @@
-.nested-fields.stop_point.row
- = f.inputs do
- .col-md-1.resize
- = link_to_remove_association "<i class='fa fa-trash-o'></i>".html_safe, f
-
- span.handle alt="#{t('stop_points.index.move')}" title="#{t('stop_points.index.move')}"
- i.fa.fa-arrows
+= f.input :stop_area_id
- .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 }
- - 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, :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 }
+/ = link_to_add_association t("routes.actions.add_stop_point"), f, :stop_points
+/ = link_to t('routes.actions.new_stop_point'), new_referential_stop_area_path(@referential), target: '_blank'
diff --git a/app/views/routes/edit.html.slim b/app/views/routes/edit.html.slim
index 300a2f86b..a0431dc32 100644
--- a/app/views/routes/edit.html.slim
+++ b/app/views/routes/edit.html.slim
@@ -1,3 +1,5 @@
= title_tag t('routes.edit.title', route: @route.name )
-== render 'form'
+.row
+ .col-lg-8.col-lg-offset-2.col-md-8.col-md-offset-2.col-sm-8.col-sm-offset-2
+ == render 'form'