af83/chouette-core

View on GitHub
app/views/companies/show.html.slim

Summary

Maintainability
Test Coverage
- breadcrumb :company, @workbench, @company

- page_header_content_for @company

.page_content
  .container-fluid

    .row
      .col-lg-6.col-md-6.col-sm-6.col-xs-6
        - attributes = { t('id_codif') => @company.get_objectid.try(:short_id) }
        - %i(name short_name code default_language time_zone fare_url).each do |field|
          - attributes[Chouette::Company.human_attribute_name(field)] = @company.send(field)
        - @company.custom_fields(current_referential.workgroup).for_section("identification").each do |code, field|
          - attributes.merge!(field.name => field.display_value)
        - attributes[Chouette::Company.tmf(:objectid)] = @company.objectid
        = definition_list t("companies.form.sections.identification"), attributes

        - attributes = %w(house_number address_line_1 address_line_2 street town postcode postcode_extension).map { |attr| [Chouette::Company.tmf(attr), @company.send(attr)]}.to_h
        - attributes[Chouette::Company.tmf(:country_code)] = @company.country_code.present? ? label_for_country(@company.country_code) + ISO3166::Country[@company.country_code].translation(I18n.locale) : '-'
        = definition_list t("companies.form.sections.address"), attributes

        = simple_block_for @company, title: t("layouts.form.sections.codes") do |d|
          = d.attribute :registration_number

        = render 'codes/block', model: @company

      .col-lg-6.col-md-6.col-sm-12.col-xs-12
        - attributes = %w(name email phone fax url organizational_unit operating_department_name more).map { |attr| [Chouette::Company.tmf("default_contact_#{attr}"), @company.send("default_contact_#{attr}")]}.to_h
        = definition_list Chouette::Company.tmf(:default_contact), attributes

        - if @company.has_private_contact?
          - attributes =  %w(name email phone url more).map { |attr| [Chouette::Company.tmf("private_contact_#{attr}"), @company.send("private_contact_#{attr}")]}.to_h
          = definition_list Chouette::Company.tmf(:private_contact), attributes

        - if @company.has_customer_service_contact?
          - attributes =  %w(name email phone url more).map { |attr| [Chouette::Company.tmf("customer_service_contact_#{attr}"), @company.send("customer_service_contact_#{attr}")]}.to_h
          = definition_list Chouette::Company.tmf(:customer_service_contact), attributes

        = simple_block_for @company, title: Chouette::Company.tmf('is_referent') do |d|
          - if @company.is_referent
            = d.attribute :particulars, as: :count, value: @company.particulars, link: workbench_line_referential_companies_path(@workbench, :'q[referent_id_eq]' => @company.id)
            - if @company.particulars.present?
              table.table.table-bordered.mt-5
                thead
                  tr
                    th scope="col"
                      = Chouette::Company.tmf('id')
                    th scope="col"
                      = Chouette::Company.tmf('name')
                tbody
                  - @company.particulars.limit(5).each do |c|
                    tr
                      td
                        = c.get_objectid.short_id
                      td
                        = link_to(c.name, workbench_line_referential_company_path(@workbench, c))
          - else
            = d.attribute :referent, as: :association, link: ->(referent) { workbench_line_referential_company_path(@workbench, referent) }

        = simple_block_for @company, title: t("companies.form.sections.internals") do |d|
          = d.attribute :line_provider, as: :association, link: ->(line_provider) { workbench_line_referential_line_provider_path(@workbench, @company.line_provider_id) }

        = render 'shared/documentable/documents', documentable: @company, document_memberships_path: workbench_line_referential_company_document_memberships_path(@workbench, @company)