Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model display name fixes #319

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/rails_admin/history_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def slider

def for_model
@page_type = @abstract_model.pretty_name.downcase
@page_name = t("admin.history.page_name", :name => @model_config.list.label)
@page_name = t("admin.history.page_name", :name => @model_config.navigation.label)
@general = true

@page_count, @history = AbstractHistory.history_for_model @abstract_model, params[:query], params[:sort], params[:sort_reverse], params[:all], params[:page]
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/rails_admin/main_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def update
def delete
@authorization_adapter.authorize(:delete, @abstract_model, @object) if @authorization_adapter

@page_name = t("admin.actions.delete").capitalize + " " + @model_config.list.label.downcase
@page_name = t("admin.actions.delete").capitalize + " " + @model_config.navigation.label.downcase
@page_type = @abstract_model.pretty_name.downcase

render :layout => 'rails_admin/delete'
Expand All @@ -131,7 +131,7 @@ def destroy
def bulk_delete
@authorization_adapter.authorize(:bulk_delete, @abstract_model) if @authorization_adapter

@page_name = t("admin.actions.delete").capitalize + " " + @model_config.list.label.downcase
@page_name = t("admin.actions.delete").capitalize + " " + @model_config.navigation.label.downcase
@page_type = @abstract_model.pretty_name.downcase

render :layout => 'rails_admin/delete'
Expand Down Expand Up @@ -301,7 +301,7 @@ def list_entries(other = {})
@record_count = @abstract_model.count(options, scope)

@page_type = @abstract_model.pretty_name.downcase
@page_name = t("admin.list.select", :name => @model_config.list.label.downcase)
@page_name = t("admin.list.select", :name => @model_config.navigation.label.downcase)
end

def associations_hash
Expand Down
4 changes: 2 additions & 2 deletions app/views/layouts/rails_admin/list.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<% if @history %>
<li>
&rsaquo;
<%= link_to(@model_config.list.label, rails_admin_list_path(:model_name => @abstract_model.to_param)) %>
<%= link_to(@model_config.navigation.label, rails_admin_list_path(:model_name => @abstract_model.to_param)) %>
</li>
<li>
&rsaquo;
Expand All @@ -52,7 +52,7 @@
<% else %>
<li>
&rsaquo;
<span><%= @model_config.list.label %></span>
<span><%= @model_config.navigation.label %></span>
</li>
<% end%>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion app/views/rails_admin/main/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<% if authorized? :list, abstract_model %>
<tr class="<%= cycle 'odd', 'even' %>">
<td class="modelNameRow">
<%= link_to(RailsAdmin.config(abstract_model).list.label, rails_admin_list_path(:model_name => abstract_model.to_param), :class => "show") %>
<%= link_to(RailsAdmin.config(abstract_model).navigation.label, rails_admin_list_path(:model_name => abstract_model.to_param), :class => "show") %>
</td>
<td>
<% if (last_used = @most_recent_changes[abstract_model.pretty_name]) %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,34 @@
end
end

it 'should display edited model name in model name column' do
RailsAdmin.config Fan do
label_for_navigation "NewFan"
end
get rails_admin_dashboard_path
response.should have_tag("td.modelNameRow") do |model_name_cells|
model_name_cells.should have_tag("a[href='/admin/fans']", :content => "NewFan")
end
end

it 'should use edited model name in breadcrumbs' do
RailsAdmin.config Fan do
label_for_navigation "NewFan"
end
get rails_admin_list_path(:model_name => 'fans')
response.should have_tag(".breadcrumb li") do |model_name_cells|
model_name_cells.should have_tag("span", :content => "NewFan")
end
end

it 'should use edited model name in @page_name' do
RailsAdmin.config Fan do
label_for_navigation "NewFan"
end
get rails_admin_list_path(:model_name => 'fans')
assigns[:page_name].should =~ /NewFan/i
end

it "should be editable via shortcut" do
RailsAdmin.config Fan do
label_for_navigation "Fan test 2"
Expand Down