Add categories to jobs
This commit is contained in:
parent
983e6a3b6a
commit
08b49a4263
|
@ -52,6 +52,7 @@ class JobsController < ApplicationController
|
||||||
:budget,
|
:budget,
|
||||||
:name,
|
:name,
|
||||||
:description,
|
:description,
|
||||||
|
:category_id,
|
||||||
time_budgets_attributes: [:id, :category_id, :hours, :job_id, :_destroy]
|
time_budgets_attributes: [:id, :category_id, :hours, :job_id, :_destroy]
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,6 +7,8 @@ class Job < ActiveRecord::Base
|
||||||
presence: true
|
presence: true
|
||||||
|
|
||||||
belongs_to :project
|
belongs_to :project
|
||||||
|
belongs_to :category, class_name: "JobCategory"
|
||||||
|
|
||||||
has_many :time_entries, dependent: :restrict_with_error
|
has_many :time_entries, dependent: :restrict_with_error
|
||||||
has_many :time_budgets, dependent: :destroy
|
has_many :time_budgets, dependent: :destroy
|
||||||
accepts_nested_attributes_for :time_budgets, allow_destroy: true
|
accepts_nested_attributes_for :time_budgets, allow_destroy: true
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class JobCategory < Enumeration
|
||||||
|
has_many :jobs, foreign_key: :category_id
|
||||||
|
|
||||||
|
OptionName = :enumeration_job_category
|
||||||
|
|
||||||
|
def option_name
|
||||||
|
OptionName
|
||||||
|
end
|
||||||
|
end
|
|
@ -9,6 +9,10 @@
|
||||||
<%= f.label :description %>
|
<%= f.label :description %>
|
||||||
<%= f.text_area :description %>
|
<%= f.text_area :description %>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<%= f.label :category %>
|
||||||
|
<%= f.collection_select :category_id, JobCategory.all, :id, :name %>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<%= f.label :starts_on %>
|
<%= f.label :starts_on %>
|
||||||
<%= f.date_field :starts_on %>
|
<%= f.date_field :starts_on %>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= link_to job.name, project_job_path(job.project, job) %></td>
|
<td><%= link_to job.name, project_job_path(job.project, job) %></td>
|
||||||
|
<td><%= job.category&.name || "Unassigned" %></td>
|
||||||
<td><%= format_date(job.starts_on) %></td>
|
<td><%= format_date(job.starts_on) %></td>
|
||||||
<td><%= format_date(job.ends_on) %></td>
|
<td><%= format_date(job.ends_on) %></td>
|
||||||
<td><%= job.project_id %></td>
|
<td><%= job.project_id %></td>
|
||||||
|
|
|
@ -12,11 +12,11 @@
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
|
<th>Category</th>
|
||||||
<th>Starts on</th>
|
<th>Starts on</th>
|
||||||
<th>Ends on</th>
|
<th>Ends on</th>
|
||||||
<th>Project</th>
|
<th>Project</th>
|
||||||
<th>External project</th>
|
<th>External project</th>
|
||||||
<th>Total budget</th>
|
|
||||||
<th>Progress</th>
|
<th>Progress</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
|
@ -14,6 +14,8 @@
|
||||||
<div class="splitcontent">
|
<div class="splitcontent">
|
||||||
<div class="splitcontentleft">
|
<div class="splitcontentleft">
|
||||||
<div class="status attribute">
|
<div class="status attribute">
|
||||||
|
<div class="label">Category:</div>
|
||||||
|
<div class="value"><%= @job.category&.name || "Unassigned" %></div>
|
||||||
<div class="label">Starts on:</div>
|
<div class="label">Starts on:</div>
|
||||||
<div class="value"><%= format_date(@job.starts_on) %></div>
|
<div class="value"><%= format_date(@job.starts_on) %></div>
|
||||||
<div class="label">Ends on:</div>
|
<div class="label">Ends on:</div>
|
||||||
|
|
|
@ -3,3 +3,4 @@ en:
|
||||||
field_job: Job
|
field_job: Job
|
||||||
|
|
||||||
enumeration_time_budget_category: Time budget categories
|
enumeration_time_budget_category: Time budget categories
|
||||||
|
enumeration_job_category: Job categories
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddCategoryIdToJobs < ActiveRecord::Migration[6.1]
|
||||||
|
def change
|
||||||
|
add_column :jobs, :category_id, :integer
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue