diff options
| author | vlatka pavisic | 2016-11-10 12:07:25 +0100 |
|---|---|---|
| committer | vlatka pavisic | 2016-11-10 12:07:25 +0100 |
| commit | 0a0e87bdd9a6dbee386542b669c7d8413ee7a4ea (patch) | |
| tree | 9b07d3ac810d4400df1d19a89980c667f8881a67 | |
| parent | fadf49dc9eaa005befb826ac9f85395b08d30db5 (diff) | |
| parent | 5bf53777001a017b22677786104aea84e7c0fc57 (diff) | |
| download | chouette-core-0a0e87bdd9a6dbee386542b669c7d8413ee7a4ea.tar.bz2 | |
Merge branch 'master' of https://github.com/af83/stif-boiv
| -rw-r--r-- | Gemfile | 2 | ||||
| -rw-r--r-- | Gemfile.lock | 1 | ||||
| -rw-r--r-- | app/assets/javascripts/es6_browserified/components/BSelect2.js | 82 | ||||
| -rw-r--r-- | app/assets/javascripts/es6_browserified/components/Todo.js | 4 | ||||
| -rw-r--r-- | app/views/referentials/show.js.slim | 5 | ||||
| -rw-r--r-- | app/views/routes/show.html.slim | 13 |
6 files changed, 58 insertions, 49 deletions
@@ -56,7 +56,7 @@ gem 'polylines' # Codifligne API gem 'codifligne', git: 'git@github.com:AF83/stif-codifline-api.git' # Reflex API -gem 'reflex', git: 'git@github.com:AF83/stif-reflex-api.git', branch: 'sax_refactoring' +gem 'reflex', git: 'git@github.com:AF83/stif-reflex-api.git' # Authentication gem 'devise', '~> 3.4.0' diff --git a/Gemfile.lock b/Gemfile.lock index 832da8645..4d9e94fbd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -24,7 +24,6 @@ GIT GIT remote: git@github.com:AF83/stif-reflex-api.git revision: 2c01010dce3a6cb39339995c373faf89ae00f3f3 - branch: sax_refactoring specs: reflex (0.0.1) nokogiri (~> 1.6) diff --git a/app/assets/javascripts/es6_browserified/components/BSelect2.js b/app/assets/javascripts/es6_browserified/components/BSelect2.js index fc3112f8e..a78dc625f 100644 --- a/app/assets/javascripts/es6_browserified/components/BSelect2.js +++ b/app/assets/javascripts/es6_browserified/components/BSelect2.js @@ -2,10 +2,12 @@ var React = require('react') var PropTypes = require('react').PropTypes var Select2 = require('react-select2') + // get JSON full path var origin = window.location.origin var path = window.location.pathname.split('/', 3).join('/') + class BSelect3 extends React.Component{ constructor(props) { super(props) @@ -64,47 +66,53 @@ class BSelect3 extends React.Component{ } } -const BSelect2 = (props) => { - return ( - <Select2 - value={props.value.stoparea_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', - delay: '500', - data: function(params) { - return { - q: params.term - }; - }, - processResults: function(data, params) { - return { - results: data.map( - item => Object.assign( - {}, - item, - { text: item.name + ", " + item.zip_code + " " + item.short_city_name } +class BSelect2 extends React.Component{ + componentDidMount() { + this.refs.newSelect.el.select2('open') + } + + render() { + return ( + <Select2 + value={ this.props.value.stoparea_id } + onSelect={ this.props.onSelect } + ref='newSelect' + 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', + delay: '500', + data: function(params) { + return { + q: params.term + }; + }, + processResults: function(data, params) { + return { + results: data.map( + item => Object.assign( + {}, + item, + { text: item.name + ", " + item.zip_code + " " + item.short_city_name } + ) ) - ) - }; + }; + }, + cache: true }, - cache: true - }, - minimumInputLength: 3, - templateResult: formatRepo - }} - /> - ) + minimumInputLength: 3, + templateResult: formatRepo + }} + /> + ) + } } -// to fix: this is for custom results return const formatRepo = (props) => { if(props.text) return props.text // console.log(props) diff --git a/app/assets/javascripts/es6_browserified/components/Todo.js b/app/assets/javascripts/es6_browserified/components/Todo.js index 34eeed9c7..16e42eb3c 100644 --- a/app/assets/javascripts/es6_browserified/components/Todo.js +++ b/app/assets/javascripts/es6_browserified/components/Todo.js @@ -4,14 +4,14 @@ var BSelect2 = require('./BSelect2') const Container = {display: 'table', width: '100%'} const firstBlock = {display: 'table-cell', verticalAlign: 'middle'} -const secondBlock = {display: 'table-cell', verticalAlign: 'middle', width: '150px', textAlign: 'right'} +const secondBlock = {display: 'table-cell', verticalAlign: 'middle', width: 150, textAlign: 'right'} const Todo = (props) => { return ( <div className='list-group-item' style={Container}> <div style={firstBlock}> <div style={{display: 'inline-block', width: '10%', verticalAlign: 'middle', textAlign: 'right'}}> - <span className='label label-default' style={{marginRight: '10'}}>{props.value.stoparea_id}</span> + <span className='label label-default' style={{marginRight: 10}}>{props.value.stoparea_id}</span> </div> <div style={{display: 'inline-block', width: '90%', verticalAlign: 'middle'}}> diff --git a/app/views/referentials/show.js.slim b/app/views/referentials/show.js.slim index f1d01ce6c..5e47bf935 100644 --- a/app/views/referentials/show.js.slim +++ b/app/views/referentials/show.js.slim @@ -3,7 +3,6 @@ | update_infos = function(json) { | var info, update_info; | info = $('#referential_' + json.referential_id); -| console.log(info) | update_info = function(key, value) { | if (key.match(/_count$/)) { | return $(info.find('.' + key)[0]).text(value); @@ -16,5 +15,5 @@ | }; | _results = []; | _results.push(update_referential_details()); -| return _results; -| });
\ No newline at end of file +| return _results; +| }); diff --git a/app/views/routes/show.html.slim b/app/views/routes/show.html.slim index 3052f92cc..7552795ed 100644 --- a/app/views/routes/show.html.slim +++ b/app/views/routes/show.html.slim @@ -48,16 +48,19 @@ p.after_map .list-group - @route.stop_points.each do |point| - .list-group-item style='display: table;width: 100%;' + - if point.stop_area.zip_code && point.stop_area.city_name + - linktxt = "#{point.stop_area.name}, #{point.stop_area.zip_code} #{point.stop_area.city_name}" + - else + - linktxt = "#{point.stop_area.name}" + + = link_to [@referential, point.stop_area], { style: 'display: table;width: 100%;', class: 'list-group-item', title: "Voir l'arrêt '#{linktxt}'" } do div style='display: table-cell;vertical-align: middle;' div style='display: inline-block;width: 10%;vertical-align: middle;text-align: right;' span.label.label-default style='margin-right: 10px;' = "#{point.stop_area.id}" div style='display: inline-block;width: 90%;vertical-align: middle;' - - if point.stop_area.zip_code && point.stop_area.city_name - = "#{point.stop_area.name}, #{point.stop_area.zip_code} #{point.stop_area.city_name}" - - else - = "#{point.stop_area.name}" + = linktxt + #accordion.panel-group .panel.panel-default |
