Module: ForemanDatacenter::DevicesHelper
- Defined in:
- app/helpers/foreman_datacenter/devices_helper.rb
Instance Method Summary collapse
- #device_manufacturers_for_select(selected_id = nil) ⇒ Object
- #device_roles_for_select(selected_id = nil) ⇒ Object
- #device_type_size_for_device_form(f, device_type_id) ⇒ Object
- #device_types_for_device_form(f, manufacturer_id, device_type_id = nil) ⇒ Object
- #platforms_for_device_form(f, platform_id) ⇒ Object
- #racks_for_device_form(f, site_id, rack_id = nil) ⇒ Object
- #sites_for_device_form(site_id) ⇒ Object
Instance Method Details
#device_manufacturers_for_select(selected_id = nil) ⇒ Object
7 8 9 |
# File 'app/helpers/foreman_datacenter/devices_helper.rb', line 7 def device_manufacturers_for_select(selected_id = nil) (Manufacturer.all, 'id', 'name', selected_id) end |
#device_roles_for_select(selected_id = nil) ⇒ Object
3 4 5 |
# File 'app/helpers/foreman_datacenter/devices_helper.rb', line 3 def device_roles_for_select(selected_id = nil) (DeviceRole.all, 'id', 'name', selected_id) end |
#device_type_size_for_device_form(f, device_type_id) ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'app/helpers/foreman_datacenter/devices_helper.rb', line 27 def device_type_size_for_device_form(f, device_type_id) if device_type_id device_type = DeviceType.find(device_type_id) height = device_type.u_height else height = 1 end text_f f, :size, type: 'number', min: 0, value: height, id: 'device_type_size', label: 'Size', help_inline: 'For multi-U devices, how many rack units occupied be device.' end |
#device_types_for_device_form(f, manufacturer_id, device_type_id = nil) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/helpers/foreman_datacenter/devices_helper.rb', line 11 def device_types_for_device_form(f, manufacturer_id, device_type_id = nil) if manufacturer_id collection = DeviceType.select(:id, :model). where(manufacturer_id: manufacturer_id). all else collection = [] end selectable_f f, :device_type_id, (collection, 'id', 'model', device_type_id), { include_blank: 'Choose a device type'}, { required: true, label: 'Device Type', :onchange => 'devicesNewDeviceTypeSelected(this)', :'data-url' => device_type_size_devices_path } end |
#platforms_for_device_form(f, platform_id) ⇒ Object
60 61 62 63 64 65 |
# File 'app/helpers/foreman_datacenter/devices_helper.rb', line 60 def platforms_for_device_form(f, platform_id) collection = Platform.select(:id, :name).all selectable_f f, :platform_id, (collection, 'id', 'name', platform_id), { include_blank: 'Choose a platform', label: 'Platform' } end |
#racks_for_device_form(f, site_id, rack_id = nil) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/helpers/foreman_datacenter/devices_helper.rb', line 38 def racks_for_device_form(f, site_id, rack_id = nil) if site_id collection = Rack.where(site_id: site_id).select(:id, :name).all else collection = [] end selectable_f f, :rack_id, (collection, 'id', 'name', rack_id), { include_blank: 'Choose a rack' }, { required: true, label: 'Rack' } end |
#sites_for_device_form(site_id) ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'app/helpers/foreman_datacenter/devices_helper.rb', line 50 def sites_for_device_form(site_id) collection = Site.select(:id, :name).all select_tag :site_id, (collection, 'id', 'name', site_id), { :include_blank => 'Choose a site', :onchange => 'devicesNewSiteSelected(this)', :'data-url' => racks_devices_path, :class => 'form-control' } end |