Skip to content

🛡️ Warracker is an open source, self-hostable warranty tracker to monitor expirations, store receipts, files. You own the data, your rules!

Better Edit

sassanix09c10c0d5a24
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 03ac7da..1595f9f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,17 @@
# Changelog
+## [0.9.8.2] - 2025-03-22
+
+- **Edit Warranty Modal Improvements**
+ - Added tabbed interface for the edit warranty modal with three sections:
+ - Product Info: Product name, URL, and serial numbers
+ - Warranty Details: Purchase date, warranty period, and price
+ - Documents: Invoice and manual uploads
+- Visual indicators for active tabs
+- Improved dark mode support for the edit modal
+- Better form organization and user experience
+
+
## [0.9.8.1] - 2025-03-21
diff --git a/frontend/index.html b/frontend/index.html
index 8b0abbe..e3c2bff 100644
--- a/frontend/index.html
+++ b/frontend/index.html
@@ -511,65 +511,88 @@
<button class="close-btn" data-dismiss="modal">&times;</button>
</div>
<div class="modal-body">
+ <!-- Tab Navigation -->
+ <div class="edit-tabs-nav">
+ <button type="button" class="edit-tab-btn active" data-tab="edit-product-info">
+ <i class="fas fa-box"></i> Product
+ </button>
+ <button type="button" class="edit-tab-btn" data-tab="edit-warranty-details">
+ <i class="fas fa-shield-alt"></i> Warranty
+ </button>
+ <button type="button" class="edit-tab-btn" data-tab="edit-documents">
+ <i class="fas fa-file-alt"></i> Documents
+ </button>
+ </div>
+
<form id="editWarrantyForm">
<input type="hidden" id="editWarrantyId">
- <div class="form-group">
- <label for="editProductName">Product Name</label>
- <input type="text" id="editProductName" name="product_name" class="form-control" required>
- </div>
-
- <div class="form-group">
- <label for="editProductUrl">Product URL (Optional)</label>
- <input type="url" id="editProductUrl" name="product_url" class="form-control" placeholder="https://example.com/product">
- </div>
-
- <div class="form-group">
- <label for="editPurchaseDate">Purchase Date</label>
- <input type="date" id="editPurchaseDate" name="purchase_date" class="form-control" required>
- </div>
- <div class="form-group">
- <label for="editWarrantyYears">Warranty Period (Years)</label>
- <input type="number" id="editWarrantyYears" name="warranty_years" class="form-control" min="1" max="100" required>
- </div>
-
- <div class="form-group">
- <label for="editPurchasePrice">Purchase Price (Optional)</label>
- <div class="price-input-wrapper">
- <span class="currency-symbol">$</span>
- <input type="number" id="editPurchasePrice" name="purchase_price" class="form-control" min="0" step="0.01" placeholder="0.00">
+ <!-- Product Info Tab -->
+ <div class="edit-tab-content active" id="edit-product-info">
+ <div class="form-group">
+ <label for="editProductName">Product Name</label>
+ <input type="text" id="editProductName" name="product_name" class="form-control" required>
</div>
- </div>
-
- <div class="form-group">
- <label>Serial Numbers</label>
- <div id="editSerialNumbersContainer">
- <!-- Serial number inputs will be added dynamically -->
+
+ <div class="form-group">
+ <label for="editProductUrl">Product URL (Optional)</label>
+ <input type="url" id="editProductUrl" name="product_url" class="form-control" placeholder="https://example.com/product">
+ </div>
+
+ <div class="form-group">
+ <label>Serial Numbers</label>
+ <div id="editSerialNumbersContainer">
+ <!-- Serial number inputs will be added dynamically -->
+ </div>
</div>
</div>
- <div class="form-group">
- <label>Invoice/Receipt</label>
- <div class="file-input-wrapper">
- <label for="editInvoice" class="file-input-label">
- <i class="fas fa-upload"></i> Choose File
- </label>
- <input type="file" id="editInvoice" name="invoice" class="file-input" accept=".pdf,.png,.jpg,.jpeg">
+ <!-- Warranty Details Tab -->
+ <div class="edit-tab-content" id="edit-warranty-details">
+ <div class="form-group">
+ <label for="editPurchaseDate">Purchase Date</label>
+ <input type="date" id="editPurchaseDate" name="purchase_date" class="form-control" required>
+ </div>
+
+ <div class="form-group">
+ <label for="editWarrantyYears">Warranty Period (Years)</label>
+ <input type="number" id="editWarrantyYears" name="warranty_years" class="form-control" min="1" max="100" required>
+ </div>
+
+ <div class="form-group">
+ <label for="editPurchasePrice">Purchase Price (Optional)</label>
+ <div class="price-input-wrapper">
+ <span class="currency-symbol">$</span>
+ <input type="number" id="editPurchasePrice" name="purchase_price" class="form-control" min="0" step="0.01" placeholder="0.00">
+ </div>
</div>
- <div id="editFileName" class="file-name"></div>
- <div id="currentInvoice" class="mt-10"></div>
</div>
- <div class="form-group">
- <label>Product Manual (Optional)</label>
- <div class="file-input-wrapper">
- <label for="editManual" class="file-input-label">
- <i class="fas fa-upload"></i> Choose File
- </label>
- <input type="file" id="editManual" name="manual" class="file-input" accept=".pdf,.png,.jpg,.jpeg">
+ <!-- Documents Tab -->
+ <div class="edit-tab-content" id="edit-documents">
+ <div class="form-group">
+ <label>Invoice/Receipt</label>
+ <div class="file-input-wrapper">
+ <label for="editInvoice" class="file-input-label">
+ <i class="fas fa-upload"></i> Choose File
+ </label>
+ <input type="file" id="editInvoice" name="invoice" class="file-input" accept=".pdf,.png,.jpg,.jpeg">
+ </div>
+ <div id="editFileName" class="file-name"></div>
+ <div id="currentInvoice" class="mt-10"></div>
+ </div>
+
+ <div class="form-group">
+ <label>Product Manual (Optional)</label>
+ <div class="file-input-wrapper">
+ <label for="editManual" class="file-input-label">
+ <i class="fas fa-upload"></i> Choose File
+ </label>
+ <input type="file" id="editManual" name="manual" class="file-input" accept=".pdf,.png,.jpg,.jpeg">
+ </div>
+ <div id="editManualFileName" class="file-name"></div>
+ <div id="currentManual" class="mt-10"></div>
</div>
- <div id="editManualFileName" class="file-name"></div>
- <div id="currentManual" class="mt-10"></div>
</div>
</form>
</div>
diff --git a/frontend/script.js b/frontend/script.js
index ca0605d..76f3cd9 100644
--- a/frontend/script.js
+++ b/frontend/script.js
@@ -1102,11 +1102,40 @@ function openEditModal(warranty) {
}
}
- // Reset file input display
+ // Reset file inputs
+ document.getElementById('editInvoice').value = '';
+ document.getElementById('editManual').value = '';
document.getElementById('editFileName').textContent = '';
-
- // Show modal
- editModal.classList.add('active');
+ document.getElementById('editManualFileName').textContent = '';
+
+ // Show edit modal
+ const modal = document.getElementById('editModal');
+ modal.classList.add('active'); // Add active class instead of setting display style
+
+ // Reset tabs to first tab
+ const editTabBtns = document.querySelectorAll('.edit-tab-btn');
+ editTabBtns.forEach(btn => btn.classList.remove('active'));
+ document.querySelector('.edit-tab-btn[data-tab="edit-product-info"]').classList.add('active');
+
+ // Reset tab content
+ document.querySelectorAll('.edit-tab-content').forEach(content => content.classList.remove('active'));
+ document.getElementById('edit-product-info').classList.add('active');
+
+ // Validate all tabs to update completion indicators
+ validateEditTab('edit-product-info');
+ validateEditTab('edit-warranty-details');
+ validateEditTab('edit-documents');
+
+ // Add input event listeners to update validation status
+ document.querySelectorAll('#editWarrantyForm input').forEach(input => {
+ input.addEventListener('input', function() {
+ // Find the tab this input belongs to
+ const tabContent = this.closest('.edit-tab-content');
+ if (tabContent) {
+ validateEditTab(tabContent.id);
+ }
+ });
+ });
}
function openDeleteModal(warrantyId) {
@@ -1499,16 +1528,16 @@ document.addEventListener('DOMContentLoaded', () => {
if (fileInput) fileInput.addEventListener('change', (e) => updateFileName(e, 'invoice', 'fileName'));
if (manualInput) manualInput.addEventListener('change', (e) => updateFileName(e, 'manual', 'manualFileName'));
- const editInvoice = document.getElementById('editInvoice');
- if (editInvoice) {
- editInvoice.addEventListener('change', () => {
+ const editInvoiceInput = document.getElementById('editInvoice');
+ if (editInvoiceInput) {
+ editInvoiceInput.addEventListener('change', () => {
updateFileName(null, 'editInvoice', 'editFileName');
});
}
- const editManual = document.getElementById('editManual');
- if (editManual) {
- editManual.addEventListener('change', () => {
+ const editManualInput = document.getElementById('editManual');
+ if (editManualInput) {
+ editManualInput.addEventListener('change', () => {
updateFileName(null, 'editManual', 'editManualFileName');
});
}
@@ -1566,5 +1595,61 @@ document.addEventListener('DOMContentLoaded', () => {
loadWarranties();
}
+ // Initialize edit tabs
+ initEditTabs();
+
console.log('App initialization complete');
-});
\ No newline at end of file
+});
+
+// Add this function to handle edit tab functionality
+function initEditTabs() {
+ const editTabBtns = document.querySelectorAll('.edit-tab-btn');
+
+ editTabBtns.forEach(btn => {
+ btn.addEventListener('click', () => {
+ // Remove active class from all tabs
+ editTabBtns.forEach(b => b.classList.remove('active'));
+
+ // Add active class to clicked tab
+ btn.classList.add('active');
+
+ // Hide all tab content
+ document.querySelectorAll('.edit-tab-content').forEach(content => {
+ content.classList.remove('active');
+ });
+
+ // Show the selected tab content
+ const tabId = btn.getAttribute('data-tab');
+ document.getElementById(tabId).classList.add('active');
+ });
+ });
+}
+
+// Update validateEditTabs function
+function validateEditTab(tabId) {
+ const tab = document.getElementById(tabId);
+ let isValid = true;
+
+ // Get all required inputs in this tab
+ const requiredInputs = tab.querySelectorAll('input[required]');
+
+ // Check if all required fields are filled
+ requiredInputs.forEach(input => {
+ if (!input.value) {
+ isValid = false;
+ input.classList.add('invalid');
+ } else {
+ input.classList.remove('invalid');
+ }
+ });
+
+ // Update the tab button to show completion status
+ const tabBtn = document.querySelector(`.edit-tab-btn[data-tab="${tabId}"]`);
+ if (isValid) {
+ tabBtn.classList.add('completed');
+ } else {
+ tabBtn.classList.remove('completed');
+ }
+
+ return isValid;
+}
\ No newline at end of file
diff --git a/frontend/style.css b/frontend/style.css
index 5a6e55c..5d7c1fb 100644
--- a/frontend/style.css
+++ b/frontend/style.css
@@ -46,6 +46,9 @@
--medium-gray: #404040;
--dark-gray: #909090;
--white: #2d2d2d;
+ --modal-background: #2d2d2d;
+ --text-muted: #909090;
+ --input-background: #1a1a1a;
}
body {
@@ -613,73 +616,85 @@ input.invalid {
left: 0;
width: 100%;
height: 100%;
- background-color: var(--modal-backdrop);
- display: flex;
+ background-color: rgba(0, 0, 0, 0.5);
+ display: none;
justify-content: center;
align-items: center;
z-index: 1000;
- opacity: 0;
- visibility: hidden;
- transition: var(--transition);
}
.modal-backdrop.active {
- opacity: 1;
- visibility: visible;
+ display: flex;
}
.modal {
- background-color: var(--card-bg);
- border-radius: var(--border-radius);
- box-shadow: var(--shadow);
+ background-color: var(--modal-background, #ffffff);
+ border-radius: 8px;
+ box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
width: 90%;
- max-width: 500px;
- transform: translateY(-20px);
- transition: var(--transition);
+ max-width: 600px;
+ max-height: 90vh;
+ display: flex;
+ flex-direction: column;
+ animation: slide-in 0.3s ease;
+ position: relative;
+ overflow: hidden;
}
-.modal-backdrop.active .modal {
- transform: translateY(0);
+@keyframes slide-in {
+ from {
+ opacity: 0;
+ transform: translateY(-20px);
+ }
+ to {
+ opacity: 1;
+ transform: translateY(0);
+ }
}
.modal-header {
- padding: 20px;
- border-bottom: 1px solid var(--medium-gray);
+ padding: 1rem;
+ border-bottom: 1px solid var(--border-color);
display: flex;
justify-content: space-between;
align-items: center;
+ background-color: var(--modal-background, #ffffff);
}
.modal-title {
- font-size: 1.2rem;
- color: var(--text-color);
margin: 0;
+ font-size: 1.25rem;
+ color: var(--text-color);
}
.close-btn {
background: none;
border: none;
font-size: 1.5rem;
- line-height: 1;
+ color: var(--text-muted);
cursor: pointer;
- color: var(--dark-gray);
- transition: var(--transition);
+ padding: 0;
+ line-height: 1;
}
.close-btn:hover {
- color: var(--danger-color);
+ color: var(--text-color);
}
.modal-body {
- padding: 20px;
+ padding: 1rem;
+ overflow-y: auto;
+ flex: 1;
+ background-color: var(--modal-background, #ffffff);
}
.modal-footer {
- padding: 15px 20px;
- border-top: 1px solid var(--medium-gray);
+ padding: 1rem;
+ border-top: 1px solid var(--border-color);
display: flex;
justify-content: flex-end;
- gap: 10px;
+ gap: 0.5rem;
+ background-color: var(--modal-background, #ffffff);
}
.modal-footer .btn {
@@ -2473,4 +2488,207 @@ input.invalid {
#recentExpirationsTable .empty-row td {
vertical-align: middle;
text-align: center;
+}
+
+/* Edit Warranty Tabs */
+.edit-tabs-nav {
+ display: flex;
+ border-bottom: 1px solid var(--border-color);
+ margin-bottom: 1.5rem;
+ overflow-x: auto;
+ padding-bottom: 1px;
+}
+
+.edit-tab-btn {
+ background: none;
+ border: none;
+ cursor: pointer;
+ font-weight: 500;
+ padding: 0.75rem 1rem;
+ position: relative;
+ color: var(--text-muted);
+ white-space: nowrap;
+ transition: color 0.2s ease;
+}
+
+.edit-tab-btn:hover {
+ color: var(--text-color);
+}
+
+.edit-tab-btn.active {
+ color: var(--primary-color);
+}
+
+.edit-tab-btn.active::after {
+ content: '';
+ position: absolute;
+ bottom: -1px;
+ left: 0;
+ width: 100%;
+ height: 2px;
+ background-color: var(--primary-color);
+}
+
+.edit-tab-btn i {
+ margin-right: 0.5rem;
+}
+
+.edit-tab-content {
+ display: none;
+}
+
+.edit-tab-content.active {
+ display: block;
+ animation: fadeIn 0.3s ease;
+}
+
+/* Completed Tab Indicator for Edit Form - simplified */
+.edit-tab-btn.completed {
+ color: var(--primary-color);
+}
+
+/* Make the edit modal wider to accommodate the tabs better */
+#editModal .modal {
+ max-width: 700px;
+ background-color: var(--modal-background, #ffffff);
+}
+
+@media (max-width: 768px) {
+ .edit-tabs-nav {
+ justify-content: space-between;
+ }
+
+ .edit-tab-btn {
+ padding: 0.5rem;
+ font-size: 0.85rem;
+ }
+
+ .edit-tab-btn i {
+ margin-right: 0.25rem;
+ }
+}
+
+#editModal .modal-body {
+ background-color: var(--modal-background, #ffffff);
+ padding: 1.5rem;
+ padding-top: 0.5rem;
+ max-height: 70vh;
+ overflow-y: auto;
+}
+
+.edit-tab-content {
+ padding: 1rem 0;
+}
+
+.edit-tabs-nav {
+ position: sticky;
+ top: 0;
+ background-color: var(--modal-background, #ffffff);
+ z-index: 5;
+ padding-top: 1rem;
+ border-bottom: 1px solid var(--border-color);
+}
+
+/* Style for validation errors in the edit form */
+#editWarrantyForm input.invalid {
+ border-color: var(--danger-color);
+ background-color: rgba(255, 0, 0, 0.03);
+}
+
+#editWarrantyForm input.invalid:focus {
+ box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
+}
+
+/* Add animation for tab switching */
+@keyframes editTabFade {
+ from { opacity: 0; transform: translateY(5px); }
+ to { opacity: 1; transform: translateY(0); }
+}
+
+.edit-tab-content.active {
+ animation: editTabFade 0.3s ease;
+}
+
+/* Edit modal dark mode styles */
+:root[data-theme="dark"] #editModal .modal {
+ background-color: var(--modal-background);
+}
+
+:root[data-theme="dark"] #editModal .modal-header,
+:root[data-theme="dark"] #editModal .modal-body,
+:root[data-theme="dark"] #editModal .modal-footer,
+:root[data-theme="dark"] .edit-tabs-nav {
+ background-color: var(--modal-background);
+ color: var(--text-color);
+}
+
+:root[data-theme="dark"] #editModal .form-control {
+ background-color: var(--input-background);
+ color: var(--text-color);
+ border-color: var(--border-color);
+}
+
+:root[data-theme="dark"] #editModal .form-control:focus {
+ border-color: var(--primary-color);
+ box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.25);
+}
+
+:root[data-theme="dark"] #editModal label {
+ color: var(--text-color);
+}
+
+:root[data-theme="dark"] .edit-tab-btn {
+ color: var(--text-muted);
+}
+
+:root[data-theme="dark"] .edit-tab-btn:hover {
+ color: var(--text-color);
+}
+
+:root[data-theme="dark"] .edit-tab-btn.active {
+ color: var(--primary-color);
+}
+
+:root[data-theme="dark"] .currency-symbol {
+ color: var(--text-color);
+}
+
+:root[data-theme="dark"] .file-input-label {
+ background-color: var(--input-background);
+ color: var(--text-color);
+ border: 1px solid var(--border-color);
+}
+
+:root[data-theme="dark"] .file-input-label:hover {
+ background-color: var(--primary-color);
+ color: white;
+ border-color: var(--primary-color);
+}
+
+:root[data-theme="dark"] .file-name {
+ color: var(--text-muted);
+}
+
+:root[data-theme="dark"] #currentInvoice,
+:root[data-theme="dark"] #currentManual {
+ color: var(--text-color);
+}
+
+:root[data-theme="dark"] #currentInvoice a,
+:root[data-theme="dark"] #currentManual a {
+ color: var(--primary-color);
+}
+
+:root[data-theme="dark"] .serial-number-input {
+ margin-bottom: 10px;
+}
+
+:root[data-theme="dark"] .serial-number-input .form-control {
+ background-color: var(--input-background);
+ color: var(--text-color);
+ border-color: var(--border-color);
+}
+
+:root[data-theme="dark"] .modal-backdrop {
+ background-color: rgba(0, 0, 0, 0.7);
}
\ No newline at end of file