add function of bulk delete time entries (#7996).
Contributed by Adam Soltys. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5316 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
c2baf187ac
commit
098fabd6ce
|
@ -18,8 +18,8 @@
|
||||||
class TimelogController < ApplicationController
|
class TimelogController < ApplicationController
|
||||||
menu_item :issues
|
menu_item :issues
|
||||||
before_filter :find_project, :only => [:new, :create]
|
before_filter :find_project, :only => [:new, :create]
|
||||||
before_filter :find_time_entry, :only => [:show, :edit, :update, :destroy]
|
before_filter :find_time_entry, :only => [:show, :edit, :update]
|
||||||
before_filter :find_time_entries, :only => [:bulk_edit, :bulk_update]
|
before_filter :find_time_entries, :only => [:bulk_edit, :bulk_update, :destroy]
|
||||||
before_filter :authorize, :except => [:index]
|
before_filter :authorize, :except => [:index]
|
||||||
before_filter :find_optional_project, :only => [:index]
|
before_filter :find_optional_project, :only => [:index]
|
||||||
accept_key_auth :index, :show, :create, :update, :destroy
|
accept_key_auth :index, :show, :create, :update, :destroy
|
||||||
|
@ -180,30 +180,34 @@ class TimelogController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
set_flash_from_bulk_time_entry_save(@time_entries, unsaved_time_entry_ids)
|
set_flash_from_bulk_time_entry_save(@time_entries, unsaved_time_entry_ids)
|
||||||
redirect_back_or_default({:controller => 'timelog', :action => 'index', :project_id => @project})
|
redirect_back_or_default({:controller => 'timelog', :action => 'index', :project_id => @projects.first})
|
||||||
end
|
end
|
||||||
|
|
||||||
verify :method => :delete, :only => :destroy, :render => {:nothing => true, :status => :method_not_allowed }
|
verify :method => :delete, :only => :destroy, :render => {:nothing => true, :status => :method_not_allowed }
|
||||||
def destroy
|
def destroy
|
||||||
if @time_entry.destroy && @time_entry.destroyed?
|
@time_entries.each do |t|
|
||||||
respond_to do |format|
|
begin
|
||||||
format.html {
|
unless t.destroy && t.destroyed?
|
||||||
flash[:notice] = l(:notice_successful_delete)
|
|
||||||
redirect_to :back
|
|
||||||
}
|
|
||||||
format.api { head :ok }
|
|
||||||
end
|
|
||||||
else
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {
|
format.html {
|
||||||
flash[:error] = l(:notice_unable_delete_time_entry)
|
flash[:error] = l(:notice_unable_delete_time_entry)
|
||||||
redirect_to :back
|
redirect_to :back
|
||||||
}
|
}
|
||||||
format.api { render_validation_errors(@time_entry) }
|
format.api { render_validation_errors(t) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
rescue ::ActionController::RedirectBackError
|
rescue ::ActionController::RedirectBackError
|
||||||
redirect_to :action => 'index', :project_id => @time_entry.project
|
redirect_to :action => 'index', :project_id => @projects.first
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html {
|
||||||
|
flash[:notice] = l(:notice_successful_delete)
|
||||||
|
redirect_back_or_default(:action => 'index', :project_id => @projects.first)
|
||||||
|
}
|
||||||
|
format.api { head :ok }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -24,4 +24,10 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= call_hook(:view_time_entries_context_menu_end, {:time_entries => @time_entries, :can => @can, :back => @back }) %>
|
<%= call_hook(:view_time_entries_context_menu_end, {:time_entries => @time_entries, :can => @can, :back => @back }) %>
|
||||||
|
|
||||||
|
<li>
|
||||||
|
<%= context_menu_link l(:button_delete),
|
||||||
|
{:controller => 'timelog', :action => 'destroy', :ids => @time_entries.collect(&:id), :back_url => @back},
|
||||||
|
:method => :delete, :confirm => l(:text_time_entries_destroy_confirmation), :class => 'icon-del', :disabled => !@can[:delete] %>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -894,6 +894,7 @@ en:
|
||||||
text_status_changed_by_changeset: "Applied in changeset %{value}."
|
text_status_changed_by_changeset: "Applied in changeset %{value}."
|
||||||
text_time_logged_by_changeset: "Applied in changeset %{value}."
|
text_time_logged_by_changeset: "Applied in changeset %{value}."
|
||||||
text_issues_destroy_confirmation: 'Are you sure you want to delete the selected issue(s)?'
|
text_issues_destroy_confirmation: 'Are you sure you want to delete the selected issue(s)?'
|
||||||
|
text_time_entries_destroy_confirmation: 'Are you sure you want to delete the selected time entr(y/ies)?'
|
||||||
text_select_project_modules: 'Select modules to enable for this project:'
|
text_select_project_modules: 'Select modules to enable for this project:'
|
||||||
text_default_administrator_account_changed: Default administrator account changed
|
text_default_administrator_account_changed: Default administrator account changed
|
||||||
text_file_repository_writable: Attachments directory writable
|
text_file_repository_writable: Attachments directory writable
|
||||||
|
|
Loading…
Reference in New Issue