Sha256: 898f225e77fe96d6c076a4fd21d530f3f596f2ac659f20d1d2dc21d755b47eb6

Contents?: true

Size: 1.92 KB

Versions: 12

Compression:

Stored size: 1.92 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)
      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 positionable?(object_or_class)
      model = object_or_class.is_a?(Class) ? object_or_class : object_or_class.class
      model.columns_hash["position"]
    end
    
    def title_column(model)
      @_title_columns ||= {}
      @_title_columns[model] ||= ( model.column_names.map{ |c| c.to_s } & %W(title name label browser_title seo_title seo_name key claim email) ).first
    end
    
    
    def skip_filter!
      @skip_filter = true
    end
    
    def skip_filter
      @skip_filter
    end
    
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
fullstack-admin-0.1.35 app/helpers/scaffold_helper.rb
fullstack-admin-0.1.34 app/helpers/scaffold_helper.rb
fullstack-admin-0.1.33 app/helpers/scaffold_helper.rb
fullstack-admin-0.1.32 app/helpers/scaffold_helper.rb
fullstack-admin-0.1.30 app/helpers/scaffold_helper.rb
fullstack-admin-0.1.29 app/helpers/scaffold_helper.rb
fullstack-admin-0.1.28 app/helpers/scaffold_helper.rb
fullstack-admin-0.1.27 app/helpers/scaffold_helper.rb
fullstack-admin-0.1.26 app/helpers/scaffold_helper.rb
fullstack-admin-0.1.25 app/helpers/scaffold_helper.rb
fullstack-admin-0.1.24 app/helpers/scaffold_helper.rb
fullstack-admin-0.1.23 app/helpers/scaffold_helper.rb