Commit 4a821187 authored by ira.maier's avatar ira.maier
Browse files

JS reloading

parent 2c155927
......@@ -14,6 +14,8 @@
//= require jquery.turbolinks
//= require jquery_ujs
//= require bootstrap
// require turbolinks
//= require turbolinks
//= require_tree .
//= require cocoon
//= require samples
......@@ -117,14 +117,22 @@ aside {
input, textarea, select, .uneditable-input {
border: 1px solid #bbb;
display: inline-block; // new todo?
height: auto !important;
width: 100%;
margin-bottom: 10px;
// @include box_sizing;
}
input {
height: auto !important;
//input {
// height: auto !important;
//}
input[type="checkbox"]{
margin: 0;
width: auto;
}
#error_explanation {
color: red;
ul {
......@@ -136,9 +144,19 @@ input {
.field_with_errors {
@extend .has-error;
.form-control {
color: $state-danger-text;
color: red;
}
}
form{
input{
margin: 0.5rem 0.5rem 0.5rem 0.5rem;
}
label{
margin: 0;
}
}
.checkbox {
margin-top: -10px;
margin-bottom: 10px;
......@@ -160,7 +178,7 @@ input {
li {
overflow: auto;
padding: 10px 0;
border-bottom: 1px solid $gray-lighter;
border-bottom: 1px solid lightgrey;
}
}
/* microposts */
......@@ -178,7 +196,7 @@ input {
}
.timestamp {
color: $gray-light;
color: lightgrey;
//todo
display: block;
margin-left: 4rem;
......@@ -277,6 +295,16 @@ div.absolute {
// background-color: gray;
padding: 12px;
}
.file_storage_button{
background: #5bc0de;
border: #5bc0de;
border-radius: 0.5rem;
color:white;
magin: none;
padding: 0.5rem;
}
.font {
font: 100 70px/1.2 'Merienda One', Helvetica, sans-serif;
......@@ -296,8 +324,7 @@ div.absolute {
}
.form_with{
class: "btn btn-info";
// class: "btn btn-info";
}
.remember-me {
......
......@@ -14,7 +14,7 @@
display:inline-block;
float: left;
margin: 0rem 0rem 0.5rem 0.5rem;
width:71%;
width:60%;
}
.splitScreen{
......@@ -36,7 +36,7 @@
// err scrolling not working
overflow-y: scroll;
max-width:49%;
width:25%;
width:30%;
}
......
/* Place all the styles related to the StaticPages controller here.*/
/* They will automatically be included in application.css.*/
.about{
display:inline-block;
float: left;
/* margin-top, margin-right, margin-bottom, margin-left*/
margin: 0.0rem 1rem 0.5rem 0.0rem;
}
#text{
max-width: 50%;
text-align: left;
}
\ No newline at end of file
// Place all the styles related to the StaticPages controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
.about{
display:inline-block;
float: left;
// margin-top, margin-right, margin-bottom, margin-left
margin: 0.0rem 1rem 0.5rem 0.0rem;
}
#text{
max-width: 50%;
text-align: left;
}
\ No newline at end of file
......@@ -2,8 +2,7 @@
<html>
<head>
<%= csrf_meta_tags %>
<%= stylesheet_link_tag 'application', media: 'all',
'data-turbolinks-track': 'reload' %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
<%= render 'layouts/shim' %>
</head>
......
<%= 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 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%"%>
</div>
<% end %>
\ No newline at end of file
<%= form_with model: @sample, id:"form_delete_files" do |f| %>
<%=form_with model: @sample do |f| %>
<% if @sample.files.attached? %>
<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| %>
<div style="text-align: left">
<%= b.check_box%>
<%= b.label %></td>
<%= b.label %>
</div>
<% end %>
<div style="text-align: left">
<%= f.submit "Delete Files", class: "btn btn-info", data: { confirm: "Are you sure?" } %>
<%= 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() {
let lastChecked;
function handleCheck(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) {
if (selectAllCheckbox.checked === true) {
filenameCheckboxes.forEach(checkbox => {
checkbox.checked = true;
})
} else {
filenameCheckboxes.forEach(checkbox => {
checkbox.checked = false;
})
}
}
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>
......
......@@ -30,11 +30,11 @@
</thead>
<tbody id= "resultTable">
<tr>
<td >Expected:</td>
<td>Expected:</td>
<% Sample::PREDEF_ELEMENTS.each do |k| %>
<td> <%= "%.2f" % (@sample.calculation[k] || 0) %></td>
<%end if @sample.calculation %>
<td ><%=sum_other(@sample)%></td>
<td><%=sum_other(@sample)%></td>
<% (@sample.calculation.keys-Sample::PREDEF_ELEMENTS).each do|k| %>
<td> <%= "%.2f" % @sample.calculation[k] %></td>
<%end if @sample.calculation%>
......
......@@ -37,9 +37,8 @@
Email
</th>
<%end%>
<th class="text-center">
Action
</th>
<th class="text-center">Action</th>
<th class="text-center">Files</th>
</tr>
</thead>
......@@ -81,6 +80,12 @@
<%= link_to '<i class="fa fa-trash" aria-hidden="true"></i>'.html_safe, sample, method: :delete,
data: { confirm: "You sure?"}%>
<%end%>
</td>
<td>
<%# todo %>
<%= sample.files.attached? %>
</td>
</tr>
<%end%>
</tbody>
......@@ -93,54 +98,4 @@
<%else%>
<div class="panel panel-default" id="show" style="display:none;"></div>
<%end%>
</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
</div>
\ No newline at end of file
<script>
$(document).ready(function(){
console.log($('#tb tr.y_n'));
// let selectAllCheckbox = document.querySelector('#sample_delete_files');
// console.log('all checkboxes? ', selectAllCheckbox.checked);
$('#tb tr.y_n').each(function(i){
let good = true;
$(this).find('td.y_n').each(function(j){
......@@ -12,6 +15,27 @@
$('tbody#resultTable').on('cocoon:before-insert', function() {
console.log('yepyep');
});
// let selectAllCheckbox = document.querySelector('#sample_delete_files');
// let filenameCheckboxes = document.querySelectorAll('[name="sample[delete_file][]"]');
// console.log(selectAllCheckbox);
// console.log(filenameCheckboxes);
// function handleSelectAll(e) {
// if (selectAllCheckbox.checked === true) {
// filenameCheckboxes.forEach(checkbox => {
// checkbox.checked = true;
// })
// } else {
// filenameCheckboxes.forEach(checkbox => {
// checkbox.checked = false;
// })
// }
// }
//
// if(selectAllCheckbox){
// selectAllCheckbox.addEventListener('click', handleSelectAll, false);
// }
})
</script>
......@@ -149,19 +173,19 @@
<div style="float: left; width: auto;" >
<%unless @sample.files.attached? %>
<%= form_with model: @sample do |f| %>
<%= 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", style: "text-align: left; width: 70%" %>
<%= f.submit "Save Files", class: "btn btn-info", style: "text-align: left; width: 70%" %>
<%= 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%" %>
</div>
<% end %>
<% end %>
<%if @sample.files.attached? %>
<div style="float: left; width: auto;" ><%= render 'samples/form_delete_files'%></div>
<div style="float: left; width: auto;" ><%= render 'samples/form_add_files'%></div>
<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>
......
......@@ -9,3 +9,4 @@ Rails.application.config.assets.version = '1.0'
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
# Rails.application.config.assets.precompile += %w( search.js )
# Rails.application.config.assets.precompile = [search.js]
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