Skip to content

Commit 93f4e41

Browse files
committed
gray out assignments of zero days
1 parent dd9890c commit 93f4e41

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

app/assets/stylesheets/assignments_table.css.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ table {
1515
&.total {
1616
background-color: #ddd;
1717
}
18+
.no-assignment {
19+
color: #ccc;
20+
}
1821
}
1922
&.editable {
2023
text-align:center;

app/views/application/_cell_assignment.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<%= content_tag :span,
22
@assignment_days[worker][project],
33
:id => "w#{worker.id}_p#{project.id}_label",
4-
:class => "assignment_label" %>
4+
:class => "assignment_label #{ "no-assignment" if @assignment_days[worker][project] == 0 }" %>
55
<%= content_tag :span,
66
render("assignments/form_days_only", :assignment => @assignments[worker][project]),
77
:id => "w#{worker.id}_p#{project.id}_form",

app/views/assignments/_create_or_update.js.coffee

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
(->
22
worker = <%= @assignment.worker_id %>
33
project = <%= @assignment.project_id %>
4-
days = <%= @assignment.days_per_week %>
4+
days = <%= @assignment.destroyed? ? @assignment.previous_days : @assignment.days_per_week %>
55
assignment = <%= @assignment.id %>
66

77
label_id = '#w' + worker + '_p' + project + '_label'
88
form_id = '#w' + worker + '_p' + project + '_form form'
99

10+
$(label_id).html days
1011
<% if @assignment.destroyed? %>
1112
<%# assignment was deleted, days_per_week should have the value of the previous assignment %>
12-
$(label_id).html('<%= @assignment.previous_days %>')
1313
<%# form for creating assignments %>
1414
$(form_id).attr 'id', 'new_assignment'
1515
$(form_id).attr 'action', '/assignments'
1616
$(form_id + ' div input[name=\'_method\']').remove()
1717
<% else %>
1818
<%# update the value of days_per_week %>
19-
$(label_id).html days
2019
<%# form for updating assignments %>
2120
$(form_id).attr 'id', 'edit_assignment_' + assignment
2221
$(form_id).attr 'action', '/assignments/' + assignment
@@ -26,6 +25,11 @@
2625
$(form_id).children('div').first().append input
2726
<% end %>
2827

28+
if days == 0
29+
$(label_id).addClass('no-assignment')
30+
else
31+
$(label_id).removeClass('no-assignment')
32+
2933
<%# recalculate column and row sums for total assignments %>
3034
worker_total = 0
3135
$('.worker_' + worker + ' .assignment_label').each( ->

0 commit comments

Comments
 (0)