diff options
| author | jpl | 2016-11-02 18:23:48 +0100 |
|---|---|---|
| committer | Thomas Haddad | 2016-11-08 18:15:11 +0100 |
| commit | 7d32da0a6e2384eef088bc66b6fa08cda9d2b8ab (patch) | |
| tree | c918bb260623ef184605e5ca97d3ad2b82f897b2 /app | |
| parent | e0d0a82b9eca2ae425cdfbaccb2d164cd5fb3855 (diff) | |
| download | chouette-core-7d32da0a6e2384eef088bc66b6fa08cda9d2b8ab.tar.bz2 | |
mess stuff
Diffstat (limited to 'app')
| -rw-r--r-- | app/assets/javascripts/es6_browserified/test.js | 6 | ||||
| -rw-r--r-- | app/views/routes/_form.html.slim | 143 | ||||
| -rw-r--r-- | app/views/routes/_stop_point_fields.html.slim | 2 | ||||
| -rw-r--r-- | app/views/routes/_test.html.slim | 63 |
4 files changed, 115 insertions, 99 deletions
diff --git a/app/assets/javascripts/es6_browserified/test.js b/app/assets/javascripts/es6_browserified/test.js index eff33368a..757e61e95 100644 --- a/app/assets/javascripts/es6_browserified/test.js +++ b/app/assets/javascripts/es6_browserified/test.js @@ -1,7 +1,9 @@ +// get json statham + class Welcome { constructor() { - alert('Yo bitch'); + console.log('Welcome'); } } -// new Welcome(); +new Welcome(); diff --git a/app/views/routes/_form.html.slim b/app/views/routes/_form.html.slim index 3c24f1062..754ecfc06 100644 --- a/app/views/routes/_form.html.slim +++ b/app/views/routes/_form.html.slim @@ -10,10 +10,9 @@ = form.input :objectid, :required => !@route.new_record?, :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.route.objectid")} #stop_points - = form.semantic_fields_for :stop_points, :include_id => false do |p| - / == render "stop_point_fields", f: p - // TEST ES6 - = render 'test', f: p + .list-group + = form.semantic_fields_for :stop_points, :include_id => false do |p| + = render 'test', f: p .links = link_to_add_association t("routes.actions.add_stop_point"), form, :stop_points, class: 'add_stop_point add' @@ -24,70 +23,74 @@ = form.action :submit, as: :button = form.action :cancel, as: :link -javascript: - $(document).ready(function() { - var stop_point_ids = []; +// TEST ES6 += javascript_include_tag 'es6_browserified/test.js' - 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(); - }); - }); +// 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 f80e24796..5c086d324 100644 --- a/app/views/routes/_stop_point_fields.html.slim +++ b/app/views/routes/_stop_point_fields.html.slim @@ -10,8 +10,10 @@ - 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 } diff --git a/app/views/routes/_test.html.slim b/app/views/routes/_test.html.slim index c4b085873..deb525d32 100644 --- a/app/views/routes/_test.html.slim +++ b/app/views/routes/_test.html.slim @@ -1,27 +1,36 @@ -.nested-fields.stop_point - .list-group - = f.inputs do - .list-group-item - div style="display:table-cell;vertical-align:middle;width:75%;" - - 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 } - - div.text-right style="display:table-cell;vertical-align:middle;width:25%;" - .btn-group.btn-group-sm - = link_to_remove_association f, class: 'btn btn-danger' do - span.fa.fa-trash - - .btn.btn-primary data-event='handle' title="#{t('stop_points.index.move')}" - span.fa.fa-arrows - -// TEST ES6 -= javascript_include_tag 'es6_browserified/test.js' +.list-group-item + = f.inputs do + - if f.object.stop_area.nil? || f.object.new_record? + div style="display:inline-block;vertical-align:middle;width:75%;" + span + span.text-danger = "[#{@route.stop_areas.find(f.object.stop_area_id).position.inspect}] " + = @route.stop_areas.find(f.object.stop_area_id).name + + / = 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 + + = f.input :id, as: :hidden, :input_html => { :class => "stop_point_id added_stop_point", :value => "" } + = f.input :position, as: :hidden, :input_html => { :class => "position" } + + - else + div style="display:inline-block;vertical-align:middle;width:75%;" + span + span.text-danger = "[#{@route.stop_areas.find(f.object.stop_area_id).position.inspect}] " + = @route.stop_areas.find(f.object.stop_area_id).name + + / = 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 } + + = f.input :id, as: :hidden, :input_html => { class: 'stop_point_id' } + = f.input :position, as: :hidden, :input_html => { class: 'position' } + + div.text-right style="display:inline-block;;vertical-align:middle;width:25%;" + .btn-group.btn-group-sm style="padding:0;" + .btn.btn-default + span.fa.fa-times + .btn.btn-primary + span.fa.fa-arrow-up + .btn.btn-primary + span.fa.fa-arrow-down + = link_to_remove_association f, class: 'btn btn-danger' do + span.fa.fa-trash |
