Commit 2c155927 authored by ira.maier's avatar ira.maier
Browse files

layout changed

parent b78e964f
......@@ -282,6 +282,19 @@ div.absolute {
}
// todo rmv?
#form_delete_files{
input{
width:auto; // important
height: 100%;
text-align: left;
}
.row{
margin: 0rem 0rem 0rem 0rem;
text-align: left;
}
}
.form_with{
class: "btn btn-info";
......
<%= form_with model: @sample do |f| %>
<div style="text-align: left">
<%= f.file_field :add_files, multiple: true, class: "btn btn-info", style: "text-align: left; width: 70%" %>
<%= f.submit "Add Files", class: "btn btn-info", style: "text-align: left; width: 70%"%>
</div>
<% end %>
\ No newline at end of file
<%= form_with model: @sample do |f| %>
<%= form_with model: @sample, id:"form_delete_files" do |f| %>
<% if @sample.files.attached? %>
<%# calls controller update: %>
<%= f.label :delete_files, "All" %>
<%= f.check_box :delete_files%>
<br>
<div style="text-align: left">
<%= f.check_box :delete_files, :id => "sample_delete_files"%>
<%= f.label :delete_files, "All", :for => "sample_delete_files"%>
</div>
<%# todo :id! :filename! like :first! ? %>
<%= f.collection_check_boxes :delete_file, @sample.files, :id, :filename do |b| %>
<%= b.label %>
<%= b.check_box %>
<br>
<div style="text-align: left">
<%= b.check_box%>
<%= b.label %></td>
</div>
<% end %>
<% end %>
<%= f.submit "Delete Files", data: { confirm: "Are you sure?" } %>
<div style="text-align: left">
<%= f.submit "Delete Files", class: "btn btn-info", data: { confirm: "Are you sure?" } %>
</div>
<% end %>
<% end %>
<script>
let selectAllCheckbox= document.querySelector('#sample_delete_files');
let filenameCheckboxes = document.querySelectorAll('[name="sample[delete_file][]"]');
function shiftToSelect() {
let lastChecked;
function handleCheck(event) {
// Check if shift key is down and check if checkbox is checked
let inBetween = false;
if (event.shiftKey && this.checked) {
filenameCheckboxes.forEach(checkbox => {
if (checkbox === this || checkbox === lastChecked) {
inBetween = !inBetween;
}
if (inBetween) {
checkbox.checked = true;
}
});
}
lastChecked = this;
}
filenameCheckboxes.forEach(checkbox => checkbox.addEventListener('click', handleCheck, false));
}
function selectAll(){
function handleSelectAll(event){
if(selectAllCheckbox.checked === true){
filenameCheckboxes.forEach(checkbox => {
checkbox.checked=true;
})
}else{
filenameCheckboxes.forEach(checkbox => {
checkbox.checked=false;
})
}
}
selectAllCheckbox.addEventListener('click', handleSelectAll, false);
}
shiftToSelect();
selectAll();
</script>
......@@ -93,4 +93,54 @@
<%else%>
<div class="panel panel-default" id="show" style="display:none;"></div>
<%end%>
</div>
\ No newline at end of file
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
let selectAllCheckbox = document.querySelector('#sample_delete_files');
let filenameCheckboxes = document.querySelectorAll('[name="sample[delete_file][]"]');
function shiftToSelect() {
let lastChecked;
function handleCheck(e) {
console.log('handleCheck event',e);
// 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;
}
if (inBetween) {
checkbox.checked = true;
}
});
}
lastChecked = this;
}
filenameCheckboxes.forEach(checkbox => checkbox.addEventListener('click', handleCheck, false));
}
function handleSelectAll(e) {
console.log(e);
console.log(selectAllCheckbox.checked);
if (selectAllCheckbox.checked === true) {
filenameCheckboxes.forEach(checkbox => {
checkbox.checked = true;
})
} else {
filenameCheckboxes.forEach(checkbox => {
checkbox.checked = false;
})
}
}
selectAllCheckbox.addEventListener('click', handleSelectAll, false);
shiftToSelect();
});
</script>
\ No newline at end of file
......@@ -8,7 +8,6 @@
});
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');
......@@ -131,9 +130,6 @@
</tbody>
</table>
<!-- <br>-->
<!--status-->
<%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' %>
......@@ -149,22 +145,30 @@
<%end%>
<div style="display: inline-block">
<h4>File Attachments</h4>
<div style="float: left; width: auto;">
<h4 style="text-align: left">File Attachments</h4>
<div style="float: left; width: auto;" >
<%unless @sample.files.attached? %>
<%= 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: "btn btn-info" %>
<%= f.submit "Save Files", class: "btn btn-info" %>
<%= f.file_field :add_files, multiple: true, class: "btn btn-info", style: "text-align: left; width: 70%" %>
<%= f.submit "Save Files", class: "btn btn-info", style: "text-align: left; width: 70%" %>
</div>
<% end %>
<% end %>
<%if @sample.files.attached? %>
<%= link_to 'Open Files List', files_sample_path, target: "_blank", class:'btn btn-info'%>
<div style="float: left; width: auto;" ><%= render 'samples/form_delete_files'%></div>
<div style="float: left; width: auto;" ><%= render 'samples/form_add_files'%></div>
<%end%>
</div>
</div>
</div>
</div>
<%#= link_to 'Open Files List', files_sample_path, target: "_blank", class:'btn btn-info'%>
<%= render 'samples/comment' %>
<br>
<p><%=link_to "Download PDF", sample_path(@sample, format: "pdf"), target: "_blank" %>&nbsp;<%=link_to "Download PNG", sample_path(@sample, format: "png"), target: "_blank" %><p>
\ No newline at end of file
<p><%=link_to "Download PDF", sample_path(@sample, format: "pdf"), target: "_blank" %>&nbsp;<%=link_to "Download PNG", sample_path(@sample, format: "png"), target: "_blank" %><p>
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