Sha256: 449f9be291cf186db6fcffd0b3cd13abdf6d1bb01938740d294b519e519c5cc9

Contents?: true

Size: 1.29 KB

Versions: 13

Compression:

Stored size: 1.29 KB

Contents

# frozen_string_literal: true

module Tramway::Admin::ActionsHelper
  def destroy_is_available?(association_object, _main_object)
    ::Tramway::Admin.action_is_available?(
      association_object,
      project: (@application_engine || @application.name),
      model_name: association_object.model.class.name,
      role: current_admin.role,
      action: :destroy
    )
  end

  def update_is_available?(association_object, _main_object)
    ::Tramway::Admin.action_is_available?(
      association_object,
      project: (@application_engine || @application.name),
      model_name: association_object.model.class.name,
      role: current_admin.role,
      action: :update
    )
  end

  def create_is_available?(association_class)
    ::Tramway::Admin.action_is_available?(
      nil,
      project: (@application_engine || @application.name),
      model_name: association_class,
      role: current_admin.role,
      action: :create
    )
  end

  # delete_button is in smart-buttons gem

  def edit_button(url:, button_options:)
    link_to(url, **button_options) { yield }
  end

  def habtm_destroy_is_available?(association_object, main_object)
    ::Tramway::Admin.forms&.include?("#{main_object.model.class.to_s.underscore.pluralize}/remove_#{association_object.model.class.to_s.underscore}")
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
tramway-admin-5.0 app/helpers/tramway/admin/actions_helper.rb
tramway-admin-4.1.2.1 app/helpers/tramway/admin/actions_helper.rb
tramway-admin-4.1.2 app/helpers/tramway/admin/actions_helper.rb
tramway-admin-4.1.1.5 app/helpers/tramway/admin/actions_helper.rb
tramway-admin-4.1.1.4 app/helpers/tramway/admin/actions_helper.rb
tramway-admin-4.1.1.3 app/helpers/tramway/admin/actions_helper.rb
tramway-admin-4.1.1.2 app/helpers/tramway/admin/actions_helper.rb
tramway-admin-4.1.1.1 app/helpers/tramway/admin/actions_helper.rb
tramway-admin-4.1.1 app/helpers/tramway/admin/actions_helper.rb
tramway-admin-4.1.0.1 app/helpers/tramway/admin/actions_helper.rb
tramway-admin-4.1 app/helpers/tramway/admin/actions_helper.rb
tramway-admin-4.0.1.1 app/helpers/tramway/admin/actions_helper.rb
tramway-admin-4.0.1 app/helpers/tramway/admin/actions_helper.rb