diff options
| author | jpl | 2016-11-09 15:43:46 +0100 | 
|---|---|---|
| committer | jpl | 2016-11-09 15:43:46 +0100 | 
| commit | 1d1c449573811f16e4360622d7c9baf27cf0aa72 (patch) | |
| tree | 9220c03fec2dccf64b0754701eca1e8bce7f2de7 | |
| parent | 21c6807d2167ffdbcaed58844d1ebafb06c22d6e (diff) | |
| parent | e7bb28f100a5833628b776689750c0587de9bab4 (diff) | |
| download | chouette-core-1d1c449573811f16e4360622d7c9baf27cf0aa72.tar.bz2 | |
fix merging issues w reactux branch
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | app/assets/javascripts/es6_browserified/actions/index.js | 1 | ||||
| -rw-r--r-- | app/assets/javascripts/es6_browserified/components/BSelect2.js | 46 | ||||
| -rw-r--r-- | app/assets/javascripts/es6_browserified/components/Todo.js | 9 | ||||
| -rw-r--r-- | app/assets/javascripts/es6_browserified/components/TodoList.js | 7 | ||||
| -rw-r--r-- | app/assets/stylesheets/vendor/bootstrap_changes.sass | 16 | ||||
| -rw-r--r-- | app/assets/stylesheets/vendor/select2-bootstrap.css | 1 | ||||
| -rw-r--r-- | app/views/routes/_form.html.slim | 115 | ||||
| -rw-r--r-- | app/views/routes/show.html.slim | 20 | 
9 files changed, 70 insertions, 146 deletions
| diff --git a/.gitignore b/.gitignore index 762c156eb..4bd57ce25 100644 --- a/.gitignore +++ b/.gitignore @@ -30,5 +30,6 @@ coverage  .idea  bin/ +  # Ignore node modules  /node_modules diff --git a/app/assets/javascripts/es6_browserified/actions/index.js b/app/assets/javascripts/es6_browserified/actions/index.js index 8967c0322..de3bfc113 100644 --- a/app/assets/javascripts/es6_browserified/actions/index.js +++ b/app/assets/javascripts/es6_browserified/actions/index.js @@ -23,7 +23,6 @@ module.exports = {      }    },    updateInputValue: (index, text) => { -    console.log('action',index, text)      return {        type : "UPDATE_INPUT_VALUE",        index, diff --git a/app/assets/javascripts/es6_browserified/components/BSelect2.js b/app/assets/javascripts/es6_browserified/components/BSelect2.js index 7e4782563..590e755fd 100644 --- a/app/assets/javascripts/es6_browserified/components/BSelect2.js +++ b/app/assets/javascripts/es6_browserified/components/BSelect2.js @@ -18,40 +18,56 @@ class BSelect3 extends React.Component{      this.setState({edit: !this.state.edit})    }    onChange(e) { -    console.log(e.currentTarget.value, e.currentTarget.textContent) -    this.props.onChange(this.props.index, {text: e.currentTarget.textContent, id: e.currentTarget.value}) +    this.props.onChange(this.props.index, { +      text: e.currentTarget.textContent, id: e.currentTarget.value +    })      this.setState({edit: false})    }    render() {      if(this.state.edit)        return ( -        <div> +        <div className='input-group select2-bootstrap-append'>            <BSelect2 {...this.props} onSelect={ this.onChange.bind(this) }/> -        </div> -      ) -    else -      return ( -        <div> -          <span -            title="Cliquez pour changer l'arrêt" -            style={{cursor: 'pointer', display: 'block'}} -            onClick={this.onToggleEdit.bind(this)} -          > -            {this.props.value.text} + +          <span className='input-group-btn'> +            <button type='button' className='btn btn-default' onClick={this.onToggleEdit.bind(this)}> +              <span className='fa fa-undo'></span> +            </button>            </span>          </div>        ) +    else +      if(!this.props.value.id) +        return ( +          <div> +            <BSelect2 {...this.props} onSelect={ this.onChange.bind(this) }/> +          </div> +        ) +      else +        return ( +          <div className='input-group'> +            <span className='form-control'>{this.props.value.text} </span> +            <span className='input-group-btn'> +              <button type='button' className='btn btn-default' onClick={this.onToggleEdit.bind(this)}> +                <span className='fa fa-pencil'></span> +              </button> +            </span> +          </div> +        )    }  }  const BSelect2 = (props) => {    return (      <Select2 -      value={props.value.id} +      value={ props.value.id }        onSelect={ props.onSelect }        options={{          placeholder: 'Sélectionnez un arrêt existant...', +        allowClear: true, +        language: 'fr', /* Doesn't seem to work... :( */          theme: 'bootstrap', +        width: '100%',          ajax: {            url: origin + path + '/autocomplete_stop_areas.json',            dataType: 'json', diff --git a/app/assets/javascripts/es6_browserified/components/Todo.js b/app/assets/javascripts/es6_browserified/components/Todo.js index 0e74e728f..3b6ad9508 100644 --- a/app/assets/javascripts/es6_browserified/components/Todo.js +++ b/app/assets/javascripts/es6_browserified/components/Todo.js @@ -2,7 +2,7 @@ var React = require('react')  var PropTypes = require('react').PropTypes  var BSelect2 = require('./BSelect2') -const Container = {display: 'table',  width: '100%'} +const Container = {display: 'table', width: '100%'}  const firstBlock = {display: 'table-cell', verticalAlign: 'middle'}  const secondBlock = {display: 'table-cell', verticalAlign: 'middle', width: '150px', textAlign: 'right'} @@ -15,15 +15,12 @@ const Todo = (props) => {          </div>          <div style={{display: 'inline-block', width: '91%', verticalAlign: 'middle'}}> -          <BSelect2 id={'route_stop_points_' + props.id} value={props.value} onChange={props.onChange} index={props.index} defaultData={props.defaultData}/> +          <BSelect2 id={'route_stop_points_' + props.id} value={props.value} onChange={props.onChange} index={props.index} />          </div>        </div>        <div style={secondBlock}>          <div className='btn-group btn-group-sm'> -          <div className='btn btn-default'> -            <span className='fa fa-times'></span> -          </div>            <div              className={'btn btn-primary' + (props.first ? ' disabled' : '')}              onClick={props.onMoveUpClick} @@ -56,7 +53,7 @@ Todo.propTypes = {    first: PropTypes.bool,    last: PropTypes.bool,    index: PropTypes.number, -  defaultData: PropTypes.array +  value: PropTypes.object  }  module.exports = Todo diff --git a/app/assets/javascripts/es6_browserified/components/TodoList.js b/app/assets/javascripts/es6_browserified/components/TodoList.js index 367cfc256..e909f07bb 100644 --- a/app/assets/javascripts/es6_browserified/components/TodoList.js +++ b/app/assets/javascripts/es6_browserified/components/TodoList.js @@ -3,7 +3,6 @@ var PropTypes = require('react').PropTypes  var Todo = require('./Todo')  const TodoList = ({ todos, onDeleteClick, onMoveUpClick, onMoveDownClick, onChange }) => { -  console.log(todos)    return (      <div className='list-group'>        {todos.map((todo, index) => @@ -11,15 +10,13 @@ const TodoList = ({ todos, onDeleteClick, onMoveUpClick, onMoveDownClick, onChan            key={'item-' + index}            onDeleteClick={() => onDeleteClick(index)}            onMoveUpClick={() => { -            console.log(index, todos) -            onMoveUpClick(index)} -          } +            onMoveUpClick(index) +          }}            onMoveDownClick={() => onMoveDownClick(index)}            onChange={ onChange }            first={ index === 0 }            last={ index === (todos.length - 1) }            index={ index } -          defaultData={ todos }            value={ todo }          />        )} diff --git a/app/assets/stylesheets/vendor/bootstrap_changes.sass b/app/assets/stylesheets/vendor/bootstrap_changes.sass index 900949492..085f860a8 100644 --- a/app/assets/stylesheets/vendor/bootstrap_changes.sass +++ b/app/assets/stylesheets/vendor/bootstrap_changes.sass @@ -18,10 +18,10 @@    .validity_out      color: $brand-danger -   +    .validity_out_soon      color: $brand-warning -   +    .validity_regular      color: $brand-success @@ -42,6 +42,14 @@    > ul      margin: 0      padding: 0 -     +      > li -      list-style: none !important
\ No newline at end of file +      list-style: none !important + + +//-----------------------// +// Bootstrap-rails fixes // +//-----------------------// + +.input-group-btn > .btn +  height: 34px diff --git a/app/assets/stylesheets/vendor/select2-bootstrap.css b/app/assets/stylesheets/vendor/select2-bootstrap.css index 65f772696..99437f434 100644 --- a/app/assets/stylesheets/vendor/select2-bootstrap.css +++ b/app/assets/stylesheets/vendor/select2-bootstrap.css @@ -6,7 +6,6 @@  .select2-container--bootstrap {    display: block; -  width: 100% !important    /*------------------------------------*      #COMMON STYLES    \*------------------------------------*/    /** diff --git a/app/views/routes/_form.html.slim b/app/views/routes/_form.html.slim index 32d738de1..1005b7046 100644 --- a/app/views/routes/_form.html.slim +++ b/app/views/routes/_form.html.slim @@ -24,18 +24,18 @@    .row style="margin-top:20px"      .col-lg-12.col-md-12.col-sm-12.col-xs-12        #stop_points -      /   div.clearfix style="margin-bottom:5px" -      /     label style="margin:0" Arrêts -      /     .btn.btn-primary.btn-xs.pull-right data-event="add_stop_point" -      /       span.fa.fa-plus -      /       = " #{t('routes.actions.add_stop_point')}" - -          / = link_to_add_association f, :stop_points, class: 'btn btn-primary btn-xs pull-right' do -          /   span.fa.fa-plus -          /   = " #{t('routes.actions.add_stop_point')}" -          / THIS IS BROKEN -          / = link_to t('routes.actions.new_stop_point'), new_referential_stop_area_path(@referential), target: '_blank' - +        / div.clearfix style="margin-bottom:5px" +        /   label style="margin:0" Arrêts +        /   .btn.btn-primary.btn-xs.pull-right data-event="add_stop_point" +        /     span.fa.fa-plus +        /     = " #{t('routes.actions.add_stop_point')}" +        /  +        /   = link_to_add_association f, :stop_points, class: 'btn btn-primary btn-xs pull-right' do +        /     span.fa.fa-plus +        /     = " #{t('routes.actions.add_stop_point')}" +        /   THIS IS BROKEN +        /   = link_to t('routes.actions.new_stop_point'), new_referential_stop_area_path(@referential), target: '_blank' +        /           / .list-group          /   = f.simple_fields_for :stop_points do |point|          /     = render 'stop_point_fields', f: point @@ -51,94 +51,3 @@  / StopPoints Reactux component  = javascript_include_tag 'es6_browserified/stop_points.js' -= 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, :include_blank => false -    = form.input :wayback, :include_blank => false -    = 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 - -    .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 - -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/show.html.slim b/app/views/routes/show.html.slim index f71a01cef..26cf2f33f 100644 --- a/app/views/routes/show.html.slim +++ b/app/views/routes/show.html.slim @@ -43,17 +43,15 @@  p.after_map -#accordion.panel-group -  .panel.panel-default -    .panel-heading -      h4.panel-title -        a data-toggle="collapse" data-parent="#accordion" href="#stop_points" -          = t('.stop_points') - -    #stop_points.panel-collapse.collapse -      .panel-body -        .stop_points.paginated_content -          = paginated_content(@route.stop_points, "stop_points/stop_point") +h3 = t('.stop_points') +#stop_points.list-group +  - @route.stop_points.each do |stop| +    .list-group-item style='display: table;width: 100%;' +      div style='display: table-cell;vertical-align: middle;' +        div style='display: inline-block;width: 9%; vertical-align: middle;' +          = "##{stop.stop_area.id}" +        div style='display: inline-block;width: 91%; vertical-align: middle;' +          = stop.stop_area.inspect  #accordion.panel-group    .panel.panel-default | 
