Associate time entries with a job

This commit is contained in:
Trevor Vallender 2023-11-21 13:59:43 +00:00
parent 2384c4eb00
commit 6b1646e180
6 changed files with 13 additions and 3 deletions

View File

@ -4,6 +4,8 @@ class Job < ActiveRecord::Base
:name, :name,
presence: true presence: true
scope :project, ->(project) { where(project_id: project.id) }
def time_logged def time_logged
42 42
end end

View File

@ -1,6 +1,6 @@
<% html_title "Jobs" %> <% html_title "Jobs" %>
<div class="contextual"> <div class="contextual">
<%= link_to 'Create new job', new_job_path(project_id: @project.id), class: "icon icon-add new-job" %> <%= link_to 'New job', new_job_path(project_id: @project.id), class: "icon icon-add new-job" %>
</div> </div>
<h2>Jobs</h2> <h2>Jobs</h2>

View File

@ -1 +1,4 @@
<h1>FOOBAR</h1> <p>
<%= form.label :job_id %>
<%= form.collection_select :job_id, Job.project(@project), :id, :name %>
</p>

View File

@ -8,6 +8,8 @@ class CreateJobs < ActiveRecord::Migration[6.1]
t.references :project, foreign_key: true t.references :project, foreign_key: true
t.string :description t.string :description
t.integer :budget t.integer :budget
t.timestamps
end end
add_index :jobs, :name, unique: true add_index :jobs, :name, unique: true
end end

View File

@ -8,4 +8,6 @@ Redmine::Plugin.register :jobs do
permission :jobs, { jobs: [:index, :show, :new, :create, :edit, :update, :destroy] }, public: true permission :jobs, { jobs: [:index, :show, :new, :create, :edit, :update, :destroy] }, public: true
menu :project_menu, :jobs, { controller: 'jobs', action: 'index' }, caption: 'Jobs', after: :issues, param: :project_id menu :project_menu, :jobs, { controller: 'jobs', action: 'index' }, caption: 'Jobs', after: :issues, param: :project_id
TimeEntry.safe_attributes 'job_id'
end end

View File

@ -1,3 +1,4 @@
class JobsHookListener < Redmine::Hook::ViewListener class JobsHookListener < Redmine::Hook::ViewListener
render_on :view_timelog_edit_form_bottom, partial: "timelogs/edit_form_bottom.html.erb" render_on :view_timelog_edit_form_bottom, partial: "timelogs/edit_form_bottom"
end end