aboutsummaryrefslogtreecommitdiffstats
path: root/app/helpers/imports_helper.rb
blob: 62a09b216c7c3170fe497092c42223ad3f13f81a (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
# -*- coding: utf-8 -*-
module ImportsHelper

  # Import statuses helper
  def import_status(status, verbose: false, default_status: nil)
    status ||= default_status
    return unless status
    status = status.to_s.downcase
    out = if %w[new running pending].include? status
      content_tag :span, '', class: "fa fa-clock-o"
    else
      cls =''
      cls = 'success' if status == 'successful'
      cls = 'success' if status == 'ok'
      cls = 'warning' if status == 'warning'
      cls = 'danger' if %w[failed aborted canceled error].include? status

      content_tag :span, '', class: "fa fa-circle text-#{cls}"
    end
    if verbose
      out += content_tag :span do
        txt = "imports.status.#{status}".t(fallback: "")
      end
    end
    out
  end

  # Compliance check set messages
  def bootstrap_class_for_message_criticity message_criticity
    case message_criticity.downcase
      when "error", "aborted"
        "alert alert-danger"
      when "warning"
        "alert alert-warning"
      when "info"
        "alert alert-info"
      when "ok", "success"
        "alert alert-success"
      else
        message_criticity.to_s
    end
  end

  def import_message_content message
    export_message_content message
  end
end