Skip to content

Commit

Permalink
feat: allow columns status and strategy to be added to the risk list
Browse files Browse the repository at this point in the history
  • Loading branch information
xel1045 committed Feb 9, 2022
1 parent 7a6a482 commit 2522304
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/helpers/risks_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ def column_value_with_risks(column, item, value)
format_risk_probability(value)
when :impact
format_risk_impact(value)
when :status
format_risk_status(value)
when :strategy
format_risk_strategy(value)
when :treatments
Expand Down
5 changes: 4 additions & 1 deletion app/models/risk_query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class RiskQuery < Query
QueryColumn.new(:probability, :sortable => "#{Risk.table_name}.probability", :default_order => 'desc'),
QueryColumn.new(:impact, :sortable => "#{Risk.table_name}.impact", :default_order => 'desc'),
QueryColumn.new(:magnitude, :sortable => "(#{Risk.table_name}.impact * #{Risk.table_name}.probability)", :default_order => 'desc'),
QueryColumn.new(:status, :sortable => "#{Risk.table_name}.status"),
QueryColumn.new(:strategy, :sortable => "#{Risk.table_name}.strategy"),
QueryColumn.new(:author, :sortable => lambda {User.fields_for_order_statement("authors")}, :groupable => true),
QueryColumn.new(:assigned_to, :sortable => lambda {User.fields_for_order_statement}, :groupable => true),
QueryColumn.new(:created_on, :sortable => "#{Risk.table_name}.created_on", :default_order => 'desc'),
Expand All @@ -37,6 +39,7 @@ def initialize_available_filters
add_available_filter "member_of_group", :type => :list_optional, :values => lambda { Group.givable.visible.collect {|g| [g.name, g.id.to_s] } }
add_available_filter "assigned_to_role", :type => :list_optional, :values => lambda { Role.givable.collect {|r| [r.name, r.id.to_s] } }
add_available_filter "status", :type => :list, :values => Risk::RISK_STATUS.map{|s| [format_risk_status(s), s] }
add_available_filter "strategy", :type => :list, :values => Risk::RISK_STRATEGY.map{|s| [format_risk_strategy(s), s] }
add_available_filter "subject", :type => :text
add_available_filter "description", :type => :text
add_available_filter "created_on", :type => :date_past
Expand All @@ -57,7 +60,7 @@ def visible?(user=User.current)
end

def default_columns_names
@default_columns_names = [:id, :subject, :category, :probability, :impact, :magnitude, :assigned_to, :updated_on, :treatments]
@default_columns_names = [:id, :subject, :category, :probability, :impact, :magnitude, :strategy, :assigned_to, :updated_on, :treatments]
end

def default_sort_criteria
Expand Down

0 comments on commit 2522304

Please sign in to comment.