Feature #7996 » bulk_time_entry_edit.diff
| app/controllers/context_menus_controller.rb | ||
|---|---|---|
|
|
||
|
render :layout => false
|
||
|
end
|
||
|
|
||
|
def time_entries
|
||
|
@time_entries = TimeEntry.all(:conditions => {:id => params[:ids]}, :include => :project)
|
||
|
|
||
|
@projects = @time_entries.collect(&:project).compact.uniq
|
||
|
@project = @projects.first if @projects.size == 1
|
||
|
|
||
|
@activities = TimeEntryActivity.shared.active
|
||
|
@can = {:edit => User.current.allowed_to?(:log_time, @projects),
|
||
|
:update => User.current.allowed_to?(:log_time, @projects),
|
||
|
:delete => User.current.allowed_to?(:log_time, @projects)
|
||
|
}
|
||
|
@back = back_url
|
||
|
render :layout => false
|
||
|
end
|
||
|
end
|
||
| app/controllers/timelog_controller.rb | ||
|---|---|---|
|
class TimelogController < ApplicationController
|
||
|
menu_item :issues
|
||
|
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, :destroy]
|
||
|
before_filter :authorize, :except => [:index]
|
||
|
before_filter :find_optional_project, :only => [:index]
|
||
|
accept_key_auth :index, :show, :create, :update, :destroy
|
||
| ... | ... | |
|
end
|
||
|
end
|
||
|
def bulk_edit
|
||
|
@available_activities = TimeEntryActivity.shared.active
|
||
|
@custom_fields = TimeEntry.first.available_custom_fields
|
||
|
end
|
||
|
def bulk_update
|
||
|
attributes = parse_params_for_bulk_time_entry_attributes(params)
|
||
|
unsaved_time_entry_ids = []
|
||
|
@time_entries.each do |time_entry|
|
||
|
time_entry.reload
|
||
|
time_entry.attributes = attributes
|
||
|
call_hook(:controller_time_entries_bulk_edit_before_save, { :params => params, :time_entry => time_entry })
|
||
|
unless time_entry.save
|
||
|
# Keep unsaved time_entry ids to display them in flash error
|
||
|
unsaved_time_entry_ids << time_entry.id
|
||
|
end
|
||
|
end
|
||
|
set_flash_from_bulk_time_entry_save(@time_entries, unsaved_time_entry_ids)
|
||
|
redirect_back_or_default({:controller => 'timelog', :action => 'index', :project_id => @projects.first})
|
||
|
end
|
||
|
verify :method => :delete, :only => :destroy, :render => {:nothing => true, :status => :method_not_allowed }
|
||
|
def destroy
|
||
|
if @time_entry.destroy && @time_entry.destroyed?
|
||
|
respond_to do |format|
|
||
|
format.html {
|
||
|
flash[:notice] = l(:notice_successful_delete)
|
||
|
redirect_to :back
|
||
|
}
|
||
|
format.api { head :ok }
|
||
|
end
|
||
|
else
|
||
|
respond_to do |format|
|
||
|
format.html {
|
||
|
flash[:error] = l(:notice_unable_delete_time_entry)
|
||
|
redirect_to :back
|
||
|
}
|
||
|
format.api { render_validation_errors(@time_entry) }
|
||
|
@time_entries.each do |t|
|
||
|
begin
|
||
|
unless t.destroy && t.destroyed?
|
||
|
respond_to do |format|
|
||
|
format.html {
|
||
|
flash[:error] = l(:notice_unable_delete_time_entry)
|
||
|
redirect_to :back
|
||
|
}
|
||
|
format.api { render_validation_errors(t) }
|
||
|
end
|
||
|
end
|
||
|
rescue ::ActionController::RedirectBackError
|
||
|
redirect_to :action => 'index', :project_id => @projects.first
|
||
|
end
|
||
|
end
|
||
|
rescue ::ActionController::RedirectBackError
|
||
|
redirect_to :action => 'index', :project_id => @time_entry.project
|
||
|
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
|
||
|
private
|
||
| ... | ... | |
|
render_404
|
||
|
end
|
||
|
def find_time_entries
|
||
|
@time_entries = TimeEntry.find_all_by_id(params[:id] || params[:ids])
|
||
|
raise ActiveRecord::RecordNotFound if @time_entries.empty?
|
||
|
@projects = @time_entries.collect(&:project).compact.uniq
|
||
|
@project = @projects.first if @projects.size == 1
|
||
|
rescue ActiveRecord::RecordNotFound
|
||
|
render_404
|
||
|
end
|
||
|
def set_flash_from_bulk_time_entry_save(time_entries, unsaved_time_entry_ids)
|
||
|
if unsaved_time_entry_ids.empty?
|
||
|
flash[:notice] = l(:notice_successful_update) unless time_entries.empty?
|
||
|
else
|
||
|
flash[:error] = l(:notice_failed_to_save_time_entries,
|
||
|
:count => unsaved_time_entry_ids.size,
|
||
|
:total => time_entries.size,
|
||
|
:ids => '#' + unsaved_time_entry_ids.join(', #'))
|
||
|
end
|
||
|
end
|
||
|
def find_project
|
||
|
if (issue_id = (params[:issue_id] || params[:time_entry] && params[:time_entry][:issue_id])).present?
|
||
|
@issue = Issue.find(issue_id)
|
||
| ... | ... | |
|
@to ||= (TimeEntry.latest_date_for_project(@project) || Date.today)
|
||
|
end
|
||
|
def parse_params_for_bulk_time_entry_attributes(params)
|
||
|
attributes = (params[:time_entry] || {}).reject {|k,v| v.blank?}
|
||
|
attributes.keys.each {|k| attributes[k] = '' if attributes[k] == 'none'}
|
||
|
attributes[:custom_field_values].reject! {|k,v| v.blank?} if attributes[:custom_field_values]
|
||
|
attributes
|
||
|
end
|
||
|
end
|
||
| app/models/project.rb | ||
|---|---|---|
|
def all_issue_custom_fields
|
||
|
@all_issue_custom_fields ||= (IssueCustomField.for_all + issue_custom_fields).uniq.sort
|
||
|
end
|
||
|
# Returns an array of all custom fields enabled for project time entries
|
||
|
# (explictly associated custom fields and custom fields enabled for all projects)
|
||
|
def all_time_entry_custom_fields
|
||
|
@all_time_entry_custom_fields ||= (TimeEntryCustomField.for_all + time_entry_custom_fields).uniq.sort
|
||
|
end
|
||
|
|
||
|
def project
|
||
|
self
|
||
| app/views/context_menus/time_entries.html.erb | ||
|---|---|---|
|
<ul>
|
||
|
<%= call_hook(:view_time_entries_context_menu_start, {:time_entries => @time_entries, :can => @can, :back => @back }) %>
|
||
|
<% if !@time_entry.nil? -%>
|
||
|
<li><%= context_menu_link l(:button_edit), {:controller => 'timelog', :action => 'edit', :id => @time_entry},
|
||
|
:class => 'icon-edit', :disabled => !@can[:edit] %></li>
|
||
|
<% else %>
|
||
|
<li><%= context_menu_link l(:button_edit), {:controller => 'timelog', :action => 'bulk_edit', :ids => @time_entries.collect(&:id)},
|
||
|
:class => 'icon-edit', :disabled => !@can[:edit] %></li>
|
||
|
<% end %>
|
||
|
<% if @activities.present? -%>
|
||
|
<li class="folder">
|
||
|
<a href="#" class="submenu"><%= l(:field_activity) %></a>
|
||
|
<ul>
|
||
|
<% @activities.each do |u| -%>
|
||
|
<li><%= context_menu_link u.name, {:controller => 'timelog', :action => 'bulk_edit', :ids => @time_entries.collect(&:id), :time_entry => {'activity_id' => u}, :back_url => @back}, :method => :post,
|
||
|
:selected => (@time_entry && u == @time_entry.activity), :disabled => !@can[:update] %></li>
|
||
|
<% end -%>
|
||
|
<li><%= context_menu_link l(:label_nobody), {:controller => 'timelog', :action => 'bulk_edit', :ids => @time_entries.collect(&:id), :time_entry => {'activity_id' => 'none'}, :back_url => @back}, :method => :post,
|
||
|
:selected => (@time_entry && @time_entry.activity.nil?), :disabled => !@can[:update] %></li>
|
||
|
</ul>
|
||
|
</li>
|
||
|
<% end %>
|
||
|
<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>
|
||
|
<%= call_hook(:view_time_entries_context_menu_end, {:time_entries => @time_entries, :can => @can, :back => @back }) %>
|
||
|
</ul>
|
||
| app/views/timelog/_list.rhtml | ||
|---|---|---|
|
<% content_for :header_tags do %>
|
||
|
<%= javascript_include_tag 'context_menu' %>
|
||
|
<%= stylesheet_link_tag 'context_menu' %>
|
||
|
<%= stylesheet_link_tag 'context_menu_rtl' if l(:direction) == 'rtl' %>
|
||
|
<% end %>
|
||
|
<% form_tag({}) do -%>
|
||
|
<%= hidden_field_tag 'back_url', url_for(params) %>
|
||
|
<table class="list time-entries">
|
||
|
<thead>
|
||
|
<tr>
|
||
|
<th class="checkbox hide-when-print">
|
||
|
<%= link_to image_tag('toggle_check.png'),
|
||
|
{},
|
||
|
:onclick => 'toggleIssuesSelection(Element.up(this, "form")); return false;',
|
||
|
:title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}" %>
|
||
|
</th>
|
||
|
<%= sort_header_tag('spent_on', :caption => l(:label_date), :default_order => 'desc') %>
|
||
|
<%= sort_header_tag('user', :caption => l(:label_member)) %>
|
||
|
<%= sort_header_tag('activity', :caption => l(:label_activity)) %>
|
||
| ... | ... | |
|
</thead>
|
||
|
<tbody>
|
||
|
<% entries.each do |entry| -%>
|
||
|
<tr class="time-entry <%= cycle("odd", "even") %>">
|
||
|
<tr class="time-entry <%= cycle("odd", "even") %> hascontextmenu">
|
||
|
<td class="checkbox hide-when-print"><%= check_box_tag("ids[]", entry.id, false, :id => nil) %></td>
|
||
|
<td class="spent_on"><%= format_date(entry.spent_on) %></td>
|
||
|
<td class="user"><%=h entry.user %></td>
|
||
|
<td class="activity"><%=h entry.activity %></td>
|
||
| ... | ... | |
|
<% end -%>
|
||
|
</tbody>
|
||
|
</table>
|
||
|
<% end -%>
|
||
|
<%= context_menu time_entries_context_menu_path %>
|
||
| app/views/timelog/bulk_edit.rhtml | ||
|---|---|---|
|
<h2><%= l(:label_bulk_edit_selected_time_entries) %></h2>
|
||
|
<ul><%= @time_entries.collect {|i| content_tag('li', link_to(h("#{i.spent_on.strftime("%Y-%m-%d")} -- #{i.project}: #{l(:label_f_hour_plural, :value => i.hours)}"), { :action => 'edit', :id => i }))} %></ul>
|
||
|
<% form_tag(:action => 'bulk_update') do %>
|
||
|
<%= @time_entries.collect {|i| hidden_field_tag('ids[]', i.id)}.join %>
|
||
|
<div class="box tabular">
|
||
|
<fieldset class="attributes">
|
||
|
<legend><%= l(:label_change_properties) %></legend>
|
||
|
<div>
|
||
|
<p>
|
||
|
<label><%= l(:field_issue) %></label>
|
||
|
<%= text_field :time_entry, :issue_id, :size => 6 %>
|
||
|
</p>
|
||
|
<p>
|
||
|
<label><%= l(:field_spent_on) %></label>
|
||
|
<%= text_field :time_entry, :spent_on, :size => 10 %><%= calendar_for('time_entry_spent_on') %>
|
||
|
</p>
|
||
|
<p>
|
||
|
<label><%= l(:field_hours) %></label>
|
||
|
<%= text_field :time_entry, :hours, :size => 6 %>
|
||
|
</p>
|
||
|
<% if @available_activities.any? %>
|
||
|
<p>
|
||
|
<label><%= l(:field_activity) %></label>
|
||
|
<%= select_tag('time_entry[activity_id]', "<option value=\"\">#{l(:label_no_change_option)}</option>" + options_from_collection_for_select(@available_activities, :id, :name)) %>
|
||
|
</p>
|
||
|
<% end %>
|
||
|
<p>
|
||
|
<label><%= l(:field_comments) %></label>
|
||
|
<%= text_field(:time_entry, :comments, :size => 100) %>
|
||
|
</p>
|
||
|
<% @custom_fields.each do |custom_field| %>
|
||
|
<p><label><%= h(custom_field.name) %></label> <%= custom_field_tag_for_bulk_edit('time_entry', custom_field) %></p>
|
||
|
<% end %>
|
||
|
<%= call_hook(:view_time_entries_bulk_edit_details_bottom, { :time_entries => @time_entries }) %>
|
||
|
</div>
|
||
|
</fieldset>
|
||
|
</div>
|
||
|
<p><%= submit_tag l(:button_submit) %></p>
|
||
|
<% end %>
|
||
| config/locales/bg.yml | ||
|---|---|---|
|
button_expand_all: Expand all
|
||
|
button_collapse_all: Collapse all
|
||
|
label_bulk_edit_selected_time_entries: Bulk edit selected time entries
|
||
|
text_time_entries_destroy_confirmation: Are you sure you want to delete the selected time entr(y/ies) ?
|
||
| config/locales/bs.yml | ||
|---|---|---|
|
label_news_comment_added: Comment added to a news
|
||
|
button_expand_all: Expand all
|
||
|
button_collapse_all: Collapse all
|
||
|
label_bulk_edit_selected_time_entries: Bulk edit selected time entries
|
||
|
text_time_entries_destroy_confirmation: Are you sure you want to delete the selected time entr(y/ies) ?
|
||
| config/locales/ca.yml | ||
|---|---|---|
|
label_news_comment_added: Comment added to a news
|
||
|
button_expand_all: Expand all
|
||
|
button_collapse_all: Collapse all
|
||
|
label_bulk_edit_selected_time_entries: Bulk edit selected time entries
|
||
|
text_time_entries_destroy_confirmation: Are you sure you want to delete the selected time entr(y/ies) ?
|
||
| config/locales/cs.yml | ||
|---|---|---|
|
label_news_comment_added: Comment added to a news
|
||
|
button_expand_all: Expand all
|
||
|
button_collapse_all: Collapse all
|
||
|
label_bulk_edit_selected_time_entries: Bulk edit selected time entries
|
||
|
text_time_entries_destroy_confirmation: Are you sure you want to delete the selected time entr(y/ies) ?
|
||
| config/locales/da.yml | ||
|---|---|---|
|
label_news_comment_added: Comment added to a news
|
||
|
button_expand_all: Expand all
|
||
|
button_collapse_all: Collapse all
|
||
|
label_bulk_edit_selected_time_entries: Bulk edit selected time entries
|
||
|
text_time_entries_destroy_confirmation: Are you sure you want to delete the selected time entr(y/ies) ?
|
||
| config/locales/de.yml | ||
|---|---|---|
|
label_news_comment_added: Comment added to a news
|
||
|
button_expand_all: Expand all
|
||
|
button_collapse_all: Collapse all
|
||
|
label_bulk_edit_selected_time_entries: Bulk edit selected time entries
|
||
|
text_time_entries_destroy_confirmation: Are you sure you want to delete the selected time entr(y/ies) ?
|
||
| config/locales/el.yml | ||
|---|---|---|
|
label_news_comment_added: Comment added to a news
|
||
|
button_expand_all: Expand all
|
||
|
button_collapse_all: Collapse all
|
||
|
label_bulk_edit_selected_time_entries: Bulk edit selected time entries
|
||
|
text_time_entries_destroy_confirmation: Are you sure you want to delete the selected time entr(y/ies) ?
|
||
| config/locales/en-GB.yml | ||
|---|---|---|
|
label_news_comment_added: Comment added to a news
|
||
|
button_expand_all: Expand all
|
||
|
button_collapse_all: Collapse all
|
||
|
label_bulk_edit_selected_time_entries: Bulk edit selected time entries
|
||
|
text_time_entries_destroy_confirmation: Are you sure you want to delete the selected time entr(y/ies) ?
|
||
| config/locales/en.yml | ||
|---|---|---|
|
label_default_columns: Default columns
|
||
|
label_no_change_option: (No change)
|
||
|
label_bulk_edit_selected_issues: Bulk edit selected issues
|
||
|
label_bulk_edit_selected_time_entries: Bulk edit selected time entries
|
||
|
label_theme: Theme
|
||
|
label_default: Default
|
||
|
label_search_titles_only: Search titles only
|
||
| ... | ... | |
|
text_status_changed_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_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_default_administrator_account_changed: Default administrator account changed
|
||
|
text_file_repository_writable: Attachments directory writable
|
||
| config/locales/es.yml | ||
|---|---|---|
|
label_news_comment_added: Comment added to a news
|
||
|
button_expand_all: Expand all
|
||
|
button_collapse_all: Collapse all
|
||
|
label_bulk_edit_selected_time_entries: Bulk edit selected time entries
|
||
|
text_time_entries_destroy_confirmation: Are you sure you want to delete the selected time entr(y/ies) ?
|
||
| config/locales/eu.yml | ||
|---|---|---|
|
label_news_comment_added: Comment added to a news
|
||
|
button_expand_all: Expand all
|
||
|
button_collapse_all: Collapse all
|
||
|
label_bulk_edit_selected_time_entries: Bulk edit selected time entries
|
||
|
text_time_entries_destroy_confirmation: Are you sure you want to delete the selected time entr(y/ies) ?
|
||
| config/locales/fa.yml | ||
|---|---|---|
|
label_news_comment_added: Comment added to a news
|
||
|
button_expand_all: Expand all
|
||
|
button_collapse_all: Collapse all
|
||
|
label_bulk_edit_selected_time_entries: Bulk edit selected time entries
|
||
|
text_time_entries_destroy_confirmation: Are you sure you want to delete the selected time entr(y/ies) ?
|
||
| config/locales/fi.yml | ||
|---|---|---|
|
label_news_comment_added: Comment added to a news
|
||
|
button_expand_all: Expand all
|
||
|
button_collapse_all: Collapse all
|
||
|
label_bulk_edit_selected_time_entries: Bulk edit selected time entries
|
||
|
text_time_entries_destroy_confirmation: Are you sure you want to delete the selected time entr(y/ies) ?
|
||
| config/locales/fr.yml | ||
|---|---|---|
|
field_member_of_group: Groupe de l'assigné
|
||
|
field_assigned_to_role: Rôle de l'assigné
|
||
|
setting_emails_header: En-tête des emails
|
||
|
label_bulk_edit_selected_time_entries: Bulk edit selected time entries
|
||
|
text_time_entries_destroy_confirmation: Are you sure you want to delete the selected time entr(y/ies) ?
|
||
| config/locales/gl.yml | ||
|---|---|---|
|
label_news_comment_added: Comment added to a news
|
||
|
button_expand_all: Expand all
|
||
|
button_collapse_all: Collapse all
|
||
|
label_bulk_edit_selected_time_entries: Bulk edit selected time entries
|
||
|
text_time_entries_destroy_confirmation: Are you sure you want to delete the selected time entr(y/ies) ?
|
||
| config/locales/he.yml | ||
|---|---|---|
|
label_news_comment_added: Comment added to a news
|
||
|
button_expand_all: Expand all
|
||
|
button_collapse_all: Collapse all
|
||
|
label_bulk_edit_selected_time_entries: Bulk edit selected time entries
|
||
|
text_time_entries_destroy_confirmation: Are you sure you want to delete the selected time entr(y/ies) ?
|
||
| config/locales/hr.yml | ||
|---|---|---|
|
label_news_comment_added: Comment added to a news
|
||
|
button_expand_all: Expand all
|
||
|
button_collapse_all: Collapse all
|
||
|
label_bulk_edit_selected_time_entries: Bulk edit selected time entries
|
||
|
text_time_entries_destroy_confirmation: Are you sure you want to delete the selected time entr(y/ies) ?
|
||
| config/locales/hu.yml | ||
|---|---|---|
|
label_news_comment_added: Comment added to a news
|
||
|
button_expand_all: Expand all
|
||
|
button_collapse_all: Collapse all
|
||
|
label_bulk_edit_selected_time_entries: Bulk edit selected time entries
|
||
|
text_time_entries_destroy_confirmation: Are you sure you want to delete the selected time entr(y/ies) ?
|
||
| config/locales/id.yml | ||
|---|---|---|
|
label_news_comment_added: Comment added to a news
|
||
|
button_expand_all: Expand all
|
||
|
button_collapse_all: Collapse all
|
||
|
label_bulk_edit_selected_time_entries: Bulk edit selected time entries
|
||
|
text_time_entries_destroy_confirmation: Are you sure you want to delete the selected time entr(y/ies) ?
|
||
| config/locales/it.yml | ||
|---|---|---|
|
label_news_comment_added: Comment added to a news
|
||
|
button_expand_all: Expand all
|
||
|
button_collapse_all: Collapse all
|
||
|
label_bulk_edit_selected_time_entries: Bulk edit selected time entries
|
||
|
text_time_entries_destroy_confirmation: Are you sure you want to delete the selected time entr(y/ies) ?
|
||
| config/locales/ja.yml | ||
|---|---|---|
|
label_news_comment_added: Comment added to a news
|
||
|
button_expand_all: Expand all
|
||
|
button_collapse_all: Collapse all
|
||
|
label_bulk_edit_selected_time_entries: Bulk edit selected time entries
|
||
|
text_time_entries_destroy_confirmation: Are you sure you want to delete the selected time entr(y/ies) ?
|
||
| config/locales/ko.yml | ||
|---|---|---|
|
label_news_comment_added: Comment added to a news
|
||
|
button_expand_all: Expand all
|
||
|
button_collapse_all: Collapse all
|
||
|
label_bulk_edit_selected_time_entries: Bulk edit selected time entries
|
||
|
text_time_entries_destroy_confirmation: Are you sure you want to delete the selected time entr(y/ies) ?
|
||
| config/locales/lt.yml | ||
|---|---|---|
|
label_news_comment_added: Comment added to a news
|
||
|
button_expand_all: Expand all
|
||
|
button_collapse_all: Collapse all
|
||
|
label_bulk_edit_selected_time_entries: Bulk edit selected time entries
|
||
|
text_time_entries_destroy_confirmation: Are you sure you want to delete the selected time entr(y/ies) ?
|
||
| config/locales/lv.yml | ||
|---|---|---|
|
label_news_comment_added: Comment added to a news
|
||
|
button_expand_all: Expand all
|
||
|
button_collapse_all: Collapse all
|
||
|
label_bulk_edit_selected_time_entries: Bulk edit selected time entries
|
||
|
text_time_entries_destroy_confirmation: Are you sure you want to delete the selected time entr(y/ies) ?
|
||
| config/locales/mk.yml | ||
|---|---|---|
|
label_news_comment_added: Comment added to a news
|
||
|
button_expand_all: Expand all
|
||
|
button_collapse_all: Collapse all
|
||
|
label_bulk_edit_selected_time_entries: Bulk edit selected time entries
|
||
|
text_time_entries_destroy_confirmation: Are you sure you want to delete the selected time entr(y/ies) ?
|
||
| config/locales/mn.yml | ||
|---|---|---|
|
label_news_comment_added: Comment added to a news
|
||
|
button_expand_all: Expand all
|
||
|
button_collapse_all: Collapse all
|
||
|
label_bulk_edit_selected_time_entries: Bulk edit selected time entries
|
||
|
text_time_entries_destroy_confirmation: Are you sure you want to delete the selected time entr(y/ies) ?
|
||
| config/locales/nl.yml | ||
|---|---|---|
|
label_news_comment_added: Commentaar toegevoegd aan een nieuwsitem
|
||
|
button_expand_all: Expand all
|
||
|
button_collapse_all: Collapse all
|
||
|
label_bulk_edit_selected_time_entries: Bulk edit selected time entries
|
||
|
text_time_entries_destroy_confirmation: Are you sure you want to delete the selected time entr(y/ies) ?
|
||
| config/locales/no.yml | ||
|---|---|---|
|
label_news_comment_added: Comment added to a news
|
||
|
button_expand_all: Expand all
|
||
|
button_collapse_all: Collapse all
|
||
|
label_bulk_edit_selected_time_entries: Bulk edit selected time entries
|
||
|
text_time_entries_destroy_confirmation: Are you sure you want to delete the selected time entr(y/ies) ?
|
||
| config/locales/pl.yml | ||
|---|---|---|
|
label_news_comment_added: Comment added to a news
|
||
|
button_expand_all: Expand all
|
||
|
button_collapse_all: Collapse all
|
||
|
label_bulk_edit_selected_time_entries: Bulk edit selected time entries
|
||
|
text_time_entries_destroy_confirmation: Are you sure you want to delete the selected time entr(y/ies) ?
|
||
| config/locales/pt-BR.yml | ||
|---|---|---|
|
label_news_comment_added: Notícia recebeu um comentário
|
||
|
button_expand_all: Expand all
|
||
|
button_collapse_all: Collapse all
|
||
|
label_bulk_edit_selected_time_entries: Bulk edit selected time entries
|
||
|
text_time_entries_destroy_confirmation: Are you sure you want to delete the selected time entr(y/ies) ?
|
||
| config/locales/pt.yml | ||
|---|---|---|
|
label_news_comment_added: Comment added to a news
|
||
|
button_expand_all: Expand all
|
||
|
button_collapse_all: Collapse all
|
||
|
label_bulk_edit_selected_time_entries: Bulk edit selected time entries
|
||
|
text_time_entries_destroy_confirmation: Are you sure you want to delete the selected time entr(y/ies) ?
|
||
| config/locales/ro.yml | ||
|---|---|---|
|
label_news_comment_added: Comment added to a news
|
||
|
button_expand_all: Expand all
|
||
|
button_collapse_all: Collapse all
|
||
|
label_bulk_edit_selected_time_entries: Bulk edit selected time entries
|
||
|
text_time_entries_destroy_confirmation: Are you sure you want to delete the selected time entr(y/ies) ?
|
||
| config/locales/ru.yml | ||
|---|---|---|
|
label_news_comment_added: Comment added to a news
|
||
|
button_expand_all: Expand all
|
||
|
button_collapse_all: Collapse all
|
||
|
label_bulk_edit_selected_time_entries: Bulk edit selected time entries
|
||
|
text_time_entries_destroy_confirmation: Are you sure you want to delete the selected time entr(y/ies) ?
|
||
| config/locales/sk.yml | ||
|---|---|---|
|
label_news_comment_added: Comment added to a news
|
||
|
button_expand_all: Expand all
|
||
|
button_collapse_all: Collapse all
|
||
|
label_bulk_edit_selected_time_entries: Bulk edit selected time entries
|
||
|
text_time_entries_destroy_confirmation: Are you sure you want to delete the selected time entr(y/ies) ?
|
||
| config/locales/sl.yml | ||
|---|---|---|
|
label_news_comment_added: Comment added to a news
|
||
|
button_expand_all: Expand all
|
||
|
button_collapse_all: Collapse all
|
||
|
label_bulk_edit_selected_time_entries: Bulk edit selected time entries
|
||
|
text_time_entries_destroy_confirmation: Are you sure you want to delete the selected time entr(y/ies) ?
|
||
| config/locales/sr-YU.yml | ||
|---|---|---|
|
label_news_comment_added: Comment added to a news
|
||
|
button_expand_all: Expand all
|
||
|
button_collapse_all: Collapse all
|
||
|
label_bulk_edit_selected_time_entries: Bulk edit selected time entries
|
||
|
text_time_entries_destroy_confirmation: Are you sure you want to delete the selected time entr(y/ies) ?
|
||
| config/locales/sr.yml | ||
|---|---|---|
|
label_news_comment_added: Comment added to a news
|
||
|
button_expand_all: Expand all
|
||
|
button_collapse_all: Collapse all
|
||
|
label_bulk_edit_selected_time_entries: Bulk edit selected time entries
|
||
|
text_time_entries_destroy_confirmation: Are you sure you want to delete the selected time entr(y/ies) ?
|
||
| config/locales/sv.yml | ||
|---|---|---|
|
label_news_comment_added: Comment added to a news
|
||
|
button_expand_all: Expand all
|
||
|
button_collapse_all: Collapse all
|
||
|
label_bulk_edit_selected_time_entries: Bulk edit selected time entries
|
||
|
text_time_entries_destroy_confirmation: Are you sure you want to delete the selected time entr(y/ies) ?
|
||
| config/locales/th.yml | ||
|---|---|---|
|
label_news_comment_added: Comment added to a news
|
||
|
button_expand_all: Expand all
|
||
|
button_collapse_all: Collapse all
|
||
|
label_bulk_edit_selected_time_entries: Bulk edit selected time entries
|
||
|
text_time_entries_destroy_confirmation: Are you sure you want to delete the selected time entr(y/ies) ?
|
||
| config/locales/tr.yml | ||
|---|---|---|
|
label_news_comment_added: Comment added to a news
|
||
|
button_expand_all: Expand all
|
||
|
button_collapse_all: Collapse all
|
||
|
label_bulk_edit_selected_time_entries: Bulk edit selected time entries
|
||
|
text_time_entries_destroy_confirmation: Are you sure you want to delete the selected time entr(y/ies) ?
|
||
| config/locales/uk.yml | ||
|---|---|---|
|
label_news_comment_added: Comment added to a news
|
||
|
button_expand_all: Expand all
|
||
|
button_collapse_all: Collapse all
|
||
|
label_bulk_edit_selected_time_entries: Bulk edit selected time entries
|
||
|
text_time_entries_destroy_confirmation: Are you sure you want to delete the selected time entr(y/ies) ?
|
||
| config/locales/vi.yml | ||
|---|---|---|
|
label_news_comment_added: Comment added to a news
|
||
|
button_expand_all: Expand all
|
||
|
button_collapse_all: Collapse all
|
||
|
label_bulk_edit_selected_time_entries: Bulk edit selected time entries
|
||
|
text_time_entries_destroy_confirmation: Are you sure you want to delete the selected time entr(y/ies) ?
|
||
| config/locales/zh-TW.yml | ||
|---|---|---|
|
label_news_comment_added: Comment added to a news
|
||
|
button_expand_all: Expand all
|
||
|
button_collapse_all: Collapse all
|
||
|
label_bulk_edit_selected_time_entries: Bulk edit selected time entries
|
||
|
text_time_entries_destroy_confirmation: Are you sure you want to delete the selected time entr(y/ies) ?
|
||
| config/locales/zh.yml | ||
|---|---|---|
|
label_news_comment_added: Comment added to a news
|
||
|
button_expand_all: Expand all
|
||
|
button_collapse_all: Collapse all
|
||
|
label_bulk_edit_selected_time_entries: Bulk edit selected time entries
|
||
|
text_time_entries_destroy_confirmation: Are you sure you want to delete the selected time entr(y/ies) ?
|
||
| config/routes.rb | ||
|---|---|---|
|
time_report.connect 'projects/:project_id/time_entries/report.:format'
|
||
|
end
|
||
|
map.bulk_edit_time_entry 'time_entries/bulk_edit', :controller => 'timelog', :action => 'bulk_edit', :conditions => { :method => :get }
|
||
|
map.bulk_update_time_entry 'time_entries/bulk_edit', :controller => 'timelog', :action => 'bulk_update', :conditions => { :method => :post }
|
||
|
map.time_entries_context_menu '/time_entries/context_menu', :controller => 'context_menus', :action => 'time_entries'
|
||
|
# TODO: wasteful since this is also nested under issues, projects, and projects/issues
|
||
|
map.resources :time_entries, :controller => 'timelog'
|
||
|
|
||
| ... | ... | |
|
map.resources :issues, :path_prefix => '/projects/:project_id', :collection => { :create => :post } do |issues|
|
||
|
issues.resources :time_entries, :controller => 'timelog'
|
||
|
end
|
||
|
# map.time_entries_context_menu '/time_entries/context_menu', :controller => 'context_menus', :action => 'time_entries'
|
||
|
map.with_options :controller => 'issue_relations', :conditions => {:method => :post} do |relations|
|
||
|
relations.connect 'issues/:issue_id/relations/:id', :action => 'new'
|
||
| lib/redmine.rb | ||
|---|---|---|
|
end
|
||
|
|
||
|
map.project_module :time_tracking do |map|
|
||
|
map.permission :log_time, {:timelog => [:new, :create, :edit, :update]}, :require => :loggedin
|
||
|
map.permission :log_time, {:timelog => [:new, :create, :edit, :update, :bulk_edit, :bulk_update]}, :require => :loggedin
|
||
|
map.permission :view_time_entries, :timelog => [:index, :show], :time_entry_reports => [:report]
|
||
|
map.permission :edit_time_entries, {:timelog => [:new, :create, :edit, :update, :destroy]}, :require => :member
|
||
|
map.permission :edit_own_time_entries, {:timelog => [:new, :create, :edit, :update, :destroy]}, :require => :loggedin
|
||
|
map.permission :edit_time_entries, {:timelog => [:new, :create, :edit, :update, :destroy, :bulk_edit, :bulk_update]}, :require => :member
|
||
|
map.permission :edit_own_time_entries, {:timelog => [:new, :create, :edit, :update, :destroy,:bulk_edit, :bulk_update]}, :require => :loggedin
|
||
|
map.permission :manage_project_activities, {:project_enumerations => [:update, :destroy]}, :require => :member
|
||
|
end
|
||
|
|
||
| test/fixtures/custom_fields.yml | ||
|---|---|---|
|
field_format: date
|
||
|
default_value: ""
|
||
|
editable: true
|
||
|
custom_fields_010:
|
||
|
name: Overtime
|
||
|
min_length: 0
|
||
|
regexp: ""
|
||
|
is_for_all: false
|
||
|
is_filter: false
|
||
|
type: TimeEntryCustomField
|
||
|
max_length: 0
|
||
|
possible_values: ""
|
||
|
id: 10
|
||
|
is_required: false
|
||
|
field_format: bool
|
||
|
default_value: 0
|
||
|
editable: true
|
||
| test/fixtures/time_entries.yml | ||
|---|---|---|
|
hours: 7.65
|
||
|
user_id: 1
|
||
|
tyear: 2007
|
||
|
time_entries_005:
|
||
|
created_on: 2011-03-22 12:20:48 +02:00
|
||
|
tweek: 12
|
||
|
tmonth: 3
|
||
|
project_id: 5
|
||
|
comments: Time spent on a subproject
|
||
|
updated_on: 2011-03-22 12:20:48 +02:00
|
||
|
activity_id: 10
|
||
|
spent_on: 2011-03-22
|
||
|
issue_id:
|
||
|
id: 5
|
||
|
hours: 7.65
|
||
|
user_id: 1
|
||
|
tyear: 2011
|
||
|
|
||
| test/functional/timelog_controller_test.rb | ||
|---|---|---|
|
assert_equal 2, entry.issue_id
|
||
|
assert_equal 2, entry.user_id
|
||
|
end
|
||
|
def test_get_bulk_edit
|
||
|
@request.session[:user_id] = 2
|
||
|
get :bulk_edit, :ids => [1, 2]
|
||
|
assert_response :success
|
||
|
assert_template 'bulk_edit'
|
||
|
|
||
|
# System wide custom field
|
||
|
assert_tag :select, :attributes => {:name => 'time_entry[custom_field_values][10]'}
|
||
|
end
|
||
|
def test_get_bulk_edit_on_different_projects
|
||
|
@request.session[:user_id] = 2
|
||
|
get :bulk_edit, :ids => [1, 2, 6]
|
||
|
assert_response :success
|
||
|
assert_template 'bulk_edit'
|
||
|
end
|
||
|
def test_bulk_update
|
||
|
@request.session[:user_id] = 2
|
||
|
# update time entry activity
|
||
|
post :bulk_update, :ids => [1, 2], :time_entry => { :activity_id => 9}
|
||
|
|
||
|
assert_response 302
|
||
|
# check that the issues were updated
|
||
|
assert_equal [9, 9], TimeEntry.find_all_by_id([1, 2]).collect {|i| i.activity_id}
|
||
|
end
|
||
|
def test_bulk_update_on_different_projects
|
||
|
@request.session[:user_id] = 2
|
||
|
# update time entry activity
|
||
|
post :bulk_update, :ids => [1, 2, 4], :time_entry => { :activity_id => 9 }
|
||
|
|
||
|
assert_response 302
|
||
|
# check that the issues were updated
|
||
|
assert_equal [9, 9, 9], TimeEntry.find_all_by_id([1, 2, 4]).collect {|i| i.activity_id}
|
||
|
end
|
||
|
def test_bulk_update_on_different_projects_without_rights
|
||
|
@request.session[:user_id] = 3
|
||
|
user = User.find(3)
|
||
|
action = { :controller => "timelog", :action => "bulk_update" }
|
||
|
assert user.allowed_to?(action, TimeEntry.find(1).project)
|
||
|
assert ! user.allowed_to?(action, TimeEntry.find(5).project)
|
||
|
post :bulk_update, :ids => [1, 5], :time_entry => { :activity_id => 9 }
|
||
|
assert_response 403
|
||
|
end
|
||
|
def test_bulk_update_custom_field
|
||
|
@request.session[:user_id] = 2
|
||
|
post :bulk_update, :ids => [1, 2], :time_entry => { :custom_field_values => {'10' => '0'} }
|
||
|
|
||
|
assert_response 302
|
||
|
assert_equal ["0", "0"], TimeEntry.find_all_by_id([1, 2]).collect {|i| i.custom_value_for(10).value}
|
||
|
end
|
||
|
def test_post_bulk_update_should_redirect_back_using_the_back_url_parameter
|
||
|
@request.session[:user_id] = 2
|
||
|
post :bulk_update, :ids => [1,2], :back_url => '/time_entries'
|
||
|
assert_response :redirect
|
||
|
assert_redirected_to '/time_entries'
|
||
|
end
|
||
|
def test_post_bulk_update_should_not_redirect_back_using_the_back_url_parameter_off_the_host
|
||
|
@request.session[:user_id] = 2
|
||
|
post :bulk_update, :ids => [1,2], :back_url => 'http://google.com'
|
||
|
assert_response :redirect
|
||
|
assert_redirected_to :controller => 'timelog', :action => 'index', :project_id => Project.find(1).identifier
|
||
|
end
|
||
|
|
||
|
def test_destroy
|
||
|
@request.session[:user_id] = 2
|
||
| ... | ... | |
|
get :index, :format => 'csv'
|
||
|
assert_response :success
|
||
|
assert_equal 'text/csv', @response.content_type
|
||
|
assert @response.body.include?("Date,User,Activity,Project,Issue,Tracker,Subject,Hours,Comment\n")
|
||
|
assert @response.body.include?("\n04/21/2007,redMine Admin,Design,eCookbook,3,Bug,Error 281 when updating a recipe,1.0,\"\"\n")
|
||
|
assert @response.body.include?("Date,User,Activity,Project,Issue,Tracker,Subject,Hours,Comment,Overtime\n")
|
||
|
assert @response.body.include?("\n04/21/2007,redMine Admin,Design,eCookbook,3,Bug,Error 281 when updating a recipe,1.0,\"\",\"\"\n")
|
||
|
end
|
||
|
|
||
|
def test_index_csv_export
|
||
| ... | ... | |
|
get :index, :project_id => 1, :format => 'csv'
|
||
|
assert_response :success
|
||
|
assert_equal 'text/csv', @response.content_type
|
||
|
assert @response.body.include?("Date,User,Activity,Project,Issue,Tracker,Subject,Hours,Comment\n")
|
||
|
assert @response.body.include?("\n04/21/2007,redMine Admin,Design,eCookbook,3,Bug,Error 281 when updating a recipe,1.0,\"\"\n")
|
||
|
assert @response.body.include?("Date,User,Activity,Project,Issue,Tracker,Subject,Hours,Comment,Overtime\n")
|
||
|
assert @response.body.include?("\n04/21/2007,redMine Admin,Design,eCookbook,3,Bug,Error 281 when updating a recipe,1.0,\"\",\"\"\n")
|
||
|
end
|
||
|
end
|
||