Sha256: cdc7be5529f409f0544add3a661aeceb9f7404836555c5e31a2c090dc0afefe1

Contents?: true

Size: 1.8 KB

Versions: 39

Compression:

Stored size: 1.8 KB

Contents

module ScaffoldHelper
    def default_collection_actions_for(content, scope = :admin)
      buttons = []

      if subject.can_show?(content) && lookup_context.exists?('show', lookup_context.prefixes, false)
        buttons << link_to(t('fullstack.admin.show', :default => "Show"), self.send(:"#{scope}_#{resource_name}_path", content), :class => "btn")
      end

      if subject.can_edit?(content)
        buttons << link_to(t('fullstack.admin.edit', :default => "Edit"), self.send(:"edit_#{scope}_#{resource_name}_path", content), :class => "btn")
      end

      if subject.can_destroy?(content)
        buttons << link_to(t('fullstack.admin.delete', :default => "Delete"),
                self.send(:"#{scope}_#{resource_name}_path", content),
                :confirm => t('fullstack.admin.are_you_sure', :default => "Are you sure?"), :method => "delete",
                :remote => true,  :class => "btn hide btn-danger"
                )
      end
      "#{buttons.join('&nbsp;')}".html_safe
    end

    def labelize_attribute_name(method)
    method ||= "id" 
         I18n.t("helpers.label.#{method}", :default => method.to_s.humanize)
    end

    def sort_link(method)
      method = "#{method}"
      super(@search, method, labelize_attribute_name(method))
    end
    
    def app_name
      Rails.application.class.to_s.split("::").first.underscore.humanize
    end
    
    def has_timestamps?(model)
      model.columns_hash["created_at"]
    end

    def has_locale?(model)
      model.columns_hash["locale"]
    end
        
    def positionable?(object_or_class)
      model = object_or_class.is_a?(Class) ? object_or_class : object_or_class.class
      model.ancestors.include?(Positionable)
    end
    
    def skip_filter!
      @skip_filter = true
    end
    
    def skip_filter
      @skip_filter
    end
    
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
fullstack-admin-0.2.5 app/helpers/scaffold_helper.rb
fullstack-admin-0.2.4 app/helpers/scaffold_helper.rb
fullstack-admin-0.2.3 app/helpers/scaffold_helper.rb
fullstack-admin-0.2.2 app/helpers/scaffold_helper.rb
fullstack-admin-0.2.1 app/helpers/scaffold_helper.rb
fullstack-admin-0.1.56 app/helpers/scaffold_helper.rb
fullstack-admin-0.1.55 app/helpers/scaffold_helper.rb
fullstack-admin-0.1.54 app/helpers/scaffold_helper.rb
fullstack-admin-0.1.53 app/helpers/scaffold_helper.rb
fullstack-admin-0.1.52 app/helpers/scaffold_helper.rb
fullstack-admin-0.1.51 app/helpers/scaffold_helper.rb
fullstack-admin-0.1.50 app/helpers/scaffold_helper.rb
fullstack-admin-0.1.49 app/helpers/scaffold_helper.rb
fullstack-admin-0.1.48 app/helpers/scaffold_helper.rb
fullstack-admin-0.1.47 app/helpers/scaffold_helper.rb
fullstack-admin-0.1.46 app/helpers/scaffold_helper.rb
fullstack-admin-0.1.45 app/helpers/scaffold_helper.rb
fullstack-admin-0.1.44 app/helpers/scaffold_helper.rb
fullstack-admin-0.1.43 app/helpers/scaffold_helper.rb