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_progress_bar(*opts) ⇒ 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
16 17 18 19 20 21 22 |
# File 'app/helpers/bootstrap_builders/application_helper.rb', line 16 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
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/helpers/bootstrap_builders/application_helper.rb', line 37 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
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/helpers/bootstrap_builders/application_helper.rb', line 24 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
95 96 97 98 |
# File 'app/helpers/bootstrap_builders/application_helper.rb', line 95 def bb_flash(args = {}) flash = BootstrapBuilders::Flash.new(args.merge(context: self)) flash.html end |
#bb_index_btn(*args) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'app/helpers/bootstrap_builders/application_helper.rb', line 64 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
53 54 55 56 57 58 59 60 61 62 |
# File 'app/helpers/bootstrap_builders/application_helper.rb', line 53 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: "plus", 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 |
# File 'app/helpers/bootstrap_builders/application_helper.rb', line 6 def bb_panel(*opts, &blk) panel = BootstrapBuilders::Panel.with_parsed_args(*opts, &blk) panel.context = self panel.html end |
#bb_progress_bar(*opts) ⇒ Object
12 13 14 |
# File 'app/helpers/bootstrap_builders/application_helper.rb', line 12 def (*opts) BootstrapBuilders::ProgressBar.with_parsed_args(*opts) end |
#bb_show_btn(*args) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 |
# File 'app/helpers/bootstrap_builders/application_helper.rb', line 83 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
100 101 102 103 |
# File 'app/helpers/bootstrap_builders/application_helper.rb', line 100 def bb_table(args = {}, &blk) table = BootstrapBuilders::Table.new(args.merge(context: self, blk: blk)) table.html end |
#bb_tabs(*args) {|tabs| ... } ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 |
# File 'app/helpers/bootstrap_builders/application_helper.rb', line 105 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 |