mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-16 15:20:13 +01:00
finish migration of the feeds page
This commit is contained in:
parent
51106d015e
commit
2fa431ef54
14 changed files with 205 additions and 128 deletions
|
|
@ -26,13 +26,19 @@ class FeedlistController < ApplicationController
|
|||
end
|
||||
|
||||
def get_feeds_for_context
|
||||
context = current_user.contexts.find params[:context_id]
|
||||
render :partial => 'feed_for_context', :locals => { :context => context }
|
||||
@context = current_user.contexts.find params[:context_id]
|
||||
respond_to do |format|
|
||||
format.html { render :text => "This page should not be called directly"}
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def get_feeds_for_project
|
||||
project = current_user.projects.find params[:project_id]
|
||||
render :partial => 'feed_for_project', :locals => { :project => project }
|
||||
@project = current_user.projects.find params[:project_id]
|
||||
respond_to do |format|
|
||||
format.html { render :text => "This page should not be called directly"}
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -15,7 +15,25 @@ module FeedlistHelper
|
|||
linkoptions = merge_hashes( {:format => 'ics'}, user_token_hash, options)
|
||||
link_to('<span class="feed">iCal</span>', linkoptions, :title => "iCal feed" )
|
||||
end
|
||||
|
||||
|
||||
def feed_links(feeds, link_options, title)
|
||||
space = " "
|
||||
html = ""
|
||||
html << rss_formatted_link(link_options)+space if feeds.include?(:rss)
|
||||
html << text_formatted_link(link_options)+space if feeds.include?(:txt)
|
||||
html << ical_formatted_link(link_options)+space if feeds.include?(:ical)
|
||||
html << title
|
||||
return html
|
||||
end
|
||||
|
||||
def all_feed_links_for_project(project)
|
||||
feed_links([:rss, :txt, :ical], { :controller=> 'todos', :action => 'index', :project_id => project.to_param }, content_tag(:strong, project.name))
|
||||
end
|
||||
|
||||
def all_feed_links_for_context(context)
|
||||
feed_links([:rss, :txt, :ical], { :controller=> 'todos', :action => 'index', :context_id => context.to_param }, content_tag(:strong, context.name))
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def merge_hashes(*hashes)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,25 @@
|
|||
<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>
|
||||
<% context = @active_contexts.empty? ? @hidden_contexts.first : @active_contexts.first
|
||||
-%>
|
||||
|
||||
<h4><%= t('feedlist.context_centric_actions') %>:</h4>
|
||||
<% if @active_contexts.empty? && @hidden_contexts.empty? -%>
|
||||
<ul><li><%= t('feedlist.context_needed') %></li></ul>
|
||||
<% else -%>
|
||||
<ul>
|
||||
<li><%= t('common.numbered_step', :number => 1) %> - <%= t('feedlist.choose_context') %>:
|
||||
<select name="feed-contexts" id="feed-contexts">
|
||||
<%= options_from_collection_for_select(@active_contexts, "id", "name", @active_contexts.first.id) unless @active_contexts.empty?-%>
|
||||
<%= options_from_collection_for_select(@hidden_contexts, "id", "name") -%>
|
||||
</select>
|
||||
</li>
|
||||
<li><%= t('common.numbered_step', :number => 2) %> - <%= t('feedlist.select_feed_for_context') %>
|
||||
<div id="feedicons-context">
|
||||
<div id="feeds-for-context">
|
||||
<li><%= all_feed_links_for_context(context) %></li>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<% end -%>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,22 @@
|
|||
<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>
|
||||
<% project = @active_projects.empty? ? @hidden_projects.first : @active_projects.first -%>
|
||||
<h4><%= t('feedlist.project_centric') %>:</h4>
|
||||
<ul>
|
||||
<% if @active_projects.empty? && @hidden_projects.empty? -%>
|
||||
<li><%= t('feedlist.project_needed') %></li>
|
||||
<% else -%>
|
||||
<li><%= t('common.numbered_step', :number => 1) %> - <%= t('feedlist.choose_project') %>:
|
||||
<select name="feed-projects" id="feed-projects">
|
||||
<%= options_from_collection_for_select(@active_projects, "id", "name", @active_projects.first.id) unless @active_projects.empty?-%>
|
||||
<%= options_from_collection_for_select(@hidden_projects, "id", "name") -%>
|
||||
<%= options_from_collection_for_select(@completed_projects, "id", "name") -%>
|
||||
</select>
|
||||
</li>
|
||||
<li><%= t('common.numbered_step', :number => 2) %> - <%= t('feedlist.select_feed_for_project') %>
|
||||
<div id="feedicons-project">
|
||||
<div id="feeds-for-project">
|
||||
<li><%= all_feed_links_for_project(project) %></li>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<% end -%>
|
||||
</ul>
|
||||
14
app/views/feedlist/_legend.rhtml
Normal file
14
app/views/feedlist/_legend.rhtml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<div id="feedlegend">
|
||||
<h3><%= t('feedlist.legend') %></h3>
|
||||
<dl>
|
||||
<dt><%= image_tag("feed-icon.png", :size => "16X16", :border => 0)%></dt>
|
||||
<dd><%= t('feedlist.rss_feed') %></dd>
|
||||
|
||||
<dt><span class="feed">TXT</span></dt>
|
||||
<dd><%= t('feedlist.plain_text_feed') %></dd>
|
||||
|
||||
<dt><span class="feed">iCal</span></dt>
|
||||
<dd><%= t('feedlist.ical_feed') %></dd>
|
||||
</dl>
|
||||
<p><%= t('feedlist.notice_incomplete_only') %></p>
|
||||
</div>
|
||||
1
app/views/feedlist/get_feeds_for_context.erb
Normal file
1
app/views/feedlist/get_feeds_for_context.erb
Normal file
|
|
@ -0,0 +1 @@
|
|||
<li><%= all_feed_links_for_context(@context) %></li>
|
||||
1
app/views/feedlist/get_feeds_for_project.erb
Normal file
1
app/views/feedlist/get_feeds_for_project.erb
Normal file
|
|
@ -0,0 +1 @@
|
|||
<li><%= all_feed_links_for_project(@project) %></li>
|
||||
|
|
@ -1,115 +1,23 @@
|
|||
<div id="display_box">
|
||||
<div id="feeds">
|
||||
<div id="feedlegend">
|
||||
<h3><%= t('feedlist.legend') %></h3>
|
||||
<dl>
|
||||
<dt><%= image_tag("feed-icon.png", :size => "16X16", :border => 0)%></dt><dd><%= t('feedlist.rss_feed') %></dd>
|
||||
<dt><span class="feed">TXT</span></dt><dd><%= t('feedlist.plain_text_feed') %></dd>
|
||||
<dt><span class="feed">iCal</span></dt><dd><%= t('feedlist.ical_feed') %></dd>
|
||||
</dl>
|
||||
<p><%= t('feedlist.notice_incomplete_only') %></p>
|
||||
</div>
|
||||
<%= render :partial => 'legend' %>
|
||||
<ul>
|
||||
<li>
|
||||
<%= rss_formatted_link({ :controller => 'todos', :action => 'index', :limit => 15 }) %>
|
||||
<%= text_formatted_link({ :controller => 'todos', :action => 'index', :limit => 15 }) %>
|
||||
<%= ical_formatted_link({ :controller => 'todos', :action => 'index', :limit => 15 }) %>
|
||||
<%= t('feedlist.last_fixed_number', :number=>15) %>
|
||||
</li>
|
||||
<li>
|
||||
<%= rss_formatted_link( { :controller => 'todos', :action => 'index' } ) %>
|
||||
<%= text_formatted_link( { :controller => 'todos', :action => 'index' } ) %>
|
||||
<%= ical_formatted_link( { :controller => 'todos', :action => 'index' } ) %>
|
||||
<%= t('feedlist.all_actions') %>
|
||||
</li>
|
||||
<li>
|
||||
<%= rss_formatted_link({ :controller => 'todos', :action => 'index', :due => 0 }) %>
|
||||
<%= text_formatted_link({ :controller => 'todos', :action => 'index', :due => 0 }) %>
|
||||
<%= ical_formatted_link({ :controller => 'todos', :action => 'index', :due => 0 }) %>
|
||||
<%= t('feedlist.actions_due_today') %>
|
||||
</li>
|
||||
<li>
|
||||
<%= rss_formatted_link({ :controller => 'todos', :action => 'index', :due => 6 }) %>
|
||||
<%= text_formatted_link({ :controller => 'todos', :action => 'index', :due => 6 }) %>
|
||||
<%= ical_formatted_link({ :controller => 'todos', :action => 'index', :due => 6 }) %>
|
||||
<%= t('feedlist.actions_due_next_week') %>
|
||||
</li>
|
||||
<li>
|
||||
<%= rss_formatted_link({ :controller => 'todos', :action => 'index', :done => 7 }) %>
|
||||
<%= text_formatted_link({ :controller => 'todos', :action => 'index', :done => 7 }) %>
|
||||
<%= t('feedlist.actions_completed_last_week') %>
|
||||
</li>
|
||||
<li>
|
||||
<%= rss_formatted_link({:controller => 'contexts', :action => 'index'}) %>
|
||||
<%= text_formatted_link({:controller => 'contexts', :action => 'index'}) %>
|
||||
<%= t('feedlist.all_contexts') %>
|
||||
</li>
|
||||
<li>
|
||||
<%= rss_formatted_link({:controller => 'projects', :action => 'index'}) %>
|
||||
<%= text_formatted_link({:controller => 'projects', :action => 'index'}) %>
|
||||
<%= t('feedlist.all_projects') %>
|
||||
</li>
|
||||
<li>
|
||||
<%= rss_formatted_link({:controller => 'projects', :action => 'index', :only_active_with_no_next_actions => true}) %>
|
||||
<%= text_formatted_link({:controller => 'projects', :action => 'index', :only_active_with_no_next_actions => true}) %>
|
||||
<%= t('feedlist.active_projects_wo_next') %>
|
||||
</li>
|
||||
<li>
|
||||
<%= rss_formatted_link({:controller => 'todos', :action => 'index', :tag => 'starred'}) %>
|
||||
<%= text_formatted_link({:controller => 'todos', :action => 'index', :tag => 'starred'}) %>
|
||||
<%= t('feedlist.active_starred_actions') %>
|
||||
</li>
|
||||
<li>
|
||||
<%= text_formatted_link({:controller => 'projects', :action => 'index', :projects_and_actions => true}) %>
|
||||
<%= t('feedlist.projects_and_actions') %>
|
||||
</li>
|
||||
<li><h4><%= t('feedlist.context_centric_actions') %>:</h4>
|
||||
<% if @active_contexts.empty? && @hidden_contexts.empty? -%>
|
||||
<ul><li><%= t('feedlist.context_needed') %></li></ul>
|
||||
<% else -%>
|
||||
<ul>
|
||||
<li><%= t('common.numbered_step', :number => 1) %> - <%= t('feedlist.choose_context') %>:
|
||||
<select name="feed-contexts" id="feed-contexts">
|
||||
<%= options_from_collection_for_select(@active_contexts, "id", "name", @active_contexts.first.id) unless @active_contexts.empty?-%>
|
||||
<%= options_from_collection_for_select(@hidden_contexts, "id", "name") -%>
|
||||
</select>
|
||||
</li>
|
||||
<li><%= t('common.numbered_step', :number => 2) %> - <%= t('feedlist.select_feed_for_context') %>
|
||||
<div id="feedicons-context">
|
||||
<div id="feeds-for-context">
|
||||
<%= render :partial => 'feed_for_context', :locals => { :context => @active_contexts.empty? ? @hidden_contexts.first : @active_contexts.first } %>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<% end -%>
|
||||
</li>
|
||||
<li><h4><%= t('feedlist.project_centric') %>:</h4>
|
||||
<% if @active_projects.empty? && @hidden_projects.empty? -%>
|
||||
<ul><li><%= t('feedlist.project_needed') %></li></ul>
|
||||
<% else -%>
|
||||
<ul>
|
||||
<li><%= t('common.numbered_step', :number => 1) %> - <%= t('feedlist.choose_project') %>:
|
||||
<select name="feed-projects" id="feed-projects">
|
||||
<%= options_from_collection_for_select(@active_projects, "id", "name", @active_projects.first.id) unless @active_projects.empty?-%>
|
||||
<%= options_from_collection_for_select(@hidden_projects, "id", "name") -%>
|
||||
<%= options_from_collection_for_select(@completed_projects, "id", "name") -%>
|
||||
</select>
|
||||
</li>
|
||||
<li><%= t('common.numbered_step', :number => 2) %> - <%= t('feedlist.select_feed_for_project') %>
|
||||
<div id="feedicons-project">
|
||||
<div id="feeds-for-project">
|
||||
<%= render :partial => 'feed_for_project', :locals => { :project => @active_projects.empty? ? @hidden_projects.first : @active_projects.first } %>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<% end -%>
|
||||
</li>
|
||||
<li><%= feed_links([:rss, :txt, :ical], { :controller => 'todos', :action => 'index', :limit => 15 }, t('feedlist.last_fixed_number', :number=>15)) %></li>
|
||||
<li><%= feed_links([:rss, :txt, :ical], { :controller => 'todos', :action => 'index' }, t('feedlist.all_actions')) %></li>
|
||||
<li><%= feed_links([:rss, :txt, :ical], { :controller => 'todos', :action => 'index', :due => 0 }, t('feedlist.actions_due_today')) %></li>
|
||||
<li><%= feed_links([:rss, :txt, :ical], { :controller => 'todos', :action => 'index', :due => 6 }, t('feedlist.actions_due_next_week')) %></li>
|
||||
<li><%= feed_links([:rss, :txt], { :controller => 'todos', :action => 'index', :done => 7 }, t('feedlist.actions_completed_last_week')) %></li>
|
||||
<li><%= feed_links([:rss, :txt], { :controller => 'contexts', :action => 'index' }, t('feedlist.all_contexts')) %></li>
|
||||
<li><%= feed_links([:rss, :txt], { :controller => 'projects', :action => 'index' }, t('feedlist.all_projects')) %></li>
|
||||
<li><%= feed_links([:rss, :txt], { :controller => 'projects', :action => 'index', :only_active_with_no_next_actions => true }, t('feedlist.active_projects_wo_next')) %></li>
|
||||
<li><%= feed_links([:rss, :txt], { :controller => 'todos', :action => 'index', :tag => 'starred' }, t('feedlist.active_starred_actions')) %></li>
|
||||
<li><%= feed_links([:txt], {:controller => 'projects', :action => 'index', :projects_and_actions => true}, t('feedlist.projects_and_actions')) %></li>
|
||||
<li><%= render :partial => 'feed_for_context' %></li>
|
||||
<li><%= render :partial => 'feed_for_project' %></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div><!-- End of display_box -->
|
||||
</div>
|
||||
|
||||
<div id="input_box">
|
||||
<%= render :file => "sidebar/sidebar.html.erb" %>
|
||||
</div><!-- End of input box -->
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ en:
|
|||
rss_feed: "RSS Feed"
|
||||
plain_text_feed: "Plain Text Feed"
|
||||
ical_feed: "iCal feed"
|
||||
notice_incomplete_only: "Note: All feeds show only actions that have not been marked as done."
|
||||
notice_incomplete_only: "Note: All feeds show only actions that have not been marked as done, unless stated otherwise."
|
||||
last_fixed_number: "Last {{number}} actions"
|
||||
all_actions: "All actions"
|
||||
actions_due_today: "Actions due today or earlier"
|
||||
|
|
|
|||
48
features/feedlist.feature
Normal file
48
features/feedlist.feature
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
Feature: Get all sorts of lists from Tracks
|
||||
In order to get reports on todos managed by Tracks
|
||||
As a Tracks user
|
||||
I want to be be able to select a feed
|
||||
|
||||
Background:
|
||||
Given the following user record
|
||||
| login | password | is_admin |
|
||||
| testuser | secret | false |
|
||||
And I have logged in as "testuser" with password "secret"
|
||||
And I have the following contexts:
|
||||
| context |
|
||||
| @pc |
|
||||
| @home |
|
||||
| @shops |
|
||||
| @boss |
|
||||
And I have the following projects:
|
||||
| project_name |
|
||||
| Test feedlist |
|
||||
| Get release out |
|
||||
|
||||
Scenario: I cannot see context scripts when I do not have a context
|
||||
Given I have no contexts
|
||||
When I go to the feeds page
|
||||
Then I should see a message that you need a context to get feeds for contexts
|
||||
|
||||
Scenario: I cannot see proejct scripts when I do not have a project
|
||||
Given I have no projects
|
||||
When I go to the feeds page
|
||||
Then I should see a message that you need a project to get feeds for projects
|
||||
|
||||
Scenario: I can see scripts when I have one or more contexts
|
||||
When I go to the feeds page
|
||||
Then I should see feeds for projects
|
||||
And I should see "Test feedlist" as the selected project
|
||||
And I should see feeds for contexts
|
||||
And I should see "@pc" as the selected context
|
||||
|
||||
@selenium @wip
|
||||
Scenario Outline: I can select the item for getting feeds for that item
|
||||
When I go to the feeds page
|
||||
And I select "<item>" from "<item-list>"
|
||||
Then I should see feeds for "<item>" in list of "<item-type>"
|
||||
|
||||
Examples:
|
||||
| item | item-list | item-type |
|
||||
| @boss | feed-contexts | context |
|
||||
| Get release out | feed-projects | project |
|
||||
|
|
@ -10,7 +10,7 @@ Given /^there exists an active context called "([^"]*)" for user "([^"]*)"$/ do
|
|||
end
|
||||
|
||||
Given /^there exists a context called "([^"]*)" for user "([^"]*)"$/ do |context_name, login|
|
||||
Given "there exists an active context called \"#{context_name}\" for user \"#{login}\""
|
||||
Given "there exists an active context called \"#{context_name}\" for user \"#{login}\""
|
||||
end
|
||||
|
||||
Given /^there exists a hidden context called "([^"]*)" for user "([^"]*)"$/ do |context_name, login|
|
||||
|
|
@ -75,3 +75,8 @@ end
|
|||
Then /^he should see that a context named "([^\"]*)" is not present$/ do |context_name|
|
||||
Then "I should not see \"#{context_name} (\""
|
||||
end
|
||||
|
||||
Then /^I should see feeds for "([^"]*)" in list of "([^"]*)"$/ do |name, list_type|
|
||||
xpath= "//div[@id='feeds-for-#{list_type}']//strong"
|
||||
name.should == response.selenium.get_text("xpath=#{xpath}")
|
||||
end
|
||||
|
|
|
|||
31
features/step_definitions/feedlist_steps.rb
Normal file
31
features/step_definitions/feedlist_steps.rb
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
Then /^I should see a message that you need a context to get feeds for contexts$/ do
|
||||
Then "I should see \"There need to be at least one context before you can request a feed\""
|
||||
end
|
||||
|
||||
Then /^I should see a message that you need a project to get feeds for projects$/ do
|
||||
Then "I should see \"There need to be at least one project before you can request a feed\""
|
||||
end
|
||||
|
||||
Then /^I should see feeds for projects$/ do
|
||||
within 'select[id="feed-projects"]' do |scope|
|
||||
scope.should have_selector("option[value=\"#{@current_user.projects.first.id}\"]")
|
||||
end
|
||||
end
|
||||
|
||||
Then /^I should see feeds for contexts$/ do
|
||||
within 'select[id="feed-contexts"]' do |scope|
|
||||
scope.should have_selector("option[value=\"#{@current_user.contexts.first.id}\"]")
|
||||
end
|
||||
end
|
||||
|
||||
Then /^I should see "([^"]*)" as the selected project$/ do |project_name|
|
||||
within 'select[id="feed-projects"]' do |scope|
|
||||
scope.should have_selector("option[selected=\"selected\"]", :content => project_name)
|
||||
end
|
||||
end
|
||||
|
||||
Then /^I should see "([^"]*)" as the selected context$/ do |context_name|
|
||||
within 'select[id="feed-contexts"]' do |scope|
|
||||
scope.should have_selector("option[selected=\"selected\"]", :content => context_name)
|
||||
end
|
||||
end
|
||||
|
|
@ -24,6 +24,16 @@ Given /^I have a project called "([^"]*)"$/ do |project_name|
|
|||
Given "there exists a project \"#{project_name}\" for user \"#{@current_user.login}\""
|
||||
end
|
||||
|
||||
Given /^I have the following projects:$/ do |table|
|
||||
table.hashes.each do |project|
|
||||
Given 'I have a project called "'+project[:project_name]+'"'
|
||||
end
|
||||
end
|
||||
|
||||
Given /^I have no projects$/ do
|
||||
Project.delete_all
|
||||
end
|
||||
|
||||
When /^I visit the "([^\"]*)" project$/ do |project_name|
|
||||
@project = Project.find_by_name(project_name)
|
||||
@project.should_not be_nil
|
||||
|
|
|
|||
|
|
@ -491,10 +491,10 @@ var FeedsPage = {
|
|||
FeedsPage.get_script_for_project("#feeds-for-project", "get_feeds_for_project", this.value );
|
||||
});
|
||||
},
|
||||
get_script_for_context: function(element, getter, param){
|
||||
get_script_for_context: function(element, getter, context){
|
||||
generic_get_script_for_list(element, "feedlist/"+getter, "context_id="+context);
|
||||
},
|
||||
get_script_for_project: function(element, getter, param){
|
||||
get_script_for_project: function(element, getter, project){
|
||||
generic_get_script_for_list(element, "feedlist/"+getter, "project_id="+project);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue