Module: BootstrapBuilders::ApplicationHelper
- Defined in:
- app/helpers/bootstrap_builders/application_helper.rb
Instance Method Summary collapse
- #bb_attribute_rows(model, attributes) ⇒ Object
- #bb_btn(*args) ⇒ Object
- #bb_destroy_btn(*args) ⇒ Object
- #bb_edit_btn(*args) ⇒ Object
- #bb_flash(args = {}) ⇒ Object
- #bb_index_btn(*args) ⇒ Object
- #bb_new_btn(*args) ⇒ Object
- #bb_panel(*opts, &blk) ⇒ Object
- #bb_show_btn(*args) ⇒ Object
- #bb_table(args = {}, &blk) ⇒ Object
- #bb_tabs(*args) {|tabs| ... } ⇒ Object
Instance Method Details
#bb_attribute_rows(model, attributes) ⇒ Object
2 3 4 |
# File 'app/helpers/bootstrap_builders/application_helper.rb', line 2 def bb_attribute_rows(model, attributes) BootstrapBuilders::AttributeRows.new(model: model, attributes: attributes, context: self).html end |
#bb_btn(*args) ⇒ Object
22 23 24 25 26 27 28 |
# File 'app/helpers/bootstrap_builders/application_helper.rb', line 22 def bb_btn(*args) args = BootstrapBuilders::Button.parse_url_args(args) args[:context] = self = BootstrapBuilders::Button.new(args) .classes.add("bb-btn") .html end |
#bb_destroy_btn(*args) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'app/helpers/bootstrap_builders/application_helper.rb', line 43 def bb_destroy_btn(*args) args = BootstrapBuilders::Button.parse_url_args(args) args[:label] = t("delete") unless args.key?(:label) args[:title] ||= t("delete") if args[:mini] args[:data] ||= {} args[:data][:confirm] ||= t("are_you_sure") = BootstrapBuilders::Button.new(args.merge(icon: "remove", context: self, can_type: :destroy, method: :delete)) .classes.remove(["btn-default"]) .classes.add(["btn-danger", "bb-btn", "bb-btn-destroy"]) .classes.add("bb-btn-destroy-#{button.can_model_class.name.tableize.singularize}") if .can_model_class .classes.add("bb-btn-destroy-#{button.can_model_class.name.tableize.singularize}-#{button.can_model.id}") if .can_model .html end |
#bb_edit_btn(*args) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/helpers/bootstrap_builders/application_helper.rb', line 30 def bb_edit_btn(*args) args = BootstrapBuilders::Button.parse_url_args(args) args[:label] = t("edit") unless args.key?(:label) args[:title] ||= t("edit") if args[:mini] args[:url] = [:edit, args.fetch(:url)] if args[:url] && !args[:url].is_a?(Array) && BootstrapBuilders::IsAChecker.is_a?(args[:url], "ActiveRecord::Base") = BootstrapBuilders::Button.new(args.merge(icon: "wrench", context: self, can_type: :edit)) .classes.add(["bb-btn", "bb-btn-edit"]) .classes.add("bb-btn-edit-#{button.can_model_class.name.tableize.singularize}") if .can_model_class .classes.add("bb-btn-edit-#{button.can_model_class.name.tableize.singularize}-#{button.can_model.id}") if .can_model .html end |
#bb_flash(args = {}) ⇒ Object
101 102 103 104 |
# File 'app/helpers/bootstrap_builders/application_helper.rb', line 101 def bb_flash(args = {}) flash = BootstrapBuilders::Flash.new(args.merge(context: self)) flash.html end |
#bb_index_btn(*args) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'app/helpers/bootstrap_builders/application_helper.rb', line 70 def bb_index_btn(*args) args = BootstrapBuilders::Button.parse_url_args(args) args[:title] ||= t("index") if args[:mini] = BootstrapBuilders::Button.new(args.merge(icon: "table", context: self, can_type: :index)) if .label.to_s.strip.empty? if .can_model_class .label = .can_model_class.model_name.human(count: 2) else .label = t("index") end end .classes.add(["bb-btn", "bb-btn-index"]) .classes.add("bb-btn-index-#{button.can_model_class.name.tableize}") if .can_model_class .html end |
#bb_new_btn(*args) ⇒ Object
59 60 61 62 63 64 65 66 67 68 |
# File 'app/helpers/bootstrap_builders/application_helper.rb', line 59 def bb_new_btn(*args) args = BootstrapBuilders::Button.parse_url_args(args) args[:label] = t("add_new") unless args.key?(:label) args[:title] ||= t("new") if args[:mini] = BootstrapBuilders::Button.new(args.merge(icon: "pencil", context: self, can_type: :new)) .classes.add(["bb-btn", "bb-btn-new"]) .classes.add("bb-btn-new-#{button.can_model_class.name.tableize.singularize}") if .can_model_class .html end |
#bb_panel(*opts, &blk) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/helpers/bootstrap_builders/application_helper.rb', line 6 def bb_panel(*opts, &blk) title = opts.shift unless opts.first.is_a?(Hash) width = opts.shift unless opts.first.is_a?(Hash) if opts.length == 1 && opts.first.is_a?(Hash) args = opts.first title = args.fetch(:title) if args.key?(:title) width = args[:width] if args.key?(:width) right = args[:right] if args.key?(:right) else args = {} end BootstrapBuilders::Panel.new(args.merge(title: title, width: width, right: right, block: blk, context: self)).html end |
#bb_show_btn(*args) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 |
# File 'app/helpers/bootstrap_builders/application_helper.rb', line 89 def bb_show_btn(*args) args = BootstrapBuilders::Button.parse_url_args(args) args[:label] = t("show") unless args.key?(:label) args[:title] ||= t("show") if args[:mini] = BootstrapBuilders::Button.new(args.merge(icon: "square-o", context: self, can_type: :show)) .classes.add(["bb-btn", "bb-btn-show"]) .classes.add("bb-btn-show-#{button.can_model_class.name.tableize.singularize}") if .can_model_class .classes.add("bb-btn-show-#{button.can_model_class.name.tableize.singularize}-#{button.can_model.id}") if .can_model .html end |
#bb_table(args = {}, &blk) ⇒ Object
106 107 108 109 |
# File 'app/helpers/bootstrap_builders/application_helper.rb', line 106 def bb_table(args = {}, &blk) table = BootstrapBuilders::Table.new(args.merge(context: self, blk: blk)) table.html end |
#bb_tabs(*args) {|tabs| ... } ⇒ Object
111 112 113 114 115 116 117 118 119 120 121 |
# File 'app/helpers/bootstrap_builders/application_helper.rb', line 111 def bb_tabs(*args) args = BootstrapBuilders::ArgumentsParser.new( arguments: args, argument_hash_default: {context: self}, short_true_arguments: [:justified, :pills, :stacked] ).arguments tabs = BootstrapBuilders::Tabs.new(*args) yield tabs tabs.to_html end |