Skip to content

Commit

Permalink
add icons, fix history rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
bbenezech committed Feb 7, 2012
1 parent 81c54d3 commit b9f78d1
Show file tree
Hide file tree
Showing 16 changed files with 59 additions and 19 deletions.
16 changes: 4 additions & 12 deletions app/assets/stylesheets/rails_admin/base/theming.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ body.rails_admin {
}
}

.nav.nav-tabs li.icon a {
color: $black;
}

/* Table cells behaviour */
.table {
Expand Down Expand Up @@ -110,18 +113,7 @@ body.rails_admin {
max-width: none;
.inline {
margin:0px;
li {
display:inline-block;
a {
border-right: 1px solid #DDD;
padding-right: 5px;
}
&:last-child {
a {
border-right: none;
}
}
}
li { display:inline-block; }
}
}

Expand Down
8 changes: 5 additions & 3 deletions app/helpers/rails_admin/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,15 @@ def breadcrumb action = @action, acc = []
end

# parent => :root, :collection, :member
def menu_for(parent, abstract_model = nil, object = nil) # perf matters here (no action view trickery)
def menu_for(parent, abstract_model = nil, object = nil, only_icon = false) # perf matters here (no action view trickery)
actions = actions(parent, abstract_model, object).select{ |a| a.http_methods.include?(:get) }
actions.map do |action|
wording = wording_for(:menu, action)
%{
<li class="#{action.key}_#{parent}_link #{'active' if current_action?(action)}">
<li data-original-title="#{wording}" rel="#{'tooltip' if only_icon}" class="icon #{action.key}_#{parent}_link #{'active' if current_action?(action)}">
<a href="#{url_for({ :action => action.action_name, :controller => 'rails_admin/main', :model_name => abstract_model.try(:to_param), :id => object.try(:id) })}">
#{wording_for(:menu, action)}
<i class="#{action.link_icon}"></i>
<span#{only_icon ? " style='display:none'" : ""}>#{wording}</span>
</a>
</li>
}
Expand Down
2 changes: 1 addition & 1 deletion app/views/rails_admin/main/dashboard.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
- percent = count > 0 ? (@max < 2.0 ? count : ((Math.log(count) * 100.0) / Math.log(@max))) : -1
.label.animate-width-to{:class => 'label-'+get_indicator(percent), :'data-animate-length' => ([1.0, percent].max.to_i * 20), :'data-animate-width-to' => "#{[2.0, percent - 1].max.to_i}%", :style => "width:2%"}= @count[abstract_model.pretty_name]
%td.links
%ul.inline= menu_for :collection, abstract_model
%ul.inline= menu_for :collection, abstract_model, nil, true
- if @auditing_adapter && authorized?(:history)
#block-tables.block
.content
Expand Down
2 changes: 1 addition & 1 deletion app/views/rails_admin/main/history.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
%input{:name => "query", :type => "search", :value => query, :placeholder => "#{t("admin.misc.filter")}"}
.span3
%button.btn.btn-primary{:type => "submit", :'data-disable-with' => t("admin.misc.refresh")}= t("admin.misc.refresh")
%table#history.zebra-striped
%table#history.table.table-striped.table-condensed
%thead
%tr
- columns = []
Expand Down
2 changes: 1 addition & 1 deletion app/views/rails_admin/main/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
- if @other_right_link ||= other_right && index_path(params.merge(:set => (params[:set].to_i + 1)))
%td.other.right= link_to "...", @other_right_link, :class => 'pjax'
%td.last.links
%ul.inline= menu_for :member, @abstract_model, object
%ul.inline= menu_for :member, @abstract_model, object, true
- unless params[:all]
- total_count = @objects.total_count
= paginate(@objects, :theme => 'twitter-bootstrap', :remote => true)
Expand Down
5 changes: 5 additions & 0 deletions lib/rails_admin/config/actions/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ module Actions
class Base < RailsAdmin::Config::Base
include RailsAdmin::Config::Hideable

# http://twitter.github.com/bootstrap/base-css.html#icons
register_instance_option :link_icon do
'icon-question-sign'
end

# Should the action be visible
register_instance_option :visible? do
authorized?
Expand Down
4 changes: 4 additions & 0 deletions lib/rails_admin/config/actions/dashboard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ class Dashboard < RailsAdmin::Config::Actions::Base
register_instance_option :route_fragment do
''
end

register_instance_option :link_icon do
'icon-home'
end
end
end
end
Expand Down
5 changes: 4 additions & 1 deletion lib/rails_admin/config/actions/delete.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@ class Delete < RailsAdmin::Config::Actions::Base
redirect_to back_or_index

end

end
end

register_instance_option :link_icon do
'icon-remove'
end
end
end
end
Expand Down
4 changes: 4 additions & 0 deletions lib/rails_admin/config/actions/edit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ class Edit < RailsAdmin::Config::Actions::Base

end
end

register_instance_option :link_icon do
'icon-pencil'
end
end
end
end
Expand Down
3 changes: 3 additions & 0 deletions lib/rails_admin/config/actions/export.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ class Export < RailsAdmin::Config::Actions::Base
true
end

register_instance_option :link_icon do
'icon-file'
end
end
end
end
Expand Down
4 changes: 4 additions & 0 deletions lib/rails_admin/config/actions/history_index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ class HistoryIndex < RailsAdmin::Config::Actions::Base
register_instance_option :template_name do
:history
end

register_instance_option :link_icon do
'icon-book'
end
end
end
end
Expand Down
4 changes: 4 additions & 0 deletions lib/rails_admin/config/actions/history_show.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ class HistoryShow < RailsAdmin::Config::Actions::Base
register_instance_option :template_name do
:history
end

register_instance_option :link_icon do
'icon-book'
end
end
end
end
Expand Down
5 changes: 5 additions & 0 deletions lib/rails_admin/config/actions/index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ class Index < RailsAdmin::Config::Actions::Base

end
end


register_instance_option :link_icon do
'icon-th-list'
end
end
end
end
Expand Down
4 changes: 4 additions & 0 deletions lib/rails_admin/config/actions/new.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ class New < RailsAdmin::Config::Actions::Base
end
end
end

register_instance_option :link_icon do
'icon-pencil'
end
end
end
end
Expand Down
5 changes: 5 additions & 0 deletions lib/rails_admin/config/actions/show.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ class Show < RailsAdmin::Config::Actions::Base
render @action.template_name
end
end


register_instance_option :link_icon do
'icon-info-sign'
end
end
end
end
Expand Down
5 changes: 5 additions & 0 deletions lib/rails_admin/config/actions/show_in_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ class ShowInApp < RailsAdmin::Config::Actions::Base
redirect_to main_app.url_for(@object)
end
end


register_instance_option :link_icon do
'icon-eye-open'
end
end
end
end
Expand Down

0 comments on commit b9f78d1

Please sign in to comment.