Working on better table support
This commit is contained in:
parent
a6b43ed329
commit
397cb560a5
@ -1,14 +1,15 @@
|
|||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html data-theme="light">
|
<html data-theme="light" class="has-navbar-fixed-top">
|
||||||
|
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<title>{{ title }}</title>
|
<title>{{ tmp }} - {{ title }}</title>
|
||||||
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"> <!-- CSS Reset -->
|
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"> <!-- CSS Reset -->
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.4/css/bulma.min.css">
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.4/css/bulma.min.css">
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js" integrity="sha512-v2CJ7UaYy4JwqLDIrZUI/4hqeoQieOmAZNXBeQyjo21dadnwR+8ZaIJVT8EE2iyI61OV8e6M8PP2/4hpQINQ/g==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js" integrity="sha512-v2CJ7UaYy4JwqLDIrZUI/4hqeoQieOmAZNXBeQyjo21dadnwR+8ZaIJVT8EE2iyI61OV8e6M8PP2/4hpQINQ/g==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
||||||
th {
|
th {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
margin: 0px;
|
margin: 0px;
|
||||||
@ -16,7 +17,8 @@ th {
|
|||||||
}
|
}
|
||||||
|
|
||||||
table {
|
table {
|
||||||
|
width: 100%; /* Ensure the table takes full width of its container */
|
||||||
|
border-collapse: collapse; /* Collapse the borders of the table */
|
||||||
}
|
}
|
||||||
|
|
||||||
#data {
|
#data {
|
||||||
@ -24,23 +26,23 @@ table {
|
|||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.name-class {
|
||||||
|
max-width: 300px;
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
/*
|
||||||
#data th:nth-child(3),
|
#data th:nth-child(3),
|
||||||
#data td:nth-child(3) {
|
#data td:nth-child(3) {
|
||||||
max-width: 300px; /* Adjust as needed */
|
max-width: 100px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
}
|
} */
|
||||||
|
|
||||||
#data th:nth-child(4),
|
|
||||||
#data td:nth-child(4) {
|
|
||||||
max-width: 100px; /* Adjust as needed */
|
|
||||||
overflow: hidden;
|
|
||||||
white-space: nowrap;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
}
|
|
||||||
|
|
||||||
.center-table {
|
.center-table {
|
||||||
|
overflow-x: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
td {
|
td {
|
||||||
@ -76,10 +78,16 @@ td {
|
|||||||
}
|
}
|
||||||
@media only screen and (max-width: 600px) {
|
@media only screen and (max-width: 600px) {
|
||||||
table {
|
table {
|
||||||
width: 100%; /* Expand table to full width on mobile */
|
width: auto; /* Expand table to full width on mobile */
|
||||||
table-layout: fixed;
|
table-layout: fixed;
|
||||||
}
|
}
|
||||||
|
/* #data th:nth-child(2),
|
||||||
|
#data td:nth-child(2) {
|
||||||
|
width: auto; /* Allow "Name" column to adjust width based on content
|
||||||
|
} */
|
||||||
|
.center-table {
|
||||||
|
overflow-x: auto; /* Enable horizontal scrolling */
|
||||||
|
}
|
||||||
|
|
||||||
.fixed-width {
|
.fixed-width {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@ -103,6 +111,48 @@ td {
|
|||||||
text-align: center; /* Center the content horizontally within the cell */
|
text-align: center; /* Center the content horizontally within the cell */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.highlighted {
|
||||||
|
background-color: yellow; /* Adjust as needed */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Chrome, Safari, Edge, Opera */
|
||||||
|
input::-webkit-outer-spin-button,
|
||||||
|
input::-webkit-inner-spin-button {
|
||||||
|
-webkit-appearance: none;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Firefox */
|
||||||
|
input[type=number] {
|
||||||
|
-moz-appearance: textfield;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header {
|
||||||
|
width:100%;
|
||||||
|
text-align:center;
|
||||||
|
z-index: 99;
|
||||||
|
background-color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Table */
|
||||||
|
td img{
|
||||||
|
display: block;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: 5px;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
.inputContainer {
|
.inputContainer {
|
||||||
display: inline-block; /* Display as an inline block */
|
display: inline-block; /* Display as an inline block */
|
||||||
vertical-align: middle; /* Center vertically within the cell */
|
vertical-align: middle; /* Center vertically within the cell */
|
||||||
@ -136,20 +186,9 @@ td {
|
|||||||
border: 1px solid #d1d1d1;
|
border: 1px solid #d1d1d1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.highlighted {
|
|
||||||
background-color: yellow; /* Adjust as needed */
|
|
||||||
}
|
|
||||||
|
|
||||||
td img{
|
|
||||||
display: block;
|
|
||||||
margin-left: auto;
|
|
||||||
margin-right: 5px;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Modal Styles */
|
/* Modal Styles */
|
||||||
#lightbox-modal {
|
#lightbox-modal {
|
||||||
display: none;
|
display: none;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
z-index: 1000;
|
z-index: 1000;
|
||||||
@ -204,79 +243,42 @@ td img{
|
|||||||
max-width: 90%;
|
max-width: 90%;
|
||||||
max-height: 90%;
|
max-height: 90%;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Chrome, Safari, Edge, Opera */
|
|
||||||
input::-webkit-outer-spin-button,
|
|
||||||
input::-webkit-inner-spin-button {
|
|
||||||
-webkit-appearance: none;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Firefox */
|
|
||||||
input[type=number] {
|
|
||||||
-moz-appearance: textfield;
|
|
||||||
}
|
|
||||||
|
|
||||||
.header {
|
|
||||||
width:100%;
|
|
||||||
text-align:center;
|
|
||||||
z-index: 99;
|
|
||||||
background-color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
.content {
|
|
||||||
padding: 16px;
|
|
||||||
}
|
|
||||||
/* The sticky class is added to the header with JS when it reaches its scroll position */
|
|
||||||
.sticky {
|
|
||||||
position: fixed;
|
|
||||||
top: 0;
|
|
||||||
width: 100%
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Add some top padding to the page content to prevent sudden quick movement (as the header gets a new position at the top of the page (position:fixed and top:0) */
|
|
||||||
.sticky + .content {
|
|
||||||
padding-top: 102px;
|
|
||||||
}
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<nav class="navbar is-dark is-fixed-top" role="navigation" aria-label="main navigation">
|
||||||
|
<div class="navbar-brand">
|
||||||
<div class="header" id='myHeader'>
|
<a class="navbar-item" href="/">
|
||||||
<span><h2>{{ tmp }} - {{ title }} </h2></span>
|
Home
|
||||||
|
</a>
|
||||||
<span><button class="button is-link" style="width: 98%;margin: 1%;" onclick="goToPage('/')">Home</button></span>
|
|
||||||
</div>
|
<a class="navbar-item" href="/create">
|
||||||
|
Add Set
|
||||||
|
</a>
|
||||||
|
<a class="navbar-item hidden-desktop" id="expand-button">
|
||||||
|
Expand Columns
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="navMenu" class="navbar-menu">
|
||||||
|
<div class="navbar-start">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="navbar-end">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<center>
|
<center>
|
||||||
|
<h1 class="title">{{ tmp }} - {{ title }}</h1>
|
||||||
<img class="lightbox-trigger" id="cover" style='height: 100px; width: auto; object-fit: contain' src="/static/sets/{{ tmp }}.jpg" alt="Image">
|
<img class="lightbox-trigger" id="cover" style='height: 150px; width: auto; object-fit: contain' src="/static/sets/{{ tmp }}.jpg" alt="{{ tmp }} - {{ title }}">
|
||||||
{% block content %}{% endblock %}
|
{% block content %}{% endblock %}
|
||||||
</div>
|
</div>
|
||||||
{% block scripts %}{% endblock %}
|
{% block scripts %}{% endblock %}
|
||||||
</body>
|
</body>
|
||||||
<script>
|
|
||||||
// When the user scrolls the page, execute myFunction
|
|
||||||
window.onscroll = function() {myFunction()};
|
|
||||||
|
|
||||||
// Get the header
|
|
||||||
var header = document.getElementById("myHeader");
|
|
||||||
|
|
||||||
// Get the offset position of the navbar
|
|
||||||
var sticky = header.offsetTop;
|
|
||||||
|
|
||||||
// Add the sticky class to the header when you reach its scroll position. Remove "sticky" when you leave the scroll position
|
|
||||||
function myFunction() {
|
|
||||||
if (window.pageYOffset > sticky) {
|
|
||||||
header.classList.add("sticky");
|
|
||||||
} else {
|
|
||||||
header.classList.remove("sticky");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,30 +1,25 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<center><button class="hidden-desktop button is-primary" id="expand-button">Expand Columns</button></center>
|
|
||||||
|
|
||||||
|
<div class="center-table" >
|
||||||
{{ inventory_list[0][5] }}
|
|
||||||
|
|
||||||
|
|
||||||
<div class="center-table">
|
|
||||||
<table id="data" class="table">
|
<table id="data" class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="fixed-width" style="width:50px;"></th>
|
<th class="fixed-width"></th>
|
||||||
<th style="text-align:left;margin:0px;" class="fixed-width hidden-mobile">Name</th>
|
<th style="text-align:left;margin:0px;" class="fixed-width hidden-mobile name-class">Name</th>
|
||||||
<th class="hidden-mobile">Color</th>
|
<th class="fixed-width hidden-mobile">Color</th>
|
||||||
<th style="text-align: center;">Qty</th>
|
<th class="fixed-width" style="text-align: center;">Qty</th>
|
||||||
<th style="text-align: center;">Missing</th>
|
<th class="fixed-width" style="text-align: center;">Missing</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for brick in inventory_list %}
|
{% for brick in inventory_list %}
|
||||||
<tr>
|
<tr>
|
||||||
<td class="fixed-width" style="width:50px;"><img src="{{ '/static/parts/' + brick[5] + '.jpg' }}" class="lightbox-trigger" class="fixed-width" style="height: 50px; width: 50px;"></td>
|
<td><img src="{{ '/static/parts/' + brick[5] + '.jpg' }}" class="lightbox-trigger" alt="{{ brick[3] }}" style="height: 50px; width: 50px;margin:0;padding: 0;"></td>
|
||||||
<td style="text-align:left;margin:0px;" class="hidden-mobile">{{ brick[3] }}</td>
|
<td style="text-align:left;margin:0px;" class="hidden-mobile name-class">{{ brick[3] }}</td>
|
||||||
<td class="hidden-mobile">{{ brick[7] }}</td>
|
<td class="hidden-mobile">{{ brick[7] }}</td>
|
||||||
<td>{{ brick[8] }}</td>
|
<td style="text-align: center;">{{ brick[8] }}</td>
|
||||||
<td class="centered-cell">
|
<td class="centered-cell">
|
||||||
<div class="inputContainer">
|
<div class="inputContainer">
|
||||||
{% set ns = namespace(count='') %}
|
{% set ns = namespace(count='') %}
|
||||||
@ -78,30 +73,6 @@
|
|||||||
// } );
|
// } );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// document.addEventListener('DOMContentLoaded', function () {
|
|
||||||
// const myDataTable = document.getElementById('data');
|
|
||||||
|
|
||||||
// myDataTable.addEventListener('click', function (event) {
|
|
||||||
// const clickedRow = event.target.closest('td');
|
|
||||||
// if (clickedRow) {
|
|
||||||
// // Remove highlighting from all rows
|
|
||||||
// const rows = myDataTable.querySelectorAll('tr');
|
|
||||||
// rows.forEach(row => row.classList.remove('highlighted'));
|
|
||||||
|
|
||||||
// // Add highlighting to the clicked row
|
|
||||||
// if (clickedRow.classList.contains('highlighted')) {
|
|
||||||
|
|
||||||
// clickedRow.classList.remove('highlighted');
|
|
||||||
// } else {
|
|
||||||
// clickedRow.classList.add('highlighted');
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
|
|
||||||
function goToPage(url) {
|
function goToPage(url) {
|
||||||
window.location.href = url;
|
window.location.href = url;
|
||||||
}
|
}
|
||||||
@ -135,12 +106,11 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
element.addEventListener('click', function () {
|
element.addEventListener('click', function () {
|
||||||
const imgSrc = element.getAttribute('src');
|
const imgSrc = element.getAttribute('src');
|
||||||
textContent = '';
|
textContent = '';
|
||||||
try {
|
console.log(element.getAttribute('alt'));
|
||||||
textContent = element.closest('tr').querySelector('td:nth-child(2)').textContent; // Adjust the index accordingly
|
textContent = element.getAttribute('alt');
|
||||||
|
// textContent = element.closest('tr').querySelector('td:nth-child(2)').textContent; // Adjust the index accordingly
|
||||||
lightboxText.textContent = textContent;
|
lightboxText.textContent = textContent;
|
||||||
} catch (e) {
|
|
||||||
textContent = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
lightboxImage.setAttribute('src', imgSrc);
|
lightboxImage.setAttribute('src', imgSrc);
|
||||||
lightboxModal.style.display = 'block';
|
lightboxModal.style.display = 'block';
|
||||||
|
Loading…
Reference in New Issue
Block a user