Let subprojects view their parents’ jobs

This commit is contained in:
Trevor Vallender 2023-11-22 20:11:25 +00:00
parent 9294216abc
commit c6cb6fa64d
4 changed files with 3 additions and 3 deletions

View File

@ -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

View File

@ -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)

View File

@ -34,5 +34,4 @@
</div>
<%= f.submit %>
<%= link_to "Cancel", job_path(@job, project_id: @project.id) %>
<% end %>

View File

@ -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>