diff options
| author | Luc Donnet | 2018-04-15 15:04:30 +0200 | 
|---|---|---|
| committer | Luc Donnet | 2018-04-15 15:04:30 +0200 | 
| commit | af36cb9b844760adb26863bb4d9c3c55209557a9 (patch) | |
| tree | 112027e0269d67a392bac493d94544bff00111ed /app | |
| parent | 264f373d7298278f84972d5b15470daea7728e72 (diff) | |
| download | chouette-core-af36cb9b844760adb26863bb4d9c3c55209557a9.tar.bz2 | |
Add generic navbar and fix codifligne, reflex navigation Refs #6545 @8
Diffstat (limited to 'app')
| -rw-r--r-- | app/helpers/line_referential_syncs_helper.rb | 31 | ||||
| -rw-r--r-- | app/helpers/stop_area_referential_syncs_helper.rb | 31 | ||||
| -rw-r--r-- | app/views/layouts/navigation/_main_nav_left_content.html.slim | 93 | ||||
| -rw-r--r-- | app/views/layouts/navigation/_main_nav_left_content_stif.html.slim | 232 | ||||
| -rw-r--r-- | app/views/line_referentials/show.html.slim | 57 | ||||
| -rw-r--r-- | app/views/stop_area_referentials/show.html.slim | 54 | 
6 files changed, 322 insertions, 176 deletions
| diff --git a/app/helpers/line_referential_syncs_helper.rb b/app/helpers/line_referential_syncs_helper.rb new file mode 100644 index 000000000..37f08b154 --- /dev/null +++ b/app/helpers/line_referential_syncs_helper.rb @@ -0,0 +1,31 @@ +module LineReferentialSyncsHelper + +  def last_line_ref_sync_message(line_ref_sync) +    line_ref_sync.line_referential_sync_messages.last +  end + +  def line_referential_sync_created_at(line_ref_sync) +    l(last_line_ref_sync_message(line_ref_sync).created_at, format: :short_with_time) +  end + +  def line_referential_sync_status(line_ref_sync) +    status =  line_ref_sync.status + +    if %w[new pending].include? status +      content_tag :span, '', class: "fa fa-clock-o" +    else +      cls ='' +      cls = 'success' if status == 'successful' +      cls = 'danger' if status == 'failed' + +      content_tag :span, '', class: "fa fa-circle text-#{cls}" +    end +  end + +  def line_referential_sync_message(line_ref_sync) +    last_line_ref_sync_message = last_line_ref_sync_message(line_ref_sync) +    data = last_line_ref_sync_message.message_attributes.symbolize_keys! +    data[:processing_time] = distance_of_time_in_words(data[:processing_time].to_i) +    t("line_referential_sync.message.#{last_line_ref_sync_message.message_key}", last_line_ref_sync_message.message_attributes.symbolize_keys!).html_safe +  end +end diff --git a/app/helpers/stop_area_referential_syncs_helper.rb b/app/helpers/stop_area_referential_syncs_helper.rb new file mode 100644 index 000000000..3e2837fda --- /dev/null +++ b/app/helpers/stop_area_referential_syncs_helper.rb @@ -0,0 +1,31 @@ +module StopAreaReferentialSyncsHelper + +  def last_stop_area_ref_sync_message(stop_area_ref_sync) +    stop_area_ref_sync.stop_area_referential_sync_messages.last +  end + +  def stop_area_referential_sync_created_at(stop_area_ref_sync) +    l(last_stop_area_ref_sync_message(stop_area_ref_sync).created_at, format: :short_with_time) +  end + +  def stop_area_referential_sync_status(stop_area_ref_sync) +    status =  stop_area_ref_sync.status + +    if %w[new pending].include? status +      content_tag :span, '', class: "fa fa-clock-o" +    else +      cls ='' +      cls = 'success' if status == 'successful' +      cls = 'danger' if status == 'failed' + +      content_tag :span, '', class: "fa fa-circle text-#{cls}" +    end +  end + +  def stop_area_referential_sync_message(stop_area_ref_sync) +    last_stop_area_ref_sync_message = last_stop_area_ref_sync_message(stop_area_ref_sync) +    data = last_stop_area_ref_sync_message.message_attributes.symbolize_keys! +    data[:processing_time] = distance_of_time_in_words(data[:processing_time].to_i) +    t("stop_area_referential_sync.message.#{last_stop_area_ref_sync_message.message_key}", last_stop_area_ref_sync_message.message_attributes.symbolize_keys!).html_safe +  end +end diff --git a/app/views/layouts/navigation/_main_nav_left_content.html.slim b/app/views/layouts/navigation/_main_nav_left_content.html.slim index e69de29bb..60085060e 100644 --- a/app/views/layouts/navigation/_main_nav_left_content.html.slim +++ b/app/views/layouts/navigation/_main_nav_left_content.html.slim @@ -0,0 +1,93 @@ +- if current_organisation +  - current_organisation.workbenches.each do |workbench| +    #menu-items.panel-group +      .menu-item.panel +        .panel-heading +          h4.panel-title +            = link_to '#miOne', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do +              = t('layouts.navbar.current_offer.other') + +        #miOne.panel-collapse.collapse +          .list-group +            = link_to root_path, class: "list-group-item" do +              span = t('layouts.navbar.dashboard') +            = link_to workbench_output_path(workbench), class: 'list-group-item' do +              span = t('layouts.navbar.workbench_outputs.organisation') +            = link_to '#', class: 'list-group-item' do +              span = t('layouts.navbar.workbench_outputs.idf') + +      .menu-item.panel +        .panel-heading +          h4.panel-title +            = link_to '#miTwo', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do +              - t('activerecord.models.workbench.one').capitalize + +        #miTwo.panel-collapse.collapse +          .list-group +            = link_to workbench_path(workbench), class: "list-group-item" do +              span = t('activerecord.models.referential.other').capitalize +            = link_to workbench_imports_path(workbench), class: "list-group-item" do +              span = t('activerecord.models.import.other').capitalize +            = link_to workbench_exports_path(workbench), class: "list-group-item" do +              span = t('activerecord.models.export.other').capitalize +            = link_to workgroup_calendars_path(workbench.workgroup), class: 'list-group-item' do +              span = t('activerecord.models.calendar.other').capitalize +            = link_to workbench_compliance_check_sets_path(workbench), class: 'list-group-item' do +              span = t('activerecord.models.compliance_check_set.other').capitalize +            = link_to compliance_control_sets_path, class: 'list-group-item' do +              span = t('activerecord.models.compliance_control_set.other').capitalize + +      .menu-item.panel +        .panel-heading +          h4.panel-title +            = link_to '#miThree', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do +              = t('layouts.navbar.referential_datas') + +        #miThree.panel-collapse.collapse +          - if @referential.try(:id) && respond_to?(:current_referential) +            .list-group +              .list-group-item +                = (current_referential.name).upcase +                .list-group +                  = link_to referential_networks_path(current_referential), class: 'list-group-item' do +                    span = t('networks.index.title') + +                  = link_to referential_companies_path(current_referential), class: 'list-group-item' do +                    span = t('companies.index.title') + +                  = link_to '#', class: 'list-group-item disabled' do +                    span = t('layouts.navbar.shapes') + +                  = link_to referential_time_tables_path(current_referential), class: 'list-group-item' do +                    span = t('time_tables.index.title') + +          - else +            .panel-body +              em.text-muted +                = t('layouts.navbar.select_referential_for_more_features') + +      .menu-item.panel +        .panel-heading +          h4.panel-title +            = link_to '#miFour', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do +              = t('layouts.navbar.line_referential') + +        #miFour.panel-collapse.collapse +          .list-group +            = link_to line_referential_lines_path(workbench.line_referential), class: "list-group-item" do +              span = Chouette::Line.t +            = link_to line_referential_networks_path(workbench.line_referential), class: "list-group-item" do +              span = Chouette::Network.t +            = link_to line_referential_companies_path(workbench.line_referential), class: "list-group-item" do +              span = Chouette::Company.t + +      .menu-item.panel +        .panel-heading +          h4.panel-title +            = link_to '#miFive', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do +              = t('layouts.navbar.stop_area_referential') + +        #miFive.panel-collapse.collapse +          .list-group +            = link_to stop_area_referential_stop_areas_path(workbench.stop_area_referential), class: "list-group-item" do +              span = Chouette::StopArea.t diff --git a/app/views/layouts/navigation/_main_nav_left_content_stif.html.slim b/app/views/layouts/navigation/_main_nav_left_content_stif.html.slim index 3741ef19b..323fffedd 100644 --- a/app/views/layouts/navigation/_main_nav_left_content_stif.html.slim +++ b/app/views/layouts/navigation/_main_nav_left_content_stif.html.slim @@ -1,109 +1,125 @@ -- @localizationUrl = "#{params[:controller]}##{params[:action]}" - -#menu-items.panel-group -  .menu-item.panel -    .panel-heading -      h4.panel-title -        = link_to '#miOne', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do -          = t('layouts.navbar.current_offer.other') - -    #miOne.panel-collapse.collapse -      .list-group -        = link_to root_path, class: "list-group-item #{(@localizationUrl == 'workbenches#index') ? 'active' : ''}" do -          span = t('layouts.navbar.dashboard') -        = link_to workbench_output_path(current_user.workbenches.first), class: 'list-group-item' do -          span = t('layouts.navbar.workbench_outputs.organisation') -        = link_to '#', class: 'list-group-item' do -          span = t('layouts.navbar.workbench_outputs.idf') - -  .menu-item.panel -    .panel-heading -      h4.panel-title -        = link_to '#miTwo', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do -          - t('activerecord.models.workbench.one').capitalize - -    #miTwo.panel-collapse.collapse -      .list-group -        - current_user.workbenches.each do |current_workbench| -          = link_to workbench_path(current_workbench), class: "list-group-item #{params[:controller] == 'workbenches' ? 'active' : ''}" do -            span = t('activerecord.models.referential.other').capitalize -          = link_to workbench_imports_path(current_workbench), class: "list-group-item #{(params[:controller] == 'imports') ? 'active' : ''}" do -            span = t('activerecord.models.import.other').capitalize -          = link_to workbench_exports_path(current_workbench), class: "list-group-item #{(params[:controller] == 'exports') ? 'active' : ''}" do -            span = t('activerecord.models.export.other').capitalize -          = link_to workgroup_calendars_path(current_workbench.workgroup), class: 'list-group-item' do -            span = t('activerecord.models.calendar.other').capitalize -          = link_to workbench_compliance_check_sets_path(current_workbench), class: 'list-group-item' do -            span = t('activerecord.models.compliance_check_set.other').capitalize -          = link_to compliance_control_sets_path, class: 'list-group-item' do -            span = t('activerecord.models.compliance_control_set.other').capitalize - -  .menu-item.panel -    .panel-heading -      h4.panel-title -        = link_to '#miThree', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do -          = t('layouts.navbar.referential_datas') - -    #miThree.panel-collapse.collapse -      - if @referential.try(:id) && respond_to?(:current_referential) -        .list-group -          .list-group-item -            = (current_referential.name).upcase +- if current_organisation +  - current_organisation.workbenches.each do |workbench| +    #menu-items.panel-group +      .menu-item.panel +        .panel-heading +          h4.panel-title +            = link_to '#miOne', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do +              = t('layouts.navbar.current_offer.other') + +        #miOne.panel-collapse.collapse +          .list-group +            = link_to root_path, class: "list-group-item" do +              span = t('layouts.navbar.dashboard') +            = link_to workbench_output_path(workbench), class: 'list-group-item' do +              span = t('layouts.navbar.workbench_outputs.organisation') +            = link_to '#', class: 'list-group-item' do +              span = t('layouts.navbar.workbench_outputs.idf') + +      .menu-item.panel +        .panel-heading +          h4.panel-title +            = link_to '#miTwo', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do +              - t('activerecord.models.workbench.one').capitalize + +        #miTwo.panel-collapse.collapse +          .list-group +            = link_to workbench_path(workbench), class: "list-group-item" do +              span = t('activerecord.models.referential.other').capitalize +            = link_to workbench_imports_path(workbench), class: "list-group-item" do +              span = t('activerecord.models.import.other').capitalize +            = link_to workbench_exports_path(workbench), class: "list-group-item" do +              span = t('activerecord.models.export.other').capitalize +            = link_to workgroup_calendars_path(workbench.workgroup), class: 'list-group-item' do +              span = t('activerecord.models.calendar.other').capitalize +            = link_to workbench_compliance_check_sets_path(workbench), class: 'list-group-item' do +              span = t('activerecord.models.compliance_check_set.other').capitalize +            = link_to compliance_control_sets_path, class: 'list-group-item' do +              span = t('activerecord.models.compliance_control_set.other').capitalize + +      .menu-item.panel +        .panel-heading +          h4.panel-title +            = link_to '#miThree', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do +              = Referential.ts.capitalize + +        #miThree.panel-collapse.collapse +          - if @referential.try(:id) && respond_to?(:current_referential)              .list-group -              = link_to referential_networks_path(current_referential), class: 'list-group-item' do -                span = t('networks.index.title') - -              = link_to referential_companies_path(current_referential), class: 'list-group-item' do -                span = t('companies.index.title') - -              = link_to '#', class: 'list-group-item disabled' do -                span = t('layouts.navbar.shapes') - -              = link_to referential_time_tables_path(current_referential), class: 'list-group-item' do -                span = t('time_tables.index.title') - -      - else -        .panel-body -          em.text-muted -            = t('layouts.navbar.select_referential_for_more_features') - -  .menu-item.panel -    .panel-heading -      h4.panel-title -        = link_to '#miFour', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do -          = t('layouts.navbar.sync') - -    #miFour.panel-collapse.collapse -      .list-group -        = link_to line_referential_path(1), class: "list-group-item #{(@localizationUrl == 'line_referentials#show') ? 'active' : ''}" do -          span = t('layouts.navbar.sync_ilico') -        = link_to stop_area_referential_path(1), class: "list-group-item #{(@localizationUrl == 'stop_area_referentials#show') ? 'active' : ''}" do -          span = t('layouts.navbar.sync_icar') - -  .menu-item.panel -    .panel-heading -      h4.panel-title -        = link_to '#miFive', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do -          = t('layouts.navbar.tools') - -    #miFive.panel-collapse.collapse -      .list-group -        = link_to Rails.application.config.try(:portal_url), target: '_blank', class: 'list-group-item' do -          span -            span.fa.fa-2x.fa-circle -            = t('layouts.navbar.portal') - -        = link_to Rails.application.config.try(:codifligne_url), target: '_blank', class: 'list-group-item' do -          span -            span.fa.fa-2x.fa-circle -            = t('layouts.navbar.ilico') - -        = link_to Rails.application.config.try(:reflex_url), target: '_blank', class: 'list-group-item' do -          span -            span.fa.fa-2x.fa-circle -            = t('layouts.navbar.icar') - -        = link_to '#', target: '_blank', class: 'list-group-item' do -          span -            span.fa.fa-2x.fa-circle -            = t('layouts.navbar.support')
\ No newline at end of file +              .list-group-item +                = (current_referential.name).upcase +                .list-group +                  = link_to referential_networks_path(current_referential), class: 'list-group-item' do +                    span = t('networks.index.title') + +                  = link_to referential_companies_path(current_referential), class: 'list-group-item' do +                    span = t('companies.index.title') + +                  = link_to '#', class: 'list-group-item disabled' do +                    span = t('layouts.navbar.shapes') + +                  = link_to referential_time_tables_path(current_referential), class: 'list-group-item' do +                    span = t('time_tables.index.title') + +          - else +            .panel-body +              em.text-muted +                = t('layouts.navbar.select_referential_for_more_features') + +      .menu-item.panel +        .panel-heading +          h4.panel-title +            = link_to '#miFour', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do +              = t('layouts.navbar.line_referential') + +        #miFour.panel-collapse.collapse +          .list-group +            = link_to line_referential_path(workbench.line_referential), class: "list-group-item" do +              span = t('layouts.navbar.sync_ilico') +            = link_to line_referential_lines_path(workbench.line_referential), class: "list-group-item" do +              span = Chouette::Line.t.capitalize +            = link_to line_referential_networks_path(workbench.line_referential), class: "list-group-item" do +              span = Chouette::Network.t.capitalize +            = link_to line_referential_companies_path(workbench.line_referential), class: "list-group-item" do +              span = Chouette::Company.t.capitalize + +      .menu-item.panel +        .panel-heading +          h4.panel-title +            = link_to '#miFive', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do +              = t('layouts.navbar.stop_area_referential') + +        #miFive.panel-collapse.collapse +          .list-group +            = link_to stop_area_referential_path(workbench.stop_area_referential), class: "list-group-item" do +              span = t('layouts.navbar.sync_icar') +            = link_to stop_area_referential_stop_areas_path(workbench.stop_area_referential), class: "list-group-item" do +              span = Chouette::StopArea.t.capitalize + +      .menu-item.panel +        .panel-heading +          h4.panel-title +            = link_to '#miSix', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do +              = t('layouts.navbar.tools') + +        #miSix.panel-collapse.collapse +          .list-group +            = link_to Rails.application.config.try(:portal_url), target: '_blank', class: 'list-group-item' do +              span +                span.fa.fa-2x.fa-circle +                = t('layouts.navbar.portal') + +            = link_to Rails.application.config.try(:codifligne_url), target: '_blank', class: 'list-group-item' do +              span +                span.fa.fa-2x.fa-circle +                = t('layouts.navbar.ilico') + +            = link_to Rails.application.config.try(:reflex_url), target: '_blank', class: 'list-group-item' do +              span +                span.fa.fa-2x.fa-circle +                = t('layouts.navbar.icar') + +            = link_to '#', target: '_blank', class: 'list-group-item' do +              span +                span.fa.fa-2x.fa-circle +                = t('layouts.navbar.support') diff --git a/app/views/line_referentials/show.html.slim b/app/views/line_referentials/show.html.slim index 763eb076e..4a4acc427 100644 --- a/app/views/line_referentials/show.html.slim +++ b/app/views/line_referentials/show.html.slim @@ -4,44 +4,29 @@    - content_for :page_header_actions do      = link_to(t('actions.sync'), sync_line_referential_path(@line_referential), method: :post, class: 'btn btn-default') -- content_for :page_header_content do -  .row.mb-md -    .col-lg-12.text-right -      = link_to line_referential_companies_path(@line_referential), class: 'btn btn-primary' do -        = Referential.human_attribute_name(:companies) -        em.small = " (#{@line_referential.companies.size})" -      = link_to line_referential_networks_path(@line_referential), class: 'btn btn-primary' do -        = Referential.human_attribute_name(:networks) -        em.small = " (#{@line_referential.networks.size})" -      = link_to line_referential_lines_path(@line_referential), class: 'btn btn-primary' do -        = Referential.human_attribute_name(:lines) -        em.small = " (#{@line_referential.lines.size})" -  .page_content    .container-fluid      .row        .col-lg-12 -        - unless @line_referential.line_referential_syncs.empty? -          table.table -            thead -              tr -                th = t('.synchronized') -                th = t('.status') -                th = t('.message') +          = table_builder_2 @line_referential.line_referential_syncs, +            [ \ +              TableBuilderHelper::Column.new( \ +                name: t('.synchronized'), \ +                attribute: Proc.new { |sync| line_referential_sync_created_at(sync) }, \ +              ), \ +              TableBuilderHelper::Column.new( \ +                name: t('.status'), \ +                attribute: Proc.new { |sync| line_referential_sync_status(sync) }, \ +              ), \ +              TableBuilderHelper::Column.new( \ +                name: t('.message'), \ +                attribute: Proc.new { |sync| line_referential_sync_message(sync) }, \ +              ), \ +            ], +            sortable: false, +            cls: 'table' -            tbody -              - @line_referential.line_referential_syncs.each_with_index do |sync, i| -                / Display only 10 msgs -                - if i < 10 -                  - unless sync.line_referential_sync_messages.empty? -                    - sync.line_referential_sync_messages.last.tap do |log| -                      - if log.criticity = log.criticity -                        tr -                          td style='width: 150px' -                            = l(log.created_at, format: :short_with_time) -                          td.text-center -                            .fa.fa-circle class="text-#{criticity_class(log.criticity)}" -                          td -                            - data = log.message_attributes.symbolize_keys! -                            - data[:processing_time] = distance_of_time_in_words(data[:processing_time].to_i) -                            = t("line_referential_sync.message.#{log.message_key}", log.message_attributes.symbolize_keys!).html_safe +    - unless @line_referential.line_referential_syncs.any? +      .row.mt-xs +        .col-lg-12 +          = replacement_msg t('line_referential_syncs.search_no_results') diff --git a/app/views/stop_area_referentials/show.html.slim b/app/views/stop_area_referentials/show.html.slim index 911006c39..9a0079330 100644 --- a/app/views/stop_area_referentials/show.html.slim +++ b/app/views/stop_area_referentials/show.html.slim @@ -2,40 +2,30 @@  - if policy(@stop_area_referential).synchronize?    - content_for :page_header_actions do      = link_to(t('actions.sync'), sync_stop_area_referential_path(@stop_area_referential), method: :post, class: 'btn btn-default') - -- content_for :page_header_content do -  .row.mb-md -    .col-lg-12.text-right -      = link_to stop_area_referential_stop_areas_path(@stop_area_referential), class: 'btn btn-primary' do -        = Referential.human_attribute_name(:stop_areas) -        em.small = " (#{@stop_area_referential.stop_areas.count})" -- page_header_content_for @stop_area_referential - +      .page_content    .container-fluid      .row        .col-lg-12 -        - unless @stop_area_referential.stop_area_referential_syncs.empty? -          table.table -            thead -              tr -                th Synchronisé -                th Statut -                th Message +          = table_builder_2 @stop_area_referential.stop_area_referential_syncs, +            [ \ +              TableBuilderHelper::Column.new( \ +                name: t('.synchronized'), \ +                attribute: Proc.new { |sync| stop_area_referential_sync_created_at(sync) }, \ +              ), \ +              TableBuilderHelper::Column.new( \ +                name: t('.status'), \ +                attribute: Proc.new { |sync| stop_area_referential_sync_status(sync) }, \ +              ), \ +              TableBuilderHelper::Column.new( \ +                name: t('.message'), \ +                attribute: Proc.new { |sync| stop_area_referential_sync_message(sync) }, \ +              ), \ +            ], +            sortable: false, +            cls: 'table' -            tbody -              - @stop_area_referential.stop_area_referential_syncs.each_with_index do |sync, i| -                / Display only 10 msgs -                - if i < 10 -                  - unless sync.stop_area_referential_sync_messages.empty? -                    - sync.stop_area_referential_sync_messages.last.tap do |log| -                      - if log.criticity = log.criticity -                        tr -                          td style='width:150px' -                            = l(log.created_at, format: :short_with_time) -                          td.text-center -                            .fa.fa-circle class="text-#{criticity_class(log.criticity)}" -                          td -                            - data = log.message_attributes.symbolize_keys! -                            - data[:processing_time] = distance_of_time_in_words(data[:processing_time].to_i) -                            = t("stop_area_referential_sync.message.#{log.message_key}", log.message_attributes.symbolize_keys!).html_safe +    - unless @stop_area_referential.stop_area_referential_syncs.any? +      .row.mt-xs +        .col-lg-12 +          = replacement_msg t('stop_area_referential_syncs.search_no_results') | 
