change feed page to dynamically select feed for project/context

when you have a long list of projects and/or contexts, the page got really crowded
This commit is contained in:
Reinier Balt 2008-07-24 20:51:50 +02:00
parent c3fa86fc36
commit e3f444575d
5 changed files with 85 additions and 22 deletions

View file

@ -5,14 +5,28 @@ class FeedlistController < ApplicationController
def index
@page_title = 'TRACKS::Feeds'
init_data_for_sidebar unless mobile?
@active_projects = @projects.select{ |p| p.active? }
@hidden_projects = @projects.select{ |p| p.hidden? }
@completed_projects = @projects.select{ |p| p.completed? }
@active_contexts = @contexts.select{ |c| !c.hidden? }
@hidden_contexts = @contexts.select{ |c| c.hidden? }
respond_to do |format|
format.html { render :layout => 'standard' }
format.m {
# @projects = @projects || current_user.projects.find(:all, :include => [:default_context ])
# @contexts = @contexts || current_user.contexts
render :action => 'mobile_index'
}
format.m { render :action => 'mobile_index' }
end
end
def get_feeds_for_context
context = current_user.contexts.find params[:context_id]
render :partial => 'feed_for_context', :locals => { :context => context }
end
def get_feeds_for_project
project = current_user.projects.find params[:project_id]
render :partial => 'feed_for_project', :locals => { :project => project }
end
end

View file

@ -0,0 +1,6 @@
<li>
<%= rss_formatted_link({ :controller=> 'todos', :action => 'index', :context_id => context.to_param }) %>
<%= text_formatted_link({ :controller=> 'todos', :action => 'index', :context_id => context.to_param }) %>
<%= ical_formatted_link({ :controller=> 'todos', :action => 'index', :context_id => context.to_param }) %>
<strong><%=h context.name %></strong>
</li>

View file

@ -0,0 +1,6 @@
<li>
<%= rss_formatted_link({ :controller=> 'todos', :action => 'index', :project_id => project.to_param }) %>
<%= text_formatted_link({ :controller=> 'todos', :action => 'index', :project_id => project.to_param }) %>
<%= ical_formatted_link({ :controller=> 'todos', :action => 'index', :project_id => project.to_param }) %>
<strong><%=h project.name %></strong>
</li>

View file

@ -60,26 +60,49 @@
</li>
<li><h4>Feeds for incomplete actions in a specific context:</h4>
<ul>
<% for context in @contexts %>
<li>
<%= rss_formatted_link({ :controller=> 'todos', :action => 'index', :context_id => context.to_param }) %>
<%= text_formatted_link({ :controller=> 'todos', :action => 'index', :context_id => context.to_param }) %>
<%= ical_formatted_link({ :controller=> 'todos', :action => 'index', :context_id => context.to_param }) %>
Next actions in <strong><%=h context.name %></strong>
</li>
<% end %>
<li>Step 1 - Choose the context you want a feed of:
<select name="feed-contexts" id="feed-contexts">
<%= options_from_collection_for_select(@active_contexts, "id", "name", @active_contexts.first.id) -%>
<%= options_from_collection_for_select(@hidden_contexts, "id", "name") -%>
</select>
<%= observe_field "feed-contexts", :update => "feeds-for-context",
:with => 'context_id',
:url => { :controller => "feedlist", :action => "get_feeds_for_context" },
:before => "$('feeds-for-context').startWaiting()",
:complete => "$('feeds-for-context').stopWaiting()"
-%>
</li>
<li>Step 2 - Select the feed for this context
<div id="feedicons-context">
<div id="feeds-for-context">
<%= render :partial => 'feed_for_context', :locals => { :context => @active_contexts.first } %>
</div>
</div>
</li>
</ul>
</li>
<li><h4>Feeds for incomplete actions in a specific project:</h4>
<ul>
<% for project in @projects %>
<li>
<%= rss_formatted_link({ :controller=> 'todos', :action => 'index', :project_id => project.to_param }) %>
<%= text_formatted_link({ :controller=> 'todos', :action => 'index', :project_id => project.to_param }) %>
<%= ical_formatted_link({ :controller=> 'todos', :action => 'index', :project_id => project.to_param }) %>
Next actions for <strong><%=h project.name %></strong>
</li>
<% end %>
<li>Step 1 - Choose the project you want a feed of:
<select name="feed-projects" id="feed-projects">
<%= options_from_collection_for_select(@active_projects, "id", "name", @active_projects.first.id) -%>
<%= options_from_collection_for_select(@hidden_projects, "id", "name") -%>
<%= options_from_collection_for_select(@completed_projects, "id", "name") -%>
</select>
<%= observe_field "feed-projects", :update => "feeds-for-project",
:with => 'project_id',
:url => { :controller => "feedlist", :action => "get_feeds_for_project" },
:before => "$('feeds-for-project').startWaiting()",
:complete => "$('feeds-for-project').stopWaiting()"
-%>
</li>
<li>Step 2 - Select the feed for this project
<div id="feedicons-project">
<div id="feeds-for-project">
<%= render :partial => 'feed_for_project', :locals => { :project => @active_projects.first } %>
</div>
</div>
</li>
</ul>
</li>
</ul>
@ -89,3 +112,11 @@
<div id="input_box">
<%= render "sidebar/sidebar" %>
</div><!-- End of input box -->
<script type="text/javascript">
window.onload=function(){
Nifty("div#feedicons-project","normal");
Nifty("div#feedicons-context","normal");
Nifty("div#feedlegend","normal");
}
</script>

View file

@ -845,6 +845,13 @@ input, select, textarea {
margin: 0px 0px 5px 0px;
}
#feedicons-project, #feedicons-context {
background-color: #D2D3D6;
margin: 0px 0px 0px 60px;
padding: 0px 0px 0px 5px;
width: 70%;
}
.feed {
font-family: verdana, sans-serif;
font-size: 10px;
@ -948,7 +955,6 @@ ul#prefs {list-style-type: disc; margin-left: 15px;}
}
#feedlegend {
padding: 2px;
border: 1px solid #CCC;
background-color: #D2D3D6;
color: #666;
padding: 5px 20px;