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]
|
||||
|
||||
def index
|
||||
@jobs = Job.all
|
||||
@jobs = Job.project_or_parent(@project)
|
||||
end
|
||||
|
||||
def show
|
||||
|
|
|
@ -10,6 +10,7 @@ class Job < ActiveRecord::Base
|
|||
has_many :time_entries
|
||||
|
||||
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
|
||||
TimeEntry.where(job_id: id)
|
||||
|
|
|
@ -34,5 +34,4 @@
|
|||
|
||||
</div>
|
||||
<%= f.submit %>
|
||||
<%= link_to "Cancel", job_path(@job, project_id: @project.id) %>
|
||||
<% end %>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<p>
|
||||
<%= 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>
|
||||
|
|
Loading…
Reference in New Issue