Skip to content

Commit

Permalink
Colours
Browse files Browse the repository at this point in the history
  • Loading branch information
pikesley committed Jan 28, 2016
1 parent 561e8c2 commit 6e6c088
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 7 deletions.
8 changes: 8 additions & 0 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
@import 'bootstrap';
@import 'plugins';

.bg-high {
background-color: $warning-pink;
}

.bg-low {
background-color: $warning-blue;
}

/* Dragones below this line */

nav {
Expand Down
2 changes: 2 additions & 0 deletions app/assets/stylesheets/colours.scss
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
$brand-primary: #fa8100;
$warning-pink: #FFE6E6;
$warning-blue: #ECE6FF;
4 changes: 2 additions & 2 deletions app/assets/stylesheets/fonts.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import url(http://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css);
@import url(http://fonts.googleapis.com/css?family=Ubuntu);
@import url(http://fonts.googleapis.com/css?family=NTR);

$font-family-sans-serif: Ubuntu, sans-serif;
$font-family-sans-serif: NTR, sans-serif;
10 changes: 8 additions & 2 deletions app/models/medication_event.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
class MedicationEvent < ActiveRecord::Base
# this didn't work http://stackoverflow.com/questions/14113057/how-to-have-a-drop-down-select-field-in-a-rails-form
def self.insulins
[
'humalog',
'lantus'
]
end

validates :datetime, presence: true
validates :amount, presence: true, numericality: { greater_than: 0 }
validates :insulin, presence: true, inclusion: { in: [ 'humalog', 'lantus' ] }
validates :insulin, presence: true, inclusion: { in: insulins }
end
16 changes: 14 additions & 2 deletions app/views/glucose_measurements/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<%= link_to 'Add new measurement', new_glucose_measurement_url, class: 'btn btn-success pull-right' %>
<h1>Glucose</h1>

<table class='table table-bordered table-striped'>
<table class='table table-bordered table-striped' id='blood-glucose'>
<% date_sift(@glucose_measurements).each_pair do |day, values| %>
<tr>
<th colspan=2>
Expand All @@ -14,10 +14,22 @@
<td>
<%= link_to v.datetime.strftime('%H:%M'), edit_glucose_measurement_path(v) %>
</td>
<td>

<td class='bg-value'>
<%= v.value %>
</td>
</tr>
<% end %>
<% end %>
</table>

<script>
$('.bg-value').each(function() {
if($(this).text() > 8.0) {
$(this).addClass('bg-high')
}
if($(this).text() < 4.0) {
$(this).addClass('bg-low')
}
})
</script>
2 changes: 1 addition & 1 deletion app/views/medication_events/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

<p>
<%= f.label :insulin %><br>
<%= f.select :insulin, [ 'humalog', 'lantus' ] %>
<%= f.select :insulin, MedicationEvent.insulins %>
</p>

<p>
Expand Down
8 changes: 8 additions & 0 deletions app/views/shared/_nav.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
<!-- Collect the nav links, forms, and other content for toggling -->
<div class='collapse navbar-collapse' id='navbar-collapse'>
<ul class='nav navbar-nav'>
<% {
'Glucose' => '/glucose',
'Meds' => '/meds'
}.each_pair do |label, url| %>
<li>
<%= link_to label, url %>
</li>
<% end %>
</ul>
<p class="navbar-text navbar-right">
<% if signed_in? %>
Expand Down

0 comments on commit 6e6c088

Please sign in to comment.