Module: Para::TagHelper
- Included in:
- Admin::CrudResourcesController
- Defined in:
- app/helpers/para/tag_helper.rb
Instance Method Summary collapse
- #add_button_for(component, relation, model) ⇒ Object
- #icon_link_to(name, url_options = nil, options = nil, &block) ⇒ Object
- #listing_for(resources, options = {}) ⇒ Object
- #table_for(options) ⇒ Object
Instance Method Details
#add_button_for(component, relation, model) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'app/helpers/para/tag_helper.rb', line 54 def (component, relation, model) return unless can?(:create, model) partial_name = if component.subclassable? :subclassable_add_button else :add_button end render partial: find_partial_for(relation, partial_name), locals: { component: component, model: model } end |
#icon_link_to(name, url_options = nil, options = nil, &block) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'app/helpers/para/tag_helper.rb', line 3 def icon_link_to(name, = nil, = nil, &block) if block , = , name name = capture { block.call } end if (icon = .delete(:icon)) icon_tag = content_tag(:i, '', class: "fa fa-#{ icon }") name = [icon_tag, name].join(' ').html_safe end link_to(name, , ) end |
#listing_for(resources, options = {}) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/helpers/para/tag_helper.rb', line 17 def listing_for(resources, = {}) model = resources.model attributes = model_field_mappings(model).fields relation = .fetch(:relation, model.name.to_s.underscore.pluralize) allow_adding_resource = .fetch(:addable, true) force_list = .fetch(:force_list, false) partial = if !force_list && model.respond_to?(:roots) && can?(:tree, model) :tree else :list end render( partial: find_partial_for(relation, partial), locals: { component: @component, resources: resources, relation: relation, model: model, attributes: attributes, allow_adding_resource: allow_adding_resource } ) end |
#table_for(options) ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'app/helpers/para/tag_helper.rb', line 43 def table_for() partial = :table render( partial: find_partial_for( [:model].name.underscore.pluralize, partial ), locals: ) end |