Skip to content

Commit

Permalink
Update traffic-light hover-tip to show revert r/a/g image
Browse files Browse the repository at this point in the history
  • Loading branch information
JonJagger committed Aug 6, 2020
1 parent 0b58082 commit 86bd3b6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
14 changes: 12 additions & 2 deletions app/helpers/traffic_light_tip_helper.rb
Expand Up @@ -41,12 +41,22 @@ def traffic_light_img(light)
if colour.to_s === ''
''
else
predicted = rag?(colour) ? "_predicted_#{light.predicted}" : ''
"<img src='/traffic-light/image/#{light.colour}#{predicted}.png'" +
"<img src='/traffic-light/image/#{light.colour}#{imgSuffix(light)}.png'" +
" class='traffic-light-diff-tip-traffic-light-image'>"
end
end

def imgSuffix(light)
if !rag?(light.colour)
''
elsif light.revert
'_revert'
else
predicted = light.predicted || 'none'
"_predicted_#{predicted}"
end
end

def rag?(colour)
%w( red amber green ).include?(colour.to_s)
end
Expand Down
4 changes: 4 additions & 0 deletions app/models/event.rb
Expand Up @@ -29,6 +29,10 @@ def status
event['status']
end

def revert
event['revert']
end

def time
Time.mktime(*@hash['time'])
end
Expand Down
3 changes: 1 addition & 2 deletions app/views/kata/_traffic_lights.html.erb
Expand Up @@ -78,9 +78,8 @@ $(() => {
};

const imgSuffix = (event) => {
const colour = event.colour;
const predicted = event.predicted || 'none';
if (!isRag(colour)) {
if (!isRag(event.colour)) {
return '';
} else if (event.revert) {
return '_revert';
Expand Down

0 comments on commit 86bd3b6

Please sign in to comment.