From 5a2ffa227c99a271366735fa43a02ef93b99a673 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Wed, 21 Jul 2010 21:48:32 +0100 Subject: [PATCH] Convert trace views to use CSS based user specific components --- app/controllers/trace_controller.rb | 6 +++--- app/views/trace/_trace_form.html.erb | 4 ++-- app/views/trace/_trace_header.html.erb | 14 ++++++++------ app/views/trace/list.html.erb | 2 +- app/views/trace/view.html.erb | 18 ++++++++---------- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/app/controllers/trace_controller.rb b/app/controllers/trace_controller.rb index c51f54c5e..d82308baa 100644 --- a/app/controllers/trace_controller.rb +++ b/app/controllers/trace_controller.rb @@ -23,10 +23,10 @@ class TraceController < ApplicationController # Counts and selects pages of GPX traces for various criteria (by user, tags, public etc.). # target_user - if set, specifies the user to fetch traces for. if not set will fetch all traces - def list(target_user = nil, action = "list") + def list # from display name, pick up user id if one user's traces only display_name = params[:display_name] - if target_user.nil? and !display_name.blank? + if !display_name.blank? target_user = User.find(:first, :conditions => { :status => ["active", "confirmed"], :display_name => display_name }) if target_user.nil? @title = t'trace.no_such_user.title' @@ -103,7 +103,7 @@ class TraceController < ApplicationController end # final helper vars for view - @action = action + @target_user = target_user @display_name = target_user.display_name if target_user @all_tags = tagset.values @trace = Trace.new(:visibility => default_visibility) if @user diff --git a/app/views/trace/_trace_form.html.erb b/app/views/trace/_trace_form.html.erb index 3d93b65e8..c6e755b1e 100644 --- a/app/views/trace/_trace_form.html.erb +++ b/app/views/trace/_trace_form.html.erb @@ -1,5 +1,5 @@ -<% if @user.traces.count(:conditions => ["inserted=?", false]) > 4 %> -

<%= t'trace.trace_header.traces_waiting', :count => @user.traces.count(:conditions => ["inserted=?", false]) %>

+<% if @target_user.traces.count(:conditions => ["inserted=?", false]) > 4 %> +

<%= t'trace.trace_header.traces_waiting', :count => @target_user.traces.count(:conditions => ["inserted=?", false]) %>

<% end %> <% form_for :trace, @trace, :url => { :action => "create" }, :html => { :multipart => true } do |f| %> diff --git a/app/views/trace/_trace_header.html.erb b/app/views/trace/_trace_header.html.erb index 85de77396..37b944fd4 100644 --- a/app/views/trace/_trace_header.html.erb +++ b/app/views/trace/_trace_header.html.erb @@ -6,13 +6,15 @@

<%= rss_link_to :action => 'georss', :display_name => @display_name, :tag => @tag %> - <% if @user.nil? or @display_name.nil? or @user.display_name != @display_name %> + <% unless_user(@target_user, :span) do %> | <%= link_to t('trace.trace_header.see_just_your_traces'), :action => 'mine' %> <% end %> - <% if @tag or @display_name %> - | <%= link_to t('trace.trace_header.see_all_traces'), :controller => 'trace', :action => 'list' %> - <% end %> - <% if @tag and @user and @user.display_name == @display_name %> - | <%= link_to t('trace.trace_header.see_your_traces'), :controller => 'trace', :action => 'mine' %> + <% if @tag %> + <% if @display_name %> + | <%= link_to t('trace.trace_header.see_all_traces'), :controller => 'trace', :action => 'list' %> + <% end %> + <% if_user(@target_user, :span) do %> + | <%= link_to t('trace.trace_header.see_your_traces'), :controller => 'trace', :action => 'mine' %> + <% end %> <% end %>

diff --git a/app/views/trace/list.html.erb b/app/views/trace/list.html.erb index fe7e5a13a..a954dd766 100644 --- a/app/views/trace/list.html.erb +++ b/app/views/trace/list.html.erb @@ -1,5 +1,5 @@ <%= render :partial => 'trace_header' %> -<% if @user and @user.display_name == @display_name %> +<% if_user(@target_user) do %> <%= render :partial => 'trace_form' %> <% end %> <%= render :partial => 'trace_list' %> diff --git a/app/views/trace/view.html.erb b/app/views/trace/view.html.erb index 73638cb3d..bfef5d901 100644 --- a/app/views/trace/view.html.erb +++ b/app/views/trace/view.html.erb @@ -52,13 +52,11 @@

- - - <% if @trace.user == @user %> - - <% end %> - <% if @trace.user == @user %> - - <% end %> - -
<%= button_to t('trace.view.edit_track'), :controller => 'trace', :action => 'edit', :id => @trace.id %><%= button_to t('trace.view.delete_track'), :controller => 'trace', :action => 'delete', :id => @trace.id %>
+<% if_user(@trace.user) do %> + + + + + +
<%= button_to t('trace.view.edit_track'), :controller => 'trace', :action => 'edit', :id => @trace.id %><%= button_to t('trace.view.delete_track'), :controller => 'trace', :action => 'delete', :id => @trace.id %>
+<% end %> -- 2.39.5