Let subprojects view their parents’ jobs
This commit is contained in:
parent
9294216abc
commit
c6cb6fa64d
|
@ -3,7 +3,7 @@ class JobsController < ApplicationController
|
||||||
before_action :set_job, only: [:show, :edit, :update, :destroy]
|
before_action :set_job, only: [:show, :edit, :update, :destroy]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@jobs = Job.all
|
@jobs = Job.project_or_parent(@project)
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
|
|
@ -10,6 +10,7 @@ class Job < ActiveRecord::Base
|
||||||
has_many :time_entries
|
has_many :time_entries
|
||||||
|
|
||||||
scope :project, ->(project) { where(project_id: project.id) }
|
scope :project, ->(project) { where(project_id: project.id) }
|
||||||
|
scope :project_or_parent, ->(project) { where(project_id: [project.id, project.parent.id]) }
|
||||||
|
|
||||||
def total_time_logged
|
def total_time_logged
|
||||||
TimeEntry.where(job_id: id)
|
TimeEntry.where(job_id: id)
|
||||||
|
|
|
@ -34,5 +34,4 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<%= f.submit %>
|
<%= f.submit %>
|
||||||
<%= link_to "Cancel", job_path(@job, project_id: @project.id) %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<p>
|
<p>
|
||||||
<%= form.label :job_id %>
|
<%= form.label :job_id %>
|
||||||
<%= form.collection_select :job_id, Job.project(@project), :id, :name %>
|
<%= form.collection_select :job_id, Job.project_or_parent(@project), :id, :name %>
|
||||||
</p>
|
</p>
|
||||||
|
|
Loading…
Reference in New Issue