Commit 3903e9cf authored by ira.maier's avatar ira.maier
Browse files

Final for now: download link for files

parent 79d0ecb6
......@@ -9,6 +9,8 @@ Things you may want to cover:
* Bootstrap 3
* JavaScript: no ES6
* System dependencies
* Configuration
......
......@@ -29,12 +29,10 @@ p {
.row.content {height: 650px}
/* Set gray background color and 100% height */
//todo
.sidenav {
padding-top: 20px;
background-color: #f1f1f1;
height: 100%;
}
/* Set black background color, white text and some padding */
......@@ -52,19 +50,12 @@ footer {
/* On small screens, set height to 'auto' for sidenav and grid */
@media screen and (max-width: 767px) {
.sidenav {
height: auto;
padding: 15px;
}
.row.content {height:auto;}
}
body {
// done removed --> navbar sticks on the top
//padding-top: 25px;
}
section {
overflow: auto;
}
......@@ -119,7 +110,7 @@ aside {
input, textarea, select, .uneditable-input {
border: 1px solid #bbb;
display: inline-block; // new todo?
display: inline-block;
height: auto !important;
width: 100%;
margin-bottom: 10px;
......@@ -151,15 +142,6 @@ input[type="checkbox"]{
}
}
//form{
// input{
// margin: 0.5rem 0.5rem 0.5rem 0.5rem;
// }
// label{
// margin: 0;
// }
//}
#edit_sample_table{
border-radius: 0.5rem;
......@@ -217,7 +199,6 @@ input[type="checkbox"]{
.timestamp {
color: lightgrey;
//todo
display: block;
margin-left: 4rem;
}
......@@ -275,7 +256,6 @@ input.transparent-input{
text-decoration: underline;
}
// todo?
.panel-default{
//max-height:400px;
width: 145%;
......@@ -294,11 +274,11 @@ input.transparent-input{
div.absolute {
margin-top:10px;
width: 99%;
}
.div-table{
display:table;
width: auto !important;
// background-color:#eee;
border-spacing:5px;/*cellspacing:poor IE support for this*/
}
.div-table-row{
......@@ -316,13 +296,23 @@ div.absolute {
padding: 12px;
}
.comment_button{
background: #337ab7;
border: #337ab7;
border-radius: 0.5rem;
color:white;
padding: 0.5rem;
margin: 0.5rem;
width: 98%;
}
.file_storage_button{
background: #5bc0de;
border: #5bc0de;
border-radius: 0.5rem;
color:white;
magin: none;
padding: 0.5rem;
text-align: left;
}
.font {
......@@ -330,7 +320,6 @@ div.absolute {
}
// todo rmv?
#form_delete_files{
input{
width:auto; // important
......@@ -343,10 +332,6 @@ div.absolute {
}
}
.form_with{
// class: "btn btn-info";
}
.remember-me {
display: flex;
#user_remember_me {
......@@ -355,7 +340,13 @@ div.absolute {
}
.rm-mg-bottom {
border-collapse: collapse;
margin-bottom: unset;
.form-control{
padding: 0.5rem;
margin: 0.5rem;
width: 96%;
}
}
.form-inline {
......@@ -369,10 +360,12 @@ div.absolute {
table{
text-align: center;
tbody{
//border: solid lightgray;
}
td{
border: 1px solid lightgray;
}
}
//for downloading file attached to sample
.download_label:hover::after{
content: attr(tooltip);
}
\ No newline at end of file
......@@ -6,47 +6,35 @@
box-sizing: inherit;
}
.div{
display:inline-block;
#samples_list{
border-collapse: collapse;
display:inline-block;
float: left;
margin: 0rem 0.5rem 0rem 0rem;
max-width:49%;
width:30%;
}
#show{
display:inline-block;
float: left;
margin: 0rem 0.5rem 0.5rem 0.5rem;
padding: 0rem 0.5rem 0.5rem 0.5rem;
width:65%;
width:55%;
}
.splitScreen{
margin: 0rem 0rem 0rem 0rem;
padding : 0rem 0rem 0rem 0rem;
margin: 0;
padding : 0;
width:100%;
}
.table{
margin: 0rem 0rem 0rem 0rem;
padding : 0rem 0rem 0rem 0rem;
/*overflow-y: scroll;*/
margin: 0;
padding : 0;
}
/*.scrollbar{*/
/* margin: 0;*/
/* overflow-y: scroll;*/
/* padding: 0;*/
/* max-width:49%;*/
/* width:30%;*/
/*}*/
#samples_list{
display:inline-block;
float: left;
margin: 0rem 0.5rem 0rem 0rem;
// err scrolling not working
max-width:49%;
width:30%;
}
......
......@@ -76,17 +76,14 @@ class SamplesController < ApplicationController
# files processing:
if params[:sample][:add_files]
logger.debug "add my files"
sample.files.attach(params[:sample][:add_files])
end
if params[:sample][:delete_files] == "1"
logger.debug "purged all at once"
sample.files.purge_later
elsif params[:sample][:delete_files] == "0" and params[:sample][:delete_file]
params[:sample][:delete_file].each{ |id|
unless id && id.to_s.strip.empty?
@file = ActiveStorage::Attachment.find(id)
logger.debug "purged sample by sample"
@file.purge_later
end
}
......
class Sample < ApplicationRecord
attr_reader :formul
# todo delete?
attr_accessor :mw #:add_file, :delete_files, :delete_file
attr_accessor :mw
has_many :results
accepts_nested_attributes_for :results, :reject_if => :all_blank, :allow_destroy => true
......
......@@ -17,7 +17,6 @@
<%= yield %>
</div>
</div>
<%# todo don't hide page content under footer %>
<%= render 'layouts/footer' %>
</div>
</body>
......
......@@ -15,20 +15,18 @@
<div class="table-responsive">
<table class="table rm-mg-bottom">
<tbody>
<tr>
<td>
<tr style="border-top: 0;">
<td style="border-bottom: 0; border-right: 0;">
<label for="comment_by_op">Operator comments</label>
<%= f.text_area :comment_by_operator, class: 'form-control', rows: 3, id: 'comment_by_op', readonly: !operator? %>
</td>
<td>
<td style="border-bottom: 0; border-left: 0;">
<label for="comment_by_user">Submitter comments</label>
<%= f.text_area :comment_by_user, class: 'form-control', rows: 3, id: 'comment_by_user', readonly: operator? %>
</td>
</tr>
<tr><td colspan="2" style="border-top: 0;"><%= f.submit "Save Comments", class: "comment_button" %></td></tr>
</tbody>
</table>
<div class="links">
<%= f.submit "Save Comments", class: "btn btn-primary" %>
</div>
</div>
<% end %>
<% provide(:title, "Edit sample") %>
<%if @sample.status=="in preparation"%>
<%# todo %>
<%= form_for(@sample) do |f| %>
<%= render 'shared/error_messages', object: f.object %>
<table id="edit_sample_table">
......
<%= form_with model: @sample do |f| %>
<div style="text-align: right">
<%= f.file_field :add_files, multiple: true, class: "file_storage_button", style: "float: right; text-align: left; width: 70%" %>
<%= f.submit "Add Files", class: "file_storage_button", style: "text-align: left; width: 70%"%>
<%= f.file_field :add_files, multiple: true, direct_upload: true, class: "file_storage_button", style: "float: right; width: 70%" %>
<%= f.submit "Add Files", class: "file_storage_button", style: "width: 70%"%>
</div>
<% end %>
\ No newline at end of file
......@@ -4,23 +4,19 @@
<%= f.check_box :delete_files, :id => "sample_delete_files"%>
<%= f.label :delete_files, "All", :for => "sample_delete_files"%>
</div>
<%= f.collection_check_boxes :delete_file, @sample.files, :id, :filename do |b| %>
<div style="text-align: left">
<%= b.check_box%>
<%= b.label %>
<%= b.check_box%>
<%= link_to b.label, rails_blob_path(b.object, disposition: 'attachment'), {:class=>"download_label", :tooltip=>" Download"}%>
</div>
<% end %>
<div style="text-align: left">
<%= f.submit "Delete Files", data: { confirm: "Are you sure?" }, class: "file_storage_button"%>
</div>
<% end %>
<% end %>
<script>
let selectAllCheckbox = document.querySelector('#sample_delete_files');
// let selectAllCheckboxElem = document.getElementById('sample_delete_files');
let filenameCheckboxes = document.querySelectorAll('[name="sample[delete_file][]"]');
function shiftToSelect() {
......@@ -30,7 +26,6 @@
// Check if shift key is down and check if checkbox is checked
let inBetween = false;
if (e.shiftKey && this.checked) {
// console.log(e.shiftKey);
filenameCheckboxes.forEach(checkbox => {
if (checkbox === this || checkbox === lastChecked) {
inBetween = !inBetween;
......@@ -60,13 +55,9 @@
}
if (selectAllCheckbox) {
// console.log(selectAllCheckbox);
console.log("hit all checkboxes from form_delete_files.html.erb");
selectAllCheckbox.addEventListener('click', handleSelectAll, false);
}
if(filenameCheckboxes){
// console.log(filenameCheckboxes);
console.log("hit filename checkboxes from form_delete_files.html.erb");
shiftToSelect();
}
</script>
......
<h1>File Attachments for <%=@sample.name %></h1>
<h2>Delete Files</h2>
<p>
<%= render 'samples/form_delete_files'%>
</p>
<h2>Add Files</h2>
<p>
<%= form_with model: @sample do |f| %>
<%= f.file_field :add_files, multiple: true %><br>
<%= f.submit "Add Files", data: { confirm: "Are you sure?" } %>
<% end %>
</p>
......@@ -6,8 +6,7 @@
<%end%>
<!--left side-->
<!--<div class="scrollbar">-->
<table id="samples_list" class="table table-hover table-bordered" style="overflow-y: scroll">
<table id="samples_list" class="table table-hover table-bordered">
<thead>
<tr>
<th class="text-center">ID</th>
......@@ -83,16 +82,13 @@
data: { confirm: "You sure?"}%>
<%end%>
</td>
<td>
<%# todo %>
<%= sample.files.attached? %>
</td>
</tr>
<%end%>
</tbody>
</table>
<!--</div>-->
<%if @sample&.persisted? %>
<div class="panel panel-default" id="show">
......
......@@ -137,15 +137,15 @@
<%if @sample.status == "in preparation" %>
<div class='absolute'><%=link_to (@sample.status ? "Submit for Measurement" : "No"),
Measured_sample_path(@sample), :action => 'solve', :class => 'btn btn-block btn-success' %>
Measured_sample_path(@sample), :action => 'solve', :class => 'btn btn-block btn-success', :style=>"width:99%"%>
</div>
<%elsif current_user?(@sample.user) && @sample.status == "submitted" %>
<div class='absolute'><%=link_to (@sample.status ? "Withdraw this Sample" : "No"),
Withdraw_sample_path(@sample), :action => 'solve', :class => 'btn btn-block btn-danger' %>
Withdraw_sample_path(@sample), :action => 'solve', :class => 'btn btn-block btn-danger', :style=>"width:99%" %>
</div>
<%elsif operator? && @sample.status == "submitted" %>
<div class='absolute'><%=link_to (@sample.status ? "Release Measurement" : "No"),
ReleaseMeasurment_sample_path(@sample), :action => 'solve', :class => 'btn btn-block btn-success' %>
ReleaseMeasurment_sample_path(@sample), :action => 'solve', :class => 'btn btn-block btn-success', :style=>"width:99%" %>
</div>
<%end%>
......@@ -157,19 +157,17 @@
<%= form_with model: @sample do |f| %>
<div style="text-align: left">
<%= f.label "Create new File Attachment:" %>
<%= f.file_field :add_files, multiple: true, class: "file_storage_button", style: "text-align: left; width: 70%" %>
<%= f.submit "Save Files", class: "file_storage_button", style: "text-align: left; width: 70%" %>
<%= f.file_field :add_files, multiple: true, direct_upload: true, class: "file_storage_button", style: "width: 70%" %>
<%= f.submit "Save Files", class: "file_storage_button", style: "width: 70%" %>
</div>
<% end %>
<% end %>
<%if @sample.files.attached? %>
<div style="float: left; margin: 0.5rem; width: auto" ><%= render 'samples/form_delete_files'%></div>
<%# todo float: left? %>
<div style="float: left; margin: 0.5rem; width: auto" ><%= render 'samples/form_add_files'%></div>
<%end%>
</div>
</div>
<%#= link_to 'Open Files List', files_sample_path, target: "_blank", class:'btn btn-info'%>
......
......@@ -18,7 +18,7 @@ ActiveSupport.to_time_preserves_timezone = true
Rails.application.config.active_record.belongs_to_required_by_default = true
# Do not halt callback chains when a callback returns false. Previous versions had true.
#ActiveSupport.halt_callback_chains_on_return_false = false todo?
#ActiveSupport.halt_callback_chains_on_return_false = false
# Configure SSL options to enable HSTS with subdomains. Previous versions had false.
Rails.application.config.ssl_options = { hsts: { subdomains: true } }
......@@ -7,11 +7,9 @@ Rails.application.routes.draw do
get 'password_resets/new'
get 'password_resets/edit'
# not used?
get 'submitformeasurements/new'
get 'results/new'
# not used?
get 'sessions/new'
get 'results_field/new'
get 'results_field/create'
......@@ -41,7 +39,6 @@ Rails.application.routes.draw do
get :Measured
get :ReleaseMeasurment
get :Withdraw
get :files
end
end
......
Markdown is supported
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