diff --git a/app/models/job.rb b/app/models/job.rb index 746c1d3..83c05b7 100644 --- a/app/models/job.rb +++ b/app/models/job.rb @@ -4,6 +4,8 @@ class Job < ActiveRecord::Base :name, presence: true + scope :project, ->(project) { where(project_id: project.id) } + def time_logged 42 end diff --git a/app/views/jobs/index.html.erb b/app/views/jobs/index.html.erb index 56879f4..a6e64e4 100644 --- a/app/views/jobs/index.html.erb +++ b/app/views/jobs/index.html.erb @@ -1,6 +1,6 @@ <% html_title "Jobs" %>
+<%= form.label :job_id %> +<%= form.collection_select :job_id, Job.project(@project), :id, :name %> +
diff --git a/db/migrate/20231116202759_create_jobs.rb b/db/migrate/20231116202759_create_jobs.rb index f076ec5..bcef011 100644 --- a/db/migrate/20231116202759_create_jobs.rb +++ b/db/migrate/20231116202759_create_jobs.rb @@ -8,6 +8,8 @@ class CreateJobs < ActiveRecord::Migration[6.1] t.references :project, foreign_key: true t.string :description t.integer :budget + + t.timestamps end add_index :jobs, :name, unique: true end diff --git a/init.rb b/init.rb index b96a81a..c2464cd 100644 --- a/init.rb +++ b/init.rb @@ -8,4 +8,6 @@ Redmine::Plugin.register :jobs do 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 + + TimeEntry.safe_attributes 'job_id' end diff --git a/lib/jobs_hook_listener.rb b/lib/jobs_hook_listener.rb index 50dc71f..fe19ee9 100644 --- a/lib/jobs_hook_listener.rb +++ b/lib/jobs_hook_listener.rb @@ -1,3 +1,4 @@ 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 +