Bugfix: Allow time log outside of project context
Fixes an issue where opening the log time page at the top-level causes errors due to expecting a project to be set. Refs #2804
This commit is contained in:
parent
472d2b0479
commit
61ce2d0901
|
@ -13,7 +13,7 @@ class Job < ActiveRecord::Base
|
||||||
has_many :time_budgets, dependent: :destroy
|
has_many :time_budgets, dependent: :destroy
|
||||||
accepts_nested_attributes_for :time_budgets, allow_destroy: true
|
accepts_nested_attributes_for :time_budgets, allow_destroy: true
|
||||||
|
|
||||||
scope :project_or_parent, ->(project) { where(project_id: [project.id, project.parent&.id]) }
|
scope :project_or_parent, ->(project) { where(project_id: [project&.id, project&.parent&.id]) }
|
||||||
scope :active, -> { where(starts_on: ..Date.today, ends_on: Date.today..) }
|
scope :active, -> { where(starts_on: ..Date.today, ends_on: Date.today..) }
|
||||||
|
|
||||||
def with_all_time_budgets
|
def with_all_time_budgets
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
<p>
|
<p>
|
||||||
<%= form.label :job_id %>
|
<%= form.label :job_id %>
|
||||||
|
<% if @project.nil? %>
|
||||||
|
<%= form.collection_select :job_id, Job.active, :id, :name, include_blank: true %>
|
||||||
|
<% else %>
|
||||||
<%= form.collection_select :job_id, Job.active.project_or_parent(@project), :id, :name, include_blank: true %>
|
<%= form.collection_select :job_id, Job.active.project_or_parent(@project), :id, :name, include_blank: true %>
|
||||||
|
<% end %>
|
||||||
|
</p>
|
||||||
|
|
Loading…
Reference in New Issue