Class: DSMediaLibrary::FormHelper::MediaLibrary
- Inherits:
-
Struct
- Object
- Struct
- DSMediaLibrary::FormHelper::MediaLibrary
- Defined in:
- app/helpers/ds_media_library/form_helper.rb
Instance Attribute Summary collapse
-
#dimensions ⇒ Object
Returns the value of attribute dimensions.
-
#field ⇒ Object
Returns the value of attribute field.
-
#helptext ⇒ Object
Returns the value of attribute helptext.
-
#ids ⇒ Object
Returns the value of attribute ids.
-
#label ⇒ Object
Returns the value of attribute label.
-
#multiple ⇒ Object
Returns the value of attribute multiple.
-
#optional ⇒ Object
Returns the value of attribute optional.
-
#preview ⇒ Object
Returns the value of attribute preview.
-
#required ⇒ Object
Returns the value of attribute required.
Class Method Summary collapse
Instance Method Summary collapse
- #field_id_name ⇒ Object
- #field_type ⇒ Object
- #file_field_name ⇒ Object
- #height ⇒ Object
- #html_id ⇒ Object
- #label_css_class ⇒ Object
- #root ⇒ Object
- #root_folders ⇒ Object
- #root_resources ⇒ Object
- #selected_resources ⇒ Object
- #single_field ⇒ Object
- #width ⇒ Object
Instance Attribute Details
#dimensions ⇒ Object
Returns the value of attribute dimensions
11 12 13 |
# File 'app/helpers/ds_media_library/form_helper.rb', line 11 def dimensions @dimensions end |
#field ⇒ Object
Returns the value of attribute field
11 12 13 |
# File 'app/helpers/ds_media_library/form_helper.rb', line 11 def field @field end |
#helptext ⇒ Object
Returns the value of attribute helptext
11 12 13 |
# File 'app/helpers/ds_media_library/form_helper.rb', line 11 def helptext @helptext end |
#ids ⇒ Object
Returns the value of attribute ids
11 12 13 |
# File 'app/helpers/ds_media_library/form_helper.rb', line 11 def ids @ids end |
#label ⇒ Object
Returns the value of attribute label
11 12 13 |
# File 'app/helpers/ds_media_library/form_helper.rb', line 11 def label @label end |
#multiple ⇒ Object
Returns the value of attribute multiple
11 12 13 |
# File 'app/helpers/ds_media_library/form_helper.rb', line 11 def multiple @multiple end |
#optional ⇒ Object
Returns the value of attribute optional
11 12 13 |
# File 'app/helpers/ds_media_library/form_helper.rb', line 11 def optional @optional end |
#preview ⇒ Object
Returns the value of attribute preview
11 12 13 |
# File 'app/helpers/ds_media_library/form_helper.rb', line 11 def preview @preview end |
#required ⇒ Object
Returns the value of attribute required
11 12 13 |
# File 'app/helpers/ds_media_library/form_helper.rb', line 11 def required @required end |
Class Method Details
.from_params(params) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/helpers/ds_media_library/form_helper.rb', line 12 def self.from_params params new( Array(params[:ids] || []).map(&:to_i), params[:field], params[:label], params[:multiple] == "true", params[:optional] == "true", params[:dimensions], params[:helptext], params[:preview] == "true", params[:required] == "true", ) end |
Instance Method Details
#field_id_name ⇒ Object
42 43 44 45 46 47 48 |
# File 'app/helpers/ds_media_library/form_helper.rb', line 42 def field_id_name if multiple :"#{single_field}_ids" else :"#{field}_id" end end |
#field_type ⇒ Object
50 51 52 |
# File 'app/helpers/ds_media_library/form_helper.rb', line 50 def field_type multiple ? "checkbox" : "radio" end |
#file_field_name ⇒ Object
34 35 36 37 38 39 40 |
# File 'app/helpers/ds_media_library/form_helper.rb', line 34 def file_field_name if multiple :"new_#{single_field}_files" else :"#{field}_file" end end |
#height ⇒ Object
70 71 72 |
# File 'app/helpers/ds_media_library/form_helper.rb', line 70 def height dimensions.split("x").last if dimensions end |
#html_id ⇒ Object
54 55 56 |
# File 'app/helpers/ds_media_library/form_helper.rb', line 54 def html_id "media-modal-#{field}" end |
#label_css_class ⇒ Object
58 59 60 |
# File 'app/helpers/ds_media_library/form_helper.rb', line 58 def label_css_class "optional" if optional end |
#root ⇒ Object
74 75 76 |
# File 'app/helpers/ds_media_library/form_helper.rb', line 74 def root @root ||= Folder.root end |
#root_folders ⇒ Object
78 79 80 |
# File 'app/helpers/ds_media_library/form_helper.rb', line 78 def root_folders root.children end |
#root_resources ⇒ Object
82 83 84 |
# File 'app/helpers/ds_media_library/form_helper.rb', line 82 def root_resources root.resources end |
#selected_resources ⇒ Object
26 27 28 |
# File 'app/helpers/ds_media_library/form_helper.rb', line 26 def selected_resources DSNode::Resource.find(ids) end |
#single_field ⇒ Object
30 31 32 |
# File 'app/helpers/ds_media_library/form_helper.rb', line 30 def single_field field.to_s.singularize.to_sym end |
#width ⇒ Object
66 67 68 |
# File 'app/helpers/ds_media_library/form_helper.rb', line 66 def width dimensions.split("x").first if dimensions end |