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.26 app/helpers/scaffold_helper.rb
fullstack-admin-0.2.25 app/helpers/scaffold_helper.rb
fullstack-admin-0.2.24 app/helpers/scaffold_helper.rb
fullstack-admin-0.2.23 app/helpers/scaffold_helper.rb
fullstack-admin-0.2.22 app/helpers/scaffold_helper.rb
fullstack-admin-0.2.21 app/helpers/scaffold_helper.rb
fullstack-admin-0.2.20 app/helpers/scaffold_helper.rb
fullstack-admin-0.2.19 app/helpers/scaffold_helper.rb
fullstack-admin-0.2.18 app/helpers/scaffold_helper.rb
fullstack-admin-0.2.17 app/helpers/scaffold_helper.rb
fullstack-admin-0.2.16 app/helpers/scaffold_helper.rb
fullstack-admin-0.2.15 app/helpers/scaffold_helper.rb
fullstack-admin-0.2.14 app/helpers/scaffold_helper.rb
fullstack-admin-0.2.13 app/helpers/scaffold_helper.rb
fullstack-admin-0.2.12 app/helpers/scaffold_helper.rb
fullstack-admin-0.2.11 app/helpers/scaffold_helper.rb
fullstack-admin-0.2.9 app/helpers/scaffold_helper.rb
fullstack-admin-0.2.8 app/helpers/scaffold_helper.rb
fullstack-admin-0.2.7 app/helpers/scaffold_helper.rb
fullstack-admin-0.2.6 app/helpers/scaffold_helper.rb