Commit 9cd074b1 authored by Sara Kuqi's avatar Sara Kuqi
Browse files

report add operator_name for measurement, pdf row colors

parent f31e7703
......@@ -37,6 +37,7 @@ gem 'coffee-rails', '~> 4.2'
# Use jquery as the JavaScript library
gem 'jquery-rails'
gem 'jquery-ui-rails'
gem 'jquery-turbolinks'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
......
......@@ -96,10 +96,13 @@ GEM
jbuilder (2.5.0)
activesupport (>= 3.0.0, < 5.1)
multi_json (~> 1.2)
jquery-rails (4.1.1)
jquery-rails (4.2.1)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
jquery-turbolinks (2.1.0)
railties (>= 3.1.0)
turbolinks
jquery-ui-rails (6.0.1)
railties (>= 3.2.16)
json (2.0.2)
......@@ -116,18 +119,16 @@ GEM
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_portile2 (2.1.0)
minitest (5.9.0)
minitest (5.10.1)
multi_json (1.12.1)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-ssh (3.2.0)
nio4r (1.2.1)
nokogiri (1.6.8)
nokogiri (1.6.8.1)
mini_portile2 (~> 2.1.0)
pkg-config (~> 1.1.7)
pdf-core (0.6.1)
pg (0.18.4)
pkg-config (1.1.7)
prawn (2.1.0)
pdf-core (~> 0.6.1)
ttfunk (~> 1.4.0)
......@@ -160,7 +161,7 @@ GEM
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
raindrops (0.17.0)
rake (11.2.2)
rake (12.0.0)
rb-fsevent (0.9.7)
rb-inotify (0.9.7)
ffi (>= 0.5.0)
......@@ -189,7 +190,7 @@ GEM
sshkit (1.11.4)
net-scp (>= 1.1.2)
net-ssh (>= 2.8.0)
thor (0.19.1)
thor (0.19.4)
thread_safe (0.3.5)
tilt (2.0.5)
ttfunk (1.4.0)
......@@ -232,6 +233,7 @@ DEPENDENCIES
font-awesome-rails
jbuilder (~> 2.5)
jquery-rails
jquery-turbolinks
jquery-ui-rails
json
listen (~> 3.0.5)
......
......@@ -11,8 +11,24 @@
// about supported directives.
//
//= require jquery
//= require jquery.turbolinks
//= require jquery_ujs
//= require bootstrap
//= require turbolinks
//= require_tree .
//= require cocoon
$(document).ready(function(){
$('#tb tr.y_n').each(function(i){
let good = true;
$(this).find('td.y_n').each(function(j){
if ($(this).text() == 'NaN'){ return good = false}
if ($(this).text() > 0.4){ return good = false}
});
good ? $(this).css('background-color','#a9edb8') : $(this).css('background-color','#eda9ca')
});
console.log('it works too');
$('tbody#resultTable').on('cocoon:before-insert', function() {
console.log('yepyep');
});
})
$(document).ready(function(){
$('#tb tr.y_n').each(function(i){
let good = true;
$(this).find('td.y_n').each(function(j){
if ($(this).text() == 'NaN'){ return good = false}
if ($(this).text() > 0.4){ return good = false}
});
good ? $(this).css('background-color','#a9edb8') : $(this).css('background-color','#eda9ca')
});
console.log('it works too');
$('tbody#resultTable').on('cocoon:before-insert', function() {
console.log('yepyep');
});
})
// $(document).ready(function(){
// $('#tb tr.y_n').each(function(i){
// let good = true;
// $(this).find('td.y_n').each(function(j){
// if ($(this).text() == 'NaN'){ return good = false}
// if ($(this).text() > 0.4){ return good = false}
// });
// good ? $(this).css('background-color','#a9edb8') : $(this).css('background-color','#eda9ca')
// });
// console.log('it works too');
//
// $('tbody#resultTable').on('cocoon:before-insert', function() {
// console.log('yepyep');
// });
// })
// $( document ).on('turbolinks:load', function() {
// $('#tb tr.y_n').each(function(i){
......
......@@ -105,7 +105,7 @@ class SamplesController < ApplicationController
if sample.status == "submitted"
sample.status = "measured"
sample.measured_at = Time.new
# sample.operator=current_user.name
sample.operator_name = current_user.name
sample.save
end
UserMailer.delay.measured_email(@user,sample)
......
......@@ -6,21 +6,22 @@ class SamplePdf < Prawn::Document
@user = user
@sample = sample
@with_results = with_results
text "name: \ #{@user.name}
text " \ #{@user.name}
id: \ #{@sample.id}
formula_name: \ #{@sample.name}
name: \ #{@sample.name}
formula:\ #{@sample.formula}
status: \ #{@sample.status}", size: 15, style: :bold
if @sample.status=="submitted"
text "Submitted at: \ #{@sample.submitted_at}", size: 15, style: :bold
text "submitted at: \ #{@sample.submitted_at}", size: 15, style: :bold
elsif @sample.status=="measured"
text "Measured at: \ #{@sample.measured_at}",size: 15, style: :bold
text "measured at: \ #{@sample.measured_at}",size: 15, style: :bold
text "measured by: \ #{@sample.operator_name}",size: 15, style: :bold
else
text "Created at: \ #{@sample.created_at}",size: 15, style: :bold
text "created at: \ #{@sample.created_at}",size: 15, style: :bold
end
move_down 20
table(table_data,width: bounds.width)
table_rows, style: :bold
table(table_data,width: bounds.width, :row_colors => ['FFFFFF','D9D9D9'])
move_down 100
text I18n.l(DateTime.now.to_date, format: "%d %B %Y").to_s
......
......@@ -3,8 +3,8 @@
<head>
<%= csrf_meta_tags %>
<%= stylesheet_link_tag 'application', media: 'all',
'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
<%= render 'layouts/shim' %>
</head>
<body>
......
<%= javascript_include_tag "application" %>
<% provide(:title, "Edit sample") %>
<%if @sample.status=="in preparation"%>
<div class="div-table">
......
......@@ -13,6 +13,7 @@
<div class="col-sm-11">
<fieldset id="sample-results">
<table class="table table-bordered" id = "myTable" style="margin-left:20px;">
<thead>
<tr>
......@@ -37,18 +38,19 @@
<td> <%= "%.2f" % @sample.calculation[k] %></td>
<%end if @sample.calculation%>
</tr>
<fieldset id="sample-results">
<%= f.fields_for :results do |result|;render 'result_fields', f: result;end %>
</fieldset>
<%= f.fields_for :results do |result|;render 'result_fields', f: result;end %>
</tbody>
</table>
<div class="links" style="margin-left:30px">
<%= link_to_add_association 'Add Result', f, :results,
'data-association-insertion-node' => "tbody#resultTable ",
'data-association-insertion-method' => "append",
:style=>'color: Black;' , :class=>"btn btn-block btn-success " %>
<%= link_to_add_association 'Add Result', f, :results,
'data-association-insertion-node' => "#resultTable ",
'data-association-insertion-method' => "append",
:style=>'color: Black;' , :class=>"btn btn-block btn-success " %>
</div>
</fieldset>
<div class="links" style="margin-left:30px">
<br>
<%= f.submit %>
</div>
......
<%= javascript_include_tag "application" %>
<% if (current_page?('/samples, /index') || current_page?('/'))%>
<div class="panel panel-default">
<%=render 'shared/sample_form'%><br>
......
<%= javascript_include_tag "application" %>
<script>
$(document).ready(function(){
$('#tb tr.y_n').each(function(i){
let good = true;
$(this).find('td.y_n').each(function(j){
if ($(this).text() == 'NaN'){ return good = false}
if ($(this).text() > 0.4){ return good = false}
});
good ? $(this).css('background-color','#a9edb8') : $(this).css('background-color','#eda9ca')
});
console.log('it works too');
$('tbody#resultTable').on('cocoon:before-insert', function() {
console.log('yepyep');
});
})
</script>
<br>
<%if @sample.status=="submitted"%>
<p>Submitted at: <%=@sample.submitted_at%></p>
<%elsif @sample.status=="measured"%>
<p>Measured at: <%=@sample.measured_at%></p>
<p>Measured by: <b><%=@sample.operator_name%></b></p>
<%else%>
<p>Created at: <%= @sample.created_at%></p>
<%end%>
......
class AddOperatorIdToSamples < ActiveRecord::Migration[5.0]
def change
add_column :samples, :operator_id, :integer
end
end
class AddOperatorNameToSamples < ActiveRecord::Migration[5.0]
def change
add_column :samples, :operator_name, :string
end
end
......@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20161212130519) do
ActiveRecord::Schema.define(version: 20161216091554) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
......@@ -55,12 +55,14 @@ ActiveRecord::Schema.define(version: 20161212130519) do
t.string "name"
t.string "formula"
t.integer "user_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "status"
t.hstore "calculation"
t.datetime "submitted_at"
t.datetime "measured_at"
t.integer "operator_id"
t.string "operator_name"
t.index ["user_id", "created_at"], name: "index_samples_on_user_id_and_created_at", using: :btree
end
......
{"files":{"application-413d252ba59de4ab77b3224bf064edc7373d5c5ab8cc0d40edf0abd74cd76d5c.js":{"logical_path":"application.js","mtime":"2016-10-26T13:03:22+02:00","size":191197,"digest":"413d252ba59de4ab77b3224bf064edc7373d5c5ab8cc0d40edf0abd74cd76d5c","integrity":"sha256-QT0lK6Wd5Kt3syJL8GTtxzc9XFq4zA1A7fCr10zXbVw="},"application-c0296dce657d30b00d429625b3d7e50eccef7f7a6c782ef28ccb1e77254281e6.css":{"logical_path":"application.css","mtime":"2016-11-11T09:42:35+01:00","size":186308,"digest":"c0296dce657d30b00d429625b3d7e50eccef7f7a6c782ef28ccb1e77254281e6","integrity":"sha256-wCltzmV9MLANQpYls9flDszvf3pseC7yjMsedyVCgeY="},"bootstrap/glyphicons-halflings-regular-13634da87d9e23f8c3ed9108ce1724d183a39ad072e73e1b3d8cbf646d2d0407.eot":{"logical_path":"bootstrap/glyphicons-halflings-regular.eot","mtime":"2016-08-15T09:32:07+02:00","size":20127,"digest":"13634da87d9e23f8c3ed9108ce1724d183a39ad072e73e1b3d8cbf646d2d0407","integrity":"sha256-E2NNqH2eI/jD7ZEIzhck0YOjmtBy5z4bPYy/ZG0tBAc="},"bootstrap/glyphicons-halflings-regular-fe185d11a49676890d47bb783312a0cda5a44c4039214094e7957b4c040ef11c.woff2":{"logical_path":"bootstrap/glyphicons-halflings-regular.woff2","mtime":"2016-08-15T09:32:07+02:00","size":18028,"digest":"fe185d11a49676890d47bb783312a0cda5a44c4039214094e7957b4c040ef11c","integrity":"sha256-/hhdEaSWdokNR7t4MxKgzaWkTEA5IUCU55V7TAQO8Rw="},"bootstrap/glyphicons-halflings-regular-a26394f7ede100ca118eff2eda08596275a9839b959c226e15439557a5a80742.woff":{"logical_path":"bootstrap/glyphicons-halflings-regular.woff","mtime":"2016-08-15T09:32:07+02:00","size":23424,"digest":"a26394f7ede100ca118eff2eda08596275a9839b959c226e15439557a5a80742","integrity":"sha256-omOU9+3hAMoRjv8u2ghZYnWpg5uVnCJuFUOVV6WoB0I="},"bootstrap/glyphicons-halflings-regular-e395044093757d82afcb138957d06a1ea9361bdcf0b442d06a18a8051af57456.ttf":{"logical_path":"bootstrap/glyphicons-halflings-regular.ttf","mtime":"2016-08-15T09:32:07+02:00","size":45404,"digest":"e395044093757d82afcb138957d06a1ea9361bdcf0b442d06a18a8051af57456","integrity":"sha256-45UEQJN1fYKvyxOJV9BqHqk2G9zwtELQahioBRr1dFY="},"bootstrap/glyphicons-halflings-regular-42f60659d265c1a3c30f9fa42abcbb56bd4a53af4d83d316d6dd7a36903c43e5.svg":{"logical_path":"bootstrap/glyphicons-halflings-regular.svg","mtime":"2016-08-15T09:32:07+02:00","size":108738,"digest":"42f60659d265c1a3c30f9fa42abcbb56bd4a53af4d83d316d6dd7a36903c43e5","integrity":"sha256-QvYGWdJlwaPDD5+kKry7Vr1KU69Ng9MW1t16NpA8Q+U="},"fontawesome-webfont-50bbe9192697e791e2ee4ef73917aeb1b03e727dff08a1fc8d74f00e4aa812e1.eot":{"logical_path":"fontawesome-webfont.eot","mtime":"2016-09-05T12:21:28+02:00","size":76518,"digest":"50bbe9192697e791e2ee4ef73917aeb1b03e727dff08a1fc8d74f00e4aa812e1","integrity":"sha256-ULvpGSaX55Hi7k73OReusbA+cn3/CKH8jXTwDkqoEuE="},"fontawesome-webfont-7dacf83f51179de8d7980a513e67ab3a08f2c6272bb5946df8fd77c0d1763b73.woff2":{"logical_path":"fontawesome-webfont.woff2","mtime":"2016-09-05T12:21:28+02:00","size":71896,"digest":"7dacf83f51179de8d7980a513e67ab3a08f2c6272bb5946df8fd77c0d1763b73","integrity":"sha256-faz4P1EXnejXmApRPmerOgjyxicrtZRt+P13wNF2O3M="},"fontawesome-webfont-adbc4f95eb6d7f2738959cf0ecbc374672fce47e856050a8e9791f457623ac2c.woff":{"logical_path":"fontawesome-webfont.woff","mtime":"2016-09-05T12:21:28+02:00","size":90412,"digest":"adbc4f95eb6d7f2738959cf0ecbc374672fce47e856050a8e9791f457623ac2c","integrity":"sha256-rbxPlettfyc4lZzw7Lw3RnL85H6FYFCo6XkfRXYjrCw="},"fontawesome-webfont-ae19e2e4c04f2b04bf030684c4c1db8faf5c8fe3ee03d1e0c409046608b38912.ttf":{"logical_path":"fontawesome-webfont.ttf","mtime":"2016-09-05T12:21:28+02:00","size":152796,"digest":"ae19e2e4c04f2b04bf030684c4c1db8faf5c8fe3ee03d1e0c409046608b38912","integrity":"sha256-rhni5MBPKwS/AwaExMHbj69cj+PuA9HgxAkEZgiziRI="},"fontawesome-webfont-8e3586389bb4cd01b3f85bb3b622739bde6627f28bba63a020c223ca9cf1b9ae.svg":{"logical_path":"fontawesome-webfont.svg","mtime":"2016-09-05T12:21:28+02:00","size":391622,"digest":"8e3586389bb4cd01b3f85bb3b622739bde6627f28bba63a020c223ca9cf1b9ae","integrity":"sha256-jjWGOJu0zQGz+FuztiJzm95mJ/KLumOgIMIjypzxua4="}},"assets":{"application.js":"application-413d252ba59de4ab77b3224bf064edc7373d5c5ab8cc0d40edf0abd74cd76d5c.js","application.css":"application-c0296dce657d30b00d429625b3d7e50eccef7f7a6c782ef28ccb1e77254281e6.css","bootstrap/glyphicons-halflings-regular.eot":"bootstrap/glyphicons-halflings-regular-13634da87d9e23f8c3ed9108ce1724d183a39ad072e73e1b3d8cbf646d2d0407.eot","bootstrap/glyphicons-halflings-regular.woff2":"bootstrap/glyphicons-halflings-regular-fe185d11a49676890d47bb783312a0cda5a44c4039214094e7957b4c040ef11c.woff2","bootstrap/glyphicons-halflings-regular.woff":"bootstrap/glyphicons-halflings-regular-a26394f7ede100ca118eff2eda08596275a9839b959c226e15439557a5a80742.woff","bootstrap/glyphicons-halflings-regular.ttf":"bootstrap/glyphicons-halflings-regular-e395044093757d82afcb138957d06a1ea9361bdcf0b442d06a18a8051af57456.ttf","bootstrap/glyphicons-halflings-regular.svg":"bootstrap/glyphicons-halflings-regular-42f60659d265c1a3c30f9fa42abcbb56bd4a53af4d83d316d6dd7a36903c43e5.svg","fontawesome-webfont.eot":"fontawesome-webfont-50bbe9192697e791e2ee4ef73917aeb1b03e727dff08a1fc8d74f00e4aa812e1.eot","fontawesome-webfont.woff2":"fontawesome-webfont-7dacf83f51179de8d7980a513e67ab3a08f2c6272bb5946df8fd77c0d1763b73.woff2","fontawesome-webfont.woff":"fontawesome-webfont-adbc4f95eb6d7f2738959cf0ecbc374672fce47e856050a8e9791f457623ac2c.woff","fontawesome-webfont.ttf":"fontawesome-webfont-ae19e2e4c04f2b04bf030684c4c1db8faf5c8fe3ee03d1e0c409046608b38912.ttf","fontawesome-webfont.svg":"fontawesome-webfont-8e3586389bb4cd01b3f85bb3b622739bde6627f28bba63a020c223ca9cf1b9ae.svg"}}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment