aboutsummaryrefslogtreecommitdiffstats
path: root/app/views/workbenches/show.html.slim
blob: 213c9e5f2b87df53a07f384c8d4645c2a6ee50e7 (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
- breadcrumb @workbench
- page_header_content_for @workbench
- content_for :page_header_content do
  .row.mb-sm
    .col-lg-12.text-right
      - if policy(Workbench).update?
        = link_to t('workbenches.actions.configure'), edit_workbench_path(@workbench), class: 'btn btn-primary'
      - if policy(Referential).create?
        = link_to t('actions.import'), workbench_imports_path(@workbench), class: 'btn btn-primary'
        = link_to t('actions.export'), workbench_exports_path(@workbench), class: 'btn btn-primary'
        = link_to t('actions.add'), new_workbench_referential_path(@workbench), class: 'btn btn-primary'
      = link_to t('workbenches.actions.show_output'), workbench_output_path(@workbench), class: 'btn btn-primary'

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

    - if @wbench_refs.any?
      .row
        .col-lg-12
          .select_table
            = table_builder_2 @wbench_refs,
              [ \
                TableBuilderHelper::Column.new( \
                  key: :name, \
                  attribute: 'name', \
                  link_to: lambda do |referential| \
                    referential_path(referential) \
                  end \
                ), \
                TableBuilderHelper::Column.new( \
                  key: :archived_at, \
                  name: Referential.tmf('status'), \
                  attribute: Proc.new {|w| "<a href='' title='#{"referentials.states.#{w.state}".t}'>#{icon_for_referential_state(w.state)}</a>".html_safe} \
                ), \
                TableBuilderHelper::Column.new( \
                  key: :organisation, \
                  attribute: Proc.new {|w| w.organisation.name} \
                ), \
                TableBuilderHelper::Column.new( \
                  key: :validity_period, \
                  attribute: Proc.new {|w| w.validity_period.nil? ? '-' : t('validity_range', debut: l(w.try(:validity_period).try(:begin), format: :short), end: l(w.try(:validity_period).try(:end), format: :short))} \
                ), \
                TableBuilderHelper::Column.new( \
                  key: :lines, \
                  name: Referential.tmf('number_of_lines'), \
                  attribute: Proc.new {|w| w.lines.count} \
                ), \
                TableBuilderHelper::Column.new( \
                  key: :created_at, \
                  attribute: Proc.new {|w| l(w.created_at, format: :short)} \
                ), \
                TableBuilderHelper::Column.new( \
                  key: :updated_at, \
                  attribute: Proc.new {|w| l(w.updated_at, format: :short)} \
                ), \
                TableBuilderHelper::Column.new( \
                  key: :merged_at, \
                  attribute: Proc.new {|w| w.merged_at ? l(w.merged_at, format: :short) : '-'} \
                ) \
              ],
              selectable: ->(ref) { \
                @workbench.referentials.include?(ref) && \
                  !ref.pending? \
              },
              cls: 'table has-filter has-search',
              action: :index

            = multiple_selection_toolbox([:delete], collection_name: 'referentials')

          = new_pagination @wbench_refs, 'pull-right'

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

= javascript_tag do
  // | window.I18n = #{(I18n.backend.send(:translations).to_json).html_safe};

= javascript_pack_tag 'date_filters'