Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/api/v1/timesheets_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
]
Expand Down
13 changes: 7 additions & 6 deletions app/models/time_entry_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions app/models/timesheet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand Down
8 changes: 7 additions & 1 deletion app/serializers/time_entry_set_serializer.rb
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

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

Expand Down
20 changes: 10 additions & 10 deletions public/app/features/timesheets/enter-time.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,30 @@ <h2>{{ startDate | date: 'MMMM d' }} - {{ endDate | date: 'd' }}</h2>
<form name="timeEntryForm" ng-submit="saveTime()" novalidate>
<div layout="column" class="block">
<div layout="row" id="table-headers">
<div class="description header" flex="40">Description of work</div>
<div class="charge-code header" flex="10">Charge Code</div>
<div class="charge-code header" flex="10">Job Code</div>
<div class="description header" flex="10">Job Name</div>
<div class="date" ng-class="{ 'active': date === timeEntryObj.activeDate }" ng-repeat="date in dates" flex>{{ date | date: 'd' }}</div>
<div class="total" flex></div>
</div>
<div layout="row" class="table-rows" layout-align="center center" ng-repeat-start="timeEntry in timeEntryObj.timeEntrySets">
<div class="description header" flex="40" layout="column">
<textarea flex rows="2" ng-model="chargeCode.description" placeholder="Describe work"></textarea>
</div>
<div class="charge-code" flex="10">
<div class="bordered">
<input ng-model="timeEntry.chargeCode" aria-label="charge code">
</div>
<md-select ng-model="timeEntry.chargeCodeId" placeholder="Select Charge Code">
<md-option ng-repeat="job in jobs" ng-value="job.id">{{ job.code }}</md-option>
</md-select>
</div>
<div class="description" flex="10" layout="column">
<input flex rows="2" ng-value="getJobName(timeEntry.chargeCodeId)" disabled>
</div>
<div class="date bordered" ng-class="{ 'active': date === timeEntryObj.activeDate }" ng-init="timeEntry.timeEntries[$index] = { date: date }" ng-repeat="date in dates" flex>
<div>
<input ng-focus="timeEntryObj.activeDate = date" ng-model="timeEntry.timeEntries[$index].hours" ng-disabled="!timeEntry.chargeCode" aria-label="hours worked for {{ date | date: 'mediumDate' }}">
<input ng-focus="timeEntryObj.activeDate = date" ng-model="timeEntry.timeEntries[$index].hours" ng-disabled="!timeEntry.chargeCodeId" aria-label="hours worked for {{ date | date: 'mediumDate' }}">
</div>
</div>
<div class="total" flex>{{ getTotal(timeEntry) }}</div>
</div>
<md-divider ng-repeat-end ng-if="!$last"></md-divider>
<div id="totals-row" layout="row">
<div class="description header" flex="40"></div>
<div class="description header" flex="10"></div>
<div class="charge-code header" flex="10"></div>
<div class="date" ng-repeat="date in dates" flex>{{ getDateTotal(date) }}</div>
<div class="total" flex>{{ getGrandTotal() }}</div>
Expand Down
20 changes: 20 additions & 0 deletions public/app/features/timesheets/test/timesheet-controller.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,5 +164,25 @@ define([
expect($scope.processing).toBe(undefined);

});

it('should return the job name by id', () => {
$scope.jobs = [
{ id: 1, name: 'Job 1' },
{ id: 2, name: 'Job 2' },
{ id: 3, name: 'Job 3' }
];

expect($scope.getJobName(2)).toEqual('Job 2');
});

it('should not return the job name if no id is provided', () => {
$scope.jobs = [
{ id: 1, name: 'Job 1' },
{ id: 2, name: 'Job 2' },
{ id: 3, name: 'Job 3' }
];

expect($scope.getJobName()).toEqual('');
});
});
});
18 changes: 18 additions & 0 deletions public/app/features/timesheets/test/timesheets.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,22 @@ describe('Time Management', () => {
it('should have a time entry screen', () => {
expect($('h2').getText()).toEqual('May 1 - 15');
});

it('should not be able to enter time until job code is selected', () => {
page.forAllInputFields(field => {
expect(field.isEnabled()).toBe(true);
});
});

it('should enter time and show accurate totals for a day', () => {

});

it('should enter time and show accurate totals for a specific job code', () => {

});

it('should save the entered time and show save success message', () => {

});
});
5 changes: 5 additions & 0 deletions public/app/features/timesheets/test/timesheets.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@ class Timesheet extends Page {
constructor() {
super();
this.url = '/#!/timesheets';
this.inputFields = $$('input');
}

forAllInputFields(cb) {
this.fields.each(field => cb(field));
}

}

module.exports = new Timesheet();
10 changes: 9 additions & 1 deletion public/app/features/timesheets/timesheets.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ define([
'components/components',
'components/services/data-service'
], angular => {
function TimesheetsController($scope, data) {
function TimesheetsController($scope, data, $filter) {
function getLastDayOfMonth(month, year) {
return new Date(year, month, 0).getDate();
}
Expand All @@ -29,6 +29,12 @@ define([

$scope.timeEntryObj = { periodStart: dates[0], timeEntrySets: rows };

$scope.processing = true;
data.jobs.query(jobs => {
$scope.jobs = jobs;
delete $scope.processing;
});

$scope.saveTime = () => {
$scope.processing = true;
delete $scope.submitError;
Expand Down Expand Up @@ -66,6 +72,8 @@ define([
return total;
};

$scope.getJobName = id => id ? $filter('filter')($scope.jobs, { id }, true)[0].name : '';

}

angular.module('flash.timesheets', ['ngResource', 'ngRoute'])
Expand Down
4 changes: 0 additions & 4 deletions public/app/features/timesheets/timesheets.less
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@
border-radius: 5px;
text-align: center;
}
textarea {
border: none;
border-bottom: 2px solid @dark-blue;
}
&.total {
text-align: center;
font-size: 1.4em;
Expand Down
4 changes: 0 additions & 4 deletions public/assets/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,6 @@
border-radius: 5px;
text-align: center;
}
#time-entry-view div.table-rows div textarea {
border: none;
border-bottom: 2px solid #0070bb;
}
#time-entry-view div.table-rows div.total {
text-align: center;
font-size: 1.4em;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Thu May 03 2018 11:46:21 GMT-0400 (EDT)
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Thu May 03 2018 12:51:46 GMT-0400 (EDT)
</div>
</div>
<script src="../prettify.js"></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Thu May 03 2018 11:46:21 GMT-0400 (EDT)
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Thu May 03 2018 12:51:46 GMT-0400 (EDT)
</div>
</div>
<script src="../../prettify.js"></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Thu May 03 2018 11:46:21 GMT-0400 (EDT)
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Thu May 03 2018 12:51:46 GMT-0400 (EDT)
</div>
</div>
<script src="../../../../prettify.js"></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Thu May 03 2018 11:46:21 GMT-0400 (EDT)
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Thu May 03 2018 12:51:46 GMT-0400 (EDT)
</div>
</div>
<script src="../../../../prettify.js"></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Thu May 03 2018 11:46:21 GMT-0400 (EDT)
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Thu May 03 2018 12:51:46 GMT-0400 (EDT)
</div>
</div>
<script src="../../../../prettify.js"></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ <h1>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">10×</span>
<span class="cline-any cline-yes">12×</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
Expand Down Expand Up @@ -259,7 +259,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Thu May 03 2018 11:46:21 GMT-0400 (EDT)
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Thu May 03 2018 12:51:46 GMT-0400 (EDT)
</div>
</div>
<script src="../../../../prettify.js"></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Thu May 03 2018 11:46:21 GMT-0400 (EDT)
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Thu May 03 2018 12:51:46 GMT-0400 (EDT)
</div>
</div>
<script src="../../prettify.js"></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Thu May 03 2018 11:46:21 GMT-0400 (EDT)
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Thu May 03 2018 12:51:46 GMT-0400 (EDT)
</div>
</div>
<script src="../../../prettify.js"></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,20 @@ <h1>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">9×</span>
<span class="cline-any cline-yes">11×</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">9×</span>
<span class="cline-any cline-yes">11×</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">9×</span>
<span class="cline-any cline-yes">11×</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">9×</span>
<span class="cline-any cline-yes">11×</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
Expand Down Expand Up @@ -151,7 +151,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Thu May 03 2018 11:46:21 GMT-0400 (EDT)
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Thu May 03 2018 12:51:46 GMT-0400 (EDT)
</div>
</div>
<script src="../../../prettify.js"></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Thu May 03 2018 11:46:21 GMT-0400 (EDT)
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Thu May 03 2018 12:51:46 GMT-0400 (EDT)
</div>
</div>
<script src="../../../prettify.js"></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Thu May 03 2018 11:46:21 GMT-0400 (EDT)
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Thu May 03 2018 12:51:46 GMT-0400 (EDT)
</div>
</div>
<script src="../../../prettify.js"></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Thu May 03 2018 11:46:21 GMT-0400 (EDT)
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Thu May 03 2018 12:51:46 GMT-0400 (EDT)
</div>
</div>
<script src="../../../prettify.js"></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Thu May 03 2018 11:46:21 GMT-0400 (EDT)
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Thu May 03 2018 12:51:46 GMT-0400 (EDT)
</div>
</div>
<script src="../../../prettify.js"></script>
Expand Down
Loading