get context list scenario passing

This commit is contained in:
Reinier Balt 2012-05-01 09:39:53 +02:00
parent c9d64e6f4b
commit 7bce774daa
9 changed files with 29 additions and 36 deletions

View file

@ -72,32 +72,19 @@ class ApplicationController < ActionController::Base
render :text => message, :status => status
end
# def rescue_action(exception)
# log_error(exception) if logger
# respond_to do |format|
# format.html do
# notify :warning, "An error occurred on the server."
# render :action => "index"
# end
# format.js { render :action => 'error' }
# format.xml { render :text => 'An error occurred on the server.' + $! }
# end
# end
# Returns a count of next actions in the given context or project The result
# is count and a string descriptor, correctly pluralised if there are no
# actions or multiple actions
#
def count_undone_todos_phrase(todos_parent, string="actions")
def count_undone_todos_phrase(todos_parent)
count = count_undone_todos(todos_parent)
deferred_count = count_deferred_todos(todos_parent)
if count == 0 && deferred_count > 0
word = deferred_count == 1 ? string.singularize : string.pluralize
word = "deferred&nbsp;" + word
return (deferred_count.to_s + "&nbsp;" + word).html_safe
word = "#{I18n.t('common.deferred')}&nbsp;#{I18n.t('common.actions_midsentence', :count => deferred_count)}"
return "#{deferred_count.to_s}&nbsp;#{word}".html_safe
else
word = count == 1 ? string.singularize : string.pluralize
return (count.to_s + "&nbsp;" + word).html_safe
word = I18n.t('common.actions_midsentence', :count => count)
return "#{count.to_s}&nbsp;#{word}".html_safe
end
end

View file

@ -12,6 +12,7 @@ class ContextsController < ApplicationController
@active_contexts = current_user.contexts.active
@hidden_contexts = current_user.contexts.hidden
@new_context = current_user.contexts.build
init_not_done_counts(['context'])
# save all contexts here as @new_context will add an empty one to current_user.contexts
@all_contexts = @active_contexts + @hidden_contexts
@ -196,7 +197,6 @@ class ContextsController < ApplicationController
@no_hidden_contexts = @hidden_contexts.empty?
@active_count = @active_contexts.size
@hidden_count = @hidden_contexts.size
init_not_done_counts(['context'])
render
end
end

View file

@ -101,17 +101,17 @@ module ApplicationHelper
# actions or multiple actions
#
def count_undone_todos_phrase(todos_parent)
controller.count_undone_todos_phrase(todos_parent)
controller.count_undone_todos_phrase(todos_parent).html_safe
end
def count_undone_todos_phrase_text(todos_parent)
count_undone_todos_phrase(todos_parent).gsub("&nbsp;"," ")
count_undone_todos_phrase(todos_parent).gsub("&nbsp;"," ").html_safe
end
def count_undone_todos_and_notes_phrase(project)
s = count_undone_todos_phrase(project)
s += ", #{t('common.note', :count => project.note_count)}" unless project.note_count == 0
s
s.html_safe
end
def link_to_context(context, descriptor = sanitize(context.name))

View file

@ -1,15 +1,13 @@
<% context = context_form
@context = context
-%>
<% form_for(context, :html => {
<%= form_for(context, :html => {
:id => dom_id(context, 'edit_form'),
:class => "inline-form edit-project-form",
:method => :put }) do
-%>
<div id="edit_error_status"><%= error_messages_for("project") %></div>
<div id="edit_error_status"><%= get_list_of_error_messages_for(context) %></div>
<label for="context_name"><%= t 'contexts.context_name' %></label><br/>
<%= text_field('context', 'name', :class => 'context-name', :tabindex => next_tab_index) %><br/>

View file

@ -10,7 +10,7 @@ suppress_delete_button ||= false
<%= suppress_edit_button ? "" : link_to_edit_context(context, image_tag( "blank.png", :title => t('contexts.edit_context'), :class=>"edit_item")) -%>
<%= suppress_drag_handle ? "" : image_tag('grip.png', :width => '7', :height => '16', :border => '0', :title => t('common.drag_handle'), :class => 'grip')-%>
<div class="context_description">
<%= link_to_context( context ) %> <%= " (" + count_undone_todos_phrase(context) + ")" %>
<%= link_to_context( context ) %> <%= raw " (#{count_undone_todos_phrase(context)})" %>
</div>
</div>
<div id="<%= dom_id(context, 'edit') %>" class="edit-form" style="display:none;">