aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/es6_browserified/helpers/clone.js14
-rw-r--r--app/assets/javascripts/es6_browserified/itineraries/components/App.js28
-rw-r--r--app/assets/javascripts/es6_browserified/itineraries/components/BSelect2.js16
-rw-r--r--app/assets/javascripts/es6_browserified/itineraries/components/OlMap.js35
-rw-r--r--app/assets/javascripts/es6_browserified/itineraries/components/StopPoint.js14
-rw-r--r--app/assets/javascripts/es6_browserified/itineraries/components/StopPointList.js14
-rw-r--r--app/assets/javascripts/es6_browserified/itineraries/index.js4
-rw-r--r--app/assets/javascripts/es6_browserified/itineraries/show.js3
-rw-r--r--app/assets/javascripts/es6_browserified/time_tables/actions/index.js37
-rw-r--r--app/assets/javascripts/es6_browserified/time_tables/components/ConfirmModal.js17
-rw-r--r--app/assets/javascripts/es6_browserified/time_tables/components/ErrorModal.js15
-rw-r--r--app/assets/javascripts/es6_browserified/time_tables/components/Metas.js24
-rw-r--r--app/assets/javascripts/es6_browserified/time_tables/components/PeriodForm.js18
-rw-r--r--app/assets/javascripts/es6_browserified/time_tables/components/PeriodManager.js11
-rw-r--r--app/assets/javascripts/es6_browserified/time_tables/components/TagsSelect2.js10
-rw-r--r--app/assets/javascripts/es6_browserified/time_tables/components/TimeTableDay.js3
-rw-r--r--app/assets/javascripts/es6_browserified/time_tables/components/Timetable.js19
-rw-r--r--app/assets/javascripts/es6_browserified/time_tables/containers/App.js13
-rw-r--r--app/assets/javascripts/es6_browserified/time_tables/index.js5
-rw-r--r--app/assets/javascripts/es6_browserified/time_tables/reducers/timetable.js6
-rw-r--r--app/controllers/compliance_control_sets_controller.rb45
-rw-r--r--app/controllers/compliance_controls_controller.rb30
-rw-r--r--app/controllers/imports_controller.rb1
-rw-r--r--app/decorators/company_decorator.rb2
-rw-r--r--app/decorators/compliance_control_decorator.rb10
-rw-r--r--app/decorators/compliance_control_set_decorator.rb7
-rw-r--r--app/helpers/referentials_helper.rb10
-rw-r--r--app/models/compliance_check.rb1
-rw-r--r--app/models/compliance_control.rb34
-rw-r--r--app/models/compliance_control_block.rb13
-rw-r--r--app/models/compliance_control_set.rb6
-rw-r--r--app/models/generic_attribute_control/min_max.rb17
-rw-r--r--app/models/generic_attribute_control/pattern.rb13
-rw-r--r--app/models/generic_attribute_control/uniqueness.rb13
-rw-r--r--app/models/generic_attribute_min_max.rb27
-rw-r--r--app/models/generic_attribute_pattern.rb23
-rw-r--r--app/models/generic_attribute_uniqueness.rb23
-rw-r--r--app/models/journey_pattern_control/duplicates.rb6
-rw-r--r--app/models/journey_pattern_control/vehicle_journey.rb6
-rw-r--r--app/models/line_control/route.rb6
-rw-r--r--app/models/route_control/duplicates.rb6
-rw-r--r--app/models/route_control/journey_pattern.rb6
-rw-r--r--app/models/route_control/minimum_length.rb6
-rw-r--r--app/models/route_control/omnibus_journey_pattern.rb6
-rw-r--r--app/models/route_control/opposite_route.rb7
-rw-r--r--app/models/route_control/opposite_route_terminus.rb6
-rw-r--r--app/models/route_control/speed.rb6
-rw-r--r--app/models/route_control/stop_points_in_journey_pattern.rb6
-rw-r--r--app/models/route_control/time_table.rb6
-rw-r--r--app/models/route_control/unactivated_stop_points.rb6
-rw-r--r--app/models/route_control/vehicle_journey_at_stops.rb6
-rw-r--r--app/models/route_control/zdl_stop_area.rb6
-rw-r--r--app/models/routing_constaint_zone_control/maximum_length.rb6
-rw-r--r--app/models/routing_constaint_zone_control/minimum_length.rb6
-rw-r--r--app/models/routing_constaint_zone_control/unactivated_stop_point.rb6
-rw-r--r--app/models/vechicle_journey_control/delta.rb6
-rw-r--r--app/models/vechicle_journey_control/waiting_time.rb6
-rw-r--r--app/models/vehicle_journey_import.rb2
-rw-r--r--app/models/workbench.rb12
-rw-r--r--app/policies/compliance_control_policy.rb9
-rw-r--r--app/policies/import_policy.rb12
-rw-r--r--app/views/compliance_control_sets/_filters.html.slim7
-rw-r--r--app/views/compliance_control_sets/show.html.slim36
-rw-r--r--app/views/compliance_controls/_form.html.slim10
-rw-r--r--app/views/compliance_controls/edit.html.slim9
-rw-r--r--app/views/compliance_controls/show.html.slim3
-rw-r--r--app/views/lines/index.html.slim2
-rw-r--r--app/views/referentials/show.html.slim2
-rw-r--r--app/views/routes/_form.html.slim3
-rw-r--r--app/views/routes/show.html.slim2
-rw-r--r--app/views/stop_areas/index.html.slim2
-rw-r--r--app/views/time_tables/edit.html.slim2
72 files changed, 464 insertions, 351 deletions
diff --git a/app/assets/javascripts/es6_browserified/helpers/clone.js b/app/assets/javascripts/es6_browserified/helpers/clone.js
new file mode 100644
index 000000000..c3b627858
--- /dev/null
+++ b/app/assets/javascripts/es6_browserified/helpers/clone.js
@@ -0,0 +1,14 @@
+const _ = require("lodash")
+
+/* This function helps having a bit more security when we pass data from the backend to the React parts
+ It clones the obj (window variable) and then conditionnaly delete the window variable
+*/
+
+const clone = (window, key, deletable = false) => {
+ let obj = _.cloneDeep(window[key])
+
+ if (deletable) delete window[key]
+ return obj
+}
+
+module.exports = clone \ No newline at end of file
diff --git a/app/assets/javascripts/es6_browserified/itineraries/components/App.js b/app/assets/javascripts/es6_browserified/itineraries/components/App.js
index e662d140c..f4cc5e4a6 100644
--- a/app/assets/javascripts/es6_browserified/itineraries/components/App.js
+++ b/app/assets/javascripts/es6_browserified/itineraries/components/App.js
@@ -1,12 +1,28 @@
var React = require('react')
+var { Component, PropTypes } = require('react')
var AddStopPoint = require('../containers/AddStopPoint')
var VisibleStopPoints = require('../containers/VisibleStopPoints')
+const clone = require('../../helpers/clone')
+const I18n = clone(window , "I18n", true)
-const App = () => (
- <div>
- <VisibleStopPoints />
- <AddStopPoint />
- </div>
-)
+class App extends Component {
+
+ getChildContext() {
+ return { I18n }
+ }
+
+ render() {
+ return (
+ <div>
+ <VisibleStopPoints />
+ <AddStopPoint />
+ </div>
+ )
+ }
+}
+
+App.childContextTypes = {
+ I18n: PropTypes.object
+}
module.exports = App
diff --git a/app/assets/javascripts/es6_browserified/itineraries/components/BSelect2.js b/app/assets/javascripts/es6_browserified/itineraries/components/BSelect2.js
index 64c6d3ac7..9a82b7925 100644
--- a/app/assets/javascripts/es6_browserified/itineraries/components/BSelect2.js
+++ b/app/assets/javascripts/es6_browserified/itineraries/components/BSelect2.js
@@ -1,6 +1,6 @@
var _ = require('lodash')
var React = require('react')
-var PropTypes = require('react').PropTypes
+var { Component, PropTypes } = require('react')
var Select2 = require('react-select2')
@@ -9,9 +9,9 @@ var origin = window.location.origin
var path = window.location.pathname.split('/', 3).join('/')
-class BSelect3 extends React.Component{
- constructor(props) {
- super(props)
+class BSelect3 extends Component{
+ constructor(props, context) {
+ super(props, context)
}
onChange(e) {
this.props.onChange(this.props.index, {
@@ -73,7 +73,7 @@ class BSelect3 extends React.Component{
}
}
-class BSelect2 extends React.Component{
+class BSelect2 extends Component{
componentDidMount() {
this.refs.newSelect.el.select2('open')
}
@@ -85,7 +85,7 @@ class BSelect2 extends React.Component{
onSelect={ this.props.onSelect }
ref='newSelect'
options={{
- placeholder: 'Sélectionnez un arrêt existant...',
+ placeholder: this.context.I18n.routes.edit.select2.placeholder,
allowClear: true,
language: 'fr', /* Doesn't seem to work... :( */
theme: 'bootstrap',
@@ -121,4 +121,8 @@ class BSelect2 extends React.Component{
}
}
+BSelect2.contextTypes = {
+ I18n: PropTypes.object
+}
+
module.exports = BSelect3
diff --git a/app/assets/javascripts/es6_browserified/itineraries/components/OlMap.js b/app/assets/javascripts/es6_browserified/itineraries/components/OlMap.js
index b9e106c1a..937871346 100644
--- a/app/assets/javascripts/es6_browserified/itineraries/components/OlMap.js
+++ b/app/assets/javascripts/es6_browserified/itineraries/components/OlMap.js
@@ -1,11 +1,10 @@
var _ = require('lodash')
var React = require('react')
-var Component = require('react').Component
-var PropTypes = require('react').PropTypes
+var { Component, PropTypes } = require('react')
class OlMap extends Component{
- constructor(props){
- super(props)
+ constructor(props, context){
+ super(props, context)
}
fetchApiURL(id){
@@ -116,40 +115,40 @@ class OlMap extends Component{
<strong>{this.props.value.olMap.json.name}</strong>
</p>
<p>
- <strong>Type d'arrêt : </strong>
+ <strong>{this.context.I18n.routes.edit.stop_point_type} : </strong>
{this.props.value.olMap.json.area_type}
</p>
<p>
- <strong>Nom court : </strong>
+ <strong>{this.context.I18n.routes.edit.short_name} : </strong>
{this.props.value.olMap.json.short_name}
</p>
<p>
- <strong>ID Reflex : </strong>
+ <strong>{this.context.I18n.id_reflex} : </strong>
{this.props.value.olMap.json.user_objectid}
</p>
- <p><strong>Coordonnées : </strong></p>
+ <p><strong>{this.context.I18n.routes.edit.map.coordinates} : </strong></p>
<p style={{paddingLeft: 10, marginTop: 0}}>
- <em>Proj.: </em>WSG84<br/>
- <em>Lat.: </em>{this.props.value.olMap.json.latitude} <br/>
- <em>Lon.: </em>{this.props.value.olMap.json.longitude}
+ <em>{this.context.I18n.routes.edit.map.proj}.: </em>WSG84<br/>
+ <em>{this.context.I18n.routes.edit.map.lat}.: </em>{this.props.value.olMap.json.latitude} <br/>
+ <em>{this.context.I18n.routes.edit.map.lon}.: </em>{this.props.value.olMap.json.longitude}
</p>
<p>
- <strong>Code Postal : </strong>
+ <strong>{this.context.I18n.routes.edit.map.postal_code} : </strong>
{this.props.value.olMap.json.zip_code}
</p>
<p>
- <strong>Commune : </strong>
+ <strong>{this.context.I18n.routes.edit.map.city} : </strong>
{this.props.value.olMap.json.city_name}
</p>
<p>
- <strong>Commentaire : </strong>
+ <strong>{this.context.I18n.routes.edit.map.comment} : </strong>
{this.props.value.olMap.json.comment}
</p>
{(this.props.value.stoparea_id != this.props.value.olMap.json.stoparea_id) &&(
<div className='btn btn-outline-primary btn-sm'
onClick= {() => {this.props.onUpdateViaOlMap(this.props.index, this.props.value.olMap.json)}}
- >Sélectionner</div>
+ >{this.context.I18n.actions.select}</div>
)}
</div>
<div className='map_content'>
@@ -163,7 +162,11 @@ class OlMap extends Component{
}
}
-OlMap.propTypes = {
+OlMap.PropTypes = {
+}
+
+OlMap.contextTypes = {
+ I18n: PropTypes.object
}
module.exports = OlMap
diff --git a/app/assets/javascripts/es6_browserified/itineraries/components/StopPoint.js b/app/assets/javascripts/es6_browserified/itineraries/components/StopPoint.js
index 48f77b8e9..c3996f5b3 100644
--- a/app/assets/javascripts/es6_browserified/itineraries/components/StopPoint.js
+++ b/app/assets/javascripts/es6_browserified/itineraries/components/StopPoint.js
@@ -3,7 +3,7 @@ var PropTypes = require('react').PropTypes
var BSelect2 = require('./BSelect2')
var OlMap = require('./OlMap')
-const StopPoint = (props) => {
+const StopPoint = (props, {I18n}) => {
return (
<div className='nested-fields'>
<div className='wrapper'>
@@ -17,15 +17,15 @@ const StopPoint = (props) => {
<div>
<select className='form-control' value={props.value.for_boarding} id="for_boarding" onChange={props.onSelectChange}>
- <option value="normal">Montée autorisée</option>
- <option value="forbidden">Montée interdite</option>
+ <option value="normal">{I18n.routes.edit.stop_point.boarding.normal}</option>
+ <option value="forbidden">{I18n.routes.edit.stop_point.boarding.forbidden}</option>
</select>
</div>
<div>
<select className='form-control' value={props.value.for_alighting} id="for_alighting" onChange={props.onSelectChange}>
- <option value="normal">Descente autorisée</option>
- <option value="forbidden">Descente interdite</option>
+ <option value="normal">{I18n.routes.edit.stop_point.alighting.normal}</option>
+ <option value="forbidden">{I18n.routes.edit.stop_point.alighting.forbidden}</option>
</select>
</div>
@@ -90,4 +90,8 @@ StopPoint.propTypes = {
value: PropTypes.object
}
+StopPoint.contextTypes = {
+ I18n: PropTypes.object
+}
+
module.exports = StopPoint
diff --git a/app/assets/javascripts/es6_browserified/itineraries/components/StopPointList.js b/app/assets/javascripts/es6_browserified/itineraries/components/StopPointList.js
index 77077dbd8..37a480fca 100644
--- a/app/assets/javascripts/es6_browserified/itineraries/components/StopPointList.js
+++ b/app/assets/javascripts/es6_browserified/itineraries/components/StopPointList.js
@@ -2,29 +2,29 @@ var React = require('react')
var PropTypes = require('react').PropTypes
var StopPoint = require('./StopPoint')
-const StopPointList = ({ stopPoints, onDeleteClick, onMoveUpClick, onMoveDownClick, onChange, onSelectChange, onToggleMap, onToggleEdit, onSelectMarker, onUnselectMarker, onUpdateViaOlMap }) => {
+const StopPointList = ({ stopPoints, onDeleteClick, onMoveUpClick, onMoveDownClick, onChange, onSelectChange, onToggleMap, onToggleEdit, onSelectMarker, onUnselectMarker, onUpdateViaOlMap }, {I18n}) => {
return (
<div className='subform'>
<div className='nested-head'>
<div className="wrapper">
<div style={{width: 100}}>
<div className="form-group">
- <label className="control-label">ID Reflex</label>
+ <label className="control-label">{I18n.reflex_id}</label>
</div>
</div>
<div>
<div className="form-group">
- <label className="control-label">Arrêt</label>
+ <label className="control-label">{I18n.simple_form.labels.stop_point.name}</label>
</div>
</div>
<div>
<div className="form-group">
- <label className="control-label">Montée</label>
+ <label className="control-label">{I18n.simple_form.labels.stop_point.for_boarding}</label>
</div>
</div>
<div>
<div className="form-group">
- <label className="control-label">Descente</label>
+ <label className="control-label">{I18n.simple_form.labels.stop_point.for_alighting}</label>
</div>
</div>
<div className='actions-5'></div>
@@ -65,4 +65,8 @@ StopPointList.propTypes = {
onUnselectMarker : PropTypes.func.isRequired
}
+StopPointList.contextTypes = {
+ I18n: PropTypes.object
+}
+
module.exports = StopPointList
diff --git a/app/assets/javascripts/es6_browserified/itineraries/index.js b/app/assets/javascripts/es6_browserified/itineraries/index.js
index bb06126f7..13d89bec5 100644
--- a/app/assets/javascripts/es6_browserified/itineraries/index.js
+++ b/app/assets/javascripts/es6_browserified/itineraries/index.js
@@ -5,7 +5,9 @@ var createStore = require('redux').createStore
var reducers = require('./reducers')
var App = require('./components/App')
var { handleForm, handleStopPoints } = require('./form_helper')
-let datas = JSON.parse(decodeURIComponent(window.itinerary_stop))
+let clone = require('../helpers/clone')
+let datas = clone(window, "itinerary_stop", true)
+datas = JSON.parse(decodeURIComponent(datas))
// logger, DO NOT REMOVE
// var applyMiddleware = require('redux').applyMiddleware
diff --git a/app/assets/javascripts/es6_browserified/itineraries/show.js b/app/assets/javascripts/es6_browserified/itineraries/show.js
index 79a11701f..e88469900 100644
--- a/app/assets/javascripts/es6_browserified/itineraries/show.js
+++ b/app/assets/javascripts/es6_browserified/itineraries/show.js
@@ -1,4 +1,7 @@
+const clone = require('../helpers/clone')
+let route = clone(window, "route", true)
route = JSON.parse(decodeURIComponent(route))
+
const geoColPts = []
const geoColLns= []
const geoColEdges = [
diff --git a/app/assets/javascripts/es6_browserified/time_tables/actions/index.js b/app/assets/javascripts/es6_browserified/time_tables/actions/index.js
index ba5d91568..a421a8ed6 100644
--- a/app/assets/javascripts/es6_browserified/time_tables/actions/index.js
+++ b/app/assets/javascripts/es6_browserified/time_tables/actions/index.js
@@ -1,19 +1,21 @@
const _ = require('lodash')
+const clone = require('../../helpers/clone')
+const I18n = clone(window, "I18n")
const actions = {
+ weekDays: (index) => {
+ return _.range(1, 8).map(n => I18n.time_tables.edit.metas.days[n])
+ },
strToArrayDayTypes: (str) =>{
- let weekDays = ['Di', 'Lu', 'Ma', 'Me', 'Je', 'Ve', 'Sa']
- return weekDays.map((day, i) => str.indexOf(day) !== -1)
+ return actions.weekDays().map(day => str.indexOf(day) !== -1)
},
- arrayToStrDayTypes: (arr) => {
- let weekDays = ['Di', 'Lu', 'Ma', 'Me', 'Je', 'Ve', 'Sa']
- let str = []
- arr.map((dayActive, i) => {
- if(dayActive){
- str.push(weekDays[i])
- }
- })
- return str.join(',')
+ arrayToStrDayTypes: (dayTypes) => {
+ let newDayTypes = dayTypes.reduce((arr, dayActive, i) => {
+ if (dayActive) arr.push(actions.weekDays()[i])
+ return arr
+ }, [])
+
+ return newDayTypes.join(',')
},
fetchingApi: () =>({
type: 'FETCH_API'
@@ -149,8 +151,8 @@ const actions = {
type : 'CLOSE_MODAL'
}),
monthName(strDate) {
- let monthList = ["Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"]
- var date = new Date(strDate)
+ let monthList = _.range(1,13).map(n => I18n.calendars.months[n])
+ let date = new Date(strDate)
return monthList[date.getMonth()]
},
getHumanDate(strDate, mLimit) {
@@ -219,7 +221,7 @@ const actions = {
let period = periods[i]
if (index !== i && !period.deleted) {
if (new Date(period.period_start) <= end && new Date(period.period_end) >= start) {
- error = 'Les périodes ne peuvent pas se chevaucher'
+ error = I18n.time_tables.edit.error_submit.periods_overlaps
break
}
}
@@ -233,7 +235,7 @@ const actions = {
for (let day of in_days) {
if (start <= new Date(day.date) && end >= new Date(day.date)) {
- error = 'Une période ne peut chevaucher une date dans un calendrier'
+ error = I18n.time_tables.edit.error_submit.dates_overlaps
break
}
}
@@ -241,7 +243,6 @@ const actions = {
},
fetchTimeTables: (dispatch, nextPage) => {
let urlJSON = window.location.pathname.split('/', 5).join('/')
- // console.log(nextPage)
if(nextPage) {
urlJSON += "/month.json?date=" + nextPage
}else{
@@ -310,9 +311,9 @@ const actions = {
errorModalMessage: (errorKey) => {
switch (errorKey) {
case "withoutPeriodsWithDaysTypes":
- return window.I18n.fr.time_tables.edit.error_modal.withoutPeriodsWithDaysTypes
+ return I18n.time_tables.edit.error_modal.withoutPeriodsWithDaysTypes
case "withPeriodsWithoutDayTypes":
- return window.I18n.fr.time_tables.edit.error_modal.withPeriodsWithoutDayTypes
+ return I18n.time_tables.edit.error_modal.withPeriodsWithoutDayTypes
default:
return errorKey
diff --git a/app/assets/javascripts/es6_browserified/time_tables/components/ConfirmModal.js b/app/assets/javascripts/es6_browserified/time_tables/components/ConfirmModal.js
index 40ae0eccf..674a03296 100644
--- a/app/assets/javascripts/es6_browserified/time_tables/components/ConfirmModal.js
+++ b/app/assets/javascripts/es6_browserified/time_tables/components/ConfirmModal.js
@@ -1,18 +1,17 @@
var React = require('react')
-var Component = require('react').Component
-var PropTypes = require('react').PropTypes
+var { PropTypes } = require('react')
-const ConfirmModal = ({dispatch, modal, onModalAccept, onModalCancel, timetable, metas}) => (
+const ConfirmModal = ({dispatch, modal, onModalAccept, onModalCancel, timetable, metas}, {I18n}) => (
<div className={ 'modal fade ' + ((modal.type == 'confirm') ? 'in' : '') } id='ConfirmModal'>
<div className='modal-container'>
<div className='modal-dialog'>
<div className='modal-content'>
<div className='modal-header'>
- <h4 className='modal-title'>Confirmation</h4>
+ <h4 className='modal-title'>{I18n.time_tables.edit.confirm_modal.title}</h4>
</div>
<div className='modal-body'>
<div className='mt-md mb-md'>
- <p>Vous vous apprêtez à changer de page. Voulez-vous valider vos modifications avant cela ?</p>
+ <p>{I18n.time_tables.edit.confirm_modal.message}</p>
</div>
</div>
<div className='modal-footer'>
@@ -22,7 +21,7 @@ const ConfirmModal = ({dispatch, modal, onModalAccept, onModalCancel, timetable,
type='button'
onClick= {() => {onModalCancel(modal.confirmModal.callback)}}
>
- Ne pas valider
+ {I18n.cancel}
</button>
<button
className='btn btn-primary'
@@ -30,7 +29,7 @@ const ConfirmModal = ({dispatch, modal, onModalAccept, onModalCancel, timetable,
type='button'
onClick = {() => {onModalAccept(modal.confirmModal.callback, timetable, metas)}}
>
- Valider
+ {I18n.actions.submit}
</button>
</div>
</div>
@@ -45,4 +44,8 @@ ConfirmModal.propTypes = {
onModalCancel: PropTypes.func.isRequired
}
+ConfirmModal.contextTypes = {
+ I18n: PropTypes.object
+}
+
module.exports = ConfirmModal
diff --git a/app/assets/javascripts/es6_browserified/time_tables/components/ErrorModal.js b/app/assets/javascripts/es6_browserified/time_tables/components/ErrorModal.js
index 4e8f7e363..2597a4870 100644
--- a/app/assets/javascripts/es6_browserified/time_tables/components/ErrorModal.js
+++ b/app/assets/javascripts/es6_browserified/time_tables/components/ErrorModal.js
@@ -1,15 +1,14 @@
var React = require('react')
-var Component = require('react').Component
-var PropTypes = require('react').PropTypes
-var errorModalMessage = require('../actions').errorModalMessage
+var { PropTypes } = require('react')
+var { errorModalMessage } = require('../actions')
-const ErrorModal = ({dispatch, modal, I18n, onModalClose}) => (
+const ErrorModal = ({dispatch, modal, onModalClose}, {I18n}) => (
<div className={ 'modal fade ' + ((modal.type == 'error') ? 'in' : '') } id='ErrorModal'>
<div className='modal-container'>
<div className='modal-dialog'>
<div className='modal-content'>
<div className='modal-header'>
- <h4 className='modal-title'>{window.I18n.fr.time_tables.edit.error_modal.title}</h4>
+ <h4 className='modal-title'>{I18n.time_tables.edit.error_modal.title}</h4>
</div>
<div className='modal-body'>
<div className='mt-md mb-md'>
@@ -23,7 +22,7 @@ const ErrorModal = ({dispatch, modal, I18n, onModalClose}) => (
type='button'
onClick= {() => {onModalClose()}}
>
- Retour
+ {I18n.back}
</button>
</div>
</div>
@@ -37,4 +36,8 @@ ErrorModal.propTypes = {
onModalClose: PropTypes.func.isRequired
}
+ErrorModal.contextTypes = {
+ I18n: PropTypes.object
+}
+
module.exports = ErrorModal
diff --git a/app/assets/javascripts/es6_browserified/time_tables/components/Metas.js b/app/assets/javascripts/es6_browserified/time_tables/components/Metas.js
index a0fac84f3..26a96e4a6 100644
--- a/app/assets/javascripts/es6_browserified/time_tables/components/Metas.js
+++ b/app/assets/javascripts/es6_browserified/time_tables/components/Metas.js
@@ -1,9 +1,9 @@
var React = require('react')
-var PropTypes = require('react').PropTypes
-let weekDays = ['D', 'L', 'Ma', 'Me', 'J', 'V', 'S']
+var { PropTypes } = require('react')
+const { weekDays } = require('../actions')
var TagsSelect2 = require('./TagsSelect2')
-const Metas = ({metas, onUpdateDayTypes, onUpdateComment, onUpdateColor, onSelect2Tags, onUnselect2Tags}) => {
+const Metas = ({metas, onUpdateDayTypes, onUpdateComment, onUpdateColor, onSelect2Tags, onUnselect2Tags}, {I18n}) => {
let colorList = ["", "#9B9B9B", "#FFA070", "#C67300", "#7F551B", "#41CCE3", "#09B09C", "#3655D7", "#6321A0", "#E796C6", "#DD2DAA"]
return (
<div className='form-horizontal'>
@@ -12,7 +12,7 @@ const Metas = ({metas, onUpdateDayTypes, onUpdateComment, onUpdateColor, onSelec
{/* comment (name) */}
<div className="form-group">
<label htmlFor="" className="control-label col-sm-4 required">
- Nom <abbr title="Champ requis">*</abbr>
+ {I18n.time_tables.edit.metas.name} <abbr title="">*</abbr>
</label>
<div className="col-sm-8">
<input
@@ -27,7 +27,7 @@ const Metas = ({metas, onUpdateDayTypes, onUpdateComment, onUpdateColor, onSelec
{/* color */}
<div className="form-group">
- <label htmlFor="" className="control-label col-sm-4">Couleur associée</label>
+ <label htmlFor="" className="control-label col-sm-4">{I18n.activerecord.attributes.time_table.color}</label>
<div className="col-sm-8">
<div className="dropdown color_selector">
<button
@@ -72,7 +72,7 @@ const Metas = ({metas, onUpdateDayTypes, onUpdateComment, onUpdateColor, onSelec
{/* tags */}
<div className="form-group">
- <label htmlFor="" className="control-label col-sm-4">Etiquettes</label>
+ <label htmlFor="" className="control-label col-sm-4">{I18n.activerecord.attributes.time_table.tag_list}</label>
<div className="col-sm-8">
<TagsSelect2
initialTags={metas.initial_tags}
@@ -85,16 +85,16 @@ const Metas = ({metas, onUpdateDayTypes, onUpdateComment, onUpdateColor, onSelec
{/* calendar */}
<div className="form-group">
- <label htmlFor="" className="control-label col-sm-4">Modèle de calendrier associé</label>
+ <label htmlFor="" className="control-label col-sm-4">{I18n.activerecord.attributes.time_table.calendar}</label>
<div className="col-sm-8">
- <span>{metas.calendar ? metas.calendar.name : 'Aucun'}</span>
+ <span>{metas.calendar ? metas.calendar.name : I18n.time_tables.edit.metas.no_calendar}</span>
</div>
</div>
{/* day_types */}
<div className="form-group">
<label htmlFor="" className="control-label col-sm-4">
- Journées d'applications pour les périodes ci-dessous
+ {I18n.time_tables.edit.metas.day_types}
</label>
<div className="col-sm-8">
<div className="form-group labelled-checkbox-group">
@@ -112,7 +112,7 @@ const Metas = ({metas, onUpdateDayTypes, onUpdateComment, onUpdateColor, onSelec
type="checkbox"
checked={day ? 'checked' : ''}
/>
- <span className='lcbx-group-item-label'>{weekDays[i]}</span>
+ <span className='lcbx-group-item-label'>{weekDays()[i]}</span>
</label>
</div>
</div>
@@ -135,4 +135,8 @@ Metas.propTypes = {
onUnselect2Tags: PropTypes.func.isRequired
}
+Metas.contextTypes = {
+ I18n: PropTypes.object
+}
+
module.exports = Metas
diff --git a/app/assets/javascripts/es6_browserified/time_tables/components/PeriodForm.js b/app/assets/javascripts/es6_browserified/time_tables/components/PeriodForm.js
index 3234a3fd7..d494109cc 100644
--- a/app/assets/javascripts/es6_browserified/time_tables/components/PeriodForm.js
+++ b/app/assets/javascripts/es6_browserified/time_tables/components/PeriodForm.js
@@ -1,5 +1,5 @@
var React = require('react')
-var PropTypes = require('react').PropTypes
+var { PropTypes } = require('react')
var _ = require('lodash')
let monthsArray = ['Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre']
@@ -32,7 +32,7 @@ const makeYearsOptions = (yearSelected) => {
return arr
}
-const PeriodForm = ({modal, timetable, metas, onOpenAddPeriodForm, onClosePeriodForm, onUpdatePeriodForm, onValidatePeriodForm}) => (
+const PeriodForm = ({modal, timetable, metas, onOpenAddPeriodForm, onClosePeriodForm, onUpdatePeriodForm, onValidatePeriodForm}, {I18n}) => (
<div className="container-fluid">
<div className="row">
<div className="col lg-6 col-lg-offset-3">
@@ -44,7 +44,7 @@ const PeriodForm = ({modal, timetable, metas, onOpenAddPeriodForm, onClosePeriod
<div>
<div className="form-group">
<label htmlFor="" className="control-label required">
- Début de période
+ {I18n.time_tables.edit.period_form.begin}
<abbr title="requis">*</abbr>
</label>
</div>
@@ -52,7 +52,7 @@ const PeriodForm = ({modal, timetable, metas, onOpenAddPeriodForm, onClosePeriod
<div>
<div className="form-group">
<label htmlFor="" className="control-label required">
- Fin de période
+ {I18n.time_tables.edit.period_form.end}
<abbr title="requis">*</abbr>
</label>
</div>
@@ -103,14 +103,14 @@ const PeriodForm = ({modal, timetable, metas, onOpenAddPeriodForm, onClosePeriod
className='btn btn-link'
onClick={onClosePeriodForm}
>
- Annuler
+ {I18n.cancel}
</button>
<button
type='button'
className='btn btn-outline-primary mr-sm'
onClick={() => onValidatePeriodForm(modal.modalProps, timetable.time_table_periods, metas, _.filter(timetable.time_table_dates, ['in_out', true]))}
>
- Valider
+ {I18n.actions.submit}
</button>
</div>
</div>
@@ -122,7 +122,7 @@ const PeriodForm = ({modal, timetable, metas, onOpenAddPeriodForm, onClosePeriod
className='btn btn-outline-primary'
onClick={onOpenAddPeriodForm}
>
- Ajouter une période
+ {I18n.time_tables.actions.add_period}
</button>
</div>
}
@@ -142,4 +142,8 @@ PeriodForm.propTypes = {
timetable: PropTypes.object.isRequired
}
+PeriodForm.contextTypes = {
+ I18n: PropTypes.object
+}
+
module.exports = PeriodForm
diff --git a/app/assets/javascripts/es6_browserified/time_tables/components/PeriodManager.js b/app/assets/javascripts/es6_browserified/time_tables/components/PeriodManager.js
index cf4cbfb32..704e21331 100644
--- a/app/assets/javascripts/es6_browserified/time_tables/components/PeriodManager.js
+++ b/app/assets/javascripts/es6_browserified/time_tables/components/PeriodManager.js
@@ -1,11 +1,10 @@
var React = require('react')
-var Component = require('react').Component
-var PropTypes = require('react').PropTypes
+var { Component, PropTypes } = require('react')
var actions = require('../actions')
class PeriodManager extends Component {
- constructor(props) {
- super(props)
+ constructor(props, context) {
+ super(props, context)
}
toEndPeriod(curr, end) {
@@ -82,4 +81,8 @@ PeriodManager.propTypes = {
onOpenEditPeriodForm: PropTypes.func.isRequired
}
+PeriodManager.contextTypes = {
+ I18n: PropTypes.object
+}
+
module.exports = PeriodManager
diff --git a/app/assets/javascripts/es6_browserified/time_tables/components/TagsSelect2.js b/app/assets/javascripts/es6_browserified/time_tables/components/TagsSelect2.js
index a1f41a693..46188cdd1 100644
--- a/app/assets/javascripts/es6_browserified/time_tables/components/TagsSelect2.js
+++ b/app/assets/javascripts/es6_browserified/time_tables/components/TagsSelect2.js
@@ -9,8 +9,8 @@ var path = window.location.pathname.split('/', 4).join('/')
var _ = require('lodash')
class TagsSelect2 extends React.Component{
- constructor(props) {
- super(props)
+ constructor(props, context) {
+ super(props, context)
}
mapKeys(array){
@@ -38,7 +38,7 @@ class TagsSelect2 extends React.Component{
allowClear: true,
theme: 'bootstrap',
width: '100%',
- placeholder: 'Ajoutez ou cherchez une étiquette...',
+ placeholder: this.context.I18n.time_tables.edit.select2.tag.placeholder,
ajax: {
url: origin + path + '/tags.json',
dataType: 'json',
@@ -74,4 +74,8 @@ const formatRepo = (props) => {
if(props.name) return props.name
}
+TagsSelect2.contextTypes = {
+ I18n: PropTypes.object
+}
+
module.exports = TagsSelect2
diff --git a/app/assets/javascripts/es6_browserified/time_tables/components/TimeTableDay.js b/app/assets/javascripts/es6_browserified/time_tables/components/TimeTableDay.js
index 71621c874..93a0a90fe 100644
--- a/app/assets/javascripts/es6_browserified/time_tables/components/TimeTableDay.js
+++ b/app/assets/javascripts/es6_browserified/time_tables/components/TimeTableDay.js
@@ -1,6 +1,5 @@
var React = require('react')
-var Component = require('react').Component
-var PropTypes = require('react').PropTypes
+var { Component, PropTypes } = require('react')
class TimeTableDay extends Component {
constructor(props) {
diff --git a/app/assets/javascripts/es6_browserified/time_tables/components/Timetable.js b/app/assets/javascripts/es6_browserified/time_tables/components/Timetable.js
index a613549c3..22e971c6b 100644
--- a/app/assets/javascripts/es6_browserified/time_tables/components/Timetable.js
+++ b/app/assets/javascripts/es6_browserified/time_tables/components/Timetable.js
@@ -1,14 +1,13 @@
var React = require('react')
-var Component = require('react').Component
-var PropTypes = require('react').PropTypes
+var { Component, PropTypes} = require('react')
var TimeTableDay = require('./TimeTableDay')
var PeriodsInDay = require('./PeriodsInDay')
var ExceptionsInDay = require('./ExceptionsInDay')
var actions = require('../actions')
class Timetable extends Component{
- constructor(props){
- super(props)
+ constructor(props, context){
+ super(props, context)
}
currentDate(mFirstday, day) {
@@ -31,11 +30,11 @@ class Timetable extends Component{
<div className="table table-2entries mb-sm">
<div className="t2e-head w20">
<div className="th">
- <div className="strong">Synthèse</div>
+ <div className="strong">{this.context.I18n.time_tables.synthesis}</div>
</div>
- <div className="td"><span>Journées d'application</span></div>
- <div className="td"><span>Périodes</span></div>
- <div className="td"><span>Exceptions</span></div>
+ <div className="td"><span>{this.context.I18n.time_tables.edit.day_types}</span></div>
+ <div className="td"><span>{this.context.I18n.time_tables.edit.periods}</span></div>
+ <div className="td"><span>{this.context.I18n.time_tables.edit.exceptions}</span></div>
</div>
<div className="t2e-item-list w80">
<div>
@@ -111,4 +110,8 @@ Timetable.propTypes = {
onIncludeDateInPeriod: PropTypes.func.isRequired
}
+Timetable.contextTypes = {
+ I18n: PropTypes.object
+}
+
module.exports = Timetable
diff --git a/app/assets/javascripts/es6_browserified/time_tables/containers/App.js b/app/assets/javascripts/es6_browserified/time_tables/containers/App.js
index 02f0ddbd8..f12fb8a71 100644
--- a/app/assets/javascripts/es6_browserified/time_tables/containers/App.js
+++ b/app/assets/javascripts/es6_browserified/time_tables/containers/App.js
@@ -1,6 +1,6 @@
var React = require('react')
var connect = require('react-redux').connect
-var Component = require('react').Component
+var { Component, PropTypes} = require('react')
var actions = require('../actions')
var Metas = require('./Metas')
var Timetable = require('./Timetable')
@@ -10,11 +10,18 @@ var SaveTimetable = require('./SaveTimetable')
var ConfirmModal = require('./ConfirmModal')
var ErrorModal = require('./ErrorModal')
+const clone = require('../../helpers/clone')
+const I18n = clone(window, "I18n", true)
+
class App extends Component {
componentDidMount(){
this.props.onLoadFirstPage()
}
+ getChildContext() {
+ return { I18n }
+ }
+
render(){
return(
<div className='row'>
@@ -41,6 +48,10 @@ const mapDispatchToProps = (dispatch) => {
}
}
+App.childContextTypes = {
+ I18n: PropTypes.object
+}
+
const timeTableApp = connect(null, mapDispatchToProps)(App)
module.exports = timeTableApp
diff --git a/app/assets/javascripts/es6_browserified/time_tables/index.js b/app/assets/javascripts/es6_browserified/time_tables/index.js
index a91747991..6c352df6b 100644
--- a/app/assets/javascripts/es6_browserified/time_tables/index.js
+++ b/app/assets/javascripts/es6_browserified/time_tables/index.js
@@ -5,6 +5,9 @@ var createStore = require('redux').createStore
var timeTablesApp = require('./reducers')
var App = require('./containers/App')
+const clone = require('../helpers/clone')
+const actionType = clone(window, "actionType", true)
+
// logger, DO NOT REMOVE
// var applyMiddleware = require('redux').applyMiddleware
// var createLogger = require('redux-logger')
@@ -13,7 +16,7 @@ var App = require('./containers/App')
var initialState = {
status: {
- actionType: window.actionType,
+ actionType: actionType,
policy: window.perms,
fetchSuccess: true,
isFetching: false
diff --git a/app/assets/javascripts/es6_browserified/time_tables/reducers/timetable.js b/app/assets/javascripts/es6_browserified/time_tables/reducers/timetable.js
index edb965065..712808abd 100644
--- a/app/assets/javascripts/es6_browserified/time_tables/reducers/timetable.js
+++ b/app/assets/javascripts/es6_browserified/time_tables/reducers/timetable.js
@@ -96,9 +96,9 @@ const timetable = (state = {}, action) => {
let newPeriods = JSON.parse(JSON.stringify(action.timeTablePeriods))
if (action.modalProps.index !== false){
- updatePeriod = newPeriods[action.modalProps.index]
- updatePeriod.period_start = period_start
- updatePeriod.period_end = period_end
+ let updatedPeriod = newPeriods[action.modalProps.index]
+ updatedPeriod.period_start = period_start
+ updatedPeriod.period_end = period_end
newDates = _.reject(state.time_table_dates, d => actions.isInPeriod(newPeriods, d.date) && !d.in_out)
}else{
let newPeriod = {
diff --git a/app/controllers/compliance_control_sets_controller.rb b/app/controllers/compliance_control_sets_controller.rb
index c6f4288a9..306b2eac7 100644
--- a/app/controllers/compliance_control_sets_controller.rb
+++ b/app/controllers/compliance_control_sets_controller.rb
@@ -1,10 +1,12 @@
class ComplianceControlSetsController < BreadcrumbController
defaults resource_class: ComplianceControlSet
+ before_action :ransack_updated_at_params, only: [:index]
respond_to :html
def index
index! do |format|
- @q_for_form = @compliance_control_sets.ransack(params[:q])
+ scope = ransack_period @compliance_control_sets
+ @q_for_form = scope.ransack(params[:q])
format.html {
@compliance_control_sets = decorate_compliance_control_sets(@q_for_form.result)
}
@@ -12,11 +14,15 @@ class ComplianceControlSetsController < BreadcrumbController
end
def show
- show! do
- @compliance_control_set = @compliance_control_set.decorate
+ show! do |format|
+ format.html {
+ @compliance_control_set = @compliance_control_set.decorate
+ @compliance_controls = decorate_compliance_controls(@compliance_control_set.compliance_controls)
+ }
end
end
+ private
def decorate_compliance_control_sets(compliance_control_sets)
ModelDecorator.decorate(
compliance_control_sets,
@@ -31,6 +37,39 @@ class ComplianceControlSetsController < BreadcrumbController
# end
private
+ def decorate_compliance_controls(compliance_controls)
+ ModelDecorator.decorate(
+ compliance_controls,
+ with: ComplianceControlDecorator,
+ )
+ end
+
+ def ransack_updated_at_params
+ start_date = []
+ end_date = []
+
+ if params[:q] && params[:q][:updated_at] && !params[:q][:updated_at].has_value?(nil) && !params[:q][:updated_at].has_value?("")
+ [1, 2, 3].each do |key|
+ start_date << params[:q][:updated_at]["begin(#{key}i)"].to_i
+ end_date << params[:q][:updated_at]["end(#{key}i)"].to_i
+ end
+ params[:q].delete([:updated_at])
+ @begin_range = DateTime.new(*start_date,0,0,0) rescue nil
+ @end_range = DateTime.new(*end_date,23,59,59) rescue nil
+ end
+ end
+
+ # Fake ransack filter
+ def ransack_period scope
+ return scope unless !!@begin_range && !!@end_range
+
+ if @begin_range > @end_range
+ flash.now[:error] = t('imports.filters.error_period_filter')
+ else
+ scope = scope.where_updated_at_between(@begin_range, @end_range)
+ end
+ scope
+ end
def compliance_control_set_params
params.require(:compliance_control_set).permit(:name, :id)
diff --git a/app/controllers/compliance_controls_controller.rb b/app/controllers/compliance_controls_controller.rb
index dad9b935a..eb1ba68ea 100644
--- a/app/controllers/compliance_controls_controller.rb
+++ b/app/controllers/compliance_controls_controller.rb
@@ -1,18 +1,11 @@
class ComplianceControlsController < BreadcrumbController
- include PolicyChecker
defaults resource_class: ComplianceControl
belongs_to :compliance_control_set
- def index
- index! do |format|
- format.html {
- @compliance_controls = decorate_compliance_controls(@compliance_controls)
- }
- end
- end
-
- def create
- create!(notice: t('notice.compliance_control.created'))
+ def new
+ @compliance_control_set = parent
+ @compliance_control = GenericAttributeControl::MinMax.new
+ @compliance_control.build_compliance_control_block
end
def update
@@ -20,19 +13,14 @@ class ComplianceControlsController < BreadcrumbController
update!(notice: t('notice.compliance_control.updated')) { path }
end
- def destroy
- destroy!(notice: t('notice.compliance_control.destroyed'))
- end
-
private
- def decorate_compliance_controls(compliance_controls)
- ModelDecorator.decorate(
- compliance_controls,
- with: ComplianceControlDecorator,
- )
+ def dynamic_attributes_params
+ params.require(:compliance_control).permit(:type).values[0].constantize.dynamic_attributes
end
def compliance_control_params
- params.require(:compliance_control).permit(:name, :code, :criticity, :comment, :control_attributes)
+ base = [:name, :code, :origin_code, :criticity, :comment, :control_attributes, :type, compliance_control_block_attributes: [:name, :transport_mode]]
+ permited = base + dynamic_attributes_params
+ params.require(:compliance_control).permit(permited)
end
end
diff --git a/app/controllers/imports_controller.rb b/app/controllers/imports_controller.rb
index 3333dc535..f2e65e445 100644
--- a/app/controllers/imports_controller.rb
+++ b/app/controllers/imports_controller.rb
@@ -1,4 +1,5 @@
class ImportsController < BreadcrumbController
+ include PolicyChecker
skip_before_action :authenticate_user!, only: [:download]
defaults resource_class: Import, collection_name: 'imports', instance_name: 'import'
before_action :ransack_started_at_params, only: [:index]
diff --git a/app/decorators/company_decorator.rb b/app/decorators/company_decorator.rb
index 402bd3ab6..764cce3a0 100644
--- a/app/decorators/company_decorator.rb
+++ b/app/decorators/company_decorator.rb
@@ -19,8 +19,6 @@ class CompanyDecorator < Draper::Decorator
links = []
if h.policy(Chouette::Company).create?
- require 'pry'
- binding.pry
links << Link.new(
content: h.t('companies.actions.new'),
href: h.new_line_referential_company_path(context[:referential])
diff --git a/app/decorators/compliance_control_decorator.rb b/app/decorators/compliance_control_decorator.rb
index 38b968ad1..3a05a5c59 100644
--- a/app/decorators/compliance_control_decorator.rb
+++ b/app/decorators/compliance_control_decorator.rb
@@ -4,21 +4,21 @@ class ComplianceControlDecorator < Draper::Decorator
def action_links
links = []
- if h.policy(object).destroy?
+ # if h.policy(object).destroy?
links << Link.new(
content: h.destroy_link_content,
href: h.compliance_control_set_compliance_control_path(object.compliance_control_set.id, object.id),
method: :delete,
data: { confirm: h.t('compliance_controls.actions.destroy_confirm') }
)
- end
+ # end
- if h.policy(object).edit?
+ # if h.policy(object).edit?
links << Link.new(
content: h.t('compliance_controls.actions.edit'),
- href: h.edit_compliance_control_set_path(object.compliance_control_set.id, object.id)
+ href: h.edit_compliance_control_set_compliance_control_path(object.compliance_control_set.id, object.id)
)
- end
+ # end
links
end
diff --git a/app/decorators/compliance_control_set_decorator.rb b/app/decorators/compliance_control_set_decorator.rb
index 876a54d09..f9e4de836 100644
--- a/app/decorators/compliance_control_set_decorator.rb
+++ b/app/decorators/compliance_control_set_decorator.rb
@@ -19,6 +19,13 @@ class ComplianceControlSetDecorator < Draper::Decorator
href: h.edit_compliance_control_set_path(object.id)
)
# end
+
+ # if h.policy(ComplianceControl).create?
+ links << Link.new(
+ content: h.t('compliance_control_sets.actions.add_compliance_control'),
+ href: h.new_compliance_control_set_compliance_control_path(object.id)
+ )
+ # end
links
end
diff --git a/app/helpers/referentials_helper.rb b/app/helpers/referentials_helper.rb
index 73384bef6..f3c18d9f8 100644
--- a/app/helpers/referentials_helper.rb
+++ b/app/helpers/referentials_helper.rb
@@ -1,2 +1,12 @@
module ReferentialsHelper
+ # Line statuses helper
+ def line_status(status)
+ if status
+ cls = 'danger'
+ content_tag :span, status ? " #{t('false')} " : " #{t('true')}", class: "fa fa-exclamation-circle fa-lg text-#{cls}"
+ else
+ cls = 'success'
+ content_tag :span, status ? " #{t('false')} " : " #{t('true')}", class: "fa fa-check-circle fa-lg text-#{cls}"
+ end
+ end
end
diff --git a/app/models/compliance_check.rb b/app/models/compliance_check.rb
index 85cf5e37e..4c29129b9 100644
--- a/app/models/compliance_check.rb
+++ b/app/models/compliance_check.rb
@@ -6,4 +6,5 @@ class ComplianceCheck < ActiveRecord::Base
validates :criticity, presence: true
validates :name, presence: true
validates :code, presence: true
+ validates :origin_code, presence: true
end
diff --git a/app/models/compliance_control.rb b/app/models/compliance_control.rb
index 12ff4737a..c5389e832 100644
--- a/app/models/compliance_control.rb
+++ b/app/models/compliance_control.rb
@@ -1,12 +1,42 @@
class ComplianceControl < ActiveRecord::Base
+ extend Enumerize
belongs_to :compliance_control_set
- belongs_to :compliance_control_block
+ has_one :compliance_control_block, dependent: :destroy
+ accepts_nested_attributes_for :compliance_control_block
+
+ @@default_criticity = :warning
+ @@default_code = ""
- extend Enumerize
enumerize :criticity, in: %i(info warning error), scope: true, default: :info
validates :criticity, presence: true
validates :name, presence: true
validates :code, presence: true
+ validates :origin_code, presence: true
validates :compliance_control_set, presence: true
+
+ def self.policy_class
+ ComplianceControlPolicy
+ end
+
+ def self.inherited(child)
+ child.instance_eval do
+ def model_name
+ ComplianceControl.model_name
+ end
+ end
+ super
+ end
+
+ before_validation(on: :create) do
+ self.name ||= self.class.name
+ self.code ||= @@default_code
+ self.origin_code ||= @@default_code
+ self.criticity ||= @@default_criticity
+ end
+
end
+
+# Ensure STI subclasses are loaded
+# http://guides.rubyonrails.org/autoloading_and_reloading_constants.html#autoloading-and-sti
+require_dependency 'generic_attribute_control/min_max'
diff --git a/app/models/compliance_control_block.rb b/app/models/compliance_control_block.rb
index cf5a9d72b..a08e271f6 100644
--- a/app/models/compliance_control_block.rb
+++ b/app/models/compliance_control_block.rb
@@ -1,3 +1,16 @@
class ComplianceControlBlock < ActiveRecord::Base
belongs_to :compliance_control_set
+ belongs_to :compliance_control
+
+ before_save :set_compliance_control_set
+
+ hstore_accessor :condition_attributes, transport_mode: :string
+
+ def set_compliance_control_set
+ self.compliance_control_set = self.compliance_control.compliance_control_set
+ end
+
+ def self.transport_modes
+ ["all"] + StifTransportModeEnumerations.transport_mode.values
+ end
end
diff --git a/app/models/compliance_control_set.rb b/app/models/compliance_control_set.rb
index cefdfbf1f..f8f491cba 100644
--- a/app/models/compliance_control_set.rb
+++ b/app/models/compliance_control_set.rb
@@ -1,7 +1,9 @@
class ComplianceControlSet < ActiveRecord::Base
belongs_to :organisation
- has_many :compliance_controls
+ has_many :compliance_controls, dependent: :destroy
validates :name, presence: true
-
+ scope :where_updated_at_between, ->(start_date, end_date) do
+ where('updated_at BETWEEN ? AND ?', start_date, end_date)
+ end
end
diff --git a/app/models/generic_attribute_control/min_max.rb b/app/models/generic_attribute_control/min_max.rb
new file mode 100644
index 000000000..6a2e1f284
--- /dev/null
+++ b/app/models/generic_attribute_control/min_max.rb
@@ -0,0 +1,17 @@
+module GenericAttributeControl
+ class MinMax < ComplianceControl
+ hstore_accessor :control_attributes, minimum: :integer, maximum: :integer
+
+ @@default_criticity = :warning
+ @@default_code = "3-Generic-2"
+
+ validate :min_max_values
+ def min_max_values
+ true
+ end
+
+ def self.dynamic_attributes
+ self.hstore_metadata_for_control_attributes.keys
+ end
+ end
+end
diff --git a/app/models/generic_attribute_control/pattern.rb b/app/models/generic_attribute_control/pattern.rb
new file mode 100644
index 000000000..5b27da54e
--- /dev/null
+++ b/app/models/generic_attribute_control/pattern.rb
@@ -0,0 +1,13 @@
+module GenericAttributeControl
+ class Pattern < ComplianceControl
+ hstore_accessor :control_attributes, value: :string, pattern: :string
+
+ @@default_criticity = :warning
+ @@default_code = "3-Generic-3"
+
+ validate :pattern_match
+ def pattern_match
+ true
+ end
+ end
+end \ No newline at end of file
diff --git a/app/models/generic_attribute_control/uniqueness.rb b/app/models/generic_attribute_control/uniqueness.rb
new file mode 100644
index 000000000..4f1a82083
--- /dev/null
+++ b/app/models/generic_attribute_control/uniqueness.rb
@@ -0,0 +1,13 @@
+module GenericAttributeControl
+ class Uniqueness < ComplianceControl
+ hstore_accessor :control_attributes, name: :string
+
+ @@default_criticity = :warning
+ @@default_code = "3-Generic-3"
+
+ validate :unique_values
+ def unique_values
+ true
+ end
+ end
+end \ No newline at end of file
diff --git a/app/models/generic_attribute_min_max.rb b/app/models/generic_attribute_min_max.rb
deleted file mode 100644
index e9a127c56..000000000
--- a/app/models/generic_attribute_min_max.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-#module ComplianceControls
-
- class GenericAttributeMinMax < ComplianceControl
-
-
- hstore_accessor :control_attributes, minimum: :integer, maximum: :integer
- #attribute :minimum, type: :integer, optionnal: true
- #attribute :maximum, type: :integer, optionnal: true
- # #attribute :target, type: ModelAttribute
-
- @@default_criticity = :warning
- @@default_code = "3-Generic-2"
-
- validate :min_max_values
- def min_max_values
- true
- end
-
- after_initialize do
- self.name = 'GenericAttributeMinMax'
- self.code = @@default_code
- self.criticity = @@default_criticity
- end
-
- end
-
-#end
diff --git a/app/models/generic_attribute_pattern.rb b/app/models/generic_attribute_pattern.rb
deleted file mode 100644
index 0043f1563..000000000
--- a/app/models/generic_attribute_pattern.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-#module ComplianceControls
-
- class GenericAttributePattern < ComplianceControl
-
- hstore_accessor :control_attributes, value: :string, pattern: :string
-
- @@default_criticity = :warning
- @@default_code = "3-Generic-3"
-
- validate :pattern_match
- def pattern_match
- true
- end
-
- after_initialize do
- self.name = 'GenericAttributeMinMax'
- self.code = @@default_code
- self.criticity = @@default_criticity
- end
-
- end
-
-#end \ No newline at end of file
diff --git a/app/models/generic_attribute_uniqueness.rb b/app/models/generic_attribute_uniqueness.rb
deleted file mode 100644
index dcf4a16c2..000000000
--- a/app/models/generic_attribute_uniqueness.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-#module ComplianceControls
-
- class GenericAttributeUniqueness < ComplianceControl
-
- hstore_accessor :control_attributes, name: :string
-
- @@default_criticity = :warning
- @@default_code = "3-Generic-3"
-
- validate :unique_values
- def unique_values
- true
- end
-
- after_initialize do
- self.name = 'GenericAttributeMinMax'
- self.code = @@default_code
- self.criticity = @@default_criticity
- end
-
- end
-
-#end \ No newline at end of file
diff --git a/app/models/journey_pattern_control/duplicates.rb b/app/models/journey_pattern_control/duplicates.rb
index 78ca07e90..d3908cfc0 100644
--- a/app/models/journey_pattern_control/duplicates.rb
+++ b/app/models/journey_pattern_control/duplicates.rb
@@ -3,11 +3,5 @@ module JourneyPatternControl
@@default_criticity = :warning
@@default_code = "3-JourneyPattern-1"
-
- after_initialize do
- self.name = self.class.name
- self.code = @@default_code
- self.criticity = @@default_criticity
- end
end
end
diff --git a/app/models/journey_pattern_control/vehicle_journey.rb b/app/models/journey_pattern_control/vehicle_journey.rb
index a90c16138..d7151f147 100644
--- a/app/models/journey_pattern_control/vehicle_journey.rb
+++ b/app/models/journey_pattern_control/vehicle_journey.rb
@@ -3,11 +3,5 @@ module JourneyPatternControl
@@default_criticity = :warning
@@default_code = "3-JourneyPattern-2"
-
- after_initialize do
- self.name = self.class.name
- self.code = @@default_code
- self.criticity = @@default_criticity
- end
end
end \ No newline at end of file
diff --git a/app/models/line_control/route.rb b/app/models/line_control/route.rb
index 8ac13a080..21c5eca06 100644
--- a/app/models/line_control/route.rb
+++ b/app/models/line_control/route.rb
@@ -3,11 +3,5 @@ module LineControl
@@default_criticity = :warning
@@default_code = "3-Line-1"
-
- after_initialize do
- self.name = self.class.name
- self.code = @@default_code
- self.criticity = @@default_criticity
- end
end
end \ No newline at end of file
diff --git a/app/models/route_control/duplicates.rb b/app/models/route_control/duplicates.rb
index 379d7cf98..fb9c34e0a 100644
--- a/app/models/route_control/duplicates.rb
+++ b/app/models/route_control/duplicates.rb
@@ -3,11 +3,5 @@ module RouteControl
@@default_criticity = :warning
@@default_code = "3-Route-4"
-
- after_initialize do
- self.name = self.class.name
- self.code = @@default_code
- self.criticity = @@default_criticity
- end
end
end
diff --git a/app/models/route_control/journey_pattern.rb b/app/models/route_control/journey_pattern.rb
index 0559fac42..08f603d8f 100644
--- a/app/models/route_control/journey_pattern.rb
+++ b/app/models/route_control/journey_pattern.rb
@@ -3,11 +3,5 @@ module RouteControl
@@default_criticity = :warning
@@default_code = "3-Route-3"
-
- after_initialize do
- self.name = self.class.name
- self.code = @@default_code
- self.criticity = @@default_criticity
- end
end
end \ No newline at end of file
diff --git a/app/models/route_control/minimum_length.rb b/app/models/route_control/minimum_length.rb
index 14bc7064f..f42b88748 100644
--- a/app/models/route_control/minimum_length.rb
+++ b/app/models/route_control/minimum_length.rb
@@ -3,11 +3,5 @@ module RouteControl
@@default_criticity = :error
@@default_code = "3-Route-6"
-
- after_initialize do
- self.name = self.class.name
- self.code = @@default_code
- self.criticity = @@default_criticity
- end
end
end
diff --git a/app/models/route_control/omnibus_journey_pattern.rb b/app/models/route_control/omnibus_journey_pattern.rb
index 2f09ff735..3b9f6d06f 100644
--- a/app/models/route_control/omnibus_journey_pattern.rb
+++ b/app/models/route_control/omnibus_journey_pattern.rb
@@ -3,11 +3,5 @@ module RouteControl
@@default_criticity = :warning
@@default_code = "3-Route-9"
-
- after_initialize do
- self.name = self.class.name
- self.code = @@default_code
- self.criticity = @@default_criticity
- end
end
end
diff --git a/app/models/route_control/opposite_route.rb b/app/models/route_control/opposite_route.rb
index d5f2bc59e..e91b081e2 100644
--- a/app/models/route_control/opposite_route.rb
+++ b/app/models/route_control/opposite_route.rb
@@ -3,12 +3,5 @@ module RouteControl
@@default_criticity = :error
@@default_code = "3-Route-2"
-
- after_initialize do
- self.name = self.class.name
- self.code = @@default_code
- self.criticity = @@default_criticity
- end
-
end
end
diff --git a/app/models/route_control/opposite_route_terminus.rb b/app/models/route_control/opposite_route_terminus.rb
index e72229ca3..fd62b7684 100644
--- a/app/models/route_control/opposite_route_terminus.rb
+++ b/app/models/route_control/opposite_route_terminus.rb
@@ -3,11 +3,5 @@ module RouteControl
@@default_criticity = :warning
@@default_code = "3-Route-5"
-
- after_initialize do
- self.name = self.class.name
- self.code = @@default_code
- self.criticity = @@default_criticity
- end
end
end \ No newline at end of file
diff --git a/app/models/route_control/speed.rb b/app/models/route_control/speed.rb
index fb07b5c87..0a2b6ac76 100644
--- a/app/models/route_control/speed.rb
+++ b/app/models/route_control/speed.rb
@@ -5,11 +5,5 @@ module VehicleJourneyControl
@@default_criticity = :warning
@@default_code = "3-VehicleJourney-2"
-
- after_initialize do
- self.name = self.class.name
- self.code = @@default_code
- self.criticity = @@default_criticity
- end
end
end
diff --git a/app/models/route_control/stop_points_in_journey_pattern.rb b/app/models/route_control/stop_points_in_journey_pattern.rb
index 195257a4a..dced6c005 100644
--- a/app/models/route_control/stop_points_in_journey_pattern.rb
+++ b/app/models/route_control/stop_points_in_journey_pattern.rb
@@ -3,11 +3,5 @@ module RouteControl
@@default_criticity = :error
@@default_code = "3-Route-6"
-
- after_initialize do
- self.name = self.class.name
- self.code = @@default_code
- self.criticity = @@default_criticity
- end
end
end
diff --git a/app/models/route_control/time_table.rb b/app/models/route_control/time_table.rb
index 911807ba9..5d0f21b40 100644
--- a/app/models/route_control/time_table.rb
+++ b/app/models/route_control/time_table.rb
@@ -3,11 +3,5 @@ module VehicleJourneyControl
@@default_criticity = :error
@@default_code = "3-VehicleJourney-4"
-
- after_initialize do
- self.name = self.class.name
- self.code = @@default_code
- self.criticity = @@default_criticity
- end
end
end
diff --git a/app/models/route_control/unactivated_stop_points.rb b/app/models/route_control/unactivated_stop_points.rb
index 8ab680490..dee846cbb 100644
--- a/app/models/route_control/unactivated_stop_points.rb
+++ b/app/models/route_control/unactivated_stop_points.rb
@@ -3,11 +3,5 @@ module RouteControl
@@default_criticity = :warning
@@default_code = "3-Route-10"
-
- after_initialize do
- self.name = self.class.name
- self.code = @@default_code
- self.criticity = @@default_criticity
- end
end
end
diff --git a/app/models/route_control/vehicle_journey_at_stops.rb b/app/models/route_control/vehicle_journey_at_stops.rb
index 02a43fb10..149282fe6 100644
--- a/app/models/route_control/vehicle_journey_at_stops.rb
+++ b/app/models/route_control/vehicle_journey_at_stops.rb
@@ -3,11 +3,5 @@ module VehicleJourneyControl
@@default_criticity = :error
@@default_code = "3-VehicleJourney-5"
-
- after_initialize do
- self.name = self.class.name
- self.code = @@default_code
- self.criticity = @@default_criticity
- end
end
end
diff --git a/app/models/route_control/zdl_stop_area.rb b/app/models/route_control/zdl_stop_area.rb
index 4561c9b2e..088a1d2f2 100644
--- a/app/models/route_control/zdl_stop_area.rb
+++ b/app/models/route_control/zdl_stop_area.rb
@@ -3,11 +3,5 @@ module RouteControl
@@default_criticity = :warning
@@default_code = "3-Route-1"
-
- after_initialize do
- self.name = self.class.name
- self.code = @@default_code
- self.criticity = @@default_criticity
- end
end
end
diff --git a/app/models/routing_constaint_zone_control/maximum_length.rb b/app/models/routing_constaint_zone_control/maximum_length.rb
index fd63ffeda..4d289de63 100644
--- a/app/models/routing_constaint_zone_control/maximum_length.rb
+++ b/app/models/routing_constaint_zone_control/maximum_length.rb
@@ -3,11 +3,5 @@ module RoutingConstaintZoneControl
@@default_criticity = :warning
@@default_code = "3-ITL-2"
-
- after_initialize do
- self.name = self.class.name
- self.code = @@default_code
- self.criticity = @@default_criticity
- end
end
end \ No newline at end of file
diff --git a/app/models/routing_constaint_zone_control/minimum_length.rb b/app/models/routing_constaint_zone_control/minimum_length.rb
index c17bbc834..28f0791a7 100644
--- a/app/models/routing_constaint_zone_control/minimum_length.rb
+++ b/app/models/routing_constaint_zone_control/minimum_length.rb
@@ -3,11 +3,5 @@ module RoutingConstaintZoneControl
@@default_criticity = :warning
@@default_code = "3-ITL-3"
-
- after_initialize do
- self.name = self.class.name
- self.code = @@default_code
- self.criticity = @@default_criticity
- end
end
end \ No newline at end of file
diff --git a/app/models/routing_constaint_zone_control/unactivated_stop_point.rb b/app/models/routing_constaint_zone_control/unactivated_stop_point.rb
index 92a1d1a58..fe5381a34 100644
--- a/app/models/routing_constaint_zone_control/unactivated_stop_point.rb
+++ b/app/models/routing_constaint_zone_control/unactivated_stop_point.rb
@@ -3,11 +3,5 @@ module RoutingConstaintZoneControl
@@default_criticity = :warning
@@default_code = "3-ITL-1"
-
- after_initialize do
- self.name = self.class.name
- self.code = @@default_code
- self.criticity = @@default_criticity
- end
end
end
diff --git a/app/models/vechicle_journey_control/delta.rb b/app/models/vechicle_journey_control/delta.rb
index d4e1e6eca..d77eff48a 100644
--- a/app/models/vechicle_journey_control/delta.rb
+++ b/app/models/vechicle_journey_control/delta.rb
@@ -5,11 +5,5 @@ module VehicleJourneyControl
@@default_criticity = :warning
@@default_code = "3-VehicleJourney-3"
-
- after_initialize do
- self.name = self.class.name
- self.code = @@default_code
- self.criticity = @@default_criticity
- end
end
end
diff --git a/app/models/vechicle_journey_control/waiting_time.rb b/app/models/vechicle_journey_control/waiting_time.rb
index a7e90b6ac..cbffa5526 100644
--- a/app/models/vechicle_journey_control/waiting_time.rb
+++ b/app/models/vechicle_journey_control/waiting_time.rb
@@ -3,11 +3,5 @@ module VehicleJourneyControl
@@default_criticity = :warning
@@default_code = "3-VehicleJourney-1"
-
- after_initialize do
- self.name = self.class.name
- self.code = @@default_code
- self.criticity = @@default_criticity
- end
end
end
diff --git a/app/models/vehicle_journey_import.rb b/app/models/vehicle_journey_import.rb
index 44a6d457e..250f3a9e9 100644
--- a/app/models/vehicle_journey_import.rb
+++ b/app/models/vehicle_journey_import.rb
@@ -1,5 +1,3 @@
-# -*- coding: utf-8 -*-
-
class VehicleJourneyImport
include ActiveModel::Validations
include ActiveModel::Conversion
diff --git a/app/models/workbench.rb b/app/models/workbench.rb
index cd90f8253..ae111a9c5 100644
--- a/app/models/workbench.rb
+++ b/app/models/workbench.rb
@@ -2,6 +2,7 @@ class Workbench < ActiveRecord::Base
belongs_to :organisation
belongs_to :line_referential
belongs_to :stop_area_referential
+ belongs_to :output, class_name: 'ReferentialSuite'
has_many :lines, -> (workbench) { Stif::MyWorkbenchScopes.new(workbench).line_scope(self) }, through: :line_referential
has_many :networks, through: :line_referential
@@ -14,10 +15,13 @@ class Workbench < ActiveRecord::Base
validates :name, presence: true
validates :organisation, presence: true
+ validates :output, presence: true
has_many :referentials
has_many :referential_metadatas, through: :referentials, source: :metadatas
+ before_validation :initialize_output
+
def all_referentials
if line_ids.empty?
@@ -27,4 +31,12 @@ class Workbench < ActiveRecord::Base
end
end
+ private
+
+ def initialize_output
+ # Don't reset `output` if it's already initialised
+ return if !output.nil?
+
+ self.output = ReferentialSuite.create
+ end
end
diff --git a/app/policies/compliance_control_policy.rb b/app/policies/compliance_control_policy.rb
index fbea366f5..09250f013 100644
--- a/app/policies/compliance_control_policy.rb
+++ b/app/policies/compliance_control_policy.rb
@@ -6,14 +6,17 @@ class ComplianceControlPolicy < ApplicationPolicy
end
def destroy?
- user.has_permission?('compliance_controls.destroy')
+ # user.has_permission?('compliance_controls.destroy')
+ true
end
def create?
- user.has_permission?('compliance_controls.create')
+ # user.has_permission?('compliance_controls.create')
+ true
end
def update?
- user.has_permission?('compliance_controls.update')
+ # user.has_permission?('compliance_controls.update')
+ true
end
end
diff --git a/app/policies/import_policy.rb b/app/policies/import_policy.rb
index 9e1d99a66..b12dcc167 100644
--- a/app/policies/import_policy.rb
+++ b/app/policies/import_policy.rb
@@ -4,4 +4,16 @@ class ImportPolicy < ApplicationPolicy
scope
end
end
+
+ def create?
+ !archived? && user.has_permission?('imports.create')
+ end
+
+ def destroy?
+ !archived? && user.has_permission?('imports.destroy')
+ end
+
+ def update?
+ !archived? && user.has_permission?('imports.update')
+ end
end
diff --git a/app/views/compliance_control_sets/_filters.html.slim b/app/views/compliance_control_sets/_filters.html.slim
index 587f74ce4..56cac8bd2 100644
--- a/app/views/compliance_control_sets/_filters.html.slim
+++ b/app/views/compliance_control_sets/_filters.html.slim
@@ -9,6 +9,13 @@
.form-group.togglable
= f.label t('activerecord.models.organisation.one'), required: false, class: 'control-label'
= f.input :organisation_name_eq_any, collection: organisations_filters_values, as: :check_boxes, label: false, label_method: lambda {|w| ("<span>#{w.name}</span>").html_safe}, required: false, wrapper_html: {class: 'checkbox_list'}
+
+ .form-group.togglable
+ = f.label Import.human_attribute_name(:updated_at), required: false, class: 'control-label'
+ .filter_menu
+ = f.simple_fields_for :updated_at do |p|
+ = p.input :begin, as: :date, label: false, wrapper_html: {class: 'date smart_date filter_menu-item'}, default: @begin_range, include_blank: @begin_range ? false : true
+ = p.input :end, as: :date, label: false, wrapper_html: {class: 'date smart_date filter_menu-item'}, default: @end_range, include_blank: @end_range ? false : true
.actions
= link_to t('actions.erase'), @compliance_control_set, class: 'btn btn-link'
diff --git a/app/views/compliance_control_sets/show.html.slim b/app/views/compliance_control_sets/show.html.slim
index b4a5b2260..d7d4678ba 100644
--- a/app/views/compliance_control_sets/show.html.slim
+++ b/app/views/compliance_control_sets/show.html.slim
@@ -22,4 +22,38 @@
.row
.col-lg-6.col-md-6.col-sm-12.col-xs-12
= definition_list t('metadatas'),
- ComplianceControlSet.human_attribute_name(:name) => @compliance_control_set.name \ No newline at end of file
+ ComplianceControlSet.human_attribute_name(:name) => @compliance_control_set.name
+
+ .container-fluid
+ .row
+ .col-lg-12
+ /= render 'filters'
+ .row
+ .col-lg-12
+ .select_table
+ = table_builder_2 @compliance_controls,
+ [ \
+ TableBuilderHelper::Column.new( \
+ key: :code, \
+ attribute: 'code' \
+ ), \
+ TableBuilderHelper::Column.new( \
+ key: :name, \
+ attribute: 'name', \
+ link_to: lambda do |compliance_control| \
+ compliance_control_set_compliance_control_path(@compliance_control_set, compliance_control) \
+ end \
+ ), \
+ TableBuilderHelper::Column.new( \
+ key: :criticity, \
+ attribute: 'criticity' \
+ ), \
+ TableBuilderHelper::Column.new( \
+ key: :comment, \
+ attribute: 'comment' \
+ ), \
+ ],
+ sortable: true,
+ cls: 'table has-filter has-search'
+
+
diff --git a/app/views/compliance_controls/_form.html.slim b/app/views/compliance_controls/_form.html.slim
index 1377ed12b..bb8f68464 100644
--- a/app/views/compliance_controls/_form.html.slim
+++ b/app/views/compliance_controls/_form.html.slim
@@ -2,11 +2,19 @@
.row
.col-lg-12
= f.input :name
- = f.input :type
+ = f.input :type, as: :select, collection: ComplianceControl.subclasses
= f.input :code
= f.input :criticity
= f.input :comment
+ - f.object.class.dynamic_attributes.each do |attribute|
+ = f.input attribute.to_sym
+ end
+
+ = f.simple_fields_for :compliance_control_block do |c|
+ = c.input :name
+ = c.input :transport_mode, as: :select, collection:ComplianceControlBlock.transport_modes
+ end
.separator
= f.button :submit, t('actions.submit'), class: 'btn btn-default formSubmitr', form: 'compliance_control_form'
diff --git a/app/views/compliance_controls/edit.html.slim b/app/views/compliance_controls/edit.html.slim
index e69de29bb..6824c7e40 100644
--- a/app/views/compliance_controls/edit.html.slim
+++ b/app/views/compliance_controls/edit.html.slim
@@ -0,0 +1,9 @@
+= pageheader 'compliance-control',
+ t('compliance_control.index.edit')
+
+
+.page_content
+ .container-fluid
+ .row
+ .col-lg-8.col-lg-offset-2.col-md-8.col-md-offset-2.col-sm-10.col-sm-offset-1
+ = render 'form'
diff --git a/app/views/compliance_controls/show.html.slim b/app/views/compliance_controls/show.html.slim
index e69de29bb..a665f1ab1 100644
--- a/app/views/compliance_controls/show.html.slim
+++ b/app/views/compliance_controls/show.html.slim
@@ -0,0 +1,3 @@
+= @compliance_control.inspect
+br
+= @compliance_control.compliance_control_block.inspect
diff --git a/app/views/lines/index.html.slim b/app/views/lines/index.html.slim
index dda5afd44..fb07c45a2 100644
--- a/app/views/lines/index.html.slim
+++ b/app/views/lines/index.html.slim
@@ -36,7 +36,7 @@
), \
TableBuilderHelper::Column.new( \
key: :deactivated, \
- attribute: Proc.new{|n| n.deactivated? ? t('false') : t('true')} \
+ attribute: Proc.new { |n| line_status(n.deactivated?) } \
), \
TableBuilderHelper::Column.new( \
key: 'networks.name', \
diff --git a/app/views/referentials/show.html.slim b/app/views/referentials/show.html.slim
index e1d89cba4..0fdd79e14 100644
--- a/app/views/referentials/show.html.slim
+++ b/app/views/referentials/show.html.slim
@@ -58,7 +58,7 @@
), \
TableBuilderHelper::Column.new( \
key: :deactivated, \
- attribute: Proc.new { |n| n.deactivated? ? t('false') : t('true') } \
+ attribute: Proc.new { |n| line_status(n.deactivated?) } \
), \
TableBuilderHelper::Column.new( \
key: :transport_mode, \
diff --git a/app/views/routes/_form.html.slim b/app/views/routes/_form.html.slim
index 244b427dc..24c0d3c4a 100644
--- a/app/views/routes/_form.html.slim
+++ b/app/views/routes/_form.html.slim
@@ -26,7 +26,8 @@
// Get JSON data for route stop points
= javascript_tag do
- | window.itinerary_stop = "#{URI.escape(route_json_for_edit(@route))}"
+ | window.itinerary_stop = "#{URI.escape(route_json_for_edit(@route))}";
+ | window.I18n = #{(I18n.backend.send(:translations)[I18n.locale].to_json).html_safe};
/ StopPoints Reactux component
= javascript_include_tag 'es6_browserified/itineraries/index.js'
diff --git a/app/views/routes/show.html.slim b/app/views/routes/show.html.slim
index e2681d215..edc2d254b 100644
--- a/app/views/routes/show.html.slim
+++ b/app/views/routes/show.html.slim
@@ -48,7 +48,7 @@
), \
TableBuilderHelper::Column.new( \
key: :deleted_at, \
- attribute: Proc.new { |s| s.try(:stop_area).deleted_at ? t('false') : t('true') }, \
+ attribute: Proc.new { |s| line_status(s.try(:stop_area).deleted_at) } \
), \
TableBuilderHelper::Column.new( \
key: :zip_code, \
diff --git a/app/views/stop_areas/index.html.slim b/app/views/stop_areas/index.html.slim
index 4c95761d2..95b9b1b0e 100644
--- a/app/views/stop_areas/index.html.slim
+++ b/app/views/stop_areas/index.html.slim
@@ -39,7 +39,7 @@
), \
TableBuilderHelper::Column.new( \
key: :deleted_at, \
- attribute: Proc.new { |s| s.deleted_at ? t('false') : t('true') } \
+ attribute: Proc.new { |s| line_status(s.deleted_at) } \
), \
TableBuilderHelper::Column.new( \
key: :zip_code, \
diff --git a/app/views/time_tables/edit.html.slim b/app/views/time_tables/edit.html.slim
index ed55dc4e3..cc6f31489 100644
--- a/app/views/time_tables/edit.html.slim
+++ b/app/views/time_tables/edit.html.slim
@@ -11,6 +11,6 @@
= javascript_tag do
| window.actionType = "#{raw params[:action]}";
- | window.I18n = #{(I18n.backend.send(:translations).to_json).html_safe};
+ | window.I18n = #{(I18n.backend.send(:translations)[I18n.locale].to_json).html_safe};
= javascript_include_tag 'es6_browserified/time_tables/index.js'