diff --git a/app/controllers/api/v1/timesheets_controller.rb b/app/controllers/api/v1/timesheets_controller.rb index 0f4b0e70..1a0e548e 100644 --- a/app/controllers/api/v1/timesheets_controller.rb +++ b/app/controllers/api/v1/timesheets_controller.rb @@ -31,7 +31,7 @@ def timesheet_params :period_start, time_entry_sets: [ :id, - :charge_code, + :charge_code_id, :description, time_entries: %i(id date hours) ] diff --git a/app/models/time_entry_set.rb b/app/models/time_entry_set.rb index fcf5aa2f..d75d528e 100644 --- a/app/models/time_entry_set.rb +++ b/app/models/time_entry_set.rb @@ -2,16 +2,17 @@ # # Table name: time_entry_sets # -# charge_code :string -# created_at :datetime not null -# description :text -# id :integer not null, primary key -# timesheet_id :integer -# updated_at :datetime not null +# charge_code_id :integer +# created_at :datetime not null +# description :text +# id :integer not null, primary key +# timesheet_id :integer +# updated_at :datetime not null # class TimeEntrySet < ApplicationRecord belongs_to :timesheet + belongs_to :charge_code has_many :time_entries, dependent: :destroy end diff --git a/app/models/timesheet.rb b/app/models/timesheet.rb index 261735ff..d0f1e164 100644 --- a/app/models/timesheet.rb +++ b/app/models/timesheet.rb @@ -5,6 +5,7 @@ # created_at :datetime not null # id :integer not null, primary key # period_start :datetime +# status :string # updated_at :datetime not null # user_id :integer # diff --git a/app/serializers/time_entry_set_serializer.rb b/app/serializers/time_entry_set_serializer.rb index 7601d2e4..5091ee80 100644 --- a/app/serializers/time_entry_set_serializer.rb +++ b/app/serializers/time_entry_set_serializer.rb @@ -1,9 +1,15 @@ class TimeEntrySetSerializer < ActiveModel::Serializer - attributes :id, :description, :charge_code + attributes :id, :description + + belongs_to :chargeCode has_many :timeEntries def timeEntries object.time_entries end + + def chargeCode + object.charge_code + end end diff --git a/db/migrate/20180503160434_associate_time_entry_sets_with_charge_codes.rb b/db/migrate/20180503160434_associate_time_entry_sets_with_charge_codes.rb new file mode 100644 index 00000000..07b51eff --- /dev/null +++ b/db/migrate/20180503160434_associate_time_entry_sets_with_charge_codes.rb @@ -0,0 +1,6 @@ +class AssociateTimeEntrySetsWithChargeCodes < ActiveRecord::Migration[5.1] + def change + remove_column :time_entry_sets, :charge_code, :string + add_reference :time_entry_sets, :charge_code + end +end diff --git a/db/schema.rb b/db/schema.rb index 0556e164..f0b9bd6c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -56,10 +56,11 @@ create_table "time_entry_sets", force: :cascade do |t| t.text "description" - t.string "charge_code" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.bigint "timesheet_id" + t.bigint "charge_code_id" + t.index ["charge_code_id"], name: "index_time_entry_sets_on_charge_code_id" t.index ["timesheet_id"], name: "index_time_entry_sets_on_timesheet_id" end @@ -68,6 +69,7 @@ t.datetime "period_start" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.string "status" t.index ["user_id"], name: "index_timesheets_on_user_id" end diff --git a/public/app/features/timesheets/enter-time.html b/public/app/features/timesheets/enter-time.html index 644e956a..8667f9b7 100644 --- a/public/app/features/timesheets/enter-time.html +++ b/public/app/features/timesheets/enter-time.html @@ -5,30 +5,30 @@