Skip to content

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

Enhances Global View with better document access, claim visibility, and critical bug fixes.

sassanix441358bea39b
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e921565..7e718d9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,53 @@
# Changelog
+## 0.10.1.11 - 2025-09-07
+
+### Enhanced
+- **Global View Paperless-ngx Default Behavior:** Enhanced Paperless-ngx document viewing behavior in Global View to automatically open other users' documents within the Warracker app interface instead of external tabs, providing a more seamless and consistent user experience.
+ - **Smart Context Detection:** System automatically detects when viewing another user's Paperless-ngx documents in Global View and overrides individual user preferences to default to in-app viewing.
+ - **Improved User Experience:** Users can now view invoices, manuals, and other Paperless-ngx documents from other users directly within Warracker without being redirected to external Paperless-ngx interface, maintaining workflow continuity.
+ - **Preserved Personal Preferences:** User's personal Paperless-ngx viewing preferences remain unchanged for their own documents, only affecting the viewing behavior for other users' documents in Global View.
+ - **Consistent Interface:** Provides uniform document viewing experience across all Global View documents while respecting user privacy and access controls.
+ - _Files: `frontend/script.js`_
+
+- **Warranty Claims Visual Status Indicators:** Added intuitive visual indicators to warranty cards that display claim status at-a-glance through color-coded Claims buttons, eliminating the need to open modals to check claim activity.
+ - **Purple Claims Button:** Warranties with open claims (Submitted or In Progress status) display a purple Claims button with subtle pulsing animation to draw attention to items requiring action.
+ - **Blue Claims Button:** Warranties with finished claims (Resolved, Denied, Approved, or Cancelled status) display a blue Claims button indicating completed claim activity.
+ - **Default Claims Button:** Warranties with no claims retain standard gray styling, providing clear visual distinction between different claim states.
+ - **Enhanced User Experience:** Users can instantly identify warranty claim status from the main view without opening individual claim modals, improving workflow efficiency and claim management visibility.
+ - **Smart Tooltips:** Claims buttons display contextual tooltips ("Claims", "Claims (Open)", "Claims (Finished)") providing additional status information on hover.
+ - **Database Integration:** Backend APIs enhanced to calculate and return claim status summary (NO_CLAIMS, OPEN, FINISHED) across all warranty listing endpoints including main view, admin view, and global view.
+ - _Files: `backend/warranties_routes.py`, `frontend/script.js`, `frontend/style.css`_
+
+- **Global View Warranty Claims Read-Only Access:** Users can now view warranty claims from other users' warranties in Global View mode with appropriate read-only permissions, enhancing transparency and claim visibility across the organization.
+ - **Read-Only Claims Viewing:** Users in Global View can access and view detailed warranty claims information for warranties owned by other users, providing comprehensive claim visibility while maintaining data security.
+ - **Permission-Based Access Control:** Claims viewing respects existing Global View permissions - users can only view claims if Global View is enabled and they have appropriate access rights (admin-only restrictions apply when configured).
+ - **Intuitive UI Indicators:** Claims modals clearly indicate read-only mode with "View Only" labels, hidden edit/delete buttons, and contextual messaging to prevent confusion about access levels.
+ - **Seamless Integration:** Claims buttons remain fully functional in Global View, eliminating the "Failed to load claims" error and providing consistent user experience across all warranty views.
+ - **Preserved Security:** Create, edit, and delete operations remain restricted to warranty owners only, ensuring data integrity while expanding read access appropriately.
+ - _Files: `backend/warranties_routes.py`, `frontend/script.js`_
+
+### Fixed
+- **Global View Document Access Authorization:** Fixed authorization issue preventing users from viewing invoices and manuals of other users' warranties when Global View is enabled. Users can now access shared warranty documents (invoices, manuals, photos, URL links, and Paperless-ngx documents) in Global View while maintaining privacy for sensitive "other documents".
+ - **Root Cause:** The secure file access endpoint restricted invoice and manual access to warranty owners only, even when Global View was active and should allow broader document sharing. Additionally, the Global View API endpoints were missing Paperless-ngx document IDs and URL fields in their database queries, preventing these documents from being displayed in the frontend.
+ - **Solution:** Extended global view permissions logic to include invoice_path, manual_path, paperless_invoice_id, and paperless_manual_id alongside existing product_photo_path support, while explicitly maintaining privacy restrictions for other_document_path and paperless_other_id. Fixed Global View API endpoints to include all document fields (paperless_invoice_id, paperless_manual_id, paperless_photo_id, paperless_other_id, invoice_url, manual_url, other_document_url) in database queries. Enhanced frontend document link generation to properly show all shared document types in Global View with appropriate permission checks.
+ - **Security:** Maintains strict privacy controls ensuring "other documents" remain accessible only to warranty owners, and users still cannot edit or delete warranties they don't own. All document access remains read-only in Global View.
+ - **Impact:** Users can now view and access invoices, manuals, photos, URL links, and Paperless-ngx documents of other users' warranties when Global View is enabled, providing complete transparency and document sharing capabilities while preserving essential privacy boundaries.
+ - _Files: `backend/file_routes.py`, `backend/warranties_routes.py`, `frontend/script.js`_
+
+- **Warranty Claims Creation with Empty Optional Fields:** Fixed critical bug where creating warranty claims with empty 'description' or 'resolution' fields resulted in internal server errors. These fields are now properly handled as optional, allowing users to create claims with only required information (claim date) and add details later as needed.
+ - **Root Cause:** The application was not correctly converting empty strings to NULL values for optional database fields, causing database insertion errors.
+ - **Solution:** Implemented explicit empty string to NULL conversion logic for description and resolution fields during claim creation, ensuring database compatibility and preventing server errors.
+ - **Impact:** Users can now successfully create warranty claims with minimal required information and update them with additional details when available, improving workflow flexibility.
+ - _Files: `backend/warranties_routes.py`_
+
+- **Global View Claims Modal JavaScript Errors:** Fixed critical JavaScript errors preventing warranty claims modals from opening in Global View mode due to undefined function references, ensuring seamless claims viewing functionality across all view modes.
+ - **Root Cause:** The claims modal initialization code was calling non-existent functions `getCurrentUserId()` and `getViewScope()` instead of using the established patterns for accessing user information and view state in the codebase.
+ - **Solution:** Replaced undefined function calls with the correct inline patterns used throughout the application - using an immediately invoked function expression (IIFE) to extract user ID from localStorage and directly accessing the global `isGlobalView` variable for view state detection.
+ - **Impact:** Users can now successfully open and view warranty claims in Global View mode without JavaScript errors, completing the read-only claims access functionality and providing full transparency for warranty claim information across the organization.
+ - _Files: `frontend/script.js`_
+
+
## 0.10.1.10 - 2025-08-30
### Enhanced
diff --git a/backend/file_routes.py b/backend/file_routes.py
index f8bb148..dab2874 100644
--- a/backend/file_routes.py
+++ b/backend/file_routes.py
@@ -98,14 +98,15 @@ def secure_file_access(filename):
logger.info(f"[SECURE_FILE] Ownership confirmed for warranty_id={warranty_id_db}")
break
- # Check global view permissions for product photos
+ # Check global view permissions for shared documents (photos, invoices, manuals)
if not authorized and results:
for warranty_id_db, warranty_user_id_db in results:
- # Check if this file is a product photo
- cur.execute('SELECT product_photo_path FROM warranties WHERE id = %s', (warranty_id_db,))
- warranty_data = cur.fetchone()
- if warranty_data and warranty_data[0] == db_search_path:
- # This is a product photo - check global view settings
+ # Check if the requested file is a product photo, invoice, or manual for the given warranty
+ cur.execute('SELECT product_photo_path, invoice_path, manual_path FROM warranties WHERE id = %s', (warranty_id_db,))
+ warranty_files = cur.fetchone()
+ # Check if the file path is one of the globally viewable document types
+ if warranty_files and db_search_path in warranty_files:
+ # This is a shared document type - check global view settings
cur.execute("SELECT key, value FROM site_settings WHERE key IN ('global_view_enabled', 'global_view_admin_only')")
settings = {row[0]: row[1] for row in cur.fetchall()}
@@ -114,7 +115,7 @@ def secure_file_access(filename):
if global_view_enabled and (not admin_only or is_admin):
authorized = True
- logger.info(f"[SECURE_FILE] Global view access granted for product photo: {filename}")
+ logger.info(f"[SECURE_FILE] Global view access granted for shared document: {filename}")
break
if not authorized:
@@ -246,16 +247,16 @@ def serve_paperless_document(paperless_id: int):
authorized = True
break
- # Check global view for photos
+ # Check global view for shared documents (photos, invoices, manuals)
if not authorized:
cur.execute("""
SELECT w.id, w.user_id
FROM warranties w
- WHERE w.paperless_photo_id = %s
- """, (paperless_id,))
- photo_results = cur.fetchall()
+ WHERE w.paperless_photo_id = %s OR w.paperless_invoice_id = %s OR w.paperless_manual_id = %s
+ """, (paperless_id, paperless_id, paperless_id))
+ shared_doc_results = cur.fetchall()
- if photo_results:
+ if shared_doc_results:
# Get global view settings
cur.execute("SELECT key, value FROM site_settings WHERE key IN ('global_view_enabled', 'global_view_admin_only')")
settings = {row[0]: row[1] for row in cur.fetchall()}
@@ -265,6 +266,7 @@ def serve_paperless_document(paperless_id: int):
if global_view_enabled and (not admin_only or is_admin):
authorized = True
+ logger.info(f"[PAPERLESS_FILE] Global view access granted for shared Paperless document: {paperless_id}")
if not authorized:
logger.warning(f"[PAPERLESS_FILE] Unauthorized access to Paperless document {paperless_id} by user {user_id}")
diff --git a/backend/warranties_routes.py b/backend/warranties_routes.py
index 5b4f115..0a2129f 100644
--- a/backend/warranties_routes.py
+++ b/backend/warranties_routes.py
@@ -60,14 +60,22 @@ def get_warranties():
# Removed the if is_admin: block
# Replaced warranty_years with warranty_duration_years, warranty_duration_months, warranty_duration_days
cur.execute('''
- SELECT id, product_name, purchase_date, expiration_date, invoice_path, manual_path, other_document_path, product_url, notes,
- purchase_price, user_id, created_at, updated_at, is_lifetime, vendor, warranty_type,
- warranty_duration_years, warranty_duration_months, warranty_duration_days, product_photo_path, currency,
- paperless_invoice_id, paperless_manual_id, paperless_photo_id, paperless_other_id,
- invoice_url, manual_url, other_document_url
- FROM warranties
- WHERE user_id = %s
- ORDER BY CASE WHEN is_lifetime THEN 1 ELSE 0 END, expiration_date NULLS LAST, product_name
+ SELECT
+ w.id, w.product_name, w.purchase_date, w.expiration_date, w.invoice_path, w.manual_path, w.other_document_path, w.product_url, w.notes,
+ w.purchase_price, w.user_id, w.created_at, w.updated_at, w.is_lifetime, w.vendor, w.warranty_type,
+ w.warranty_duration_years, w.warranty_duration_months, w.warranty_duration_days, w.product_photo_path, w.currency,
+ w.paperless_invoice_id, w.paperless_manual_id, w.paperless_photo_id, w.paperless_other_id,
+ w.invoice_url, w.manual_url, w.other_document_url,
+ CASE
+ WHEN COUNT(c.id) = 0 THEN 'NO_CLAIMS'
+ WHEN BOOL_OR(c.status IN ('Submitted', 'In Progress')) THEN 'OPEN'
+ ELSE 'FINISHED'
+ END AS claim_status_summary
+ FROM warranties w
+ LEFT JOIN warranty_claims c ON w.id = c.warranty_id
+ WHERE w.user_id = %s
+ GROUP BY w.id
+ ORDER BY CASE WHEN w.is_lifetime THEN 1 ELSE 0 END, w.expiration_date NULLS LAST, w.product_name
''', (user_id,))
warranties = cur.fetchall()
@@ -1316,12 +1324,22 @@ def get_all_warranties():
with conn.cursor() as cur:
# Get all warranties from all users with user information
cur.execute('''
- SELECT w.id, w.product_name, w.purchase_date, w.expiration_date, w.invoice_path, w.manual_path, w.other_document_path,
- w.product_url, w.notes, w.purchase_price, w.user_id, w.created_at, w.updated_at, w.is_lifetime,
- w.vendor, w.warranty_type, w.warranty_duration_years, w.warranty_duration_months, w.warranty_duration_days, w.product_photo_path, w.currency,
- u.username, u.email, u.first_name, u.last_name
+ SELECT
+ w.id, w.product_name, w.purchase_date, w.expiration_date, w.invoice_path, w.manual_path, w.other_document_path,
+ w.product_url, w.notes, w.purchase_price, w.user_id, w.created_at, w.updated_at, w.is_lifetime,
+ w.vendor, w.warranty_type, w.warranty_duration_years, w.warranty_duration_months, w.warranty_duration_days, w.product_photo_path, w.currency,
+ w.paperless_invoice_id, w.paperless_manual_id, w.paperless_photo_id, w.paperless_other_id,
+ w.invoice_url, w.manual_url, w.other_document_url,
+ u.username, u.email, u.first_name, u.last_name,
+ CASE
+ WHEN COUNT(c.id) = 0 THEN 'NO_CLAIMS'
+ WHEN BOOL_OR(c.status IN ('Submitted', 'In Progress')) THEN 'OPEN'
+ ELSE 'FINISHED'
+ END AS claim_status_summary
FROM warranties w
JOIN users u ON w.user_id = u.id
+ LEFT JOIN warranty_claims c ON w.id = c.warranty_id
+ GROUP BY w.id, u.id
ORDER BY u.username, CASE WHEN w.is_lifetime THEN 1 ELSE 0 END, w.expiration_date NULLS LAST, w.product_name
''')
@@ -1412,12 +1430,22 @@ def get_global_warranties():
with conn.cursor() as cur:
# Get all warranties from all users with user information
cur.execute('''
- SELECT w.id, w.product_name, w.purchase_date, w.expiration_date, w.invoice_path, w.manual_path, w.other_document_path,
- w.product_url, w.notes, w.purchase_price, w.user_id, w.created_at, w.updated_at, w.is_lifetime,
- w.vendor, w.warranty_type, w.warranty_duration_years, w.warranty_duration_months, w.warranty_duration_days, w.product_photo_path, w.currency,
- u.username, u.email, u.first_name, u.last_name
+ SELECT
+ w.id, w.product_name, w.purchase_date, w.expiration_date, w.invoice_path, w.manual_path, w.other_document_path,
+ w.product_url, w.notes, w.purchase_price, w.user_id, w.created_at, w.updated_at, w.is_lifetime,
+ w.vendor, w.warranty_type, w.warranty_duration_years, w.warranty_duration_months, w.warranty_duration_days, w.product_photo_path, w.currency,
+ w.paperless_invoice_id, w.paperless_manual_id, w.paperless_photo_id, w.paperless_other_id,
+ w.invoice_url, w.manual_url, w.other_document_url,
+ u.username, u.email, u.first_name, u.last_name,
+ CASE
+ WHEN COUNT(c.id) = 0 THEN 'NO_CLAIMS'
+ WHEN BOOL_OR(c.status IN ('Submitted', 'In Progress')) THEN 'OPEN'
+ ELSE 'FINISHED'
+ END AS claim_status_summary
FROM warranties w
JOIN users u ON w.user_id = u.id
+ LEFT JOIN warranty_claims c ON w.id = c.warranty_id
+ GROUP BY w.id, u.id
ORDER BY u.username, CASE WHEN w.is_lifetime THEN 1 ELSE 0 END, w.expiration_date NULLS LAST, w.product_name
''')
@@ -1823,40 +1851,48 @@ def create_claim(warranty_id):
# Validate required fields
claim_date = data.get('claim_date')
status = data.get('status', 'Submitted')
- claim_number = data.get('claim_number', '').strip()
- description = data.get('description', '').strip()
- resolution = data.get('resolution', '').strip()
+
+ # Process optional fields, converting empty strings to None for the database
+ claim_number_raw = data.get('claim_number')
+ claim_number = claim_number_raw.strip() if claim_number_raw else None
+
+ description_raw = data.get('description')
+ description = description_raw.strip() if description_raw else None
+
+ resolution_raw = data.get('resolution')
+ resolution = resolution_raw.strip() if resolution_raw else None
+
resolution_date = data.get('resolution_date')
-
+
if not claim_date:
return jsonify({'error': 'Claim date is required'}), 400
-
+
# Parse dates
try:
parsed_claim_date = date_parse(claim_date).date() if isinstance(claim_date, str) else claim_date
except (ValueError, TypeError):
return jsonify({'error': 'Invalid claim date format'}), 400
-
+
parsed_resolution_date = None
if resolution_date:
try:
parsed_resolution_date = date_parse(resolution_date).date() if isinstance(resolution_date, str) else resolution_date
except (ValueError, TypeError):
return jsonify({'error': 'Invalid resolution date format'}), 400
-
+
# Validate status
valid_statuses = ['Submitted', 'In Progress', 'Approved', 'Denied', 'Resolved', 'Cancelled']
if status not in valid_statuses:
status = 'Submitted'
-
+
# Insert new claim
cur.execute("""
INSERT INTO warranty_claims
(warranty_id, claim_date, status, claim_number, description, resolution, resolution_date)
VALUES (%s, %s, %s, %s, %s, %s, %s)
RETURNING id, created_at, updated_at
- """, (warranty_id, parsed_claim_date, status, claim_number or None, description or None,
- resolution or None, parsed_resolution_date))
+ """, (warranty_id, parsed_claim_date, status, claim_number, description,
+ resolution, parsed_resolution_date))
result = cur.fetchone()
claim_id = result[0]
@@ -1871,9 +1907,9 @@ def create_claim(warranty_id):
'warranty_id': warranty_id,
'claim_date': parsed_claim_date.isoformat(),
'status': status,
- 'claim_number': claim_number or None,
- 'description': description or None,
- 'resolution': resolution or None,
+ 'claim_number': claim_number,
+ 'description': description,
+ 'resolution': resolution,
'resolution_date': parsed_resolution_date.isoformat() if parsed_resolution_date else None,
'created_at': created_at.isoformat() if created_at else None,
'updated_at': updated_at.isoformat() if updated_at else None
@@ -1903,18 +1939,41 @@ def get_claims(warranty_id):
try:
user_id = request.user['id']
- # Verify warranty exists and user owns it
+ is_admin = request.user.get('is_admin', False)
+
conn = get_db_connection()
cur = conn.cursor()
+ # First check if warranty exists and user owns it
cur.execute("""
- SELECT id, product_name FROM warranties
+ SELECT id, product_name, user_id FROM warranties
WHERE id = %s AND user_id = %s
""", (warranty_id, user_id))
warranty = cur.fetchone()
+
+ # If user doesn't own the warranty, check if global view access is allowed
if not warranty:
- return jsonify({'error': 'Warranty not found or access denied'}), 404
+ # Check if global view is enabled and user has access
+ cur.execute("SELECT key, value FROM site_settings WHERE key IN ('global_view_enabled', 'global_view_admin_only')")
+ settings = {row[0]: row[1] for row in cur.fetchall()}
+
+ global_view_enabled = settings.get('global_view_enabled', 'true').lower() == 'true'
+ admin_only = settings.get('global_view_admin_only', 'false').lower() == 'true'
+
+ # Check if user has global view access
+ if not global_view_enabled or (admin_only and not is_admin):
+ return jsonify({'error': 'Warranty not found or access denied'}), 404
+
+ # Check if warranty exists (regardless of ownership)
+ cur.execute("""
+ SELECT id, product_name, user_id FROM warranties
+ WHERE id = %s
+ """, (warranty_id,))
+
+ warranty = cur.fetchone()
+ if not warranty:
+ return jsonify({'error': 'Warranty not found'}), 404
# Get all claims for this warranty
cur.execute("""
diff --git a/frontend/about.html b/frontend/about.html
index ee09b1e..1cee91a 100644
--- a/frontend/about.html
+++ b/frontend/about.html
@@ -318,7 +318,7 @@
<!-- Hero Section -->
<div class="about-hero">
<h1><i class="fas fa-shield-alt"></i> Warracker</h1>
- <div class="version" id="versionDisplay" data-i18n="about.version">Version v0.10.1.10</div>
+ <div class="version" id="versionDisplay" data-i18n="about.version">Version v0.10.1.11</div>
<p class="description" data-i18n="about.description">
A comprehensive warranty management system designed to help you track, organize, and manage all your product warranties in one secure, user-friendly platform.
</p>
@@ -416,7 +416,7 @@
// Update version display dynamically
const versionDisplay = document.getElementById('versionDisplay');
if (versionDisplay && window.i18next) {
- const currentVersion = '0.10.1.4'; // This should match version-checker.js
+ const currentVersion = '0.10.1.11'; // This should match version-checker.js
versionDisplay.textContent = window.i18next.t('about.version') + ' v' + currentVersion;
}
diff --git a/frontend/script.js b/frontend/script.js
index 1a75570..4db0c87 100644
--- a/frontend/script.js
+++ b/frontend/script.js
@@ -1979,6 +1979,7 @@ async function loadWarranties(isAuthenticated) { // Added isAuthenticated parame
console.error('[DEBUG] API did not return an array! Data:', data);
}
+
// Update isGlobalView to match the loaded data
isGlobalView = shouldUseGlobalView;
console.log(`[DEBUG] Set isGlobalView to: ${isGlobalView}`);
@@ -2320,6 +2321,7 @@ async function renderWarranties(warrantiesToRender) {
const hasDocuments = warranty.product_url || warranty.invoice_path || warranty.manual_path || warranty.other_document_path ||
warranty.paperless_invoice_id || warranty.paperless_manual_id || warranty.paperless_photo_id || warranty.paperless_other_id || hasNotes;
+
// Get current user ID to check warranty ownership
const currentUserId = (() => {
try {
@@ -2335,9 +2337,21 @@ async function renderWarranties(warrantiesToRender) {
const isAdmin = getUserType() === 'admin';
const canEdit = !isGlobalView || (warranty.user_id === currentUserId) || isAdmin;
+ // Determine claims button class and title based on claim status
+ let claimsButtonClass = 'action-btn claims-link';
+ let claimsTitle = 'Claims';
+
+ if (warranty.claim_status_summary === 'OPEN') {
+ claimsButtonClass += ' claims-open';
+ claimsTitle = 'Claims (Open)';
+ } else if (warranty.claim_status_summary === 'FINISHED') {
+ claimsButtonClass += ' claims-finished';
+ claimsTitle = 'Claims (Finished)';
+ }
+
// Generate action buttons HTML based on permissions
const actionButtonsHtml = canEdit ? `
- <button class="action-btn claims-link" title="Claims" data-id="${warranty.id}">
+ <button class="${claimsButtonClass}" title="${claimsTitle}" data-id="${warranty.id}">
<i class="fas fa-clipboard-list"></i>
</button>
<button class="action-btn edit-btn" title="Edit" data-id="${warranty.id}">
@@ -2347,7 +2361,7 @@ async function renderWarranties(warrantiesToRender) {
<i class="fas fa-trash"></i>
</button>
` : `
- <button class="action-btn claims-link" title="Claims" data-id="${warranty.id}">
+ <button class="${claimsButtonClass}" title="${claimsTitle}" data-id="${warranty.id}">
<i class="fas fa-clipboard-list"></i>
</button>
<span class="action-btn-placeholder" title="View only - not your warranty">
@@ -2358,6 +2372,8 @@ async function renderWarranties(warrantiesToRender) {
const cardElement = document.createElement('div');
cardElement.className = `warranty-card ${statusClass === 'expired' ? 'expired' : statusClass === 'expiring' ? 'expiring-soon' : 'active'}`;
+ // Claims button styling will be handled in the action buttons HTML generation
+
if (currentView === 'grid') {
// Grid view HTML structure
const photoThumbnailHtml = warranty.product_photo_path && warranty.product_photo_path !== 'null' ? `
@@ -2911,7 +2927,7 @@ async function openEditModal(warranty) {
currentInvoiceElement.innerHTML = `
<span class="text-success">
<i class="fas fa-check-circle"></i> ${i18next.t('warranties.current_invoice')}:
- <a href="#" class="view-document-link" onclick="openPaperlessDocument(${warranty.paperless_invoice_id}); return false;">View</a>
+ <a href="#" class="view-document-link" onclick="openPaperlessDocument(${warranty.paperless_invoice_id}, {user_id: ${warranty.user_id}, id: ${warranty.id}}); return false;">View</a>
<i class="fas fa-cloud" style="color: #4dabf7; margin-left: 4px; font-size: 0.8em;" title="Stored in Paperless-ngx"></i> (${i18next.t('warranties.upload_new_file_replace')})
</span>
`;
@@ -2948,7 +2964,7 @@ async function openEditModal(warranty) {
currentManualElement.innerHTML = `
<span class="text-success">
<i class="fas fa-check-circle"></i> ${i18next.t('warranties.current_manual')}:
- <a href="#" class="view-document-link" onclick="openPaperlessDocument(${warranty.paperless_manual_id}); return false;">View</a>
+ <a href="#" class="view-document-link" onclick="openPaperlessDocument(${warranty.paperless_manual_id}, {user_id: ${warranty.user_id}, id: ${warranty.id}}); return false;">View</a>
<i class="fas fa-cloud" style="color: #4dabf7; margin-left: 4px; font-size: 0.8em;" title="Stored in Paperless-ngx"></i> (${i18next.t('warranties.upload_new_file_replace')})
</span>
`;
@@ -2988,7 +3004,7 @@ async function openEditModal(warranty) {
currentProductPhotoElement.innerHTML = `
<span class="text-success">
<i class="fas fa-check-circle"></i> ${i18next.t('warranties.current_photo')}:
- <a href="#" class="view-document-link" onclick="openPaperlessDocument(${warranty.paperless_photo_id}); return false;">View</a>
+ <a href="#" class="view-document-link" onclick="openPaperlessDocument(${warranty.paperless_photo_id}, {user_id: ${warranty.user_id}, id: ${warranty.id}}); return false;">View</a>
<i class="fas fa-cloud" style="color: #4dabf7; margin-left: 4px; font-size: 0.8em;" title="Stored in Paperless-ngx"></i>
<br><small>(${i18next.t('warranties.upload_new_photo_replace')})</small>
</span>
@@ -3027,7 +3043,7 @@ async function openEditModal(warranty) {
currentOtherDocumentElement.innerHTML = `
<span class="text-success">
<i class="fas fa-check-circle"></i> ${i18next.t('warranties.current_other_document')}:
- <a href="#" class="view-document-link" onclick="openPaperlessDocument(${warranty.paperless_other_id}); return false;">View</a>
+ <a href="#" class="view-document-link" onclick="openPaperlessDocument(${warranty.paperless_other_id}, {user_id: ${warranty.user_id}, id: ${warranty.id}}); return false;">View</a>
<i class="fas fa-cloud" style="color: #4dabf7; margin-left: 4px; font-size: 0.8em;" title="Stored in Paperless-ngx"></i> (${i18next.t('warranties.upload_new_file_replace')})
</span>
`;
@@ -3733,6 +3749,7 @@ document.addEventListener('DOMContentLoaded', function() {
// Global variables for claims
let currentClaimsWarrantyId = null;
let currentClaims = [];
+let currentClaimsCanEdit = false; // Track if current user can edit the warranty being viewed
/**
* Initialize claims event listeners
@@ -3797,6 +3814,23 @@ async function openClaimsModal(warrantyId) {
return;
}
+ // Determine if current user can edit this warranty
+ const currentUserId = (() => {
+ try {
+ const userInfo = JSON.parse(localStorage.getItem('user_info') || '{}');
+ return userInfo.id;
+ } catch (e) {
+ return null;
+ }
+ })();
+ const isAdmin = getUserType() === 'admin';
+ currentClaimsCanEdit = !isGlobalView || (warranty.user_id === currentUserId) || isAdmin;
+
+ // Show/hide the Add New Claim button based on edit permissions
+ if (addClaimBtn) {
+ addClaimBtn.style.display = currentClaimsCanEdit ? 'inline-block' : 'none';
+ }
+
// Update warranty info in modal
if (warrantyClaimInfo) {
warrantyClaimInfo.innerHTML = `
@@ -3874,11 +3908,15 @@ function renderClaims() {
if (!claimsListBody) return;
if (currentClaims.length === 0) {
+ const noClaimsMessage = currentClaimsCanEdit
+ ? (window.i18next ? window.i18next.t('claims.no_claims_message') : 'Click "Add New Claim" to get started')
+ : 'No claims have been filed for this warranty';
+
claimsListBody.innerHTML = `
<div class="no-claims-message" style="text-align: center; padding: 40px;">
<i class="fas fa-clipboard-list" style="font-size: 3rem; color: var(--medium-gray); margin-bottom: 1rem;"></i>
<h4 style="color: var(--text-color); margin-bottom: 0.5rem;">${window.i18next ? window.i18next.t('claims.no_claims_yet') : 'No Claims Yet'}</h4>
- <p style="color: var(--dark-gray); margin-bottom: 0;">${window.i18next ? window.i18next.t('claims.no_claims_message') : 'Click "Add New Claim" to get started'}</p>
+ <p style="color: var(--dark-gray); margin-bottom: 0;">${noClaimsMessage}</p>
</div>
`;
return;
@@ -3902,12 +3940,18 @@ function renderClaims() {
</div>
</div>
<div class="claim-actions">
- <button class="btn btn-sm btn-secondary edit-claim-btn" data-claim-id="${claim.id}">
- <i class="fas fa-edit"></i> Edit
- </button>
- <button class="btn btn-sm btn-danger delete-claim-btn" data-claim-id="${claim.id}">
- <i class="fas fa-trash"></i> Delete
- </button>
+ ${currentClaimsCanEdit ? `
+ <button class="btn btn-sm btn-secondary edit-claim-btn" data-claim-id="${claim.id}">
+ <i class="fas fa-edit"></i> Edit
+ </button>
+ <button class="btn btn-sm btn-danger delete-claim-btn" data-claim-id="${claim.id}">
+ <i class="fas fa-trash"></i> Delete
+ </button>
+ ` : `
+ <span class="claim-readonly-indicator" style="color: var(--medium-gray); font-size: 0.9em;">
+ <i class="fas fa-eye"></i> View Only
+ </span>
+ `}
</div>
</div>
${claim.description ? `<div class="claim-description">${escapeHtml(claim.description)}</div>` : ''}
@@ -3918,23 +3962,25 @@ function renderClaims() {
claimsListBody.innerHTML = claimsHtml;
- // Add event listeners for edit and delete buttons
- claimsListBody.addEventListener('click', (e) => {
- if (e.target.closest('.edit-claim-btn')) {
- const claimId = parseInt(e.target.closest('.edit-claim-btn').dataset.claimId);
- const claim = currentClaims.find(c => c.id === claimId);
- if (claim) {
- openClaimFormModal(claim);
+ // Add event listeners for edit and delete buttons (only if user can edit)
+ if (currentClaimsCanEdit) {
+ claimsListBody.addEventListener('click', (e) => {
+ if (e.target.closest('.edit-claim-btn')) {
+ const claimId = parseInt(e.target.closest('.edit-claim-btn').dataset.claimId);
+ const claim = currentClaims.find(c => c.id === claimId);
+ if (claim) {
+ openClaimFormModal(claim);
+ }
}
- }
-
- if (e.target.closest('.delete-claim-btn')) {
- const claimId = parseInt(e.target.closest('.delete-claim-btn').dataset.claimId);
- if (confirm(window.i18next ? window.i18next.t('claims.confirm_delete_claim') : 'Are you sure you want to delete this claim?')) {
- deleteClaim(claimId);
+
+ if (e.target.closest('.delete-claim-btn')) {
+ const claimId = parseInt(e.target.closest('.delete-claim-btn').dataset.claimId);
+ if (confirm(window.i18next ? window.i18next.t('claims.confirm_delete_claim') : 'Are you sure you want to delete this claim?')) {
+ deleteClaim(claimId);
+ }
}
- }
- });
+ });
+ }
}
/**
@@ -4069,6 +4115,7 @@ function closeClaimsModal() {
}
currentClaimsWarrantyId = null;
currentClaims = [];
+ currentClaimsCanEdit = false;
}
/**
@@ -4328,10 +4375,32 @@ function generateDocumentLink(warranty, docType) {
const config = docConfig[docType];
if (!config) return '';
+ // Check Global View permissions for "other" documents
+ if (docType === 'other' && isGlobalView) {
+ // Get current user ID to check warranty ownership
+ const currentUserId = (() => {
+ try {
+ const userInfo = JSON.parse(localStorage.getItem('user_info') || '{}');
+ return userInfo.id;
+ } catch (e) {
+ return null;
+ }
+ })();
+
+ const isAdmin = getUserType() === 'admin';
+ const canViewOtherDocs = !isGlobalView || (warranty.user_id === currentUserId) || isAdmin;
+
+ // Hide "other" documents in Global View unless user owns the warranty or is admin
+ if (!canViewOtherDocs) {
+ return '';
+ }
+ }
+
const hasLocal = config.localPath && config.localPath !== 'null';
const hasPaperless = config.paperlessId && config.paperlessId !== null;
const hasUrl = config.url && config.url.trim() !== '';
+
let linksHtml = '';
if (hasLocal) {
@@ -4339,7 +4408,8 @@ function generateDocumentLink(warranty, docType) {
<i class="${config.icon}"></i> ${config.label}
</a>`;
} else if (hasPaperless) {
- linksHtml += `<a href="#" onclick="openPaperlessDocument(${config.paperlessId}); return false;" class="${config.className}">
+ const warrantyContextJson = JSON.stringify({user_id: warranty.user_id, id: warranty.id}).replace(/"/g, '&quot;');
+ linksHtml += `<a href="#" onclick="openPaperlessDocument(${config.paperlessId}, JSON.parse('${warrantyContextJson}')); return false;" class="${config.className}">
<i class="${config.icon}"></i> ${config.label} <i class="fas fa-cloud" style="color: #4dabf7; margin-left: 4px; font-size: 0.8em;" title="Stored in Paperless-ngx"></i>
</a>`;
}
@@ -7586,8 +7656,8 @@ async function debugPaperlessConfiguration() {
/**
* Open a Paperless-ngx document either in Warracker interface or in Paperless-ngx directly
*/
-async function openPaperlessDocument(paperlessId) {
- console.log(`[openPaperlessDocument] Opening Paperless document: ${paperlessId}`);
+async function openPaperlessDocument(paperlessId, warrantyContext = null) {
+ console.log(`[openPaperlessDocument] Opening Paperless document: ${paperlessId}`, warrantyContext);
// First, debug the Paperless configuration
const debugInfo = await debugPaperlessConfiguration();
@@ -7621,8 +7691,8 @@ async function openPaperlessDocument(paperlessId) {
return;
}
- // Check user preference for viewing documents
- const viewInApp = await getUserPaperlessViewPreference();
+ // Check user preference for viewing documents, considering Global View context
+ const viewInApp = await getUserPaperlessViewPreference(warrantyContext);
console.log(`[openPaperlessDocument] User preference view in app: ${viewInApp}`);
if (viewInApp) {
@@ -7704,7 +7774,25 @@ async function openPaperlessDocument(paperlessId) {
/**
* Get user preference for viewing Paperless documents in app
*/
-async function getUserPaperlessViewPreference() {
+async function getUserPaperlessViewPreference(warrantyContext = null) {
+ // Special handling for Global View: default to view in app for other users' documents
+ if (warrantyContext && isGlobalView) {
+ const currentUserId = (() => {
+ try {
+ const userInfo = JSON.parse(localStorage.getItem('user_info') || '{}');
+ return userInfo.id;
+ } catch (e) {
+ return null;
+ }
+ })();
+
+ // If viewing another user's document in Global View, default to view in app
+ if (currentUserId && warrantyContext.user_id && warrantyContext.user_id !== currentUserId) {
+ console.log(`[getUserPaperlessViewPreference] Global View: Defaulting to view in app for other user's document (warranty user: ${warrantyContext.user_id}, current user: ${currentUserId})`);
+ return true;
+ }
+ }
+
// First check localStorage
const prefix = getPreferenceKeyPrefix();
const localPreference = localStorage.getItem(`${prefix}paperlessViewInApp`);
@@ -7716,6 +7804,7 @@ async function getUserPaperlessViewPreference() {
if (window.auth && window.auth.isAuthenticated && window.auth.isAuthenticated()) {
try {
const response = await fetch('/api/auth/preferences', {
+ method: 'GET',
headers: {
'Authorization': `Bearer ${window.auth.getToken()}`
}
diff --git a/frontend/style.css b/frontend/style.css
index 15ef9bb..de2cdeb 100644
--- a/frontend/style.css
+++ b/frontend/style.css
@@ -4799,3 +4799,41 @@ html.dark-mode .warracker-footer a:hover {
:root[data-theme="dark"] .claim-resolution {
background: rgba(46, 204, 113, 0.15);
}
+
+/* Claims Button Status Styles */
+.claims-link.claims-open {
+ background-color: #9b59b6 !important; /* Purple for open claims */
+ color: white !important;
+}
+
+.claims-link.claims-open:hover {
+ background-color: #8e44ad !important;
+ transform: scale(1.05);
+}
+
+.claims-link.claims-finished {
+ background-color: var(--primary-color, #3498db) !important;
+ color: white !important;
+}
+
+.claims-link.claims-finished:hover {
+ background-color: #2980b9 !important;
+ transform: scale(1.05);
+}
+
+/* Add a subtle pulse animation for open claims */
+.claims-link.claims-open {
+ animation: pulse-purple 2s infinite;
+}
+
+@keyframes pulse-purple {
+ 0% {
+ box-shadow: 0 0 0 0 rgba(155, 89, 182, 0.7);
+ }
+ 70% {
+ box-shadow: 0 0 0 10px rgba(155, 89, 182, 0);
+ }
+ 100% {
+ box-shadow: 0 0 0 0 rgba(155, 89, 182, 0);
+ }
+}
diff --git a/frontend/version-checker.js b/frontend/version-checker.js
index 8e2556c..93da7ee 100644
--- a/frontend/version-checker.js
+++ b/frontend/version-checker.js
@@ -1,6 +1,6 @@
// Version checker for Warracker
document.addEventListener('DOMContentLoaded', () => {
- const currentVersion = '0.10.1.10'; // Current version of the application
+ const currentVersion = '0.10.1.11'; // Current version of the application
const updateStatus = document.getElementById('updateStatus');
const updateLink = document.getElementById('updateLink');
const versionDisplay = document.getElementById('versionDisplay');