diff options
Diffstat (limited to 'app')
104 files changed, 343 insertions, 2984 deletions
diff --git a/app/assets/javascripts/es6_browserified/journey_patterns/actions/index.js b/app/assets/javascripts/es6_browserified/journey_patterns/actions/index.js index 3577df2b6..34689070d 100644 --- a/app/assets/javascripts/es6_browserified/journey_patterns/actions/index.js +++ b/app/assets/javascripts/es6_browserified/journey_patterns/actions/index.js @@ -90,10 +90,7 @@ const actions = { resetValidation: (target) => { $(target).parent().removeClass('has-error').children('.help-block').remove() }, - humanOID : (oid) => { - var a = oid.split(':') - return a[a.length - 1] - }, + humanOID : (oid) => oid.split(':')[2], validateFields : (fields) => { const test = [] diff --git a/app/assets/javascripts/es6_browserified/vehicle_journeys/actions/index.js b/app/assets/javascripts/es6_browserified/vehicle_journeys/actions/index.js index 2fde0d76f..de87c14af 100644 --- a/app/assets/javascripts/es6_browserified/vehicle_journeys/actions/index.js +++ b/app/assets/javascripts/es6_browserified/vehicle_journeys/actions/index.js @@ -269,10 +269,7 @@ const actions = { type: 'RECEIVE_TOTAL_COUNT', total }), - humanOID : (oid) => { - var a = oid.split(':') - return a[a.length - 1] - }, + humanOID: (oid) => oid.split(':')[2], fetchVehicleJourneys : (dispatch, currentPage, nextPage, queryString) => { if(currentPage == undefined){ currentPage = 1 diff --git a/app/assets/javascripts/filters/calendar.js b/app/assets/javascripts/filters/calendar.js new file mode 100644 index 000000000..a4e84777c --- /dev/null +++ b/app/assets/javascripts/filters/calendar.js @@ -0,0 +1,6 @@ +const DateFilter = require('../helpers/date_filters') + +$(document).ready(function(){ + const calendarDF = new DateFilter("#calendar_filter_btn", "Tous les champs du filtre de date doivent être remplis", "#q_contains_date_NUMi") + calendarDF() +}) diff --git a/app/assets/javascripts/filters/import.js b/app/assets/javascripts/filters/import.js new file mode 100644 index 000000000..d0b96da10 --- /dev/null +++ b/app/assets/javascripts/filters/import.js @@ -0,0 +1,6 @@ +const DateFilter = require('../helpers/date_filters') + +$(document).ready(function(){ + const importDF = new DateFilter("#import_filter_btn", "Tous les champs du filtre de date doivent être remplis", "#q_started_on_date_NUMi") + importDF() +}) diff --git a/app/assets/javascripts/filters/time_table.js b/app/assets/javascripts/filters/time_table.js new file mode 100644 index 000000000..9e24d03fe --- /dev/null +++ b/app/assets/javascripts/filters/time_table.js @@ -0,0 +1,7 @@ +$(document).ready(function(){ + const DateFilter = require('../helpers/date_filters') + + const timetableDF = new DateFilter("#time_table_filter_btn", window.I18n.fr.time_tables.error_period_filter, "#q_start_date_gteq_NUMi", "#q_end_date_lteq_NUMi") + + timetableDF() +}) diff --git a/app/assets/javascripts/filters/workbench.js b/app/assets/javascripts/filters/workbench.js new file mode 100644 index 000000000..af3e13c59 --- /dev/null +++ b/app/assets/javascripts/filters/workbench.js @@ -0,0 +1,6 @@ +const DateFilter = require('../helpers/date_filters') + +$(document).ready(function(){ + const workbenchDF = new DateFilter("#referential_filter_btn", window.I18n.fr.referentials.error_period_filter, "#q_validity_period_begin_gteq_NUMi", "#q_validity_period_end_lteq_NUMi") + workbenchDF() +}) diff --git a/app/assets/javascripts/helpers/date_filters.js b/app/assets/javascripts/helpers/date_filters.js new file mode 100644 index 000000000..1f48bb28f --- /dev/null +++ b/app/assets/javascripts/helpers/date_filters.js @@ -0,0 +1,38 @@ +const DateFilter = function(buttonId, message, ...inputIds) { + this.buttonId = buttonId + this.inputIds = inputIds + this.message = message + + const getVal = (str, key) => { + let newStr = str.replace(/NUM/, key) + return $(newStr).val() + } + + const getDates = () => { + return this.inputIds.reduce((arr, id) => { + let newIds = [1, 2, 3].map(key => getVal(id, key)) + arr.push(...newIds) + return arr + },[]) + } + + const allInputFilled = () => { + return getDates().every(date => !!date) + } + + const noInputFilled = () => { + return getDates().every(date => !date) + } + + const execute = () => { + $(this.buttonId).on("click", (e) => { + if (allInputFilled() == false && noInputFilled() == false) { + e.preventDefault() + alert(this.message) + } + }) + } + return execute +} + +module.exports = DateFilter diff --git a/app/assets/javascripts/time_table.coffee b/app/assets/javascripts/time_table.coffee deleted file mode 100644 index 8789cb226..000000000 --- a/app/assets/javascripts/time_table.coffee +++ /dev/null @@ -1,14 +0,0 @@ - $(document).on("click", "#time_table_filter_btn", (e) -> - dates = [1, 2, 3].reduce (arr, key) -> - arr.push $("#q_start_date_gteq_#{key}i").val(), $("#q_end_date_lteq_#{key}i").val() - arr - , [] - - validDate = dates.every (date) -> !!date - - noDate = dates.every (date) -> !date - - unless (validDate || noDate) - e.preventDefault() - alert(window.I18n.fr.time_tables.error_period_filter) - ) diff --git a/app/assets/javascripts/workbench.coffee b/app/assets/javascripts/workbench.coffee deleted file mode 100644 index 0e9fe62a3..000000000 --- a/app/assets/javascripts/workbench.coffee +++ /dev/null @@ -1,18 +0,0 @@ - $(document).on("click", "#referential_filter_btn", (e) -> - dates = [1, 2, 3].reduce (arr, key) -> - arr.push $("#q_validity_period_begin_gteq_#{key}i").val(), $("#q_validity_period_end_lteq_#{key}i").val() - arr - , [] - - validDate = dates.every (date) -> !!date - - noDate = dates.every (date) -> !date - - console.log("valid dates :", validDate) - console.log("no dates :", noDate) - console.log(dates) - - unless (validDate || noDate) - e.preventDefault() - alert(window.I18n.fr.referentials.error_period_filter) - ) diff --git a/app/assets/stylesheets/application.sass b/app/assets/stylesheets/application.sass index e3f776640..50f8b64cb 100644 --- a/app/assets/stylesheets/application.sass +++ b/app/assets/stylesheets/application.sass @@ -18,3 +18,4 @@ @import 'modules/jp_collection' @import 'modules/vj_collection' @import 'modules/timetables' +@import 'modules/import_messages' diff --git a/app/assets/stylesheets/main/access_links.sass b/app/assets/stylesheets/main/access_links.sass deleted file mode 100644 index 65a81a2f8..000000000 --- a/app/assets/stylesheets/main/access_links.sass +++ /dev/null @@ -1,18 +0,0 @@ -// Place all the styles related to the lines controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ - -#workspace.access_links.show - .summary p label - font-weight: bold - - .duration - padding-left: 10px - -#workspace.access_links.edit, -#workspace.access_links.new, -#workspace.access_links.create, -#workspace.access_links.update - .time_select ol - padding: 0 0 0 40% - width: 100%
\ No newline at end of file diff --git a/app/assets/stylesheets/main/access_points.sass b/app/assets/stylesheets/main/access_points.sass deleted file mode 100644 index 11e41967b..000000000 --- a/app/assets/stylesheets/main/access_points.sass +++ /dev/null @@ -1,78 +0,0 @@ -// Place all the styles related to the lines controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ - -// #workspace.access_points.index - -#workspace.access_points.edit, -#workspace.access_points.new, -#workspace.access_points.create, -#workspace.access_points.update - .time_select ol - padding: 0 0 0 40% - width: 100% - -#workspace.access_points.edit - legend - padding-bottom: 20px - -#workspace.access_points.show - .geo_data - padding-left: 15px - - .summary - p label - font-weight: bold - - .access_link_pairs - table - border: 0px - border-collapse: separate - border-spacing: 3px - - .link - border: 2px solid black - - .access_point - padding: 3px 15px 0px 3px - height: 25px - - * - vertical-align: middle - - span - margin-left: 7px - - img - margin: 0px 5px 0px 5px - - .stop_area - padding: 3px 15px 0px 3px - height: 25px - - * - vertical-align: middle - - span - margin-left: 7px - - img - margin: 0px 5px 0px 5px - - .info - font-size: 10px - color: #777 - font-weight: normal - padding-top: 10px - padding-left: 45px - padding-right: 3px - padding-bottom: 3px - -#sidebar ul.selection li - a - line-height: 27px - - img - height: 25px - width: 25px - vertical-align: middle
\ No newline at end of file diff --git a/app/assets/stylesheets/main/api_keys.sass b/app/assets/stylesheets/main/api_keys.sass deleted file mode 100644 index 28bf171b9..000000000 --- a/app/assets/stylesheets/main/api_keys.sass +++ /dev/null @@ -1,7 +0,0 @@ -// Place all the styles related to the routes controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ - -#workspace.api_keys.show - .summary p label - font-weight: bold
\ No newline at end of file diff --git a/app/assets/stylesheets/main/calendar.sass b/app/assets/stylesheets/main/calendar.sass deleted file mode 100644 index f24f2b212..000000000 --- a/app/assets/stylesheets/main/calendar.sass +++ /dev/null @@ -1,98 +0,0 @@ -// A grey based theme, inspired by Blinksale and their ColorBurn widget. http://firewheeldesign.com - -// AUTHOR: Geoffrey Grosenbach http://nubyonrails.com - -// Colors: -// dk: 787888 -// lt: 4f4f5b -// lter: a8a8a8 -// white: ffffff - -$selected_period_color: #ffbd2b -$selected_date_color: #8fc861 -$excluded_date_color: #ff8f85 -$overlap_date_color: #c082f4 - -.year_choice - font-size: 16px - font-weight: bold - margin: 10px 0 0 0 - text-align: center - - .year - text-align: center - -.calendar_helper - padding: auto - -.calendar - font-size: 10px - color: white - text-align: center - margin-left: 15px - display: inline-table - -thead tr - color: black - -th.monthName - font-size: 12px - font-weight: bold - text-align: center - padding-top: 1em - padding-bottom: 0.7em - color: black - -.dayName th - text-align: center - padding-top: 0.6em - padding-bottom: 0.3em - background-color: #303030 - color: white - border-bottom: 1px solid white - -.otherMonth - color: #999999 - background-color: #4f4f5b - padding: 0.7em - border-right: 1px solid #111111 - border-bottom: 1px solid #111111 - -.day - background-color: #333333 - -.day, .specialDay - border-bottom: 1px solid #111111 - padding: 0.7em - border-right: 1px solid #111111 - border-bottom: 1px solid #111111 - -.specialDay - background-color: #a8a8a8 !important - -.selected_period - background-color: $selected_period_color !important - -.selected_date - background-color: $selected_date_color !important - -.excluded_date - background-color: $excluded_date_color !important - -.overlaped_date - background-color: $overlap_date_color !important - -.specialDay, .selected_period, .selected_date, .overlaped_date, .excluded_date - a, a:visited, a:hover - color: white - text-decoration: none - -.specialDay a:hover, .selected_period a:hover, .selected_date a:hover, .excluded_date a:hover, .overlaped_date a:hover - color: black - -.weekendDay - background-color: #787888 - -.today - background-color: white - color: black
\ No newline at end of file diff --git a/app/assets/stylesheets/main/calendars.sass b/app/assets/stylesheets/main/calendars.sass deleted file mode 100644 index 298ce2a62..000000000 --- a/app/assets/stylesheets/main/calendars.sass +++ /dev/null @@ -1,11 +0,0 @@ -#calendar_form - .btn - margin: 5px - #delete-btn - margin-top: 23px - .well - padding-left: 50px - -#calendar_search_form - button - margin-top: 24px diff --git a/app/assets/stylesheets/main/companies.sass b/app/assets/stylesheets/main/companies.sass deleted file mode 100644 index 2cf1f596c..000000000 --- a/app/assets/stylesheets/main/companies.sass +++ /dev/null @@ -1,9 +0,0 @@ -// Place all the styles related to the lines controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ - -// #workspace.companies.index - -#workspace.companies.show - .summary p label - font-weight: bold
\ No newline at end of file diff --git a/app/assets/stylesheets/main/compliance_checks.sass b/app/assets/stylesheets/main/compliance_checks.sass deleted file mode 100644 index 451972fd5..000000000 --- a/app/assets/stylesheets/main/compliance_checks.sass +++ /dev/null @@ -1,157 +0,0 @@ -// #workspace.compliance_checks.index - -#workspace.compliance_checks.show - @import '../modules/job_status_colors' - @import '../modules/job_status_title' - @import '../partials/ie_report' - @import '../modules/links' - -#validation_success - margin-top: 15px - -#workspace.compliance_checks.report, #workspace.imports.compliance_check - @import '../modules/job_status_colors' - @import '../modules/job_status_title' - @import '../modules/links' - - .status - margin-left: 10px - - .order - margin-bottom: 10px - padding: 5px - border-top: 1px solid #e4e4e4 - border-bottom: 1px solid #e4e4e4 - - .status_ok_error - color: #8fc861 - .status_nok_error - color: #e22b1b - .status_uncheck_error - color: #898e7f - - .status_ok_warning - color: #8fc861 - .status_nok_warning - color: #ffbd2b - .status_uncheck_warning - color: #898e7f - - .resume - &:after - content: " " - display: block - height: 0 - clear: both - visibility: hidden - - .col1 - float: left - width: 45% - - .col2 - margin-left: 10px - float: left - width: 45% - - .graph - height: 200px - - .caption - text-align: center - font-weight: bold - - .report - .table - margin-top: 20px - - dl.inline - width: 100% - overflow: hidden - - dt - float: left - clear: left - width: 35% - padding-top: 5px - border-top: 1px solid #eee - -ms-word-break: break-all - word-break: break-all - word-break: break-word - -webkit-hyphens: auto - -moz-hyphens: auto - -ms-hyphens: auto - hyphens: auto - - dd - float: left - width: 65% - padding-top: 10px - border-top: 1px solid #eee - - .severity__improvment, - .severity_warning, - .severity_error - border: 1px solid - margin: 10px 0px - padding: 10px 10px 10px 10px - background-repeat: no-repeat - background-position: 10px center - -moz-border-radius: 0.5em - -webkit-border-radius: 0.5em - border-radius: 0.5em - height: 100% - - &:after - content: " " - display: block - height: 0 - clear: both - visibility: hidden - - .status_icon - float: left - width: 20% - height: auto - - img - vertical-align: middle - width: 48px - height: 48px - - .status_text - float: left - width: 70% - - .code - font-size: 12px - font-weight: bold - - .severity - font-size: 10px - - .explanation - display: none - font-size: 12px - margin: 5px 0 0 0 - - .attributes - font-size: 10px - font-weight: bold - margin: 5px 0 0px 0 - - .severity_improvment - color: black - background-color: #c5cf4c - - .severity_warning - color: black - background-color: #f1dd30 - - .severity_error - color: black - background-color: #ff9a0c - - .file_error - font-size: 14px - color: #898e7f
\ No newline at end of file diff --git a/app/assets/stylesheets/main/connection_links.sass b/app/assets/stylesheets/main/connection_links.sass deleted file mode 100644 index a23fbcdff..000000000 --- a/app/assets/stylesheets/main/connection_links.sass +++ /dev/null @@ -1,30 +0,0 @@ -// Place all the styles related to the lines controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ - -// #workspace.connection_links.index - -#workspace.connection_links.show - .summary p label - font-weight: bold - - .duration - padding-left: 10px - -#workspace.connection_links.select_departure - .token-input-list - display: inline-block - -#workspace.connection_links.select_arrival - .token-input-list - display: inline-block - -#workspace.connection_links.edit, -#workspace.connection_links.new, -#workspace.connection_links.create, -#workspace.connection_links.update - legend - border: 0px - - .panel - margin-left: 25%
\ No newline at end of file diff --git a/app/assets/stylesheets/main/errors.sass b/app/assets/stylesheets/main/errors.sass deleted file mode 100644 index ee603e459..000000000 --- a/app/assets/stylesheets/main/errors.sass +++ /dev/null @@ -1,21 +0,0 @@ -#workspace.errors - body - text-align: center - - div.error - width: 45em - padding: 1em - margin: 2em auto 0 auto - border: 1px solid #ccc - border-right-color: #999 - border-bottom-color: #999 - - h2 - font-size: 100% - color: #f00 - line-height: 1.5em - font-weight: bold - - a, a:visited - text-decoration: underline - color: blue
\ No newline at end of file diff --git a/app/assets/stylesheets/main/export_tasks.sass b/app/assets/stylesheets/main/export_tasks.sass deleted file mode 100644 index 799b5a13f..000000000 --- a/app/assets/stylesheets/main/export_tasks.sass +++ /dev/null @@ -1,10 +0,0 @@ -#workspace.export_tasks.new, #workspace.export_tasks.create - .nav - margin: 30px 0 10px 0 - - .highlight - padding: 9px 14px - margin-bottom: 14px - background-color: #f7f7f9 - border: 1px solid #e1e1e8 - border-radius: 4px
\ No newline at end of file diff --git a/app/assets/stylesheets/main/exports.sass b/app/assets/stylesheets/main/exports.sass deleted file mode 100644 index 875dc13f5..000000000 --- a/app/assets/stylesheets/main/exports.sass +++ /dev/null @@ -1,19 +0,0 @@ -// Place all the styles related to the Exports controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ - -#workspace.exports.index - .panel.export - .panel-footer - .history - margin-top: 5px - -#workspace.exports.show - @import '../partials/ie_report' - @import '../modules/job_status_colors' - @import '../modules/job_status_title' - @import '../modules/links' - - .export-attributes - font-size: 1.7em - margin-top: 20px
\ No newline at end of file diff --git a/app/assets/stylesheets/main/group_of_lines.sass b/app/assets/stylesheets/main/group_of_lines.sass deleted file mode 100644 index d63eeb607..000000000 --- a/app/assets/stylesheets/main/group_of_lines.sass +++ /dev/null @@ -1,15 +0,0 @@ -// Place all the styles related to the lines controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ - -// #workspace.group_of_lines.index - -#workspace.group_of_lines.show - .summary p label - font-weight: bold - - .lines_detail div.page_info - margin-top: 0px - - .lines - margin-top: 10px
\ No newline at end of file diff --git a/app/assets/stylesheets/main/help.sass b/app/assets/stylesheets/main/help.sass deleted file mode 100644 index 87f21c3c3..000000000 --- a/app/assets/stylesheets/main/help.sass +++ /dev/null @@ -1,121 +0,0 @@ -#workspace.help - ul li - list-style: circle - margin: 7px 0 7px 20px - - ol ul li - list-style: circle - margin: 7px 0 7px 20px - - ol - list-style: none - margin: 7px 0 7px 20px - padding: 0 - counter-reset: num - - li:before - content: counter(num) '. ' - counter-increment: num - - ol li:before - content: counters(num, '.') ' ' - - em, cite - font-style: italic - - strong - font-weight: bold - - p.attr_data - font-style: italic - text-decoration: underline - - p.olnext - margin: -7px 0 0 40px !important - - p.ddnext - margin: 0 0 0 30px !important - - p.note - margin-left: 20px !important - font-weight: bold - - p.border_image - text-align: center - - img - border-style: solid - border-width: 1px - border-color: rgb(187,187,187) - - table - width: 100% - - td - padding: 3px 5px - width: 30% - - &.meta - width: 50% - - th, td - border: 1px solid black - - dt - font-style: italic - margin: 5px 0 - - dd - padding-left: 10px - -#sidebarhelp.help - h2 - font-size: 17px - - h3 - font-size: 15px - - h4 - font-weight: bold - padding: 7px 0 - - ul li - list-style: circle - margin: 7px 0 7px 20px - - ol - list-style: none - margin: 7px 0 7px 20px - padding: 0 - counter-reset: num - - li:before - content: counter(num) '. ' - counter-increment: num - - ol li:before - content: counters(num, '.') ' ' - - em, cite - font-style: italic - - strong - font-weight: bold - - p.attr_data - font-style: italic - text-decoration: underline - - table - width: 100% - - td - padding: 3px 5px - width: 30% - - dt - font-style: italic - margin: 5px 0 - - dd - padding-left: 10px
\ No newline at end of file diff --git a/app/assets/stylesheets/main/import_tasks.sass b/app/assets/stylesheets/main/import_tasks.sass deleted file mode 100644 index 810582cf2..000000000 --- a/app/assets/stylesheets/main/import_tasks.sass +++ /dev/null @@ -1,11 +0,0 @@ -#workspace.import_tasks.new, -#workspace.import_tasks.create - .nav - margin: 30px 0 10px 0 - - .highlight - padding: 9px 14px - margin-bottom: 14px - background-color: #f7f7f9 - border: 1px solid #e1e1e8 - border-radius: 4px
\ No newline at end of file diff --git a/app/assets/stylesheets/main/imports.sass b/app/assets/stylesheets/main/imports.sass deleted file mode 100644 index af5e88218..000000000 --- a/app/assets/stylesheets/main/imports.sass +++ /dev/null @@ -1,40 +0,0 @@ -#workspace.imports.index - .panel.import - .panel-footer - min-height: 5.5em - - .save-mode - color: $brand-info - - .fa-lg - font-size: 1em - .fa-ban - opacity: 0.6 - - .history - margin-top: 5px - -#workspace.imports.index, -#workspace.imports.show - .import-attributes - .save-mode, .format - display: inline-block - - .save-mode - color: $brand-info - margin-left: 0.3em - - .fa-ban - opacity: 0.6 - .fa-stack - font-size: 0.9em - -#workspace.imports.show - @import '../partials/ie_report' - @import '../modules/job_status_colors' - @import '../modules/job_status_title' - @import '../modules/links' - - .import-attributes - font-size: 1.7em - margin-top: 20px
\ No newline at end of file diff --git a/app/assets/stylesheets/main/journey_patterns.sass b/app/assets/stylesheets/main/journey_patterns.sass deleted file mode 100644 index 07c3260d4..000000000 --- a/app/assets/stylesheets/main/journey_patterns.sass +++ /dev/null @@ -1,49 +0,0 @@ -// Place all the styles related to the routes controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ - -#workspace.journey_patterns.edit, -#workspace.journey_patterns.new, -#workspace.journey_patterns.create, -#workspace.journey_patterns.update - #route_color - width: 100px - color: white - font-weight: bold - - #journey_pattern_stop_point_ids_input fieldset .choices-group - margin-top: 25px - -#workspace.journey_patterns.show - .journey_pattern_color - color: white - font-weight: bold - padding: 0 5px 0 5px - - .summary p label - font-weight: bold - - .stop_points_detail div.page_info - margin-top: 0px - - .stop_points - margin-top: 20px - - .journey_pattern_stop_points - clear: both - margin: 0px - padding: 0px - - .stop_point - .position - width: 25px - height: 20px - float: left - background-color: #61970B - font-weight: bold - color: white - margin-right: 10px - padding-left: 4px - - #middle #sidebar a.control-shape - color: orange
\ No newline at end of file diff --git a/app/assets/stylesheets/main/layout.sass b/app/assets/stylesheets/main/layout.sass deleted file mode 100644 index d75c359ae..000000000 --- a/app/assets/stylesheets/main/layout.sass +++ /dev/null @@ -1,133 +0,0 @@ -body - padding-top: 50px - -h1 - color: white - -h1, .h1, h2, .h2, h3, .h3 - margin-bottom: 20px - -label.label - color: black - font-size: 100% - -ol.breadcrumb - margin-top: 10px - -.ce-hide - display: none - -#middle - position: relative - min-height: 500px - -webkit-box-shadow: 0 0 5px 2px rgba(0, 0, 0, .2) - box-shadow: 0 0 5px 2px rgba(0, 0, 0, .2) - padding-top: 10px - padding-bottom: 10px - margin-top: 20px - margin-bottom: 20px - background: white - - .main_actions - text-align: right - - .alert - margin-top: 15px - - #sidebar - height: 100% - padding-top: 20px - border-left: 1px solid $gray-lighter - - &.ce-SidebarFloatBlock - position: absolute - height: auto - right: 0 - background-color: #fff - top: 45px - - label - color: #555555 - font-weight: normal - font-size: 12px - - a - color: #666 - - .actions - margin-bottom: 20px - - li - margin-bottom: 5px - - p - font-size: 12px - - fieldset.history_tag - font-size: 12px - color: $gray-light - - legend - font-size: 14px - margin-bottom: 10px - - fieldset - border-color: white - - p - margin-top: 5px - - label - font-size: 12px - span - font-style: oblique - font-size: 12px - - ol - padding: 0px - - li - list-style: none - - ul - padding: 0px - - li - list-style: none - - ul.selection li - a - padding-left: 20px - - &.current - text-decoration: none - color: black !important - background: url(image-path('icons/accept.png')) no-repeat - - &.all - background-image: none - - div#compact_form - form - border-bottom: 1px solid #BBB - - fieldset - padding: 0 - border: 0 - - li - padding: 0 - - label - padding-left: 20px - width: 70% - - input - width: 20px - - fieldset.actions - margin-bottom: 0 - padding-left: 20px - - fieldset.inputs - padding-top: 16px
\ No newline at end of file diff --git a/app/assets/stylesheets/main/lines.sass b/app/assets/stylesheets/main/lines.sass deleted file mode 100644 index b9bdfae8f..000000000 --- a/app/assets/stylesheets/main/lines.sass +++ /dev/null @@ -1,87 +0,0 @@ -// Place all the styles related to the lines controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ - -#workspace.lines.index - input[type='checkbox'].multiple_selection - vertical-align: middle - - #search - label - margin-bottom: 0px - - input[type='checkbox'] - margin-left: 3px - -#workspace.lines.edit, -#workspace.lines.new, -#workspace.lines.create, -#workspace.lines.update - #line_color_old - width: 100px - color: white - font-weight: bold - - .nested-fields.footnote, .add_footnote - @extend .col-md-offset-3 - - .footnotes_block - margin-bottom: 30px - -#workspace.lines.show - .summary p - label - font-weight: bold - - .color - padding: 3px 15px 3px 15px - - .group_of_line - .position - width: 25px - height: 20px - float: left - background-color: #61970B - font-weight: bold - color: white - margin-right: 10px - padding-left: 4px - - .color - background-color: white - width: 64px - height: 64px - float: left - margin-right: 10px - border: 1px solid #999 - - a - text-decoration: none - - .name a - display: inline - -.ce-LineBlock-header-list - display: table - width: 100% - margin: 0 - padding: 0 - - > li - display: table-cell - vertical-align: middle - - > input - margin-top: 0 - - &:first-child - width: 37px - - &:last-child - text-align: right - width: 73px - -.ce-LineBlock-header-title - padding: 0 !important - line-height: 12px - font-size: 13px
\ No newline at end of file diff --git a/app/assets/stylesheets/main/multiple_selection.sass b/app/assets/stylesheets/main/multiple_selection.sass deleted file mode 100644 index b46dded01..000000000 --- a/app/assets/stylesheets/main/multiple_selection.sass +++ /dev/null @@ -1,17 +0,0 @@ -input[type='checkbox'].multiple_selection - margin-left: 0px - position: absolute - top: 0px - -#multiple_selection_menu - h3 - margin-top: 20px - - div - padding: 6px 8px - - .actions - margin-top: 20px - - .select_all, .deselect_all - font-size: 0.8em
\ No newline at end of file diff --git a/app/assets/stylesheets/main/networks.sass b/app/assets/stylesheets/main/networks.sass deleted file mode 100644 index 4d3717f26..000000000 --- a/app/assets/stylesheets/main/networks.sass +++ /dev/null @@ -1,9 +0,0 @@ -// Place all the styles related to the lines controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ - -// #workspace.networks.index - -#workspace.networks.show - .summary p label - font-weight: bold
\ No newline at end of file diff --git a/app/assets/stylesheets/main/organisations.sass b/app/assets/stylesheets/main/organisations.sass deleted file mode 100644 index 4bfee860a..000000000 --- a/app/assets/stylesheets/main/organisations.sass +++ /dev/null @@ -1,5 +0,0 @@ -// Place all the styles related to the lines controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ - -// #workspace.organisations.show
\ No newline at end of file diff --git a/app/assets/stylesheets/main/referentials.sass b/app/assets/stylesheets/main/referentials.sass deleted file mode 100644 index 293807560..000000000 --- a/app/assets/stylesheets/main/referentials.sass +++ /dev/null @@ -1,34 +0,0 @@ -// Place all the styles related to the referentials controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ - -// #workspace.referentials.index - -#workspace.referentials.show - .summary p label - font-weight: bold - - .panel - font-size: 12px - width: 75% - - .panel-heading - font-weight: bold - - li.list-group-item - padding: 5px 15px - -#sidebar div#clean_up - form - fieldset - li - margin-bottom: 0px - - &.date - input - width: 125px - font-size: 12px - height: 25px - - label - width: 35%
\ No newline at end of file diff --git a/app/assets/stylesheets/main/route_sections.sass b/app/assets/stylesheets/main/route_sections.sass deleted file mode 100644 index fe3c98c10..000000000 --- a/app/assets/stylesheets/main/route_sections.sass +++ /dev/null @@ -1,54 +0,0 @@ -#workspace.route_sections_selectors.edit - td.route_section - .input - padding: 0 - margin: 0 - - select - width: 100% - - a.edit-route-section - background: url(image-path('icons/edit.png')) no-repeat 0% 50% - text-indent: -9999px - display: inline-block - width: 16px - height: 16px - margin-right: 8px - - &.disabled - background-image: url(image-path('icons/edit-disabled.png')) - - #map-selection - position: relative - - span - display: inline-block - - .departure, .arrival - width: 25% - - .actions - width: 25% - overflow: visible - padding-left: 0 - position: absolute - right: 0 - -#workspace.route_sections.index - th.distance, th.points - text-align: center - - td.distance, td.points, td.actions - text-align: center - -#workspace.route_sections.edit - .formtastic - .input .label - width: 40% - - .actions - padding-left: 19% - - #map - width: 600px - heigth: 600px
\ No newline at end of file diff --git a/app/assets/stylesheets/main/routes.sass b/app/assets/stylesheets/main/routes.sass deleted file mode 100644 index 977d2f4b3..000000000 --- a/app/assets/stylesheets/main/routes.sass +++ /dev/null @@ -1,46 +0,0 @@ -// Place all the styles related to the routes controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ - -// #workspace.lines.show - -#workspace.routes.edit, -#workspace.routes.new, -#workspace.routes.create, -#workspace.routes.update - #route_color - width: 100px - color: white - font-weight: bold - - #stop_points .nested-fields - ol - margin-left: 25% - - .handle - margin-left: 5px - - .search_stop_area - margin-bottom: 0px !important - - div.resize - height: 40px - line-height: 40px - font-size: 16px - - #stop_points .links - margin: 10px 0 15px 25% - -#workspace.routes.edit_boarding_alighting - .stop_area - padding-top: 7px - -// #workspace.routes.show - -.large-map - width: 100% - height: 600px - - #map - width: 100% - height: 100%
\ No newline at end of file diff --git a/app/assets/stylesheets/main/rule_parameter_sets.sass b/app/assets/stylesheets/main/rule_parameter_sets.sass deleted file mode 100644 index ab58b7bf9..000000000 --- a/app/assets/stylesheets/main/rule_parameter_sets.sass +++ /dev/null @@ -1,45 +0,0 @@ -// Place all the styles related to the rule_parameter_sets controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ - -// #workspace.rule_parameter_sets.index - -#workspace.rule_parameter_sets.show, -#workspace.compliance_check_tasks.rule_parameter_set - .summary label - font-weight: bold - - div.attributes_group - margin: 15px 0 15px 0 - - .title - font-weight: bold - - .columns - margin-left: 10px - - div - display: inline-block - - &.two_columns - width: 45% - &.three_columns - width: 30% - &.four_columns - width: 23% - - label - color: #616161 - - .value - margin-left: 5px - - div.rule_parameter_by_mode - margin: 20px 0 0 0 !important - - .mode_specific - display: none - margin: 0 0 0 10px - - p label - color: #616161
\ No newline at end of file diff --git a/app/assets/stylesheets/main/simple_form.sass b/app/assets/stylesheets/main/simple_form.sass deleted file mode 100644 index 143ea692c..000000000 --- a/app/assets/stylesheets/main/simple_form.sass +++ /dev/null @@ -1,3 +0,0 @@ -#workspace - .submit - @extend .col-md-offset-3
\ No newline at end of file diff --git a/app/assets/stylesheets/main/stop_areas.sass b/app/assets/stylesheets/main/stop_areas.sass deleted file mode 100644 index f8e1e148a..000000000 --- a/app/assets/stylesheets/main/stop_areas.sass +++ /dev/null @@ -1,165 +0,0 @@ -// Place all the styles related to the lines controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ - -#workspace.stop_areas.index - #country_codes - display: none - -#workspace.stop_areas.edit, -#workspace.stop_areas.new, -#workspace.stop_areas.update, -#workspace.stop_areas.create - legend - padding-bottom: 20px - - #prefetch - padding: 10px 10px 20px 10px - - label - font-size: 16px - margin-right: 25px - - input - width: 330px - - #map - width: 50% - -#workspace.stop_areas.show - .geo_data - padding-left: 15px - - .summary - p label - font-weight: bold - -.genealogical - .parent - border: 2px solid black - float: left - padding: 3px 15px 3px 3px - - * - vertical-align: middle - - span - margin-left: 7px - img - margin: 0px 5px 0px 5px - - .lines - float: left - - .line - border: 2px solid black - padding: 3px 15px 3px 3px - height: 25px - margin-bottom: 5px - - * - vertical-align: middle - - span - margin-left: 7px - img - margin: 0px 5px 0px 5px - - .no_parent - float: left - padding: 3px 15px 3px 3px - width: 150px - - .target - border: 2px solid #86b41d - float: left - padding: 3px 15px 3px 3px - font-weight: bold - - * - vertical-align: middle - - span - margin-left: 7px - img - margin: 0px 5px 0px 5px - - .children - float: left - - .child - border: 2px solid black - padding: 3px 15px 3px 3px - margin-bottom: 5px - - * - vertical-align: middle - - span - margin-left: 7px - img - margin: 0px 5px 0px 5px - - .link - float: left - padding: 7px - margin-right: 10px - margin-left: 10px - height: 25px - -#workspace.stop_areas.select_parent - .token-input-list - display: inline-block - -#workspace.stop_areas.add_children - .token-input-list - display: inline-block - -#workspace.stop_areas.access_links - .access_link_pairs - .link - border: 2px solid black - - .access_point - float: left - padding: 3px 15px 0px 3px - height: 25px - - * - vertical-align: middle - - span - margin-left: 7px - img - margin: 0px 5px 0px 5px - - .stop_area - float: left - padding: 3px 15px 0px 3px - height: 25px - - * - vertical-align: middle - - span - margin-left: 7px - img - margin: 0px 5px 0px 5px - - .info - font-size: 10px - color: #777 - font-weight: normal - padding-top: 0px - padding-left: 45px - padding-right: 3px - padding-bottom: 3px - -#sidebar ul.selection li - a - line-height: 27px - - img - height: 25px - width: 25px - vertical-align: middle
\ No newline at end of file diff --git a/app/assets/stylesheets/main/stop_points.sass b/app/assets/stylesheets/main/stop_points.sass deleted file mode 100644 index a17814d3b..000000000 --- a/app/assets/stylesheets/main/stop_points.sass +++ /dev/null @@ -1,26 +0,0 @@ -// Place all the styles related to the lines controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ - -#workspace.stop_points.index - // .stop_points - - #sortable_stop_points .stop_point - /* to create multi-column index */ - width: 350px - padding-right: 10px - - .handle - cursor: move - margin-right: 7px - margin-bottom: 20px - - a.link - background: url(image-path('icons/link-small.png')) no-repeat 0% 50% - - .position - background-color: #61970B - font-weight: bold - color: white - margin-right: 10px - padding-left: 4px
\ No newline at end of file diff --git a/app/assets/stylesheets/main/time_table_combinations.sass b/app/assets/stylesheets/main/time_table_combinations.sass deleted file mode 100644 index 9de2c2235..000000000 --- a/app/assets/stylesheets/main/time_table_combinations.sass +++ /dev/null @@ -1,7 +0,0 @@ -#modal_combine - .time_table_combination - .radio input[type='radio'] - position: inherit !important - - .inputs - overflow: visible !important
\ No newline at end of file diff --git a/app/assets/stylesheets/main/time_tables.sass b/app/assets/stylesheets/main/time_tables.sass deleted file mode 100644 index 6918bec1e..000000000 --- a/app/assets/stylesheets/main/time_tables.sass +++ /dev/null @@ -1,135 +0,0 @@ -// Place all the styles related to the lines controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ - -// #workspace.time_tables.index - -#workspace.time_tables.show - .modal-body - overflow-y: visible - - .summary - margin-top: 20px - - p label - font-weight: bold - - .legend - margin-top: 20px - - .title - font-weight: bold - - .excluded_date, .overlaped_date, .selected_date, .selected_period - margin-left: 20px - margin-right: 5px - - .typeahead.dropdown-menu - z-index: 100001 - - .validity_out - color: red - - .validity_out_soon - color: orange - - .validity_regular - color: green - - span.included_day_type - font-weight: bolder - margin-right: 3px - - span.excluded_day_type - margin-right: 3px - - .period - padding-left: 50px - padding-right: 450px - - .date - padding-left: 50px - - .odd - padding-left: 50px - padding-right: 450px - - .even - padding-left: 50px - padding-right: 450px - - .actions - float: right - - #associated_calendars - padding-top: 15px - -#workspace.time_tables.edit, -#workspace.time_tables.new, -#workspace.time_tables.create, -#workspace.time_tables.update, -#workspace.time_tables.duplicate - fieldset.inputs - overflow: visible !important - - .tags - overflow: visible !important - - h3 - .dates - cursor: pointer - - .periods - cursor: pointer - - .excluded_dates - cursor: pointer - - #dates, - #excluded_dates, - #periods - margin-left: 25% - - .nested-fields - margin: 5px - - ol li - display: inline - - .day_type ol - float: left - margin: 0 - padding: 0 0 0 0 - width: 100% - list_style: none outside none - margin-top: 1em - margin-bottom: 1em - - li - float: left - margin: 0 0 0 0 - width: auto - padding: 0 - - label - padding-left: 10% - margin-top: 0 - - .day_type_label - float: left - margin-top: 0 - width: 25% - - a.add_fields - margin-left: 25% - margin-top: 20px - padding-left: 18px - background: url(image-path('icons/add.png')) no-repeat 0% 50% - - a.remove_fields - margin-left: 10px - padding-left: 18px - background: url(image-path('icons/remove.png')) no-repeat 0% 50% - - .actions - margin-top: 20px diff --git a/app/assets/stylesheets/main/vehicle_journey_frequencies.sass b/app/assets/stylesheets/main/vehicle_journey_frequencies.sass deleted file mode 100644 index a827cc4d2..000000000 --- a/app/assets/stylesheets/main/vehicle_journey_frequencies.sass +++ /dev/null @@ -1,155 +0,0 @@ -#workspace - .ce-TimeBandFormTable - .btn - white-space: normal - width: 130px - font-size: 11px - padding: 2px 0 - - .ce-TimeBandFormTable - th - text-align: left - padding: 6px 20px - - td - padding: 6px 20px - - .ce-TimeBandFormTable td - vertical-align: middle - - .ce-TimeBandFormTable-circleLine - position: relative - - .ce-TimeBandFormTable-line:after - content: '' - position: absolute - top: 0 - bottom: 0 - left: 50% - width: 2px - margin-left: -1px - background-color: #61970b - - tr:first-child td .ce-TimeBandFormTable-line:after - top: 50% - - tr:last-child td .ce-TimeBandFormTable-line:after - bottom: 50% - - .ce-TimeBandFormTable-circle - position: relative - z-index: 999 - display: block - width: 16px - height: 16px - border-radius: 8px - background-color: #4d7809 - - tr:hover .ce-TimeBandFormTable-circle - background-color: #fff - border: 2px solid #61970b - - .ce-FrequencyFormFields - display: table - width: 100% - padding-left: 25% - - .token-input-list - width: 80% - - .inline-errors - margin: 0 - - > li - display: table-cell - width: 21% - vertical-align: top - padding: 0 - margin: 0 - - &:first-child select - width: 160px - - &:nth-last-child(2), &:last-child - width: 8% - - label - font-size: 13px - padding-left: 0 - - legend - position: relative - width: auto - float: none - border: 0 - - label - position: relative - - .fragments-group - float: none - width: auto - padding: 0 - - > li - display: inline-block - vertical-align: top - - &.vehicle_journey_frequencies - .actions-add-fields - clear: both - padding-left: 25% - margin-top: 10px - - td.ce-VehicleJourneyBlock-frequency - background-color: rgba(95, 95, 95, 0.2) - - .ce-VehicleJourneyFrequencyTableBlock - margin: 0 !important - - .ce-VehicleJourneyFrequenciesMatrix - margin: 0 - padding: 0 - - > li - background-color: #eee - height: 22px - margin-bottom: 20px - position: relative - - > ul - margin: 0 - padding: 0 - - > li - cursor: pointer - position: absolute - padding: 0 2px - top: 0 - bottom: 0 - background-color: $brand-primary - border-left: 1px solid #000 - border-right: 1px solid #000 - - &:hover - z-index: 9999 - background-color: #4d7809 - top: -2px - bottom: -2px - - > span - display: block - - .ce-VehicleJourneyFrequenciesMatrix-firstDepartureTime, - .ce-VehicleJourneyFrequenciesMatrix-lastDepartureTime - display: none - position: absolute - top: -13px - font-size: 11px - color: #262626 - - .ce-VehicleJourneyFrequenciesMatrix-firstDepartureTime - left: -32px - - .ce-VehicleJourneyFrequenciesMatrix-lastDepartureTime - right: -32px
\ No newline at end of file diff --git a/app/assets/stylesheets/main/vehicle_journeys.sass b/app/assets/stylesheets/main/vehicle_journeys.sass deleted file mode 100644 index ec0b25dbc..000000000 --- a/app/assets/stylesheets/main/vehicle_journeys.sass +++ /dev/null @@ -1,118 +0,0 @@ -#workspace.vehicle_journeys.edit, -#workspace.vehicle_journeys.update, -#workspace.vehicle_journeys.create, -#workspace.vehicle_journeys.new, -#workspace.vehicle_journey_frequencies.edit, -#workspace.vehicle_journey_frequencies.update, -#workspace.vehicle_journey_frequencies.create, -#workspace.vehicle_journey_frequencies.new - #route_color - width: 100px - color: white - font-weight: bold - - .btn - padding: 6px 12px - - .time_table_list - padding-left: 25% - - #vehicle_journey_footnote_ids_input, - #vehicle_journey_frequency_footnote_ids_input - min-height: 3em - - .vehicle_journey_at_stops, - .vehicle_journey_frequency_at_stops - margin-left: 25% - - thead, tbody, tfoot - th, td - text-align: center - - .journey_pattern_dependent_list - tr.no_stop - display: none - - td.departure_time, td.arrival_time - &.missing - background-color: $brand-warning - - &.invalid_position - background-color: $brand-danger - - .title - font-weight: bold - margin-bottom: 20px - - span - margin-left: 10px - margin-right: 10px - - .slide - margin-left: 30px - -#workspace.vehicle_journeys.index, -#workspace.vehicle_journey_frequencies.index - #search - ul.token-input-list - display: inline-block - vertical-align: middle - margin-left: 15px - - .advanced_search - margin-left: 40px - - .time_tables_id_eq - margin-left: 20px - - .vehicle_journey_at_stops_departure_time_gt - margin-left: 20px - - table - margin: 20px 0 0 0 - - .calendars - font-size: 12px - - .stop_area - width: 200px - - td.hours - text-align: center - - tr th.vehicle_journey - text-align: center - -#workspace.vehicle_journeys.show, -#workspace.vehicle_journeys.edit, -#workspace.vehicle_journeys.update, -#workspace.vehicle_journeys.create, -#workspace.vehicle_journeys.new, -#workspace.vehicle_journey_journey.show, -#workspace.vehicle_journey_journey.edit, -#workspace.vehicle_journey_journey.update, -#workspace.vehicle_journey_journey.create, -#workspace.vehicle_journey_journey.new - .slide - cursor: pointer - -#workspace.vehicle_journeys.show, -#workspace.vehicle_journey_frequencies.show - .summary p label - font-weight: bold - -#workspace.vehicle_journeys.timeless, -#workspace.vehicle_journey_frequencies.timeless - .summary p label - font-weight: bold - - .vehicle_journeys, - .vehicle_journey_frequencies - margin-top: 20px - - .vehicle_journey, - .vehicle_journey_frequency - span.included_day_type - font-weight: bolder - - // span.excluded_day_type
\ No newline at end of file diff --git a/app/assets/stylesheets/main/vehicle_translation.sass b/app/assets/stylesheets/main/vehicle_translation.sass deleted file mode 100644 index f1fd12e14..000000000 --- a/app/assets/stylesheets/main/vehicle_translation.sass +++ /dev/null @@ -1,10 +0,0 @@ -#translate_form - .repeat_cloning - margin-top: 30px - - .modal-footer - .actions - padding-left: 75% - - li - margin: 0
\ No newline at end of file diff --git a/app/assets/stylesheets/modules/import_messages.sass b/app/assets/stylesheets/modules/import_messages.sass new file mode 100644 index 000000000..e5666cbcd --- /dev/null +++ b/app/assets/stylesheets/modules/import_messages.sass @@ -0,0 +1,5 @@ +.import_messages + .status_icon + padding-right: 20px + h1 + padding-bottom: 20px diff --git a/app/controllers/api/v1/netex_imports_controller.rb b/app/controllers/api/v1/netex_imports_controller.rb index 046802ff9..fc85e35dd 100644 --- a/app/controllers/api/v1/netex_imports_controller.rb +++ b/app/controllers/api/v1/netex_imports_controller.rb @@ -41,7 +41,7 @@ module Api unless @netex_import.referential Rails.logger.info "Can't create referential for import #{@netex_import.id}: #{@new_referential.inspect} #{@new_referential.metadatas.inspect} #{@new_referential.errors.full_messages}" - @netex_import.messages.create criticity: :error, message_key: "cant_create_referential" + @netex_import.messages.create criticity: :error, message_key: "referential_creation" end rescue ActiveRecord::RecordInvalid render json: {errors: @netex_import.errors}, status: 406 diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 47b54039c..cc1c30703 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -34,7 +34,8 @@ class ApplicationController < ActionController::Base helper_method :current_organisation def current_functional_scope - JSON.parse(current_organisation.sso_attributes["functional_scope"]) if current_organisation + functional_scope = current_organisation.sso_attributes.try(:[], "functional_scope") if current_organisation + JSON.parse(functional_scope) if functional_scope end helper_method :current_functional_scope diff --git a/app/controllers/autocomplete_time_tables_controller.rb b/app/controllers/autocomplete_time_tables_controller.rb index 375928aeb..d0cd94e26 100644 --- a/app/controllers/autocomplete_time_tables_controller.rb +++ b/app/controllers/autocomplete_time_tables_controller.rb @@ -9,7 +9,7 @@ class AutocompleteTimeTablesController < InheritedResources::Base end def referential - @referential ||= current_organisation.referentials.find params[:referential_id] + @referential ||= Referential.find params[:referential_id] end protected diff --git a/app/controllers/compliance_check_tasks_controller.rb b/app/controllers/compliance_check_tasks_controller.rb deleted file mode 100644 index c2995c94d..000000000 --- a/app/controllers/compliance_check_tasks_controller.rb +++ /dev/null @@ -1,49 +0,0 @@ -class ComplianceCheckTasksController < ChouetteController - defaults :resource_class => ComplianceCheckTask - - respond_to :html, :only => [:new, :create] - respond_to :js, :only => [:new, :create] - - belongs_to :referential - - def new - begin - new! - rescue Ievkit::Error, Faraday::Error => error - logger.error("Iev failure : #{error.message}") - flash[:error] = t(error.locale_for_error) - redirect_to referential_path(@referential) - end - end - - def create - begin - create! do |success, failure| - success.html { redirect_to referential_compliance_checks_path(@referential) } - end - rescue Ievkit::Error, Faraday::Error => error - logger.error("Iev failure : #{error.message}") - flash[:error] = t(error.locale_for_error) - redirect_to referential_path(@referential) - end - end - - def references - references_type = params[:filter].pluralize - references = @referential.send(references_type).where("name ilike ?", "%#{params[:q]}%").select("id, name") - puts references.inspect - respond_to do |format| - format.json do - render :json => references.collect { |child| { :id => child.id, :name => child.name } } - end - end - end - - protected - - def build_resource - @compliance_check_task ||= ComplianceCheckTask.new( params[:compliance_check_task] || {} ) - end - - -end diff --git a/app/controllers/compliance_checks_controller.rb b/app/controllers/compliance_checks_controller.rb index 2d67aae98..07438cf99 100644 --- a/app/controllers/compliance_checks_controller.rb +++ b/app/controllers/compliance_checks_controller.rb @@ -1,87 +1,4 @@ -require 'will_paginate/array' - class ComplianceChecksController < ChouetteController - defaults :resource_class => ComplianceCheck - - respond_to :html, :js - respond_to :zip, :only => :export - belongs_to :referential - - def index - begin - index! do - build_breadcrumb :index - end - rescue Ievkit::Error, Faraday::Error => error - logger.error("Iev failure : #{error.message}") - flash[:error] = t(error.locale_for_error) - redirect_to referential_path(@referential) - end - end - - def show - begin - show! do |format| - build_breadcrumb :show - end - rescue Ievkit::Error, Faraday::Error => error - logger.error("Iev failure : #{error.message}") - flash[:error] = t(error.locale_for_error) - redirect_to referential_path(@referential) - end - end - - def report - resource - build_breadcrumb :report - end - - def references - @references = referential.send(params[:type]).where("name ilike ?", "%#{params[:q]}%") - respond_to do |format| - format.json do - render json: @references.collect { |child| { id: child.id, name: child.name } } - end - end - end - - def rule_parameter_set - begin - @rule_parameter_set = resource.rule_parameter_set - build_breadcrumb :rule_parameter_set - render "rule_parameter_sets/show" - rescue Ievkit::Error, Faraday::Error => error - logger.error("Iev failure : #{error.message}") - flash[:error] = t(error.locale_for_error) - redirect_to referential_path(@referential) - end - end - - def export - respond_to do |format| - format.zip { send_file ComplianceCheckExport.new(resource, @referential.id, request).export, :type => :zip } - end - end - - protected - - alias_method :compliance_check, :resource - - def compliance_check_service - ComplianceCheckService.new(@referential) - end - - def resource - @compliance_check ||= compliance_check_service.find(params[:id]) - @line_items = @compliance_check.report.line_items - if @line_items.size > 500 - @line_items = @line_items.paginate(page: params[:page], per_page: 20) - end - @compliance_check - end - def collection - @compliance_checks ||= compliance_check_service.all.sort_by{ |compliance_check| compliance_check.created_at }.reverse.paginate(:page => params[:page]) - end end diff --git a/app/controllers/import_messages_controller.rb b/app/controllers/import_messages_controller.rb index 64eec92dd..4ad398cbb 100644 --- a/app/controllers/import_messages_controller.rb +++ b/app/controllers/import_messages_controller.rb @@ -9,7 +9,7 @@ class ImportMessagesController < BreadcrumbController def index index! do |format| format.csv { - send_data ImportMessageExport.new(:import_messages => @import_messages).to_csv(:col_sep => ";") , :filename => "test.csv" + send_data ImportMessageExport.new(:import_messages => @import_messages).to_csv(:col_sep => ";") , :filename => "#{File.basename(@import_resource.name)}_#{Time.now.to_i}.csv" } end end diff --git a/app/controllers/imports_controller.rb b/app/controllers/imports_controller.rb index b1b34731b..97a8f91aa 100644 --- a/app/controllers/imports_controller.rb +++ b/app/controllers/imports_controller.rb @@ -1,6 +1,7 @@ class ImportsController < BreadcrumbController skip_before_action :authenticate_user!, only: [:download] defaults resource_class: Import, collection_name: 'imports', instance_name: 'import' + before_action :ransack_started_on_date, only: [:index] respond_to :html belongs_to :workbench @@ -55,6 +56,17 @@ class ImportsController < BreadcrumbController private + def ransack_started_on_date + date =[] + if params[:q] && !params[:q]['started_on_date(1i)'].empty? + ['started_on_date(1i)', 'started_on_date(2i)', 'started_on_date(3i)'].each do |key| + date << params[:q][key].to_i + params[:q].delete(key) + end + params[:q]['started_on_date'] = DateTime.new(*date) rescue nil + end + end + def build_resource @import ||= WorkbenchImport.new(*resource_params) do |import| import.workbench = parent diff --git a/app/controllers/referentials_controller.rb b/app/controllers/referentials_controller.rb index a6dfaf2b6..bd0544a74 100644 --- a/app/controllers/referentials_controller.rb +++ b/app/controllers/referentials_controller.rb @@ -10,7 +10,6 @@ class ReferentialsController < BreadcrumbController if params[:from] source_referential = Referential.find(params[:from]) @referential = Referential.new_from(source_referential, current_functional_scope) - @referential.workbench_id = current_organisation.workbenches.first.id end new! do @@ -26,7 +25,7 @@ class ReferentialsController < BreadcrumbController def show resource.switch show! do |format| - @referential = @referential.decorate + @referential = @referential.decorate(context: { workbench_id: params[:workbench_id] } ) @reflines = lines_collection.paginate(page: params[:page], per_page: 10) @reflines = ModelDecorator.decorate( @reflines, diff --git a/app/controllers/workbenches_controller.rb b/app/controllers/workbenches_controller.rb index 19af28a98..bae3fcff2 100644 --- a/app/controllers/workbenches_controller.rb +++ b/app/controllers/workbenches_controller.rb @@ -20,8 +20,13 @@ class WorkbenchesController < BreadcrumbController @q_for_form = scope.ransack(params[:q]) @q_for_result = scope.ransack(ransack_params) @wbench_refs = sort_result(@q_for_result.result).paginate(page: params[:page], per_page: 30) - @wbench_refs = ModelDecorator.decorate(@wbench_refs, with: ReferentialDecorator) - + @wbench_refs = ModelDecorator.decorate( + @wbench_refs, + with: ReferentialDecorator, + context: { + workbench_id: params[:id] + } + ) show! do build_breadcrumb :show end diff --git a/app/decorators/referential_decorator.rb b/app/decorators/referential_decorator.rb index ccb47a654..4e9c242fd 100644 --- a/app/decorators/referential_decorator.rb +++ b/app/decorators/referential_decorator.rb @@ -13,7 +13,7 @@ class ReferentialDecorator < Draper::Decorator if policy.clone? links << Link.new( content: h.t('actions.clone'), - href: h.new_referential_path(from: object.id) + href: h.new_referential_path(from: object.id, workbench_id: context[:workbench_id]) ) end if policy.archive? diff --git a/app/helpers/compliance_check_tasks_helper.rb b/app/helpers/compliance_check_tasks_helper.rb deleted file mode 100644 index 5ba8bdc46..000000000 --- a/app/helpers/compliance_check_tasks_helper.rb +++ /dev/null @@ -1,11 +0,0 @@ -module ComplianceCheckTasksHelper - - def button_link_class( compliance_check_task ) - if compliance_check_task.any_error_severity_failure? || compliance_check_task.status == "failed" - "btn-danger" - else - "btn-default" - end - end - -end diff --git a/app/helpers/compliance_checks_helper.rb b/app/helpers/compliance_checks_helper.rb deleted file mode 100644 index d7e42e187..000000000 --- a/app/helpers/compliance_checks_helper.rb +++ /dev/null @@ -1,96 +0,0 @@ -# -*- coding: utf-8 -*- -module ComplianceChecksHelper - - def fields_for_compliance_check_format(form) - begin - render :partial => compliance_check_partial_name(form), :locals => { :form => form } - rescue ActionView::MissingTemplate - "" - end - end - - def compliance_check_partial_name(form) - "fields_#{form.object.format.underscore}_compliance_check" - end - - def compliance_icon( compliance_check) - return nil unless compliance_check.compliance_check_validation_report - compliance_check.compliance_check_validation_report.tap do |cct| - if cct.failed? || cct.any_error_severity_failure? - return 'icons/link_page_alert.png' - else - return 'icons/link_page.png' - end - end - end - - def status_icon( compliance_check_result_status, compliance_check_result_severity ) - if compliance_check_result_status == "uncheck" - ("<i class='fa fa-ban status_" + compliance_check_result_status + "_" + compliance_check_result_severity + "'></i>").html_safe - elsif compliance_check_result_status == "ok" - ("<i class='fa fa-check status_" + compliance_check_result_status + "_" + compliance_check_result_severity + "'></i>").html_safe - else - ("<i class='fa fa-times status_" + compliance_check_result_status + "_" + compliance_check_result_severity + "'></i>").html_safe - end - end - - def test_definition (compliance_check_result_code) - Rails.application.config.validation_spec + I18n.locale.to_s + "/" + compliance_check_result_code +".html" - end - - def object_url (referential_id, error) - location = "/referentials/" + referential_id.to_s - object_path = error[:source].object_path - if object_path.first[:type] == "vehicle_journey" - object_path.delete_at 1 - end - - types, identifiers = object_path.reverse.map { |resource| [ resource[:type], resource[:id] ] }.transpose - - method_name = (['referential'] + types + ['path']).join('_') - identifiers.unshift referential_id - - return send method_name, *identifiers - end - - def object_labels_hash (error) - ### THE error HASH STRUCTURE - # 1. error[:source] - # 0..1 file - # 1 filename - # 0..1 line_number - # 0..1 column_number - # 0..1 objectid - # 0..1 label - # 0.. object_path - # 1 type - # 1 id - # 0.. error[:target] - # 0..1 error[:error_value] - # 0..1 error[:reference_value] - object_labels_hash = Hash.new - object_labels_hash[:source_objectid] = error[:source].objectid if error[:source].objectid.present? - object_labels_hash[:source_label] = error[:source].label if error[:source].label.present? - if error[:source].file.present? - object_labels_hash[:filename] = error[:source].file.filename - object_labels_hash[:line_number] = error[:source].file.line_number if error[:source].file.line_number.present? - object_labels_hash[:column_number] = error[:source].file.column_number if error[:source].file.column_number.present? - end - - if error[:target].present? - error[:target].each_with_index do |target, index| - object_labels_hash["target_#{index}_objectid".to_sym] = target[:objectid] if target[:objectid] - object_labels_hash["target_#{index}_label".to_sym] = target[:label] if target[:label] - end - end - if error[:error_value].present? - object_labels_hash[:error_value] = error[:error_value] - end - if error[:reference_value].present? - object_labels_hash[:reference_value] = error[:reference_value] - end - return object_labels_hash - end - - -end diff --git a/app/models/chouette/access_point.rb b/app/models/chouette/access_point.rb index 476f13c08..4a1ae8a0e 100644 --- a/app/models/chouette/access_point.rb +++ b/app/models/chouette/access_point.rb @@ -4,6 +4,7 @@ require 'geo_ruby' class Chouette::AccessPoint < Chouette::ActiveRecord # FIXME http://jira.codehaus.org/browse/JRUBY-6358 self.primary_key = "id" + include StifReflexAttributesSupport include Geokit::Mappable include ProjectionFields @@ -23,12 +24,15 @@ class Chouette::AccessPoint < Chouette::ActiveRecord validates_numericality_of :longitude, :less_than_or_equal_to => 180, :greater_than_or_equal_to => -180, :allow_nil => true validates_format_of :coordinates, :with => %r{\A *-?(0?[0-9](\.[0-9]*)?|[0-8][0-9](\.[0-9]*)?|90(\.[0]*)?) *\, *-?(0?[0-9]?[0-9](\.[0-9]*)?|1[0-7][0-9](\.[0-9]*)?|180(\.[0]*)?) *\Z}, :allow_nil => true, :allow_blank => true - + before_save :coordinates_to_lat_lng def self.nullable_attributes [:street_name, :country_code, :comment, :long_lat_type, :zip_code, :city_name] end - before_save :coordinates_to_lat_lng + + def referential + @referential ||= Referential.where(:slug => Apartment::Tenant.current).first! + end def referential @referential ||= Referential.where(:slug => Apartment::Tenant.current).first! diff --git a/app/models/chouette/company.rb b/app/models/chouette/company.rb index 7b96e875e..a472020e1 100644 --- a/app/models/chouette/company.rb +++ b/app/models/chouette/company.rb @@ -1,6 +1,6 @@ class Chouette::Company < Chouette::ActiveRecord include CompanyRestrictions - include DefaultNetexAttributesSupport + include StifCodifligneAttributesSupport include LineReferentialSupport has_many :lines diff --git a/app/models/chouette/group_of_line.rb b/app/models/chouette/group_of_line.rb index d954c6699..a987d6311 100644 --- a/app/models/chouette/group_of_line.rb +++ b/app/models/chouette/group_of_line.rb @@ -1,5 +1,5 @@ class Chouette::GroupOfLine < Chouette::ActiveRecord - include DefaultNetexAttributesSupport + include StifCodifligneAttributesSupport include GroupOfLineRestrictions include LineReferentialSupport diff --git a/app/models/chouette/journey_pattern.rb b/app/models/chouette/journey_pattern.rb index fa5fba26d..2b62d5c7f 100644 --- a/app/models/chouette/journey_pattern.rb +++ b/app/models/chouette/journey_pattern.rb @@ -21,6 +21,11 @@ class Chouette::JourneyPattern < Chouette::TridentActiveRecord attr_accessor :control_checked after_update :control_route_sections, :unless => "control_checked" + + def local_id + "IBOO-#{self.try(:route).try(:line).try(:objectid).try(:local_id)}-#{self.referential.id}-#{self.id}" + end + def checksum_attributes values = self.slice(*['name', 'published_name', 'registration_number']).values values << self.stop_points.map(&:stop_area).map(&:user_objectid) diff --git a/app/models/chouette/network.rb b/app/models/chouette/network.rb index 690c39344..8df205789 100644 --- a/app/models/chouette/network.rb +++ b/app/models/chouette/network.rb @@ -1,5 +1,5 @@ class Chouette::Network < Chouette::ActiveRecord - include DefaultNetexAttributesSupport + include StifCodifligneAttributesSupport include NetworkRestrictions include LineReferentialSupport # FIXME http://jira.codehaus.org/browse/JRUBY-6358 diff --git a/app/models/chouette/route.rb b/app/models/chouette/route.rb index 6774e8a86..5b89fbbe8 100644 --- a/app/models/chouette/route.rb +++ b/app/models/chouette/route.rb @@ -75,6 +75,10 @@ class Chouette::Route < Chouette::TridentActiveRecord after_commit :journey_patterns_control_route_sections + def local_id + "IBOO-#{self.line.objectid.local_id}-#{self.referential.id}-#{self.id}" + end + def geometry_presenter Chouette::Geometry::RoutePresenter.new self end diff --git a/app/models/chouette/routing_constraint_zone.rb b/app/models/chouette/routing_constraint_zone.rb index 9931748b2..21efa2539 100644 --- a/app/models/chouette/routing_constraint_zone.rb +++ b/app/models/chouette/routing_constraint_zone.rb @@ -8,6 +8,10 @@ class Chouette::RoutingConstraintZone < Chouette::TridentActiveRecord # validates :stop_point_ids, length: { minimum: 2, too_short: I18n.t('activerecord.errors.models.routing_constraint_zone.attributes.stop_points.not_enough_stop_points') } validate :stop_points_belong_to_route, :not_all_stop_points_selected + def local_id + "IBOO-#{self.route.line.objectid.local_id}-#{self.route.objectid.local_id}-#{self.referential.id}-#{self.id}" + end + scope :order_by_stop_points_count, ->(direction) do order("array_length(stop_point_ids, 1) #{direction}") end diff --git a/app/models/chouette/stif_netex_objectid.rb b/app/models/chouette/stif_netex_objectid.rb new file mode 100644 index 000000000..3b11691d9 --- /dev/null +++ b/app/models/chouette/stif_netex_objectid.rb @@ -0,0 +1,38 @@ +class Chouette::StifNetexObjectid < String + def valid? + parts.present? + end + + @@format = /^([A-Za-z_]+):([A-Za-z]+):([0-9A-Za-z_-]+):([A-Za-z]+)$/ + cattr_reader :format + + def parts + match(format).try(:captures) + end + + def provider_id + parts.try(:first) + end + + def object_type + parts.try(:second) + end + + def local_id + parts.try(:third) + end + + def boiv_id + parts.try(:fourth) + end + + def self.create(provider_id, object_type, local_id, boiv_id) + new [provider_id, object_type, local_id, boiv_id].join(":") + end + + def self.new(string) + string ||= "" + self === string ? string : super + end + +end diff --git a/app/models/chouette/time_table.rb b/app/models/chouette/time_table.rb index 8aff3bf36..8821a5201 100644 --- a/app/models/chouette/time_table.rb +++ b/app/models/chouette/time_table.rb @@ -31,6 +31,10 @@ class Chouette::TimeTable < Chouette::TridentActiveRecord after_save :save_shortcuts + def local_id + "IBOO-#{self.referential.id}-#{self.id}" + end + def checksum_attributes [].tap do |attrs| attrs << self.int_day_types @@ -557,8 +561,7 @@ class Chouette::TimeTable < Chouette::TridentActiveRecord end def duplicate - tt = self.deep_clone :include => [:periods, :dates], :except => :object_version - tt.uniq_objectid + tt = self.deep_clone :include => [:periods, :dates], :except => [:object_version, :objectid] tt.tag_list.add(*self.tag_list) unless self.tag_list.empty? tt.created_from = self tt.comment = I18n.t("activerecord.copy", :name => self.comment) diff --git a/app/models/chouette/trident_active_record.rb b/app/models/chouette/trident_active_record.rb index c1bc0172b..e8223e3d6 100644 --- a/app/models/chouette/trident_active_record.rb +++ b/app/models/chouette/trident_active_record.rb @@ -1,5 +1,5 @@ class Chouette::TridentActiveRecord < Chouette::ActiveRecord - include DefaultAttributesSupport + include StifNetexAttributesSupport self.abstract_class = true diff --git a/app/models/chouette/vehicle_journey.rb b/app/models/chouette/vehicle_journey.rb index d5ca58959..e60afef6e 100644 --- a/app/models/chouette/vehicle_journey.rb +++ b/app/models/chouette/vehicle_journey.rb @@ -56,6 +56,10 @@ module Chouette end end + def local_id + "IBOO-#{self.route.line.objectid.local_id}-#{self.referential.id}-#{self.id}" + end + def checksum_attributes [].tap do |attrs| attrs << self.published_journey_name diff --git a/app/models/compliance_check.rb b/app/models/compliance_check.rb index d3e4054a6..a9dbc4211 100644 --- a/app/models/compliance_check.rb +++ b/app/models/compliance_check.rb @@ -1,58 +1,3 @@ class ComplianceCheck - include JobConcern - def initialize( response ) - @datas = response - end - - def report? - links["action_report"].present? - end - - def report - Rails.cache.fetch("#{cache_key}/action_report", expires_in: cache_expiration) do - if report_path = links["action_report"] - ComplianceCheckReport.new Ievkit.get(report_path) - end - end - end - - def compliance_check_validation_report? - links["validation_report"].present? - end - - def compliance_check_validation_report - Rails.cache.fetch("#{cache_key}/validation_report", expires_in: cache_expiration) do - if report_path = links["validation_report"] - ComplianceCheckResult.new Ievkit.get(report_path) - end - end - end - - def rule_parameter_set? - links["validation_params"].present? - end - - def rule_parameter_set - Rails.cache.fetch("#{cache_key}/validation_params", expires_in: cache_expiration) do - if rule_parameter_set_path = links["validation_params"] - response = Ievkit.get(rule_parameter_set_path) - RuleParameterSet.new(name: '', compliance_check: self).tap do |rps| - rps.parameters = response.validation - end - end - end - end - - def destroy - if delete_path = links["delete"] - Ievkit.delete(delete_path) - elsif cancel_path = links["cancel"] - Ievkit.delete(cancel_path) - end - end - - def format - datas.type - end end diff --git a/app/models/compliance_check_export.rb b/app/models/compliance_check_export.rb deleted file mode 100644 index 95abb3b27..000000000 --- a/app/models/compliance_check_export.rb +++ /dev/null @@ -1,56 +0,0 @@ -require 'tempfile' - -class ComplianceCheckExport - include ERB::Util - include ComplianceChecksHelper - - require 'zip' - - attr_accessor :template, :detailed_errors_template, :request - attr_reader :compliance_check - - def initialize(compliance_check, referential_id, request) - @request = request - @compliance_check = compliance_check - @referential_id = referential_id - @template = File.open('app/views/compliance_checks/summary_errors_index.csv.erb' ) { |f| f.read } - @detailed_errors_template = File.open('app/views/compliance_checks/detailed_errors_index.csv.erb' ) { |f| f.read } - end - - def export - begin - Dir.mktmpdir("#{I18n.t('compliance_check_results.file.zip_name_prefix')}_#{@referential_id}_#{@compliance_check.id}_", Dir.tmpdir) { |temp_dir| - - File.open(temp_dir + "/#{I18n.t('compliance_check_results.file.summary_errors_file_prefix')}" , "a:utf-8") do |f| - f.write("\ufeff") - f.write(render) - f.flush - end - - File.open(temp_dir + "/#{I18n.t('compliance_check_results.file.detailed_errors_file_prefix')}" , "a:utf-8") do |f| - f.write("\ufeff") - f.write(detailed_errors_render) - f.flush - end - - zip_file = Tempfile.new(["#{I18n.t('compliance_check_results.file.zip_name_prefix')}_#{@referential_id}_#{@compliance_check.id}_", ".zip"]) - - ::Zip::File.open(zip_file.path, ::Zip::File::CREATE) do |zipfile| - Dir[File.join(temp_dir, '*.csv')].each do |f| - zipfile.add(File.basename(f), f) - end - end - return zip_file - } - end - end - - def render() - ERB.new(@template).result(binding) - end - - def detailed_errors_render() - ERB.new(@detailed_errors_template).result(binding) - end - -end diff --git a/app/models/compliance_check_report.rb b/app/models/compliance_check_report.rb deleted file mode 100644 index 94deb8cc9..000000000 --- a/app/models/compliance_check_report.rb +++ /dev/null @@ -1,9 +0,0 @@ -class ComplianceCheckReport - include ReportConcern - - def initialize( response ) - @datas = response.action_report - end - -end - diff --git a/app/models/compliance_check_result.rb b/app/models/compliance_check_result.rb index cd956a021..06f8649f5 100644 --- a/app/models/compliance_check_result.rb +++ b/app/models/compliance_check_result.rb @@ -1,76 +1,3 @@ class ComplianceCheckResult - extend ActiveModel::Naming - extend ActiveModel::Translation - include ActiveModel::Model - - attr_accessor :datas - - def initialize(response) - @datas = response.validation_report - end - - def tests? - datas.tests? - end - - def ok_error - all('ok', 'error') - end - - def nok_error - all('nok', 'error') - end - - def na_error - all('uncheck', 'error') - end - - def ok_warning - all('ok', 'warning') - end - - def nok_warning - all('nok', 'warning') - end - - def na_warning - all('uncheck', 'warning') - end - - def all(status, severity) - tests? ? tests.select { |test| test.result == status.downcase && test.severity == severity.downcase } : [] - end - - def tests - @tests ||= tests? ? datas.tests.map{ |test| Test.new(test) } : [] - end - - class Test - attr_reader :options - - def initialize( options ) - @options = options - end - - def test_id - options.test_id if options.test_id? - end - - def severity - options.severity.downcase if options.severity? - end - - def result - options.result.downcase if options.result? - end - - def errors - options.errors if options.errors? - end - - def error_count - options.error_count if options.error_count? - end - end end diff --git a/app/models/compliance_check_service.rb b/app/models/compliance_check_service.rb deleted file mode 100644 index c27f36894..000000000 --- a/app/models/compliance_check_service.rb +++ /dev/null @@ -1,23 +0,0 @@ -class ComplianceCheckService - - attr_reader :referential - - def initialize(referential) - @referential = referential - end - - # Find a validation whith this id - def find(id) - ComplianceCheck.new(Ievkit.scheduled_job(referential.slug, id, { :action => "validator" })) - end - - # Find all validations - def all - [].tap do |jobs| - Ievkit.jobs(referential.slug, { :action => "validator" }).each do |job| - jobs << ComplianceCheck.new(job) - end - end - end - -end diff --git a/app/models/compliance_check_task.rb b/app/models/compliance_check_task.rb deleted file mode 100644 index da0508cbf..000000000 --- a/app/models/compliance_check_task.rb +++ /dev/null @@ -1,114 +0,0 @@ -class ComplianceCheckTask - extend Enumerize - extend ActiveModel::Naming - extend ActiveModel::Translation - extend ActiveModel::Callbacks - include ActiveModel::Validations - include ActiveModel::Conversion - - enumerize :references_type, in: %w( network line company group_of_line ) - attr_accessor :rule_parameter_set_id, :referential_id, :user_id, :user_name, :name, :references_type, :reference_ids - - validates_presence_of :referential_id, :user_id, :user_name, :name - - def initialize( params = {} ) - params.each {|k,v| send("#{k}=",v)} - end - - def referential - Referential.find(referential_id) - end - - def organisation - referential.organisation - end - - def rule_parameter_set - organisation.rule_parameter_sets.find(rule_parameter_set_id) if rule_parameter_set_id.present? - end - - def save - if valid? - # Call Iev Server - begin - Ievkit.create_job( referential.slug, "validator", "", { - :file1 => params_io, - } ) - rescue Exception => exception - raise exception - end - true - else - false - end - end - - def self.references_types - self.references_type.values - end - - def params - {}.tap do |h| - h["parameters"] = validation_params ? action_params.merge(validation_params) : action_params - end - end - - def action_params - { - "validate" => { - "name" => name, - "references_type" => references_type, - "reference_ids" => reference_ids, - "user_name" => user_name, - "organisation_name" => organisation.name, - "referential_name" => referential.name, - } - - } - end - - def validation_params - { - "validation" => rule_parameter_set.parameters - } if rule_parameter_set.present? - end - - def self.data_formats - self.data_format.values - end - - def params_io - file = StringIO.new( params.to_json ) - Faraday::UploadIO.new(file, "application/json", "parameters.json") - end - - def transport_data_io - file = File.new(saved_resources_path, "r") - if file_extname == ".zip" - Faraday::UploadIO.new(file, "application/zip", original_filename ) - elsif file_extname == ".xml" - Faraday::UploadIO.new(file, "application/xml", original_filename ) - end - end - - def save_resources - FileUtils.mkdir_p root - FileUtils.cp resources.path, saved_resources_path - end - - def delete_resources - FileUtils.rm saved_resources_path if File.exists? saved_resources_path - end - - def original_filename - resources.original_filename - end - - def file_extname - File.extname(resources.original_filename) - end - - def saved_resources_path - "#{root}/#{Time.now.to_i}#{file_extname}" - end -end diff --git a/app/models/concerns/line_referential_support.rb b/app/models/concerns/line_referential_support.rb index 4ad437fed..406730ddb 100644 --- a/app/models/concerns/line_referential_support.rb +++ b/app/models/concerns/line_referential_support.rb @@ -3,18 +3,10 @@ module LineReferentialSupport included do belongs_to :line_referential - # validates_presence_of :line_referential_id - alias_method :referential, :line_referential end def hub_restricted? false end - - def prefix - # FIXME #825 - "dummy" - end - end diff --git a/app/models/concerns/report_concern.rb b/app/models/concerns/report_concern.rb deleted file mode 100644 index f195f8f36..000000000 --- a/app/models/concerns/report_concern.rb +++ /dev/null @@ -1,170 +0,0 @@ -module ReportConcern - extend ActiveSupport::Concern - extend ActiveModel::Naming - extend ActiveModel::Translation - include ActiveModel::Model - - included do - attr_reader :datas - end - - module ClassMethods - end - - delegate :progression?, :progression, :zip_file, :stats, to: :datas - - def failure_code? - datas.result == "NOK" && datas.failure? - end - - def failure_code - datas.failure.code.downcase if failure_code? - end - - def percentage(a, b) - (a.to_f / b.to_f * 100).round(0) - end - - def level_progress - percentage( progression.current_step, progression.steps_count) if progression? - end - - def last_step - datas.progression.steps.last if progression? - end - - def current_step - datas.progression.steps[ progression.current_step - 1] - end - - def step_progress - percentage( current_step.realized, current_step.total ) - end - - def step_progress_name - return last_step.step if progression.current_step == progression.steps_count - - current_step.step - end - - def files - @files ||= datas.files || [] - end - - def error_files - files.select{ |file| file[:status] == "ERROR"} - end - - def ignored_files - files.select{ |file| file[:status] == "IGNORED"} - end - - def ok_files - files.select{ |file| file[:status] == "OK"} - end - - def line_items - @line_items ||= [].tap do |line_items| - datas.lines.each do |line| - line_items << LineItem.new(line) - end if datas.lines? - end - end - - def saved_lines - line_items.map(&:status).count(true) - end - - def unsaved_lines - line_items.map(&:status).count(false) - end - - def lines - stats.present? ? stats.line_count : 0 - end - - def routes - stats.present? ? stats.route_count : 0 - end - - def connection_links - stats.present? ? stats.connection_link_count : 0 - end - - def time_tables - stats.present? ? stats.time_table_count : 0 - end - - def stop_areas - stats.present? ? stats.stop_area_count : 0 - end - - def access_points - stats.present? ? stats.access_point_count : 0 - end - - def vehicle_journeys - stats.present? ? stats.vehicle_journey_count : 0 - end - - def journey_patterns - stats.present? ? stats.journey_pattern_count : 0 - end - - class LineItem - attr_reader :options - - def initialize( options ) - @options = options - end - - def name - @name ||= options.name if options.name? - end - - def stats - @stats ||= options.stats if options.stats? - end - - def status - @status ||= if options.status? - if %w{ok warning}.include? options.status.downcase - true - else - false - end - else - false - end - end - - def routes - stats ? stats.route_count : 0 - end - - def connection_links - stats ? stats.connection_link_count : 0 - end - - def time_tables - stats ? stats.time_table_count : 0 - end - - def stop_areas - stats ? stats.stop_area_count : 0 - end - - def access_points - stats ? stats.access_point_count : 0 - end - - def vehicle_journeys - stats ? stats.vehicle_journey_count : 0 - end - - def journey_patterns - stats ? stats.journey_pattern_count : 0 - end - - end -end diff --git a/app/models/concerns/stif_netex_attributes_support.rb b/app/models/concerns/stif_netex_attributes_support.rb new file mode 100644 index 000000000..795872755 --- /dev/null +++ b/app/models/concerns/stif_netex_attributes_support.rb @@ -0,0 +1,58 @@ +module StifNetexAttributesSupport + extend ActiveSupport::Concern + + included do + validates_numericality_of :object_version + validates :objectid, uniqueness: true, presence: true + validate :objectid_format_compliance + + after_save :build_objectid + before_validation :default_values, on: :create + end + + module ClassMethods + def object_id_key + model_name + end + + def model_name + ActiveModel::Name.new self, Chouette, self.name.demodulize + end + end + + def objectid_format_compliance + errors.add :objectid, I18n.t("activerecord.errors.models.trident.invalid_object_id") if !objectid.valid? + end + + def local_id + "IBOO-#{self.referential.id}-#{self.id}" + end + + def build_objectid + if objectid.include? ':__pending_id__' + self.objectid = Chouette::StifNetexObjectid.create(self.provider_id, self.model_name, self.local_id, self.boiv_id) + self.save + end + end + + def default_values + self.object_version ||= 1 + + if self.objectid.to_s.empty? + local_id = "__pending_id__#{rand(50)+ rand(50)}" + self.objectid = Chouette::StifNetexObjectid.create(self.provider_id, self.model_name, local_id, self.boiv_id) + end + end + + def objectid + Chouette::StifNetexObjectid.new read_attribute(:objectid) + end + + def provider_id + self.referential.workbench.organisation.name.parameterize + end + + def boiv_id + 'LOC' + end +end diff --git a/app/models/concerns/stop_area_referential_support.rb b/app/models/concerns/stop_area_referential_support.rb index 5a01ef57e..aa59cbd35 100644 --- a/app/models/concerns/stop_area_referential_support.rb +++ b/app/models/concerns/stop_area_referential_support.rb @@ -3,17 +3,10 @@ module StopAreaReferentialSupport included do belongs_to :stop_area_referential - # validates_presence_of :stop_area_referential_id - alias_method :referential, :stop_area_referential end def hub_restricted? false end - - def prefix - # FIXME #825 - "dummy" - end end diff --git a/app/models/data_format_enumerations.rb b/app/models/data_format_enumerations.rb index 94c39e152..787ab6cca 100644 --- a/app/models/data_format_enumerations.rb +++ b/app/models/data_format_enumerations.rb @@ -1,6 +1,6 @@ module DataFormatEnumerations extend Enumerize extend ActiveModel::Naming - - enumerize :data_format, in: %w[neptune netex gtfs hub], default: "neptune" + + enumerize :data_format, in: %w[neptune netex gtfs hub], default: "netex" end diff --git a/app/models/export_report.rb b/app/models/export_report.rb index ef54f40ea..3c0788106 100644 --- a/app/models/export_report.rb +++ b/app/models/export_report.rb @@ -1,9 +1,8 @@ class ExportReport - include ReportConcern + #include ReportConcern def initialize( response ) @datas = response.action_report end - -end +end diff --git a/app/models/import.rb b/app/models/import.rb index ff2f57efc..55d74c13c 100644 --- a/app/models/import.rb +++ b/app/models/import.rb @@ -9,14 +9,20 @@ class Import < ActiveRecord::Base has_many :resources, class_name: "ImportResource", dependent: :destroy has_many :children, foreign_key: :parent_id, class_name: "Import", dependent: :destroy + scope :started_on_date, ->(date) { where('started_at BETWEEN ? AND ?', date.beginning_of_day, date.end_of_day) } + extend Enumerize - enumerize :status, in: %i(new pending successful warning failed running aborted canceled), scope: true + enumerize :status, in: %i(new pending successful warning failed running aborted canceled), scope: true, default: :new validates :file, presence: true validates_presence_of :workbench, :creator before_create :initialize_fields + def self.ransackable_scopes(auth_object = nil) + [:started_on_date] + end + def self.model_name ActiveModel::Name.new Import, Import, "Import" end @@ -89,7 +95,6 @@ class Import < ActiveRecord::Base def initialize_fields self.token_download = SecureRandom.urlsafe_base64 - self.status = Import.status.new end def self.symbols_with_indifferent_access(array) diff --git a/app/models/import_message_export.rb b/app/models/import_message_export.rb index d13a3a21b..88d0f27e2 100644 --- a/app/models/import_message_export.rb +++ b/app/models/import_message_export.rb @@ -22,23 +22,14 @@ class ImportMessageExport end def column_names - ["criticity", "message key"] + ["criticity", "message key", "message"] end - - # t.integer "criticity" - # t.string "message_key" - # t.hstore "message_attributes" - # t.integer "import_id", limit: 8 - # t.integer "resource_id", limit: 8 - # t.datetime "created_at" - # t.datetime "updated_at" - # t.hstore "resource_attributes" def to_csv(options = {}) CSV.generate(options) do |csv| csv << column_names import_messages.each do |import_message| - csv << [import_message.criticity, import_message.message_key ] + csv << [import_message.criticity, import_message.message_key, I18n.t("import_messages.compliance_check_messages.#{import_message.message_key}", import_message.message_attributes.deep_symbolize_keys) ] end end end diff --git a/app/models/import_report.rb b/app/models/import_report.rb index 1dc556e1c..ba13f0118 100644 --- a/app/models/import_report.rb +++ b/app/models/import_report.rb @@ -1,9 +1,8 @@ -class ImportReport - include ReportConcern +class ImportReport + #include ReportConcern def initialize( response ) @datas = response.action_report end - -end +end diff --git a/app/models/vehicle_journey_import.rb b/app/models/vehicle_journey_import.rb index 855fa2abe..44a6d457e 100644 --- a/app/models/vehicle_journey_import.rb +++ b/app/models/vehicle_journey_import.rb @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -class VehicleJourneyImport +class VehicleJourneyImport include ActiveModel::Validations include ActiveModel::Conversion extend ActiveModel::Naming @@ -8,11 +8,11 @@ class VehicleJourneyImport attr_accessor :file, :route attr_accessor :created_vehicle_journey_count,:updated_vehicle_journey_count,:deleted_vehicle_journey_count attr_accessor :created_journey_pattern_count,:error_count - + validates_presence_of :file validates_presence_of :route - def initialize(attributes = {}) + def initialize(attributes = {}) attributes.each { |name, value| send("#{name}=", value) } if attributes self.created_vehicle_journey_count = 0 self.updated_vehicle_journey_count = 0 @@ -20,15 +20,15 @@ class VehicleJourneyImport self.deleted_vehicle_journey_count = 0 self.error_count = 0 end - + def persisted? false end - + def save begin - Chouette::VehicleJourney.transaction do - if imported_vehicle_journeys.map(&:valid?).all? + Chouette::VehicleJourney.transaction do + if imported_vehicle_journeys.map(&:valid?).all? imported_vehicle_journeys.each(&:save!) true else @@ -46,8 +46,8 @@ class VehicleJourneyImport errors.add :base, I18n.t("vehicle_journey_imports.errors.exception") false end - end - + end + def imported_vehicle_journeys @imported_vehicle_journeys ||= load_imported_vehicle_journeys end @@ -61,31 +61,31 @@ class VehicleJourneyImport if stop_points_used.length == 1 errors.add :base, I18n.t("vehicle_journey_imports.errors.one_stop_point_used", :column => column) - raise + raise end - + journey_pattern_founded = route.journey_patterns.select{ |jp| jp.stop_points.collect(&:id) == stop_points_used }.first - + # If no journey pattern founded, create a new one self.created_journey_pattern_count += 1 if journey_pattern_founded.nil? journey_pattern_founded ? journey_pattern_founded : route.journey_patterns.create(:stop_points => Chouette::StopPoint.find(stop_points_used) ) end - + def as_integer(v) v.blank? ? nil : v.to_i end - + def as_boolean(v) v.blank? ? nil : (v[1..1].downcase != "n") end - + def update_time_tables(vj,tm_ids) vj.time_tables.clear return unless tm_ids.present? ids = tm_ids.split(",").map(&:to_i) vj.time_tables << Chouette::TimeTable.where(:id => ids) end - + def update_footnotes(vj,ftn_ids) vj.footnotes.clear return unless ftn_ids.present? @@ -94,13 +94,13 @@ class VehicleJourneyImport end def load_imported_vehicle_journeys - + spreadsheet = open_spreadsheet(file) - + vehicle_journeys = [] - + first_column = spreadsheet.column(1) - + # fixed rows (first = 1) number_row = 2 published_journey_name_row = 3 @@ -111,7 +111,7 @@ class VehicleJourneyImport # rows in column (first = 0) first_stop_row_index = 8 - + stop_point_ids = first_column[first_stop_row_index..spreadsheet.last_row].map(&:to_i) # blank lines at end of file will produce id = 0 ; ignore them last_stop_row_index = stop_point_ids.length + 7 @@ -119,50 +119,50 @@ class VehicleJourneyImport stop_point_ids = stop_point_ids[0..-2] last_stop_row_index -= 1 end - + unless route.stop_points.collect(&:id) == stop_point_ids errors.add :base, I18n.t("vehicle_journey_imports.errors.not_same_stop_points", :route => route.id) raise - end - + end + (3..spreadsheet.last_column).each do |i| vehicle_journey_id = spreadsheet.column(i)[0] hours_by_stop_point_ids = Hash[[stop_point_ids, spreadsheet.column(i)[first_stop_row_index..last_stop_row_index]].transpose] - + journey_pattern = find_journey_pattern_schedule(i,hours_by_stop_point_ids) - + vehicle_journey = route.vehicle_journeys.where(:id => vehicle_journey_id, :route_id => route.id).first_or_initialize if journey_pattern.nil? - if vehicle_journey.id.present? + if vehicle_journey.id.present? self.deleted_vehicle_journey_count += 1 vehicle_journey.delete end next end - if vehicle_journey.id.present? + if vehicle_journey.id.present? self.updated_vehicle_journey_count += 1 else self.created_vehicle_journey_count += 1 end - + # number vehicle_journey.number = as_integer(spreadsheet.row(number_row)[i-1]) - + # published_name vehicle_journey.published_journey_name = spreadsheet.row(published_journey_name_row)[i-1] - + # flexible_service vehicle_journey.flexible_service = as_boolean(spreadsheet.row(flexible_service_row)[i-1]) - + # mobility vehicle_journey.mobility_restricted_suitability = as_boolean(spreadsheet.row(mobility_row)[i-1]) - + # time_tables update_time_tables(vehicle_journey,spreadsheet.row(time_tables_row)[i-1]) - + update_footnotes(vehicle_journey,spreadsheet.row(footnotes_row)[i-1]) - + # journey_pattern vehicle_journey.journey_pattern = journey_pattern vehicle_journey.vehicle_journey_at_stops.clear @@ -171,7 +171,7 @@ class VehicleJourneyImport hours_by_stop_point_ids.each_pair do |key, value| line += 1 if value.present? # Create a vehicle journey at stop when time is present - begin + begin # force UTC to ignore timezone effects main_time = Time.parse(value+" UTC") if main_time.present? @@ -182,14 +182,14 @@ class VehicleJourneyImport errors.add :base, I18n.t("vehicle_journey_imports.errors.invalid_vehicle_journey_at_stop", :column => i, :line => line, :time => value) raise exception end - end + end end vehicle_journeys << vehicle_journey end - + vehicle_journeys end - + def open_spreadsheet(file) case File.extname(file.original_filename) when '.csv' then Roo::CSV.new(file.path, csv_options: {col_sep: ";"}) @@ -199,5 +199,5 @@ class VehicleJourneyImport raise "Unknown file type: #{file.original_filename}" end end - + end diff --git a/app/models/workbench.rb b/app/models/workbench.rb index c37cba858..30692e625 100644 --- a/app/models/workbench.rb +++ b/app/models/workbench.rb @@ -10,6 +10,7 @@ class Workbench < ActiveRecord::Base has_many :stop_areas, through: :stop_area_referential has_many :imports has_many :workbench_imports + validates :name, presence: true validates :organisation, presence: true diff --git a/app/views/calendars/_filters.html.slim b/app/views/calendars/_filters.html.slim index 4c30f69dc..b5283c1e8 100644 --- a/app/views/calendars/_filters.html.slim +++ b/app/views/calendars/_filters.html.slim @@ -19,4 +19,4 @@ .actions = link_to 'Effacer', calendars_path, class: 'btn btn-link' - = f.submit 'Filtrer', id: 'filter_btn', class: 'btn btn-default' + = f.submit 'Filtrer', id: 'calendar_filter_btn', class: 'btn btn-default' diff --git a/app/views/calendars/index.html.slim b/app/views/calendars/index.html.slim index 1e38786b9..56232b0af 100644 --- a/app/views/calendars/index.html.slim +++ b/app/views/calendars/index.html.slim @@ -13,7 +13,7 @@ .row .col-lg-12 = render 'filters' - + - if @calendars.any? .row .col-lg-12 @@ -39,8 +39,10 @@ cls: 'table has-filter' = new_pagination @calendars, 'pull-right' - + - unless @calendars.any? .row.mt-xs .col-lg-12 = replacement_msg t('calendars.search_no_results') + += javascript_include_tag 'filters/calendar.js' diff --git a/app/views/compliance_check_tasks/new.html.erb b/app/views/compliance_check_tasks/new.html.erb deleted file mode 100644 index 3f43a7dd7..000000000 --- a/app/views/compliance_check_tasks/new.html.erb +++ /dev/null @@ -1,39 +0,0 @@ -<%= title_tag t(".title") %> - -<%= semantic_form_for [@referential, @compliance_check_task], :url => referential_compliance_check_tasks_path(@referential) do |form| %> - <%= form.inputs do %> - <%= form.input :user_name, :as => :hidden, :input_html => { :value => current_user.name } %> <%= form.input :user_id, :as => :hidden, :input_html => { :value => current_user.id } %> - <%= form.input :referential_id, :as => :hidden, :input_html => { :value => @referential.id } %> - <%= form.input :name %> - <%= form.input :rule_parameter_set_id, :as => :select, - :collection => @referential.organisation.rule_parameter_sets.map { |rps| [ rps.name, rps.id ] }, :include_blank => false %> - <%= form.input :references_type, :as => :select, :include_blank => t(".all") %> - <% @compliance_check_task.class.references_types.each do |type| %> - <%= form.input :reference_ids, :as => :reference_ids, :json => references_referential_compliance_check_tasks_path(@referential, :format => :json) + "?filter=#{type}", :hint_text => t('search_hint'), :no_result_text => t('no_result_text'),:searching_text => t('searching_term'), :id => "#{type}_reference_ids", :input_html => { :id => "#{type}_reference_ids" }, :wrapper_html => { :style => "display:none;", :id => "#{type}", :"data-type" => "#{type}" } %> - <% end %> - <% end %> - - <%= form.actions do %> - <%= form.action :submit, :as => :button , :label => t( 'formtastic.validate' ) %> - <%= form.action :cancel, :as => :link %> - <% end %> -<% end %> - -<!-- = title_tag t('.title') - -= semantic_form_for [@referential, @compliance_check_task], :url => referential_compliance_check_tasks_path(@referential) do |form| - = form.inputs do - = form.input :user_name, :as => :hidden, :input_html => { :value => current_user.name } - = form.input :user_id, :as => :hidden, :input_html => { :value => current_user.id } - = form.input :referential_id, :as => :hidden, :input_html => { :value => @referential.id } - = form.input :name - = form.input :rule_parameter_set_id, :as => :select, - :collection => @referential.organisation.rule_parameter_sets.map { |rps| [ rps.name, rps.id ] }, :include_blank => false - = form.input :references_type, :as => :select, :include_blank => t(".all") - - @compliance_check_task.class.references_types.each do |type| - - = form.input :reference_ids, as: :reference_ids, json: references_referential_compliance_check_tasks_path(@referential, format: :json) + "?filter=#{type}", hint_text: t('search_hint'), no_result_text: t('no_result_text'), searching_text: t('searching_term'), id: "#{type}_reference_ids", input_html: { :id => "#{type}_reference_ids" }, wrapper_html: { :style => "display:none;", :id => "#{type}", :"data-type" => "#{type}" } - - = form.actions do - = form.action :submit, as: :button, label: t('formtastic.validate') - = form.action :cancel, as: :link --> diff --git a/app/views/compliance_check_tasks/new.js.coffee b/app/views/compliance_check_tasks/new.js.coffee deleted file mode 100644 index ba62f53b2..000000000 --- a/app/views/compliance_check_tasks/new.js.coffee +++ /dev/null @@ -1,7 +0,0 @@ -jQuery -> - <% ComplianceCheckTask.references_types.map { |type| type_ids_model_references_type( ComplianceCheckTask, type)}.each do |rt| %> - $("textarea.<%= rt.input_class %>").tokenInput('<%= references_referential_compliance_check_tasks_path(@referential, :type => rt.relation_name, :format => :json) %>', { prePopulate: $('#').data('pre'), minChars: 1, hintText: '<%= t('search_hint') %>', noResultsText: '<%= t('no_result_text') %>', searchingText: '<%= t('searching_term') %>'}); - <% end %> - - # - ComplianceCheckTask.references_types.map { |type| type_ids_model_references_type( ComplianceCheckTask, type)}.each do |rt| - # $("textarea.#{rt.input_class}").tokenInput("#{references_referential_compliance_check_tasks_path(@referential, :type => rt.relation_name, format: :json)}", { prePopulate: $('#').data('pre'), minChars: 1, hintText: "#{t('search_hint')}", noResultsText: "#{t('no_result_text')}", searchingText: "#{t('searching_term')}"}); diff --git a/app/views/compliance_checks/_compliance_check.html.slim b/app/views/compliance_checks/_compliance_check.html.slim deleted file mode 100644 index 383a7ea82..000000000 --- a/app/views/compliance_checks/_compliance_check.html.slim +++ /dev/null @@ -1,17 +0,0 @@ -#index_item.panel.panel-default - .panel-heading - .panel-title.clearfix - span.pull-right - = link_to referential_compliance_check_path(@referential, compliance_check.id), :method => :delete, :data => {:confirm => t('compliance_checks.actions.destroy_confirm')}, class: 'btn btn-danger btn-sm' do - span.fa.fa-trash-o - h5 - = link_to referential_compliance_check_path(@referential, compliance_check.id), class: 'preview', title: "#{ComplianceCheck.model_name.human.capitalize} #{compliance_check.name}" do - = job_status_title(compliance_check) - - .panel-body - p - = link_to( font_awesome_classic_tag("fa-external-link") + t("compliance_checks.actions.report"), report_referential_compliance_check_path(@referential, compliance_check.id)) if compliance_check.report? - .panel-footer - .history - = l compliance_check.created_at, :format => "%d/%m/%Y %H:%M" - = " | #{compliance_check.user_name}" diff --git a/app/views/compliance_checks/_compliance_check_results.html.slim b/app/views/compliance_checks/_compliance_check_results.html.slim deleted file mode 100644 index 8e86c174e..000000000 --- a/app/views/compliance_checks/_compliance_check_results.html.slim +++ /dev/null @@ -1,92 +0,0 @@ -p - form.form-inline - .form-group - label = t('shared.ie_report.search') - input#filter.form-control type="text" - - .form-group - label = ComplianceCheckResult.human_attribute_name(:severity) - select.filter-severity.form-control - option - option value="severity-error" - = t('compliance_check_result.severities.error') - option value="severity-warning" - = t('compliance_check_result.severities.warning') - - .form-group - label = ComplianceCheckResult.human_attribute_name(:status) - select.filter-status.form-control - option - option value="status-ok" - = t('compliance_check_result.statuses.ok') - option value="status-nok" - = t('compliance_check_result.statuses.nok') - option value="status-uncheck" - = t('compliance_check_result.statuses.uncheck') - - -table.table.table-hover.toggle-circle.toggle-medium data-filter="#filter" data-page-size="20" data-title-nok="#{t('compliance_check_result.statuses.nok')}" data-title-uncheck="#{t('compliance_check_result.statuses.uncheck')}" data-title-ok="#{t('compliance_check_result.statuses.ok')}" - thead - tr - th data-sort-ignore="true" - = ComplianceCheckResult.human_attribute_name(:status) - th.col-md-1 data-sort-ignore="true" - = ComplianceCheckResult.human_attribute_name(:severity) - th.col-md-3 - = ComplianceCheckResult.human_attribute_name(:rule_code) - th.col-md-2 - = t('compliance_check_results.errors') - th.col-md-6 data-toggle="true" data-sort-ignore="true" - = ComplianceCheckResult.human_attribute_name(:detail) - th data-hide="all" data-sort-ignore="true" - - tbody - - if compliance_check_validation_report - - compliance_check_validation_report.tests.each_with_index do |test, index| - tr class="#{test.result}_#{test.severity}" - td data-value="status-#{test.result}" - = status_icon( test.result, test.severity ) - td data-value="severity-#{test.severity}" - = t("compliance_check_result.severities.#{test.severity}_txt") - td data-value="#{test.result}_#{test.severity}" - = link_to test.test_id, test_definition(test.test_id), title: ComplianceCheckResult.human_attribute_name(test.test_id), target: "compliance_check" - td - = "#{test.error_count || 0} #{ComplianceCheckResult.human_attribute_name(:violation_count)}" if test.errors.present? - td - = truncate(t("activemodel.attributes.compliance_check_result.#{test.test_id}"), length: 50) - td - p - b - = t("activemodel.attributes.compliance_check_result.#{test.test_id}") - - - if test.errors.present? - - test.errors.first(10).each do |error| - dl.inline - dt - - if error["source"].present? - - if error[:source].object_path.present? - - if error[:source].label.present? - = link_to error[:source].label, object_url(@referential.id, error), target: :_blank - - else - = link_to "#{error[:source].object_path.type} (#{error[:source].object_path.id})", object_url(@referential.id, error), target: :_blank - - - if error[:source].file.present? - = error[:source].objectid if error[:source].objectid.present? - - dd = t("compliance_check_result.details.detail_#{error[:error_id]}", object_labels_hash(error)) - - - if error[:source].file.present? - p.file_error - = error[:source].file.filename - = ", li: #{error[:source].file.line_number}" if error[:source].file.line_number.present? - = ", co: #{error[:source].file.column_number}" if error[:source].file.column_number.present? - - - else - tr - td colspan="6" - = t('compliance_check_results.in_progress') - - tfoot.hide-if-no-paging - tr - td colspan="5" - ul.pagination.pagination-centered diff --git a/app/views/compliance_checks/_compliance_checks.html.slim b/app/views/compliance_checks/_compliance_checks.html.slim deleted file mode 100644 index 48db9ae94..000000000 --- a/app/views/compliance_checks/_compliance_checks.html.slim +++ /dev/null @@ -1,9 +0,0 @@ -.page_info - span.search = t('will_paginate.page_entries_info.search') - = page_entries_info @compliance_checks - -.compliance_checks.paginated_content - = paginated_content @compliance_checks, "compliance_checks/compliance_check" - -.pagination - = will_paginate @compliance_checks, :container => false, renderer: RemoteBootstrapPaginationLinkRenderer
\ No newline at end of file diff --git a/app/views/compliance_checks/detailed_errors_index.csv.slim b/app/views/compliance_checks/detailed_errors_index.csv.slim deleted file mode 100644 index 7fe20e282..000000000 --- a/app/views/compliance_checks/detailed_errors_index.csv.slim +++ /dev/null @@ -1,37 +0,0 @@ -= I18n.t('activemodel.attributes.compliance_check_result.severity'); -= I18n.t('activemodel.attributes.compliance_check_result.rule_code'); -= I18n.t('activemodel.attributes.compliance_check_result.object'); -= I18n.t('activemodel.attributes.compliance_check_result.resource'); -= I18n.t('activemodel.attributes.compliance_check_result.title'); -= I18n.t('activemodel.attributes.compliance_check_result.detail') - -- @compliance_check.compliance_check_validation_report.tests.each do |r| - - if r.errors.present? - - r.errors.first(10).each do |error| - - case r.severity - - when "warning" - = I18n.t('compliance_check_result.severities.warning_txt') - - when "error" - = I18n.t('compliance_check_result.severities.error_txt') - - = r.test_id; - - - if error["source"].present? - = error["source"]["objectid"] if error["source"]["objectid"].present? - - - if error["source"]["object_path"].present? - = object_url(@referential_id, error) - - elsif error["source"]["file"].present? - = File.basename(error["source"]["file"]["filename"]) + " - " - = I18n.t("compliance_check_results.index.column") + ":" - = error["source"]["file"]["column_number"] + "," - = I18n.t("compliance_check_results.index.line") + ":" - = error["source"]["file"]["line_number"] - - - else - = I18n.t("activemodel.attributes.compliance_check_result.#{r.test_id}"); - = I18n.t("compliance_check_result.details.detail_#{error['error_id']}", object_labels_hash(error) ) - = "\n" - -/ <%= I18n.t("activemodel.attributes.compliance_check_result.severity") %>;<%= I18n.t("activemodel.attributes.compliance_check_result.rule_code") %>;<%= I18n.t("activemodel.attributes.compliance_check_result.object") %>;<%= I18n.t("activemodel.attributes.compliance_check_result.resource") %>;<%= I18n.t("activemodel.attributes.compliance_check_result.title") %>;<%= I18n.t("activemodel.attributes.compliance_check_result.detail") %> -/ <% @compliance_check.compliance_check_validation_report.tests.each do |r| %><% if r.errors.present? %><% r.errors.first(10).each do |error| %><% case r.severity %><% when "warning" %><%= I18n.t "compliance_check_result.severities.warning_txt" %><% when "error" %><%= I18n.t "compliance_check_result.severities.error_txt" %><% end %>;<%= r.test_id %>;<% if error["source"].present? %><%= error["source"]["objectid"] if error["source"]["objectid"].present? %>;<% if error["source"]["object_path"].present? %><%= object_url(@referential_id, error) %><% elsif error["source"]["file"].present? %><%= File.basename(error["source"]["file"]["filename"]) +" - " %><%= I18n.t "compliance_check_results.index.column" %>:<%= error["source"]["file"]["column_number"] %>,<%= I18n.t "compliance_check_results.index.line" %>:<%= error["source"]["file"]["line_number"] %><% end %>;<% else %>;;<% end %><%= I18n.t("activemodel.attributes.compliance_check_result."+r.test_id) %>;<%= I18n.t("compliance_check_result.details.detail_#{error['error_id']}", object_labels_hash(error) )%><%= "\n" %><% end %><% end %><% end %> diff --git a/app/views/compliance_checks/index.html.slim b/app/views/compliance_checks/index.html.slim deleted file mode 100644 index 392c46663..000000000 --- a/app/views/compliance_checks/index.html.slim +++ /dev/null @@ -1,14 +0,0 @@ -= title_tag t('.title') - -.warning - = t('.warning') - -#compliance_checks - = render 'compliance_checks' - -- content_for :sidebar do - ul.actions - li - = link_to t('compliance_check_tasks.actions.new'), new_referential_compliance_check_task_path(), class: 'add' - li - = link_to t('rule_parameter_sets.actions.index'), organisation_rule_parameter_sets_path, class: 'link'
\ No newline at end of file diff --git a/app/views/compliance_checks/index.js.slim b/app/views/compliance_checks/index.js.slim deleted file mode 100644 index cfd8dc40d..000000000 --- a/app/views/compliance_checks/index.js.slim +++ /dev/null @@ -1 +0,0 @@ -| $('#compliance_checks').html("#{escape_javascript(render('compliance_checks'))}");
\ No newline at end of file diff --git a/app/views/compliance_checks/report.html.slim b/app/views/compliance_checks/report.html.slim deleted file mode 100644 index be2bb8adc..000000000 --- a/app/views/compliance_checks/report.html.slim +++ /dev/null @@ -1,41 +0,0 @@ -= title_tag job_status_title(@compliance_check) - -.compliance_check_show - .links - - if @compliance_check.class == Import - = link_to(font_awesome_classic_tag('fa-eye') + t("compliance_checks.report.action_report"), referential_import_path(@referential, @compliance_check.id)) - = link_to font_awesome_classic_tag("fa-external-link") + t("compliance_checks.rule_parameter_set"), rule_parameter_set_referential_import_path(@referential, @compliance_check.id) if @compliance_check.rule_parameter_set? - - else - = link_to(font_awesome_classic_tag('fa-eye') + t("compliance_checks.report.action_report"), referential_compliance_check_path(@referential, @compliance_check.id)) - = link_to font_awesome_classic_tag("fa-external-link") + t("compliance_checks.rule_parameter_set"), rule_parameter_set_referential_compliance_check_path(@referential, @compliance_check.id) if @compliance_check.rule_parameter_set? - - .btn-group.pull-right - button.btn.btn-default.dropdown-toggle type="button" data-toggle="dropdown" aria-expanded="false" - = t('compliance_checks.show.export') - span.caret - - ul.dropdown-menu role="menu" - li - - if @compliance_check.class == Import - = link_to t('compliance_checks.show.export_csv'), export_referential_import_path(@referential, @compliance_check.id) - - else - = link_to t("compliance_checks.show.export_csv"), export_referential_compliance_check_path(@referential, @compliance_check.id) - - .report data-refresh-interval="#{job_refresh_interval(@compliance_check)}" - = render partial: 'compliance_checks/compliance_check_results', locals: { compliance_check_validation_report: @compliance_check.compliance_check_validation_report } - -- content_for :sidebar do - - if @compliance_check.compliance_check_validation_report && @compliance_check.compliance_check_validation_report.nok_error.blank? - .row - = font_awesome_classic_tag('fa-thumbs-up fa-5x col-md-3') - p#validation_success.col-md-7 - = t('.validation_success') - - ul.actions - li - - if @compliance_check.class != Import - = link_to t('compliance_checks.actions.destroy'), referential_compliance_check_path(@referential, @compliance_check.id), method: :delete, :data => {:confirm => t('compliance_checks.actions.destroy_confirm')}, class: 'remove' - - = history_tag(@compliance_check) - #error.graph - #warning.graph
\ No newline at end of file diff --git a/app/views/compliance_checks/show.html.slim b/app/views/compliance_checks/show.html.slim deleted file mode 100644 index 8c6900981..000000000 --- a/app/views/compliance_checks/show.html.slim +++ /dev/null @@ -1,22 +0,0 @@ -.test - = title_tag job_status_title(@compliance_check) - -- if @compliance_check.report.failure_code? - .alert.alert-danger - = t("iev.failure.#{@compliance_check.report.failure_code}") - -.progress_bars - = progress_bar_tag(@compliance_check) - -.compliance_check.show - .links - = link_to font_awesome_classic_tag("fa-external-link") + t("compliance_checks.actions.report"), report_referential_compliance_check_path(@referential, @compliance_check.id) if @compliance_check.compliance_check_validation_report? - - = render partial: "shared/ie_report", locals: { job: @compliance_check, type: :validation, line_items: @line_items } - -- content_for :sidebar do - ul.actions - li - = link_to t('compliance_checks.actions.destroy'), referential_compliance_check_path(@referential, @compliance_check.id), method: :delete, data: {confirm: t('compliance_checks.actions.destroy_confirm')}, class: 'remove' - - = history_tag(@compliance_check)
\ No newline at end of file diff --git a/app/views/compliance_checks/summary_errors_index.csv.slim b/app/views/compliance_checks/summary_errors_index.csv.slim deleted file mode 100644 index 8c88d5cf6..000000000 --- a/app/views/compliance_checks/summary_errors_index.csv.slim +++ /dev/null @@ -1,34 +0,0 @@ -= I18n.t("activemodel.attributes.compliance_check_result.severity"); -= I18n.t("activemodel.attributes.compliance_check_result.status"); -= I18n.t("activemodel.attributes.compliance_check_result.rule_code"); -= I18n.t("activemodel.attributes.compliance_check_result.title"); -= I18n.t("activemodel.attributes.compliance_check_result.url"); -= I18n.t("activemodel.attributes.compliance_check_result.violation_count_txt"); -= I18n.t("activemodel.attributes.compliance_check_result.objects") - -- @compliance_check.compliance_check_validation_report.tests.each do |r| - - case r.severity - - when "warning" - = I18n.t("compliance_check_result.severities.warning_txt") - - when "error" - = I18n.t("compliance_check_result.severities.error_txt") - - = r.result; - = r.test_id; - - = I18n.t("activemodel.attributes.compliance_check_result.#{r.test_id}"); - = Rails.application.config.validation_spec + I18n.locale.to_s + "/" + r.test_id + ".html"; - - = r.error_count - - - if r.error_count > 0 - - if r.errors.present? - - r.errors.first(10).each do |error| - - if error["source"] - = error["source"]["objectid"] + " " - - else - = " " - -/ <%= I18n.t("activemodel.attributes.compliance_check_result.severity") %>;<%= I18n.t("activemodel.attributes.compliance_check_result.status") %>;<%= I18n.t("activemodel.attributes.compliance_check_result.rule_code") %>;<%= I18n.t("activemodel.attributes.compliance_check_result.title") %>;<%= I18n.t("activemodel.attributes.compliance_check_result.url") %>;<%= I18n.t("activemodel.attributes.compliance_check_result.violation_count_txt") %>;<%= I18n.t("activemodel.attributes.compliance_check_result.objects") %> -/ <% @compliance_check.compliance_check_validation_report.tests.each do |r| %><% case r.severity %><% when "warning" %><%= I18n.t "compliance_check_result.severities.warning_txt" %><% when "error" %><%= I18n.t "compliance_check_result.severities.error_txt" %><% end %>;<%= r.result %>;<%= r.test_id %>;<%= I18n.t("activemodel.attributes.compliance_check_result."+r.test_id) %>;<%= Rails.application.config.validation_spec + I18n.locale.to_s + "/" + r.test_id + ".html" %>;<%= r.error_count %><% if r.error_count > 0 %><% if r.errors.present? %>;<% r.errors.first(10).each do |error| %><% if error["source"] %><%= error["source"]["objectid"] + " " %><% else %><%= " " %><% end %><% end %><% end %><% end %> -/ <% end %> diff --git a/app/views/import_resources/index.html.slim b/app/views/import_resources/index.html.slim index 17e5532ae..849ed6d8d 100644 --- a/app/views/import_resources/index.html.slim +++ b/app/views/import_resources/index.html.slim @@ -6,50 +6,53 @@ '' / PageContent -.page_content +.page_content.import_messages .container-fluid - - if @import_resources.any? - .row - .col-lg-12 - = definition_list t('metadatas'),{ 'Bilan d\'import' => link_to(@import.parent.name, workbench_import_path(@import.parent.workbench, @import.parent) ), - 'Jeu de données associé' => ( @import.referential.present? ? link_to(@import.referential.name, referential_path(@import.referential)) : '-' ) } + .row + .col-lg-12 + = definition_list t('metadatas'),{ 'Bilan d\'import' => link_to(@import.parent.name, workbench_import_path(@import.parent.workbench, @import.parent) ), + 'Jeu de données associé' => ( @import.referential.present? ? link_to(@import.referential.name, referential_path(@import.referential)) : '-' ) } - - if @import_resources.any? .row .col-lg-12 h1 - span = import_status(@import.status) + span.status_icon = import_status(@import.status) span = t('.table_state', lines_imported: @import_resources.lines_imported , lines_in_zipfile: @import_resources.lines_in_zipfile ) - .col-lg-12 - h2 = t('.table_title') - .col-lg-12 - = t('.table_explanation') - .col-lg-12 - = table_builder_2 @import_resources.where(resource_type: :file), - [ \ - TableBuilderHelper::Column.new( \ - key: :name, \ - attribute: 'name', \ - sortable: false, \ - ), \ - TableBuilderHelper::Column.new( \ - key: :status, \ - attribute: Proc.new { |n| import_resource_status(n.status) }, \ - sortable: false, \ - ), \ - TableBuilderHelper::Column.new( \ - name: 'Résultat des tests' , \ - attribute: Proc.new { |n| I18n.t('import_resources.index.metrics', n.metrics.deep_symbolize_keys) }, \ - sortable: false, \ - ), \ - TableBuilderHelper::Column.new( \ - name: 'Téléchargement' , \ - attribute: Proc.new { |n| '<i class="fa fa-download" aria-hidden="true"></i>'.html_safe }, \ - sortable: false, \ - link_to: lambda do |import_resource| \ - workbench_import_import_resource_import_messages_path(import_resource.import.workbench, import_resource.import, import_resource, format: 'csv' ) \ - end \ - ), \ - ], - links: [], - cls: 'table has-search' + - if @import_resources.present? + .col-lg-12 + h2 = t('.table_title') + .col-lg-12 + = t('.table_explanation') + .col-lg-12 + = table_builder_2 @import_resources.where(resource_type: :file), + [ \ + TableBuilderHelper::Column.new( \ + key: :name, \ + attribute: 'name', \ + sortable: false, \ + ), \ + TableBuilderHelper::Column.new( \ + key: :status, \ + attribute: Proc.new { |n| import_resource_status(n.status) }, \ + sortable: false, \ + ), \ + TableBuilderHelper::Column.new( \ + name: 'Résultat des tests' , \ + attribute: Proc.new { |n| I18n.t('import_resources.index.metrics', n.metrics.deep_symbolize_keys) }, \ + sortable: false, \ + ), \ + TableBuilderHelper::Column.new( \ + name: 'Téléchargement' , \ + attribute: Proc.new { |n| '<i class="fa fa-download" aria-hidden="true"></i>'.html_safe }, \ + sortable: false, \ + link_to: lambda do |import_resource| \ + workbench_import_import_resource_import_messages_path(import_resource.import.workbench, import_resource.import, import_resource, format: 'csv' ) \ + end \ + ), \ + ], + links: [], + cls: 'table has-search' + - else + .col-lg-12 + - @import.messages.each do |message| + = I18n.t("import_messages.compliance_check_messages.#{message.message_key}") diff --git a/app/views/imports/_filters.html.slim b/app/views/imports/_filters.html.slim index 99fcb0232..a216019b6 100644 --- a/app/views/imports/_filters.html.slim +++ b/app/views/imports/_filters.html.slim @@ -9,13 +9,13 @@ .ffg-row .form-group.togglable = f.label Import.human_attribute_name(:status), required: false, class: 'control-label' - = f.input :status_eq_any, collection: @imports.map(&:status).uniq.compact, as: :check_boxes, label: false, label_method: lambda{|l| ("<span>" + l + "</span>").html_safe}, required: false, wrapper_html: { class: 'checkbox_list'} + = f.input :status_eq_any, collection: @imports.map(&:status).uniq.compact, as: :check_boxes, label: false, label_method: lambda{|l| ("<span>" + import_status(l) + "</span>").html_safe}, required: false, wrapper_html: { class: 'checkbox_list'}, input_html: { checked: true} .form-group.togglable = f.label Import.human_attribute_name(:started_at), required: false, class: 'control-label' .filter_menu - = f.input :started_at_eq, as: :date, label: false, wrapper_html: { class: 'date smart_date filter_menu-item' }, include_blank: true + = f.input :started_on_date, as: :date, label: false, wrapper_html: { class: 'date smart_date filter_menu-item' }, include_blank: true .actions = link_to t('actions.erase'), workbench_imports_path(@workbench), class: 'btn btn-link' - = f.submit t('actions.filter'), class: 'btn btn-default' + = f.submit t('actions.filter'), id: 'import_filter_btn', class: 'btn btn-default' diff --git a/app/views/imports/index.html.slim b/app/views/imports/index.html.slim index 37ae3b3c1..2203d3584 100644 --- a/app/views/imports/index.html.slim +++ b/app/views/imports/index.html.slim @@ -47,3 +47,5 @@ .row.mt-xs .col-lg-12 = replacement_msg t('imports.search_no_results') + += javascript_include_tag 'filters/import.js' diff --git a/app/views/time_tables/index.html.slim b/app/views/time_tables/index.html.slim index 1ea5256aa..a1b9c4e09 100644 --- a/app/views/time_tables/index.html.slim +++ b/app/views/time_tables/index.html.slim @@ -68,3 +68,5 @@ = javascript_tag do | window.I18n = #{(I18n.backend.send(:translations).to_json).html_safe}; + += javascript_include_tag 'filters/timetable.js' diff --git a/app/views/workbenches/index.html.slim b/app/views/workbenches/index.html.slim index d57f579ff..eece51bca 100644 --- a/app/views/workbenches/index.html.slim +++ b/app/views/workbenches/index.html.slim @@ -41,7 +41,7 @@ - if @referentials.any? .list-group - @referentials.each_with_index do |referential, i| - = link_to referential.name, referential_path(referential), class: 'list-group-item' if i < 6 + = link_to referential.name, referential_path(referential, workbench_id: referential.workbench_id), class: 'list-group-item' if i < 6 - else .panel-body diff --git a/app/views/workbenches/show.html.slim b/app/views/workbenches/show.html.slim index bb54f07cb..50c719d12 100644 --- a/app/views/workbenches/show.html.slim +++ b/app/views/workbenches/show.html.slim @@ -29,7 +29,7 @@ key: :name, \ attribute: 'name', \ link_to: lambda do |referential| \ - referential_path(referential) \ + referential_path(referential, workbench_id: referential.workbench_id) \ end \ ), \ TableBuilderHelper::Column.new( \ @@ -77,3 +77,5 @@ = javascript_tag do | window.I18n = #{(I18n.backend.send(:translations).to_json).html_safe}; + += javascript_include_tag 'filters/workbench.js' diff --git a/app/workers/workbench_import_worker.rb b/app/workers/workbench_import_worker.rb index 706c3fc63..994493944 100644 --- a/app/workers/workbench_import_worker.rb +++ b/app/workers/workbench_import_worker.rb @@ -9,7 +9,7 @@ class WorkbenchImportWorker def perform(import_id) @workbench_import = WorkbenchImport.find(import_id) @response = nil - @workbench_import.update_attributes(status: 'running', started_at: Time.now) + @workbench_import.update(status: 'running', started_at: Time.now) downloaded = download zip_service = ZipService.new(downloaded) upload zip_service @@ -99,11 +99,6 @@ class WorkbenchImportWorker end def params file, name - if dest = ENV["DEBUG_TEMPFILE"] - require 'pry' - binding.pry - %x{unzip -oqq #{file.path} -d #{dest}} - end { netex_import: { parent_id: @workbench_import.id, parent_type: @workbench_import.class.name, |
