Sha256: 8e73924a11f4fe30f01948f73af42b71583ad233a3d43b42805dedfc7257c86c
Contents?: true
Size: 1.69 KB
Versions: 6
Compression:
Stored size: 1.69 KB
Contents
module Headmin module AdminHelper include Headmin::FilterHelper include Headmin::NotificationHelper def current_model controller_name.classify.constantize end def bootstrap_icon(icon, options = {}) data = options.has_key?(:data) ? options[:data] : nil klass = options.has_key?(:class) ? options[:class] : nil content_tag(:i, class: "bi bi-#{icon} #{klass}", data: data) {} end def current_url?(url) uri = URI(url) path = uri.path query_string = uri.query matches_path = request.path.include?(path) matches_query = uri.query ? request.query_string.include?(query_string) : true is_root = request.fullpath == url if url == admin_root_path is_root else matches_path && matches_query end end def form_field_valid?(form, name) !form.object.errors.has_key?(name) end def form_field_validation_id(form, name) [form.object_name, name.to_s, 'validation'].join('_').parameterize.underscore end def form_field_validation_class(form, name) return nil if request.get? form.object.errors.has_key?(name) ? 'is-invalid' : 'is-valid' end def default_params params.select { |key, value| is_default_param?(key) } end def add_default_param_key(key) keys = default_param_keys || [] keys.push(key) @default_param_keys = keys end def default_param_keys @default_param_keys ||= [:page, :start, :length, :per_page] end def is_default_param?(key) default_param_keys.include?(key.to_sym) || is_sort_param_key?(key) end def is_sort_param_key?(key) key.to_s.include?('sort_') end end end
Version data entries
6 entries across 6 versions & 1 rubygems