Module: ForemanDatacenter::ApplicationHelper
- Defined in:
- app/helpers/foreman_datacenter/application_helper.rb
Instance Method Summary collapse
- #associated_objects(object) ⇒ Object
- #display_fake_delete_if_authorized(options = {}, html_options = {}, as = 'button') ⇒ Object
- #documentation_url(section = "", options = {}) ⇒ Object
- #help_button ⇒ Object
- #muted_text(text, *ct) ⇒ Object
- #object_name(object) ⇒ Object
- #object_path(object) ⇒ Object
- #recursive_tags(text, tags) ⇒ Object
- #search_params(objects, parameter, sp) ⇒ Object
Instance Method Details
#associated_objects(object) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/helpers/foreman_datacenter/application_helper.rb', line 51 def associated_objects(object) case object when 'site' '(Racks, RackGroups, Devices, Interfaces, Ports, etc)' when 'rack_group' '(Racks, Devices, Interfaces, Ports, etc)' when 'rack' '(Devices, Interfaces, Ports, etc)' when 'platform' '(Devices, Interfaces, Ports, etc)' when 'device' '(Interfaces, Ports, etc)' when 'device_role' '(Devices)' when 'device_type' '(Devices)' when 'manufacturer' '(DeviceTypes, Templates, Devices, Interfaces, Port)' else '(...)' end end |
#display_fake_delete_if_authorized(options = {}, html_options = {}, as = 'button') ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/helpers/foreman_datacenter/application_helper.rb', line 25 def ( = {}, = {}, as = 'button') text = .delete(:text) || _("Delete") method = .delete(:method) || :delete = {:auth_action => :destroy}.merge() = {}.merge() if () link_to(text, , ) else "" end end |
#documentation_url(section = "", options = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/helpers/foreman_datacenter/application_helper.rb', line 12 def documentation_url(section = "", = {}) if request.env['PATH_INFO'].include?("datacenter") root_url = [:root_url] || "https://github.com/theforeman/foreman_datacenter/wiki" if section.empty? "https://github.com/theforeman/foreman_datacenter/wiki" else root_url + section end else super end end |
#help_button ⇒ Object
4 5 6 7 8 9 10 |
# File 'app/helpers/foreman_datacenter/application_helper.rb', line 4 def if request.env['PATH_INFO'].include?("datacenter") link_to(_("Help"), { :action => "welcome" }, { :class => 'btn btn-default' }) if File.exist?("#{ForemanDatacenter::Engine.root}/app/views/foreman_datacenter/#{controller_name}/welcome.html.erb") else super end end |
#muted_text(text, *ct) ⇒ Object
47 48 49 |
# File 'app/helpers/foreman_datacenter/application_helper.rb', line 47 def muted_text(text, *ct) (text, ct) end |
#object_name(object) ⇒ Object
79 80 81 |
# File 'app/helpers/foreman_datacenter/application_helper.rb', line 79 def object_name(object) object.model_name.element end |
#object_path(object) ⇒ Object
74 75 76 77 |
# File 'app/helpers/foreman_datacenter/application_helper.rb', line 74 def object_path(object) object_name = object.model_name.plural.gsub("foreman_datacenter_","") "/datacenter/#{object_name}/#{object.id}" end |
#recursive_tags(text, tags) ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'app/helpers/foreman_datacenter/application_helper.rb', line 37 def (text, ) return _("#{text}") if .empty? ct = [0].parameterize.underscore.to_sym if .length == 1 content_tag(ct, _("#{text}"), class: 'text-muted') else content_tag(ct, (text, .drop(1))) end end |
#search_params(objects, parameter, sp) ⇒ Object
83 84 85 86 87 88 89 90 |
# File 'app/helpers/foreman_datacenter/application_helper.rb', line 83 def search_params(objects, parameter, sp) str = "" objects.each_with_index do |o, i| str += ' or ' if i > 0 str += "#{sp}=#{o.send(parameter)}" end return str end |