Module: BootstrapBuilders::ButtonsHelper
- Included in:
- ApplicationHelper
- Defined in:
- app/helpers/bootstrap_builders/buttons_helper.rb
Instance Method Summary collapse
- #bb_btn(*args) ⇒ Object
- #bb_btn_drop_down(*args) {|btn_drop_down| ... } ⇒ Object
- #bb_destroy_btn(*args) ⇒ Object
- #bb_edit_btn(*args) ⇒ Object
- #bb_index_btn(*args) ⇒ Object
- #bb_new_btn(*args) ⇒ Object
- #bb_show_btn(*args) ⇒ Object
Instance Method Details
#bb_btn(*args) ⇒ Object
2 3 4 5 6 7 8 |
# File 'app/helpers/bootstrap_builders/buttons_helper.rb', line 2 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_btn_drop_down(*args) {|btn_drop_down| ... } ⇒ Object
10 11 12 13 14 15 16 |
# File 'app/helpers/bootstrap_builders/buttons_helper.rb', line 10 def bb_btn_drop_down(*args) btn_drop_down = BootstrapBuilders::ButtonDropDown.new(*args) btn_drop_down.view_context = self yield btn_drop_down btn_drop_down.html end |
#bb_destroy_btn(*args) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/helpers/bootstrap_builders/buttons_helper.rb', line 31 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-#{.can_model_class.name.tableize.singularize}") if .can_model_class .classes.add("bb-btn-destroy-#{.can_model_class.name.tableize.singularize}-#{.can_model.id}") if .can_model .html end |
#bb_edit_btn(*args) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/helpers/bootstrap_builders/buttons_helper.rb', line 18 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-#{.can_model_class.name.tableize.singularize}") if .can_model_class .classes.add("bb-btn-edit-#{.can_model_class.name.tableize.singularize}-#{.can_model.id}") if .can_model .html end |
#bb_index_btn(*args) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'app/helpers/bootstrap_builders/buttons_helper.rb', line 58 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-#{.can_model_class.name.tableize}") if .can_model_class .html end |
#bb_new_btn(*args) ⇒ Object
47 48 49 50 51 52 53 54 55 56 |
# File 'app/helpers/bootstrap_builders/buttons_helper.rb', line 47 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-#{.can_model_class.name.tableize.singularize}") if .can_model_class .html end |
#bb_show_btn(*args) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 |
# File 'app/helpers/bootstrap_builders/buttons_helper.rb', line 77 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-#{.can_model_class.name.tableize.singularize}") if .can_model_class .classes.add("bb-btn-show-#{.can_model_class.name.tableize.singularize}-#{.can_model.id}") if .can_model .html end |