Module: Promethee::Rails::Helper
- Defined in:
- lib/promethee/rails/helper.rb
Instance Method Summary collapse
- #blob_from_data(blob_data = {}) ⇒ Object
- #promethee(data, options = {}) ⇒ Object
-
#promethee_bem_classes(*args) ⇒ Object
promethee_bem_classes ‘promethee-edit__move__droppable’, ‘–{type}’, ‘–first’ -> promethee-edit__move__droppable promethee-edit__move__droppable–{type} promethee-edit__move__droppable–{type}–first“.
- #promethee_class_for(component, *modifiers) ⇒ Object
- #promethee_component_partials ⇒ Object
- #promethee_component_render_icon(icon) ⇒ Object
- #promethee_id_for(component) ⇒ Object
- #promethee_localize_partials ⇒ Object
- #promethee_preset_partials ⇒ Object
- #promethee_preset_render_icon(icon) ⇒ Object
- #promethee_template_partials ⇒ Object
- #promethee_util_partials ⇒ Object
Instance Method Details
#blob_from_data(blob_data = {}) ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/promethee/rails/helper.rb', line 49 def blob_from_data(blob_data = {}) return unless blob_data&.has_key? :id blob_find_method = ActiveStorage::Blob.respond_to?(:find_signed!) ? :find_signed! : :find_signed ActiveStorage::Blob.public_send blob_find_method, blob_data[:id] rescue nil end |
#promethee(data, options = {}) ⇒ Object
2 3 4 |
# File 'lib/promethee/rails/helper.rb', line 2 def promethee(data, = {}) render partial: 'promethee/show', locals: { master_data: data, localization_data: [:l] } end |
#promethee_bem_classes(*args) ⇒ Object
promethee_bem_classes ‘promethee-edit__move__droppable’, ‘–{type}’, ‘–first’ -> promethee-edit__move__droppable promethee-edit__move__droppable–{type} promethee-edit__move__droppable–{type}–first“
59 60 61 62 63 64 65 66 67 |
# File 'lib/promethee/rails/helper.rb', line 59 def promethee_bem_classes(*args) classes = '' current_class = '' args.each do |arg| current_class << arg classes << "#{current_class} " end classes end |
#promethee_class_for(component, *modifiers) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/promethee/rails/helper.rb', line 6 def promethee_class_for(component, *modifiers) base = "promethee__component" component_base = "#{base}__#{component[:type]}" [ base, component_base, modifiers.map { |modifier| "#{component_base}--#{modifier}" } ].flatten.select(&:present?).join ' ' end |
#promethee_component_partials ⇒ Object
21 22 23 |
# File 'lib/promethee/rails/helper.rb', line 21 def promethee_component_partials promethee_partials_for 'components/*/_edit_*.html.erb' end |
#promethee_component_render_icon(icon) ⇒ Object
25 26 27 |
# File 'lib/promethee/rails/helper.rb', line 25 def promethee_component_render_icon(icon) render(partial: "promethee/components/#{icon}/icon", formats: :svg).to_json.html_safe end |
#promethee_id_for(component) ⇒ Object
17 18 19 |
# File 'lib/promethee/rails/helper.rb', line 17 def promethee_id_for(component) "promethee-component-#{component[:id]}" end |
#promethee_localize_partials ⇒ Object
45 46 47 |
# File 'lib/promethee/rails/helper.rb', line 45 def promethee_localize_partials promethee_partials_for 'components/*/_localize.html.erb' end |
#promethee_preset_partials ⇒ Object
41 42 43 |
# File 'lib/promethee/rails/helper.rb', line 41 def promethee_preset_partials promethee_partials_for 'presets/_*.html.erb' end |
#promethee_preset_render_icon(icon) ⇒ Object
29 30 31 |
# File 'lib/promethee/rails/helper.rb', line 29 def promethee_preset_render_icon(icon) render(partial: "promethee/presets/icon_#{icon}", formats: :svg).to_json.html_safe end |
#promethee_template_partials ⇒ Object
37 38 39 |
# File 'lib/promethee/rails/helper.rb', line 37 def promethee_template_partials promethee_partials_for 'templates/_*.html.erb' end |
#promethee_util_partials ⇒ Object
33 34 35 |
# File 'lib/promethee/rails/helper.rb', line 33 def promethee_util_partials promethee_partials_for 'utils/_*.html.erb' end |