Skip to content

Commit

Permalink
Merge branch 'task_uncompleted' of github.com:VAIRIX/fat_free_crm int…
Browse files Browse the repository at this point in the history
…o VAIRIX-task_uncompleted

Conflicts:
	config/locales/ru_fat_free_crm.yml
	spec/controllers/entities/contacts_controller_spec.rb
  • Loading branch information
steveyken committed Aug 23, 2014
2 parents c286462 + 4a34da9 commit 36110f6
Show file tree
Hide file tree
Showing 24 changed files with 141 additions and 12 deletions.
2 changes: 1 addition & 1 deletion app/controllers/entities_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def versions

#----------------------------------------------------------------------------
def field_group
if @tag = Tag.find_by_name(params[:tag].strip)
if @tag = Tag.find_or_create_by_name(params[:tag].strip)
if @field_group = FieldGroup.find_by_tag_id_and_klass_name(@tag.id, klass.to_s)
@asset = klass.find_by_id(params[:asset_id]) || klass.new
render 'fields/group' and return
Expand Down
15 changes: 15 additions & 0 deletions app/controllers/tasks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,21 @@ def complete
respond_with(@task)
end

# PUT /tasks/1/uncomplete
#----------------------------------------------------------------------------
def uncomplete
@task = Task.tracked_by(current_user).find(params[:id])
@task.update_attributes(:completed_at => nil, :completed_by => nil) if @task

# Make sure bucket's div gets hidden if we're deleting last task in the bucket.
if Task.bucket_empty?(params[:bucket], current_user, @view)
@empty_bucket = params[:bucket]
end

update_sidebar
respond_with(@task)
end

# POST /tasks/auto_complete/query AJAX
#----------------------------------------------------------------------------
# Handled by ApplicationController :auto_complete
Expand Down
6 changes: 6 additions & 0 deletions app/helpers/tasks_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ def link_to_task_complete(pending, bucket)
onclick << %Q{$.ajax("#{complete_task_path(pending)}", {type: "PUT", data: {bucket: "#{bucket}"}});}
end

#----------------------------------------------------------------------------
def link_to_task_uncomplete(task, bucket)
link_to(t(:task_uncomplete), uncomplete_task_path(task, :bucket => bucket, :view => @view),
:method => :put, :remote => true)
end

# Task summary for RSS/ATOM feed.
#----------------------------------------------------------------------------
def task_summary(task)
Expand Down
4 changes: 3 additions & 1 deletion app/views/tasks/_completed.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
.tools
- if shown_on_landing_page?
= link_to_discard(completed) + (current_user == completed.user ? ' | ' : '')
= link_to_task_delete(completed, bucket) if current_user == completed.user
- if current_user == completed.user
= link_to_task_uncomplete(completed, bucket) + ' | '
= link_to_task_delete(completed, bucket)

.indent
%strike= auto_link h(completed.name)
Expand Down
12 changes: 12 additions & 0 deletions app/views/tasks/uncomplete.js.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
- if @task.errors.empty?
$('##{dom_id(@task)}').slideUp(250);

- if @empty_bucket
$('#list_#{@empty_bucket}').fadeOut({ duration:500 });

- if called_from_index_page?
= refresh_sidebar(:index, :filters)
- else # Errors
$('##{dom_id(@task)}').effect("shake", { duration:250, distance: 6 });
$('#task_name').focus();
$('#task_submit').enable();
1 change: 1 addition & 0 deletions config/locales/cz_fat_free_crm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ cz:
task_assigned: Úkol byl přiřazen k %{value}
task_assigned_to: a přiřazen k %{value}
task_completed: dokončen
task_uncomplete: Vrátit se
task_completed_ago: dokončen před %{value}
task_completed_by: dokončen před %{time_ago} (%{date}) uživatelem %{user}
task_created: Úkol byl vytvořen
Expand Down
1 change: 1 addition & 0 deletions config/locales/de_fat_free_crm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,7 @@ de:
no_button: Nein
msg_asset_not_authorized: You are not authorized to view this %{value}.
task_completed: erledigt
task_uncomplete: Zurückkehren
google: Google IM
twitter: Twitter
back: Zurück
Expand Down
1 change: 1 addition & 0 deletions config/locales/en-GB_fat_free_crm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ en-GB:
task_assigned: The task has been assigned to %{value}
task_assigned_to: and assigned to %{value}
task_completed: completed
task_uncomplete: Uncomplete
task_completed_ago: completed %{value} ago
task_completed_by: completed %{time_ago} ago (%{date}) by %{user}
task_created: The task has been created
Expand Down
1 change: 1 addition & 0 deletions config/locales/en-US_fat_free_crm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,7 @@ en-US:
task_assigned: The task has been assigned to %{value}
task_assigned_to: and assigned to %{value}
task_completed: completed
task_uncomplete: Uncomplete
task_completed_ago: completed %{value} ago
task_completed_by: completed %{time_ago} ago (%{date}) by %{user}
task_created: The task has been created
Expand Down
1 change: 1 addition & 0 deletions config/locales/es_fat_free_crm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ es:
task_assigned: La tarea ha sido encargada a %{value}
task_assigned_to: y encargada a %{value}
task_completed: completada
task_uncomplete: Revertir
task_completed_ago: completada hace %{value}
task_completed_by: completada %{time_ago} por %{user}
task_created: La tarea ha sido creada
Expand Down
1 change: 1 addition & 0 deletions config/locales/fr-CA_fat_free_crm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ fr-CA:
task_assigned: La tâche à été assignée à %{value}
task_assigned_to: et assignée à %{value}
task_completed: complétée
task_uncomplete: Revenir
task_completed_ago: complétée il y à %{value}
task_completed_by: complétée il y à %{time_ago} par %{user}
task_created: La tâche à été crée.
Expand Down
1 change: 1 addition & 0 deletions config/locales/fr_fat_free_crm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ fr:
task_assigned: La tâche à été assignée à %{value}
task_assigned_to: et assignée à %{value}
task_completed: complétée
task_uncomplete: Revenir
task_completed_ago: complétée il y à %{value}
task_completed_by: complétée il y à %{time_ago} par %{user}
task_created: La tâche à été créée
Expand Down
1 change: 1 addition & 0 deletions config/locales/it_fat_free_crm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ it:
task_assigned: Il lavoro e' stato assegnato a %{value}
task_assigned_to: e assegnato a %{value}
task_completed: completato
task_uncomplete: Ritornare
task_completed_ago: completato %{value} fa
task_completed_by: completato %{time_ago} fa (%{date}) da %{user}
task_created: Il lavoro e' stato creato
Expand Down
1 change: 1 addition & 0 deletions config/locales/ja_fat_free_crm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ ja:
task_assigned: The task has been assigned to %{value}
task_assigned_to: and assigned to %{value}
task_completed: 完了
task_uncomplete: 戻す
task_completed_ago: ! '%{value} 前に完了'
task_completed_by: ! '%{user} によって %{time_ago} 前に完了'
task_created: タスクが作成されました
Expand Down
1 change: 1 addition & 0 deletions config/locales/pl_fat_free_crm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ pl:
task_assigned: Zadanie zostało przypisane do %{value}
task_assigned_to: i przypisane do %{value}
task_completed: zakończone
task_uncomplete: Przywróć
task_completed_ago: zakończone %{value} temu
task_completed_by: zakończone %{time_ago} temu przez %{user}
task_created: Utworzono zadanie
Expand Down
1 change: 1 addition & 0 deletions config/locales/pt-BR_fat_free_crm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ pt-BR:
task_assigned: As tarefas foram atribuídas para %{value}
task_assigned_to: e artibuída para %{value}
task_completed: terminada
task_uncomplete: Reverter
task_completed_ago: terminada há %{value} atrás
task_completed_by: terminada há %{time_ago} atrás por %{user}
task_created: A tarea foi criada
Expand Down
11 changes: 6 additions & 5 deletions config/locales/ru_fat_free_crm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ ru:
#----------------------------------------------------------------------------
account: Контрагент
account_id: Контрагент
select_an_account: Выберите Контрагента
select_an_account: Выберите Контрагента
account_permissions_intro: По умолчанию только Вы будете иметь доступ к этому контрагенту. Права доступа можно будет изменить в любое время.
account_small: контрагент
account_summary: Сводка по контрагенту
Expand Down Expand Up @@ -390,7 +390,7 @@ ru:
was_supposed_to_finish: должна была закончиться %{value}
was_supposed_to_start: должна была начаться %{time_ago} назад %{start_date}
was_supposed_to_start_in: должна была начаться %{starts_in} к %{start_date}
select_a_campaign: Выберите кампанию
select_a_campaign: Выберите кампанию

# Views -> Contacts.
#----------------------------------------------------------------------------
Expand Down Expand Up @@ -505,7 +505,7 @@ ru:
stage: Стадия
total_opportunities: Всего возможностей
weighted_amount: Взвешенная сумма

# Views -> Tasks.
#----------------------------------------------------------------------------
task: Задание
Expand Down Expand Up @@ -534,6 +534,7 @@ ru:
task_assigned: Это задание поручено %{value}
task_assigned_to: и поручено %{value}
task_completed: завершено
task_uncomplete: Bозвращаться
task_completed_ago: завершено %{value} назад
task_completed_by: завершил(а) %{user} %{time_ago} назад
task_created: Задание добавлено
Expand Down Expand Up @@ -894,11 +895,11 @@ ru:
field_group_confirm_delete: Если удалить группу полей, все пользовательские поля будуь перемещены в группу полей по умолчанию.
msg_cant_delete_field_group: Группа полей не может быть удалена.
admin_fields_info: ! 'Пользовательские поля отображаются в группах. Создайте новую группу полей или добавьте пользовательское поле к одной из ниже перечисленных групп.<br /> Вы можете перетаскивать поля, что бы менять их порядок отображения или принадлежность к группе.'

# Views -> Admin -> Tags
#----------------------------------------------------------------------------
admin_fields_info2: ! 'Настоятельно рекомендуеца перезапустить ваш сервер после добавления или удаления пользовательских полей.'

tags: Метки
tag_small: метка
tagged: Помеченный
Expand Down
1 change: 1 addition & 0 deletions config/locales/sv-SE_fat_free_crm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ sv-SE:
task_assigned: Ärendet har tilldelats till %{value}
task_assigned_to: och tilldelats till %{value}
task_completed: utfört
task_uncomplete: Återställ
task_completed_ago: utfört %{value} sedan
task_completed_by: utfört %{time_ago} sedan (%{date}) av %{user}
task_created: Ärendet har skapats
Expand Down
1 change: 1 addition & 0 deletions config/locales/th_fat_free_crm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ th:
task_assigned: ภารกิจได้ถูกมอบหมายให้ %{value}
task_assigned_to: และได้มอบหมายให้ %{value}
task_completed: เสร็จสมบูรณ์
task_uncomplete: คืนกลับ
task_completed_by: เสร็จ %{time_ago} ที่ผ่านมา โดย %{user}
task_completed_ago: เสร็จ %{value} ที่ผ่านมา
task_created: ภารกิจได้ถูกสร้างขึ้นแล้ว
Expand Down
1 change: 1 addition & 0 deletions config/locales/zh-CN_fat_free_crm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ zh-CN:
task_assigned: 任务已经分配给 %{value}
task_assigned_to: 并分配给 %{value}
task_completed: 已完成
task_uncomplete: 还原
task_completed_ago: 完成于 %{value} 以前
task_completed_by: 由 %{user} 完成于 %{time_ago} 以前
task_created: 任务已被创建
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
end
member do
put :complete
put :uncomplete
end
end

Expand Down
29 changes: 29 additions & 0 deletions spec/controllers/tasks_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,35 @@ def produce_tasks(user, view)
end
end

# PUT /tasks/1/complete
# PUT /leads/1/complete.xml AJAX
#----------------------------------------------------------------------------
describe "responding to PUT uncomplete" do

it "should change task status, expose task as @task, and render template" do
@task = FactoryGirl.create(:task, :completed_at => Time.now, :user => current_user)

xhr :put, :uncomplete, :id => @task.id
@task.reload.completed_at.should == nil
assigns[:task].should == @task
assigns[:task_total].should_not == nil
response.should render_template("tasks/uncomplete")
end


describe "task got deleted" do
it "should reload current page with the flash message if the task got deleted" do
@task = FactoryGirl.create(:task, :user => FactoryGirl.create(:user), :assignee => current_user, :completed_at => Time.now)
@task.destroy

xhr :put, :uncomplete, :id => @task.id
flash[:warning].should_not == nil
response.body.should == "window.location.reload();"
end

end
end

# Ajax request to filter out a list of tasks. AJAX
#----------------------------------------------------------------------------
describe "responding to GET filter" do
Expand Down
15 changes: 10 additions & 5 deletions spec/helpers/tasks_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@

describe TasksHelper do

#Delete this example and add some real ones or delete this file
it "should be included in the object returned by #helper" do
included_modules = (class << helper; self; end).send :included_modules
included_modules.should include(TasksHelper)
end
describe "responding with generated links" do

before do
@task = FactoryGirl.create(:task)
end

it "should render link to uncomplete of a task" do
link_to_task_uncomplete(@task, nil).should include(t(:task_uncomplete))
end

end
end

44 changes: 44 additions & 0 deletions spec/views/tasks/uncomplete.js.haml_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Copyright (c) 2008-2013 Michael Dvorkin and contributors.
#
# Fat Free CRM is freely distributable under the terms of MIT license.
# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
#------------------------------------------------------------------------------
require 'spec_helper'

describe "/tasks/uncomplete" do
include TasksHelper

before do
login_and_assign
assign(:bucket, [])
end

describe "uncomplete from Tasks tab (completed view)" do
before do
@task = FactoryGirl.create(:task)
assign(:task, @task)
assign(:view, "completed")
assign(:empty_bucket, :due_asap)
assign(:task_total, stub_task_total("completed"))
end

it "should slide up uncompleted task partial" do
controller.request.env["HTTP_REFERER"] = "http://localhost/tasks"

render
rendered.should include("$('#task_#{@task.id}').slideUp")
rendered.should include("$('#list_due_asap').fadeOut")
end

it "should update tasks sidebar" do
assign(:task, FactoryGirl.create(:task))
controller.request.env["HTTP_REFERER"] = "http://localhost/tasks"

render
rendered.should include("$('#sidebar').html")
rendered.should have_text("Assigned")
rendered.should have_text("Recent Items")
rendered.should include("$('#filters').effect('shake'")
end
end
end

0 comments on commit 36110f6

Please # to comment.