Sha256: e549528133f42aa6c8c0ab4fe9c97fc5e4e3cca93ccc00f6ef5da7c06583ea12

Contents?: true

Size: 1022 Bytes

Versions: 3

Compression:

Stored size: 1022 Bytes

Contents

module DigitaloceanImagesHelper
  def digitalocean_image_field(f)
    images = @compute_resource.available_images
    images.each { |image| image.name = image.id if image.name.nil? }
    select_f f, :uuid, images.to_a.sort_by(&:full_name),
      :id, :full_name, {}, :label => _('Image')
  end

  def select_image(f, compute_resource)
    images = possible_images(compute_resource, nil, nil)

    select_f(f,
             :image_id,
             images,
             :id,
             :slug,
             { :include_blank => (images.empty? || images.size == 1) ? false : _('Please select an image') },
             { :label => ('Image'), :disabled => images.empty? } )
  end

  def select_region(f, compute_resource)
    regions = compute_resource.regions
    f.object.region = compute_resource.region
    select_f(f,
             :region,
             regions,
             :slug,
             :slug,
             {},
             :label => ('Region'),
             :disabled => compute_resource.images.empty?)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
foreman_digitalocean-1.2.0 app/helpers/digitalocean_images_helper.rb
foreman_digitalocean-1.1.0 app/helpers/digitalocean_images_helper.rb
foreman_digitalocean-1.0.0 app/helpers/digitalocean_images_helper.rb