Sha256: ccd632abdebaa83a9288a55fe668e5a87777ee7b68b1889d4a419f44fdeeb47b

Contents?: true

Size: 1.65 KB

Versions: 21

Compression:

Stored size: 1.65 KB

Contents

module Utilities::PageHelper
  # @param [BaseModel] base_class
  def title_mod_g(base_class)
    "#{t("edit")} #{base_class.model_name.human}"
  end

  # @param [BaseModel] base_class
  def title_new_g(base_class)
    "#{t("new")} #{base_class.model_name.human}"
  end

  # Quando e se servirà verrà testato:
  # - form_field dovrebbe essere il campo del modello che ha associato il has_one_attached
  # def link_download(form_field)
  #   link_to rails_blob_path(form_field, disposition: 'attachment'), class: "btn btn-primary", style: "margin:5px;" do
  #     icon("fas", "eye") + content_tag(:span, " #{I18n.t('download')} #{form_field.filename.to_s}")
  #   end
  # end
  #
  # def link_delete(form_field, delete_link)
  #   link_to delete_link, data: {turbo_method: :delete, turbo_confirm: t('are_you_sure')},
  #           class: "btn btn-danger", style: "margin:5px;" do
  #     icon("fas", "times") + content_tag(:span, " #{I18n.t('delete')} #{form_field.filename.to_s}")
  #   end
  # end

  # @param [TrueClass, FalseClass] valore
  def boolean_to_icon(valore)
    if valore
      icon("check-lg", class: "text-success")
    else
      icon("x-lg", class: "text-danger")
    end
  end

  # @param [String] path
  # @param [Hash] options
  def new_button(path, options = {})
    options.merge!({class: 'btn btn-success btn-sm'})
    link_to icon("plus-lg", I18n.t(:new)), path, options
  end

  # @param [BaseModel] obj instance
  # @param [Symbol] field
  def error_messages_for(obj, field)
    if obj.errors.include?(field)
      msg = obj.errors.full_messages_for(field).join(",")
      content_tag(:div, icon("x-circle-fill", msg), class: "invalid-feedback")
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
base_editing_bootstrap-0.16.1 app/helpers/utilities/page_helper.rb
base_editing_bootstrap-0.16.0 app/helpers/utilities/page_helper.rb
base_editing_bootstrap-0.15.0 app/helpers/utilities/page_helper.rb
base_editing_bootstrap-0.14.0 app/helpers/utilities/page_helper.rb
base_editing_bootstrap-0.13.0 app/helpers/utilities/page_helper.rb
base_editing_bootstrap-0.12.0 app/helpers/utilities/page_helper.rb
base_editing_bootstrap-0.11.0 app/helpers/utilities/page_helper.rb
base_editing_bootstrap-0.10.2 app/helpers/utilities/page_helper.rb
base_editing_bootstrap-0.10.1 app/helpers/utilities/page_helper.rb
base_editing_bootstrap-0.10.0 app/helpers/utilities/page_helper.rb
base_editing_bootstrap-0.9.1 app/helpers/utilities/page_helper.rb
base_editing_bootstrap-0.9.0 app/helpers/utilities/page_helper.rb
base_editing_bootstrap-0.8.0 app/helpers/utilities/page_helper.rb
base_editing_bootstrap-0.7.0 app/helpers/utilities/page_helper.rb
base_editing_bootstrap-0.6.0 app/helpers/utilities/page_helper.rb
base_editing_bootstrap-0.4.1 app/helpers/utilities/page_helper.rb
base_editing_bootstrap-0.4.0 app/helpers/utilities/page_helper.rb
base_editing_bootstrap-0.3.0 app/helpers/utilities/page_helper.rb
base_editing_bootstrap-0.2.0 app/helpers/utilities/page_helper.rb
base_editing_bootstrap-0.1.4 app/helpers/utilities/page_helper.rb