mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-10 03:08:50 +01:00
Apply James Kebinger's patch to improve the initial state of the projects page when a user does not yet have any projectes.
Thanks, James! git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@472 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
parent
85885f9b9b
commit
3e177ad67b
7 changed files with 37 additions and 3 deletions
|
|
@ -48,6 +48,7 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
@saved = @project.save
|
||||
@project_not_done_counts = { @project.id => 0 }
|
||||
@active_projects_count = @user.projects.count(:conditions => "state = 'active'")
|
||||
respond_to do |wants|
|
||||
wants.js
|
||||
wants.xml do
|
||||
|
|
@ -102,6 +103,9 @@ class ProjectsController < ApplicationController
|
|||
|
||||
def destroy
|
||||
@project.destroy
|
||||
@active_projects_count = @user.projects.count(:conditions => "state = 'active'")
|
||||
@hidden_projects_count = @user.projects.count(:conditions => "state = 'hidden'")
|
||||
@completed_projects_count = @user.projects.count(:conditions => "state = 'completed'")
|
||||
respond_to do |format|
|
||||
format.js
|
||||
format.xml { render :text => "Deleted project #{@project.name}" }
|
||||
|
|
|
|||
|
|
@ -8,6 +8,14 @@ module ProjectsHelper
|
|||
:url => order_projects_path
|
||||
}
|
||||
end
|
||||
|
||||
def set_element_visible(id,test)
|
||||
if (test)
|
||||
page.show id
|
||||
else
|
||||
page.hide id
|
||||
end
|
||||
end
|
||||
|
||||
def project_next_prev
|
||||
html = ''
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<div class="project-state-group">
|
||||
<h2 <%= " style=\"display:none\"" if project_state_group.empty? %>><span id="<%= state %>-projects-count" class="badge"><%= project_state_group.length %></span><%= state.titlecase %> Projects</h2>
|
||||
<div class="project-state-group" id="list-<%= state %>-projects-container" <%= " style=\"display:none\"" if project_state_group.empty? %>>
|
||||
<h2><span id="<%= state %>-projects-count" class="badge"><%= project_state_group.length %></span><%= state.titlecase %> Projects</h2>
|
||||
<div id="list-<%= state %>-projects">
|
||||
<%= render :partial => 'project_listing', :collection => project_state_group %>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
if @saved
|
||||
page.hide 'projects-empty-nd'
|
||||
page.show 'list-active-projects-container'
|
||||
page.replace_html "active-projects-count", @active_projects_count
|
||||
page.insert_html :bottom, "list-active-projects", :partial => 'project_listing', :locals => { :project_listing => @project }
|
||||
page.sortable "list-active-projects", get_listing_sortable_options('list-active-projects')
|
||||
page.call "Form.reset", "project-form"
|
||||
|
|
@ -6,4 +9,5 @@ if @saved
|
|||
else
|
||||
page.show 'status'
|
||||
page.replace_html 'status', "#{error_messages_for('project')}"
|
||||
end
|
||||
end
|
||||
page.hide "busy"
|
||||
|
|
@ -1,5 +1,12 @@
|
|||
page.visual_effect :fade, dom_id(@project, "container"), :duration => 0.5
|
||||
page.delay(0.5) do
|
||||
page[dom_id(@project, "container")].remove
|
||||
page.replace_html "active-projects-count", @active_projects_count
|
||||
page.replace_html "hidden-projects-count", @hidden_projects_count
|
||||
page.replace_html "completed-projects-count", @completed_projects_count
|
||||
page.set_element_visible ("list-hidden-projects-container", @hidden_projects_count > 0)
|
||||
page.set_element_visible ("list-active-projects-container", @active_projects_count > 0)
|
||||
page.set_element_visible ("list-completed-projects-container", @completed_projects_count > 0)
|
||||
end
|
||||
page.notify :notice, "Deleted project '#{@project.name}'", 5.0
|
||||
page.hide "busy"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,9 @@
|
|||
<% @no_projects = @active_projects.empty? && @hidden_projects.empty? && @completed_projects.empty? %>
|
||||
|
||||
<div id="display_box">
|
||||
<div id="projects-empty-nd" style="display:<%= @no_projects ? 'block' : 'none'%>;">
|
||||
<div class="message"><p>Currently there are no projects</p></div>
|
||||
</div>
|
||||
<%= render :partial => 'project_state_group', :object => @active_projects, :locals => { :state => 'active'} %>
|
||||
<%= render :partial => 'project_state_group', :object => @hidden_projects, :locals => { :state => 'hidden'} %>
|
||||
<%= render :partial => 'project_state_group', :object => @completed_projects, :locals => { :state => 'completed'} %>
|
||||
|
|
|
|||
|
|
@ -10,3 +10,9 @@ page.sortable "list-#{@project.state}-projects", get_listing_sortable_options("l
|
|||
page.replace_html "active-projects-count", @active_projects_count
|
||||
page.replace_html "hidden-projects-count", @hidden_projects_count
|
||||
page.replace_html "completed-projects-count", @completed_projects_count
|
||||
|
||||
page.set_element_visible ("list-hidden-projects-container", @hidden_projects_count > 0)
|
||||
page.set_element_visible ("list-active-projects-container", @active_projects_count > 0)
|
||||
page.set_element_visible ("list-completed-projects-container", @completed_projects_count > 0)
|
||||
|
||||
page.hide "busy"
|
||||
Loading…
Add table
Add a link
Reference in a new issue