aboutsummaryrefslogtreecommitdiffstats
path: root/app/views/referentials/show.html.slim
blob: b03fb9f53b5fbd83d7b86aed504b2928795a4d69 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
- breadcrumb @referential
/ PageHeader
= pageheader 'jeux-de-donnees',
             @referential.name,
             'Lorem ipsum dolor sit amet',
             t('last_update', time: l(@referential.updated_at, format: :short)),
             ((@referential.archived? || !policy(@referential).edit?) ? '' : link_to(t('actions.edit'), edit_referential_path(@referential), class: 'btn btn-default')) do

  / Below is secondary actions & optional contents (filters, ...)
  .row.mb-sm
    .col-lg-12.text-right
      - @referential.action_links.each do |link|
        - if link.is_a?(HTMLElement)
          = link.to_html(class: 'btn btn-primary')
        - else
          = link_to link.href,
              method: link.method,
              data: link.data,
              class: 'btn btn-primary' do
                = link.content

/ PageContent
.page_content
  .container-fluid
    .row
      .col-lg-6.col-md-6.col-sm-12.col-xs-12
        = definition_list t('metadatas'),
          { t('activerecord.attributes.referential.status') => @referential.archived? ? "<div class='td-block'><span class='fa fa-archive'></span><span>#{t('activerecord.attributes.referential.archived_at')}</span></div>".html_safe : "<div class='td-block'><span class='sb sb-lg sb-preparing'></span><span>#{t('activerecord.attributes.referential.archived_at_null')}</span></div>".html_safe,
            @referential.human_attribute_name(:validity_period) => (@referential.validity_period.present? ? t('validity_range', debut: l(@referential.try(:validity_period).try(:begin), format: :short), end: l(@referential.try(:validity_period).try(:end), format: :short)) : '-'),
            @referential.human_attribute_name(:organisation) => @referential.organisation.name,
            @referential.human_attribute_name(:published_at) => '-' }

    - if params[:q].present? or @reflines.any?
      .row
        .col-lg-12
          = render 'filters'

    - if @reflines.any?
      .row
        .col-lg-12
          / ID Codif, nom court, nom de la ligne, réseau, mode, transporteur principal, actions = [show, edit_notes]
          = table_builder_2 @reflines,
            [ \
              TableBuilderHelper::Column.new( \
                name: t('id_codif'), \
                attribute: Proc.new { |n| n.objectid.local_id }, \
                sortable: false \
              ), \
              TableBuilderHelper::Column.new( \
                key: :number, \
                attribute: 'number' \
              ), \
              TableBuilderHelper::Column.new( \
                key: :name, \
                attribute: 'name', \
                link_to: lambda do |line| \
                  referential_line_path(@referential, line) \
                end \
              ), \
              TableBuilderHelper::Column.new( \
                key: :deactivated, \
                attribute: Proc.new { |n| line_status(n.deactivated?) } \
              ), \
              TableBuilderHelper::Column.new( \
                key: :transport_mode, \
                attribute: Proc.new { |n| n.transport_mode ? t("enumerize.transport_mode.#{n.transport_mode}") : '' }, \
              ), \
              TableBuilderHelper::Column.new( \
                key: 'networks.name', \
                attribute: Proc.new { |n| n.try(:network).try(:name) } \
              ), \
              TableBuilderHelper::Column.new( \
                key: 'companies.name', \
                attribute: Proc.new { |n| n.try(:company).try(:name) } \
              ) \
            ],
            links: [:show],
            cls: 'table has-filter has-search'

          = new_pagination @reflines, 'pull-right'

    - unless @reflines.any?
      .row.mt-xs
        .col-lg-12
          = replacement_msg t('referential_lines.search_no_results')


/ Modal(s)
= modalbox 'purgeModal' do
  = simple_form_for [@referential, CleanUp.new] do |f|
    .modal-header
      h4.modal-title #{t('simple_form.labels.clean_up.title')}
    .modal-body
      .container-fluid
        .row
          .col-lg-8.col-ld-offset-2.col-md-8.col-md-offset-2.col-sm-8.col-sm-offset-2.col-xs-12
            = f.input :date_type, as: :radio_buttons, label: false

          .col-lg-8.col-ld-offset-2.col-md-8.col-md-offset-2.col-sm-8.col-sm-offset-2.col-xs-12
            label.control-label.begin_date = t('titles.clean_up.begin_date')
            label.control-label.end_date.hidden = t('titles.clean_up.end_date')
            = f.input :begin_date, as: :date, label: false, wrapper_html: { class: 'date smart_date' }

            = f.input :end_date, as: :date, label: t('titles.clean_up.end_date'), wrapper_html: { class: 'date cleanup_end_date_wrapper smart_date', id: "end_date" }

    .modal-footer
      button.btn.btn-link type='button' data-dismiss='modal' #{t('cancel')}
      - unless policy(@referential).archived?
        = f.button :submit, t('actions.clean_up') , class: 'btn btn-primary'