Commit 67d8154e by Van Hau Le

enhence/filter_activies_by_tracker

parent 5c60cbfe
Pipeline #72 canceled with stages
in 0 seconds
...@@ -30,7 +30,7 @@ class ContextMenusController < ApplicationController ...@@ -30,7 +30,7 @@ class ContextMenusController < ApplicationController
@allowed_statuses = @issues.map(&:new_statuses_allowed_to).reduce(:&) @allowed_statuses = @issues.map(&:new_statuses_allowed_to).reduce(:&)
@can = {:edit => @issues.all?(&:attributes_editable?), @can = {:edit => @issues.all?(&:attributes_editable?),
:log_time => (@project && User.current.allowed_to?(:log_time, @project)), :log_time => (@project && User.current.allowed_to?(:log_time, @project) && !@issue.is_user_story?),
:copy => User.current.allowed_to?(:copy_issues, @projects) && Issue.allowed_target_projects.any?, :copy => User.current.allowed_to?(:copy_issues, @projects) && Issue.allowed_target_projects.any?,
:add_watchers => User.current.allowed_to?(:add_issue_watchers, @projects), :add_watchers => User.current.allowed_to?(:add_issue_watchers, @projects),
:delete => @issues.all?(&:deletable?) :delete => @issues.all?(&:deletable?)
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
module TimelogHelper module TimelogHelper
include ApplicationHelper include ApplicationHelper
# Returns a collection of activities for a select field. time_entry # Returns a collection of activities for a select field. time_entry
# is optional and will be used to check if the selected TimeEntryActivity # is optional and will be used to check if the selected TimeEntryActivity
# is active. # is active.
...@@ -38,8 +37,23 @@ module TimelogHelper ...@@ -38,8 +37,23 @@ module TimelogHelper
else else
collection << [ "--- #{l(:actionview_instancetag_blank_option)} ---", '' ] unless activities.detect(&:is_default) collection << [ "--- #{l(:actionview_instancetag_blank_option)} ---", '' ] unless activities.detect(&:is_default)
end end
activities.each { |a| collection << [a.name, a.id] } collection += case @issue&.tracker&.name
collection when 'Task'
@issue.is_task_with_target? ?
TimeEntryActivity::TASK_WITH_TARGET_ACTIVITIES :
activities.collect { |a| [a.name, a.id] if a.is_activity_for_task? }
when 'Bug'
activities.collect { |a| [a.name, a.id] if a.is_activity_for_task? }
when 'User story'
[]
when 'Support'
TimeEntryActivity::SUPPORT_ACTIVITIES
else
activities.map { |a| [a.name, a.id] }
end
# activities.each { |a| collection << [a.name, a.id] }
collection.compact
end end
def select_hours(data, criteria, value) def select_hours(data, criteria, value)
......
...@@ -117,6 +117,14 @@ class Issue < ActiveRecord::Base ...@@ -117,6 +117,14 @@ class Issue < ActiveRecord::Base
after_destroy :update_parent_attributes after_destroy :update_parent_attributes
after_create :send_notification after_create :send_notification
def is_user_story?
tracker&.user_story
end
def is_task_with_target?
fixed_version&.name == 'Backlog(Internal)'
end
# Returns a SQL conditions string used to find all issues visible by the specified user # Returns a SQL conditions string used to find all issues visible by the specified user
def self.visible_condition(user, options={}) def self.visible_condition(user, options={})
Project.allowed_to_condition(user, :view_issues, options) do |role, user| Project.allowed_to_condition(user, :view_issues, options) do |role, user|
......
...@@ -20,6 +20,22 @@ class TimeEntryActivity < Enumeration ...@@ -20,6 +20,22 @@ class TimeEntryActivity < Enumeration
OptionName = :enumeration_activities OptionName = :enumeration_activities
TASK_BUGS_ACTIVITIES= [
"Estimation", "Communication",
"Coding", "Code Review", "Requirement",
"Design", "Release", "Reworking",
"Create Test-case", "Testing",
"Research - Investigate "
].freeze
TASK_WITH_TARGET_ACTIVITIES = [
'Training', 'Internal Tasks'
].freeze
SUPPORT_ACTIVITIES = [
"Communication", "Project Management", "Leave Off", "Idle", "Company Meeting", "Support", "Others"
].freeze
def option_name def option_name
OptionName OptionName
end end
...@@ -35,4 +51,8 @@ class TimeEntryActivity < Enumeration ...@@ -35,4 +51,8 @@ class TimeEntryActivity < Enumeration
def transfer_relations(to) def transfer_relations(to)
objects.update_all(:activity_id => to.id) objects.update_all(:activity_id => to.id)
end end
def is_activity_for_task?
TASK_BUGS_ACTIVITIES.include? name
end
end end
...@@ -84,6 +84,10 @@ class Tracker < ActiveRecord::Base ...@@ -84,6 +84,10 @@ class Tracker < ActiveRecord::Base
position <=> tracker.position position <=> tracker.position
end end
def user_story
name == "User story"
end
# Returns an array of IssueStatus that are used # Returns an array of IssueStatus that are used
# in the tracker's workflows # in the tracker's workflows
def issue_statuses def issue_statuses
......
<div class="contextual"> <div class="contextual">
<%= link_to l(:button_edit), edit_issue_path(@issue), :onclick => 'showAndScrollTo("update", "issue_notes"); return false;', :class => 'icon icon-edit', :accesskey => accesskey(:edit) if @issue.editable? %> <%= link_to l(:button_edit), edit_issue_path(@issue), :onclick => 'showAndScrollTo("update", "issue_notes"); return false;', :class => 'icon icon-edit', :accesskey => accesskey(:edit) if @issue.editable? %>
<%= link_to l(:button_log_time), new_issue_time_entry_path(@issue), :class => 'icon icon-time-add' if User.current.allowed_to?(:log_time, @project) %> <%= link_to l(:button_log_time), new_issue_time_entry_path(@issue), :class => 'icon icon-time-add' if User.current.allowed_to?(:log_time, @project) && !@issue.is_user_story? %>
<%= watcher_link(@issue, User.current) %> <%= watcher_link(@issue, User.current) %>
<%= link_to l(:button_copy), project_copy_issue_path(@project, @issue), :class => 'icon icon-copy' if User.current.allowed_to?(:copy_issues, @project) && Issue.allowed_target_projects.any? %> <%= link_to l(:button_copy), project_copy_issue_path(@project, @issue), :class => 'icon icon-copy' if User.current.allowed_to?(:copy_issues, @project) && Issue.allowed_target_projects.any? %>
<%= link_to l(:button_delete), issue_path(@issue), :data => {:confirm => issues_destroy_confirmation_message(@issue)}, :method => :delete, :class => 'icon icon-del' if @issue.deletable? %> <%= link_to l(:button_delete), issue_path(@issue), :data => {:confirm => issues_destroy_confirmation_message(@issue)}, :method => :delete, :class => 'icon icon-del' if @issue.deletable? %>
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
</div> </div>
</fieldset> </fieldset>
<% end %> <% end %>
<% if User.current.allowed_to?(:log_time, @project) %> <% if User.current.allowed_to?(:log_time, @project) && !@issue.is_user_story? %>
<fieldset class="tabular"><legend><%= l(:button_log_time) %></legend> <fieldset class="tabular"><legend><%= l(:button_log_time) %></legend>
<%= labelled_fields_for :time_entry, @time_entry do |time_entry| %> <%= labelled_fields_for :time_entry, @time_entry do |time_entry| %>
<div class="splitcontent"> <div class="splitcontent">
......
<div class="contextual"> <div class="contextual">
<%= link_to l(:button_log_time), <%= link_to l(:button_log_time),
_new_time_entry_path(@project, @query.filtered_issue_id), _new_time_entry_path(@project, @query.filtered_issue_id),
:class => 'icon icon-time-add' if User.current.allowed_to?(:log_time, @project, :global => true) %> :class => 'icon icon-time-add' if User.current.allowed_to?(:log_time, @project, :global => true) && !@issue.is_user_story? %>
</div> </div>
<h2><%= @query.new_record? ? l(:label_spent_time) : @query.name %></h2> <h2><%= @query.new_record? ? l(:label_spent_time) : @query.name %></h2>
......
<div class="contextual"> <div class="contextual">
<%= link_to l(:button_log_time), <%= link_to l(:button_log_time),
_new_time_entry_path(@project, @issue), _new_time_entry_path(@project, @issue),
:class => 'icon icon-time-add' if User.current.allowed_to?(:log_time, @project, :global => true) %> :class => 'icon icon-time-add' if User.current.allowed_to?(:log_time, @project, :global => true) && !@issue.is_user_story? %>
</div> </div>
<h2><%= @query.new_record? ? l(:label_spent_time) : @query.name %></h2> <h2><%= @query.new_record? ? l(:label_spent_time) : @query.name %></h2>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment