Sha256: 077c9f00b7934edaee49e5025c92721a6c59236a77ffd245f4381f86355da0a8

Contents?: true

Size: 966 Bytes

Versions: 3

Compression:

Stored size: 966 Bytes

Contents

module KonoUtils::Object::Cell::Forms::Fields # namespace
  ##
  # Bottone per la rimozione della riga nested
  # *Options:*
  # - ajax_remove: [Boolean] -> indica se vogliamo che venga veramente cancellato il record
  class NestedWrappers::RemoveButton < KonoUtils::Object::Cell::Buttons::Delete


    def url_to
      if ajax_remove?
        destroy_custom_polymorphic_path(model, format: :json)
      else
        "#"
      end
    end

    ##
    # Controlla se questo record deve essere cancellato o meno via ajax
    # @return [TrueClass, FalseClass]
    def ajax_remove?
      !!options.fetch(:ajax_remove, false)
    end

    def automatic_remove_options
      if ajax_remove?
        super.merge(remote: true)
      else
        {}
      end
    end

    def show(&block)
      super + render(&block).html_safe
    end

    ##
    # ID div in cui definire che l'elemento viene rimosso
    def remove_target
      options[:remove_target]
    end


  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
kono_utils_bootstrap_view4-0.1.0.pre.rc.3 app/concepts/kono_utils/object/cell/forms/fields/nested_wrappers/remove_button.rb
kono_utils_bootstrap_view4-0.1.0.pre.rc.2 app/concepts/kono_utils/object/cell/forms/fields/nested_wrappers/remove_button.rb
kono_utils_bootstrap_view4-0.1.0.pre.rc.1 app/concepts/kono_utils/object/cell/forms/fields/nested_wrappers/remove_button.rb