diff options
| author | Teddy Wing | 2017-07-20 12:21:35 +0200 |
|---|---|---|
| committer | Teddy Wing | 2017-07-20 12:21:35 +0200 |
| commit | 9b3778f8d2afe93486ea8e49ec7730cb1ec2be1e (patch) | |
| tree | f00016286e5af968c0b6efa3d7969cfa1dc8bdba /app | |
| parent | 42a51eef7d242583726c4942583b4ab567c4d293 (diff) | |
| parent | 4fd4fa0fd24c9cd86161358f2e36cff64f3712d7 (diff) | |
| download | chouette-core-9b3778f8d2afe93486ea8e49ec7730cb1ec2be1e.tar.bz2 | |
Merge remote-tracking branch 'origin/master' into 1726-WorkbenchImport-for-multi-Netex-import
Diffstat (limited to 'app')
25 files changed, 210 insertions, 121 deletions
diff --git a/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/select2s/CompanySelect2.js b/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/select2s/CompanySelect2.js index a6b8dcfa1..d277be003 100644 --- a/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/select2s/CompanySelect2.js +++ b/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/select2s/CompanySelect2.js @@ -51,7 +51,7 @@ class BSelect4 extends React.Component{ }, cache: true }, - minimumInputLength: 3, + minimumInputLength: 1, templateResult: formatRepo }} /> diff --git a/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/select2s/MissionSelect2.js b/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/select2s/MissionSelect2.js index b3df767ab..c04a1d642 100644 --- a/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/select2s/MissionSelect2.js +++ b/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/select2s/MissionSelect2.js @@ -43,14 +43,14 @@ class BSelect4 extends React.Component{ item => _.assign( {}, item, - { text: '<small><em>Nom: </em></small>' + item.published_name + '<br/><small><em>Code: </em></small>' + item.registration_number + '<br/><small><em>ID: </em></small>' + _.last(_.split(item.object_id, ':')) } + { text: "<strong>" + item.published_name + _.last(_.split(item.object_id, ':')) + "</strong><br/><small>" + item.registration_number + "</small>" } ) ) }; }, cache: true }, - minimumInputLength: 0, + minimumInputLength: 1, escapeMarkup: function (markup) { return markup; }, templateResult: formatRepo }} diff --git a/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/select2s/TimetableSelect2.js b/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/select2s/TimetableSelect2.js index b236e7d94..3e81290f5 100644 --- a/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/select2s/TimetableSelect2.js +++ b/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/select2s/TimetableSelect2.js @@ -2,6 +2,7 @@ var _ = require('lodash') var React = require('react') var PropTypes = require('react').PropTypes var Select2 = require('react-select2') +var actions = require('../../../actions') // get JSON full path var origin = window.location.origin @@ -37,20 +38,20 @@ class BSelect4 extends React.Component{ }; }, processResults: function(data, params) { - return { results: data.map( item => _.assign( {}, item, - {text: item.comment} + {text: '<strong>' + (item.color ? "<span class='fa fa-circle' style='color:" + item.color + "'></span> " : '') + item.comment + ' - ' + item.short_id + '</strong><br/><small>' + item.day_types.match(/[A-Z]?[a-z]+/g).join(', ') + '</small>'} ) ) }; }, cache: true }, - minimumInputLength: 3, + minimumInputLength: 1, + escapeMarkup: function (markup) { return markup; }, templateResult: formatRepo }} /> diff --git a/app/assets/stylesheets/_layout.sass b/app/assets/stylesheets/_layout.sass index c19d9b054..b6b91b2a5 100644 --- a/app/assets/stylesheets/_layout.sass +++ b/app/assets/stylesheets/_layout.sass @@ -28,3 +28,13 @@ body // width: 75% border-bottom: 1px solid rgba($blue, 0.5) margin: 30px auto 45px auto + +.content_header + font-size: 2.2rem + font-weight: normal + margin: 40px 0 + padding: 0px 15px 9px 15px + border-bottom: 1px solid #eee + + &:first-child + margin-top: 0 diff --git a/app/assets/stylesheets/components/_panels.sass b/app/assets/stylesheets/components/_panels.sass index ff384faf9..e9f615081 100644 --- a/app/assets/stylesheets/components/_panels.sass +++ b/app/assets/stylesheets/components/_panels.sass @@ -17,9 +17,31 @@ border-bottom: 2px solid $darkgrey padding: 5px 15px + .badge + color: #fff + background-color: $grey + > h3, > h4 margin: 0 + > .panel-title.with_actions + display: table + width: 100% + + .badge + vertical-align: top + + a + text-decoration: none + color: $blue + + &:hover, &:focus + color: $darkblue + + > div + display: table-cell + vertical-align: middle + .panel-footer padding: 5px 15px background-color: transparent diff --git a/app/assets/stylesheets/components/_select2.sass b/app/assets/stylesheets/components/_select2.sass index 960e8b10b..332af16cd 100644 --- a/app/assets/stylesheets/components/_select2.sass +++ b/app/assets/stylesheets/components/_select2.sass @@ -7,6 +7,10 @@ // .select2-results__message, .loading-results // display: none +.select2-container, .select2-container--bootstrap + .select2-selection--single .select2-selection__rendered + height: 100% + .select2-selection__placeholder color: rgba($grey, 0.65) font-style: italic diff --git a/app/assets/stylesheets/old_application.sass.erb b/app/assets/stylesheets/old_application.sass.erb deleted file mode 100644 index 3443a035d..000000000 --- a/app/assets/stylesheets/old_application.sass.erb +++ /dev/null @@ -1,62 +0,0 @@ -// First import journal variables -$brand-primary: <%= ChouetteIhm::Application.config.company_theme %> -$navbar-default-bg: $brand-primary -$navbar-default-link-color: white -$body-bg: #eee - -// Then bootstrap itself -@import 'bootstrap-sass-official/_bootstrap-sprockets.scss' -@import 'bootstrap-sass-official' - -// Whatever application styles you have go last -// Modules and Variables -@import 'modules/search' -@import 'modules/index_item' -@import 'modules/icons' -@import 'modules/devise' -@import 'modules/progress_bars' - -// Partials -@import 'partials/base' -@import 'partials/header' -@import 'partials/footer' - -// Third-party -@import 'tagmanager/tagmanager' -@import 'font-awesome-sprockets' -@import 'font-awesome' -@import 'jquery-ui' -@import 'formtastic' -@import 'eonasdan-bootstrap-datetimepicker' -@import 'footable' -@import 'OpenLayers/ol' -@import 'OpenLayers/custom' - -// Select2, themed w. Bootstrap -@import 'select2' -@import 'select2-bootstrap' - -@import 'vendor/openlayers_style' -@import 'vendor/openlayers_ie6-style' -@import 'vendor/openlayers_google' -@import 'vendor/openlayers_framedCloud' -@import 'vendor/formtastic_changes' -@import 'vendor/pagination' -@import 'vendor/map_layers' -@import 'vendor/token-input' -@import 'vendor/typeahead' -@import 'vendor/bootstrap_changes' -@import 'vendor/simple_form' -// Select2 -@import 'vendor/select2' -@import 'vendor/select2-bootstrap' - -// Main css -@import 'main/*' - -// Components -@import 'components/*' - -// Hack to make li simple -li - list-style: none diff --git a/app/controllers/companies_controller.rb b/app/controllers/companies_controller.rb index 07a732fc9..cf27c39cf 100644 --- a/app/controllers/companies_controller.rb +++ b/app/controllers/companies_controller.rb @@ -16,14 +16,13 @@ class CompaniesController < BreadcrumbController redirect_to params.merge(:page => 1) end - @companies = ModelDecorator.decorate( - @companies, - with: CompanyDecorator, - context: { - referential: line_referential - } - ) + @companies = decorate_companies(@companies) } + + format.json { + @companies = decorate_companies(@companies) + } + build_breadcrumb :index end end @@ -77,4 +76,14 @@ class CompaniesController < BreadcrumbController %w[asc desc].include?(params[:direction]) ? params[:direction] : 'asc' end + def decorate_companies(companies) + ModelDecorator.decorate( + companies, + with: CompanyDecorator, + context: { + referential: line_referential + } + ) + end + end diff --git a/app/controllers/networks_controller.rb b/app/controllers/networks_controller.rb index d1f83340e..5dae1ba3f 100644 --- a/app/controllers/networks_controller.rb +++ b/app/controllers/networks_controller.rb @@ -37,14 +37,13 @@ class NetworksController < BreadcrumbController redirect_to params.merge(:page => 1) end - @networks = ModelDecorator.decorate( - @networks, - with: NetworkDecorator, - context: { - line_referential: line_referential - } - ) + @networks = decorate_networks(@networks) } + + format.js { + @networks = decorate_networks(@networks) + } + build_breadcrumb :index end end @@ -87,4 +86,14 @@ class NetworksController < BreadcrumbController %w[asc desc].include?(params[:direction]) ? params[:direction] : 'asc' end + def decorate_networks(networks) + ModelDecorator.decorate( + networks, + with: NetworkDecorator, + context: { + line_referential: line_referential + } + ) + end + end diff --git a/app/controllers/referential_companies_controller.rb b/app/controllers/referential_companies_controller.rb index 53dde93bb..482f74ea0 100644 --- a/app/controllers/referential_companies_controller.rb +++ b/app/controllers/referential_companies_controller.rb @@ -14,14 +14,13 @@ class ReferentialCompaniesController < ChouetteController redirect_to params.merge(:page => 1) end - @companies = ModelDecorator.decorate( - @companies, - with: CompanyDecorator, - context: { - referential: referential - } - ) + @companies = decorate_companies(@companies) } + + format.js { + @companies = decorate_companies(@companies) + } + build_breadcrumb :index end end @@ -70,4 +69,14 @@ class ReferentialCompaniesController < ChouetteController %w[asc desc].include?(params[:direction]) ? params[:direction] : 'asc' end + def decorate_companies(companies) + ModelDecorator.decorate( + companies, + with: CompanyDecorator, + context: { + referential: referential + } + ) + end + end diff --git a/app/controllers/referential_networks_controller.rb b/app/controllers/referential_networks_controller.rb index e0ce71ce4..ee2db8008 100644 --- a/app/controllers/referential_networks_controller.rb +++ b/app/controllers/referential_networks_controller.rb @@ -30,14 +30,13 @@ class ReferentialNetworksController < ChouetteController redirect_to params.merge(:page => 1) end - @networks = ModelDecorator.decorate( - @networks, - with: ReferentialNetworkDecorator, - context: { - referential: referential - } - ) + @networks = decorate_networks(@networks) } + + format.js { + @networks = decorate_networks(@networks) + } + build_breadcrumb :index end end @@ -81,4 +80,14 @@ class ReferentialNetworksController < ChouetteController %w[asc desc].include?(params[:direction]) ? params[:direction] : 'asc' end + def decorate_networks(networks) + ModelDecorator.decorate( + networks, + with: ReferentialNetworkDecorator, + context: { + referential: referential + } + ) + end + end diff --git a/app/controllers/time_tables_controller.rb b/app/controllers/time_tables_controller.rb index 20d500ea9..edeb5a32f 100644 --- a/app/controllers/time_tables_controller.rb +++ b/app/controllers/time_tables_controller.rb @@ -37,7 +37,7 @@ class TimeTablesController < ChouetteController tt_params = time_table_params if tt_params[:calendar_id] %i(monday tuesday wednesday thursday friday saturday sunday).map { |d| tt_params[d] = true } - calendar = current_organisation.calendars.find_by_id(tt_params[:calendar_id]) + calendar = Calendar.find(tt_params[:calendar_id]) tt_params[:calendar_id] = nil if tt_params.has_key?(:dates_attributes) || tt_params.has_key?(:periods_attributes) end @@ -86,16 +86,14 @@ class TimeTablesController < ChouetteController redirect_to params.merge(:page => 1) end - @time_tables = ModelDecorator.decorate( - @time_tables, - with: TimeTableDecorator, - context: { - referential: @referential - } - ) + @time_tables = decorate_time_tables(@time_tables) build_breadcrumb :index } + + format.js { + @time_tables = decorate_time_tables(@time_tables) + } end end @@ -195,6 +193,16 @@ class TimeTablesController < ChouetteController Chouette::TimeTable.find(from_id) if from_id end + def decorate_time_tables(time_tables) + ModelDecorator.decorate( + time_tables, + with: TimeTableDecorator, + context: { + referential: @referential + } + ) + end + def time_table_params params.require(:time_table).permit( :objectid, diff --git a/app/controllers/workbenches_controller.rb b/app/controllers/workbenches_controller.rb index 22a71863a..171db6a07 100644 --- a/app/controllers/workbenches_controller.rb +++ b/app/controllers/workbenches_controller.rb @@ -2,7 +2,13 @@ class WorkbenchesController < BreadcrumbController before_action :query_params, only: [:show] defaults resource_class: Workbench - respond_to :html, only: [:show] + respond_to :html, only: [:show, :index] + + def index + # Only display Wb with selected name, according to #4108 + @workbench = current_organisation.workbenches.find_by(name: "Gestion de l'offre") + @calendars = Calendar.where('organisation_id = ? OR shared = ?', current_organisation.id, true) + end def show scope = resource.all_referentials diff --git a/app/jobs/mailer_job.rb b/app/jobs/mailer_job.rb index 761a29cd6..3918745b8 100644 --- a/app/jobs/mailer_job.rb +++ b/app/jobs/mailer_job.rb @@ -1,5 +1,5 @@ class MailerJob < ActiveJob::Base - queue_as :mail + # No need to specify queue it's already used mailers queue def perform klass, action, params klass.constantize.public_send(action, *params).deliver_later diff --git a/app/models/chouette/stop_point.rb b/app/models/chouette/stop_point.rb index 3dbf6be0d..8fe79dc0c 100644 --- a/app/models/chouette/stop_point.rb +++ b/app/models/chouette/stop_point.rb @@ -36,12 +36,12 @@ module Chouette def stop_area_id_validation if stop_area_id.nil? - errors.add(:stop_area_id, I18n.t("errors.messages.empty")) + errors.add(:stop_area_id, I18n.t("stop_areas.errors.empty")) end end def self.area_candidates - Chouette::StopArea.where( :area_type => ['Quay', 'BoardingPosition']) + Chouette::StopArea.where(:area_type => ['Quay', 'BoardingPosition']) end end diff --git a/app/models/chouette/vehicle_journey.rb b/app/models/chouette/vehicle_journey.rb index 71c339780..19299d098 100644 --- a/app/models/chouette/vehicle_journey.rb +++ b/app/models/chouette/vehicle_journey.rb @@ -142,7 +142,7 @@ module Chouette vj.update_attributes(state_permited_attributes(item)) vj.update_has_and_belongs_to_many_from_state(item) - item['errors'] = vj.errors if vj.errors.any? + item['errors'] = vj.errors.full_messages.uniq if vj.errors.any? end # Delete ids of new object from state if we had to rollback diff --git a/app/models/concerns/default_attributes_support.rb b/app/models/concerns/default_attributes_support.rb index 7928093e6..e85a59160 100644 --- a/app/models/concerns/default_attributes_support.rb +++ b/app/models/concerns/default_attributes_support.rb @@ -77,7 +77,8 @@ module DefaultAttributesSupport def build_objectid if objectid.include? ':__pending_id__' fix_uniq_objectid - update_attributes( :objectid => objectid, :object_version => (object_version - 1) ) + self.object_version = object_version - 1 + self.save(validate: false) end end diff --git a/app/models/referential.rb b/app/models/referential.rb index ed23e2e51..e65d6a33b 100644 --- a/app/models/referential.rb +++ b/app/models/referential.rb @@ -186,7 +186,7 @@ class Referential < ActiveRecord::Base before_validation :clone_associations, :on => :create, if: :created_from before_validation :assign_slug, :on => :create before_validation :assign_prefix, :on => :create - before_create :create_schema, unless: :created_from + before_create :create_schema after_create :clone_schema, if: :created_from diff --git a/app/policies/referential_policy.rb b/app/policies/referential_policy.rb index 9d0a92093..fdc80516c 100644 --- a/app/policies/referential_policy.rb +++ b/app/policies/referential_policy.rb @@ -20,7 +20,7 @@ class ReferentialPolicy < ApplicationPolicy def clone? - !archived? && organisation_match? && create? + !archived? && create? end def archive? @@ -37,7 +37,3 @@ class ReferentialPolicy < ApplicationPolicy end end - - - - diff --git a/app/views/compliance_checks/detailed_errors_index.csv.slim b/app/views/compliance_checks/detailed_errors_index.csv.slim index 0b2c3f24f..7fe20e282 100644 --- a/app/views/compliance_checks/detailed_errors_index.csv.slim +++ b/app/views/compliance_checks/detailed_errors_index.csv.slim @@ -29,7 +29,7 @@ = error["source"]["file"]["line_number"] - else - = I18n.t("activemodel.attributes.compliance_check_result."+r.test_id); + = 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" diff --git a/app/views/compliance_checks/summary_errors_index.csv.slim b/app/views/compliance_checks/summary_errors_index.csv.slim index bbb2c8c88..8c88d5cf6 100644 --- a/app/views/compliance_checks/summary_errors_index.csv.slim +++ b/app/views/compliance_checks/summary_errors_index.csv.slim @@ -16,7 +16,7 @@ = r.result; = r.test_id; - = I18n.t("activemodel.attributes.compliance_check_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 diff --git a/app/views/layouts/navigation/_main_nav_left.html.slim b/app/views/layouts/navigation/_main_nav_left.html.slim index 3cf6428af..9dfc828c0 100644 --- a/app/views/layouts/navigation/_main_nav_left.html.slim +++ b/app/views/layouts/navigation/_main_nav_left.html.slim @@ -16,7 +16,7 @@ #miOne.panel-collapse.collapse .list-group - = link_to root_path, class: "list-group-item #{(@localizationUrl == 'referentials#index') ? 'active' : ''}" do + = link_to root_path, class: "list-group-item #{(@localizationUrl == 'workbenches#index') ? 'active' : ''}" do span Tableau de bord = link_to '#', class: 'list-group-item' do span Offre de mon organisation diff --git a/app/views/referential_stop_areas/index.html.slim b/app/views/referential_stop_areas/index.html.slim index 1cbe1945f..7bf39eabd 100644 --- a/app/views/referential_stop_areas/index.html.slim +++ b/app/views/referential_stop_areas/index.html.slim @@ -4,7 +4,7 @@ .panel.panel-default .panel-heading .input-group.col-md-9.col-sm-9 - = f.text_field :name_or_objectid_cont, placeholder: t('.name_or_objectid'), class: 'form-control' + = f.text_field :name_or_objectid_cont, placeholder: t('stop_areas.filters.name_or_objectid'), class: 'form-control' .input-group-btn button.btn.btn-primary#search-btn type="submit" span.fa.fa-search diff --git a/app/views/stop_area_copies/new.html.slim b/app/views/stop_area_copies/new.html.slim index 1a8764cbc..b506d35f4 100644 --- a/app/views/stop_area_copies/new.html.slim +++ b/app/views/stop_area_copies/new.html.slim @@ -1,4 +1,4 @@ -= title_tag t("stop_area_copies.new.title."+@stop_area_copy.hierarchy) += title_tag t("stop_area_copies.new.title.#{@stop_area_copy.hierarchy}") = semantic_form_for [@referential, @stop_area, @stop_area_copy] do |form| br diff --git a/app/views/workbenches/index.html.slim b/app/views/workbenches/index.html.slim new file mode 100644 index 000000000..1bd116a85 --- /dev/null +++ b/app/views/workbenches/index.html.slim @@ -0,0 +1,67 @@ +/ PageHeader += pageheader 'map-marker', + t('.title', organisation: current_organisation.name) + +/ PageContent +.page_content + .container-fluid + .row + .col-lg-12 + h2.content_header = t('.offers.title') + + .row + .col-lg-6.col-md-6.col-sm-6.col-xs-12 + .panel.panel-default + .panel-heading + h3.panel-title + = t('.offers.organisation') + + .panel-body + em.small.text-muted = t('.offers.no_content') + + .panel.panel-default + .panel-heading + h3.panel-title + = t('.offers.idf') + + .panel-body + em.small.text-muted = t('.offers.no_content') + + .col-lg-6.col-md-6.col-sm-6.col-xs-12 + .panel.panel-default + .panel-heading + h3.panel-title.with_actions + div + = t('.offers.referentials') + span.badge.ml-xs = @workbench.referentials.count if @workbench.all_referentials.any? + + div + = link_to '', workbench_path(@workbench), class: ' fa fa-chevron-right pull-right', title: t('.offers.see') + + - if @workbench.all_referentials.any? + .list-group + - @workbench.all_referentials.each_with_index do |referential, i| + = link_to referential.name, referential_path(referential), class: 'list-group-item' if i < 6 + + - else + .panel-body + em.small.text-muted = t('.offers.no_content') + + .panel.panel-default + .panel-heading + h3.panel-title.with_actions + div + = t('.offers.calendars') + span.badge.ml-xs = @calendars.count if @calendars.any? + + div + = link_to '', calendars_path, class: ' fa fa-chevron-right pull-right', title: t('.offers.see') + + - if @calendars.any? + .list-group + - @calendars.each_with_index do |calendar, i| + = link_to calendar.name, calendar_path(calendar), class: 'list-group-item' if i < 6 + + - else + .panel-body + em.small.text-muted = t('.offers.no_content') |
