forked from FrederikBaerentsen/BrickTracker
Compare commits
28
Commits
v1.4.0
..
685857031f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
685857031f | ||
|
|
a7fd1fc4dd | ||
|
|
71d753bbb9 | ||
|
|
ef38ce32b8 | ||
|
|
8b0b85f29f | ||
|
|
6a00cba647 | ||
|
|
d1ada6b3d0 | ||
|
|
8fef6f49e1 | ||
|
|
f46f13343d | ||
|
|
2a571edb57 | ||
|
|
2cb3e96e21 | ||
|
|
e94b8d2de5 | ||
|
|
4074aa7c4c | ||
|
|
f262411dc4 | ||
|
|
711833e5de | ||
|
|
12dead4ded | ||
|
|
0e3ba26010 | ||
|
|
6177187103 | ||
|
|
5c0daed160 | ||
|
|
66bbed3597 | ||
|
|
d3a014765b | ||
|
|
665441c5ac | ||
|
|
d751a3d0af | ||
|
|
1b077e86b1 | ||
|
|
ef6bdc823d | ||
|
|
0567d9817f | ||
|
|
fa9e0c3765 | ||
|
|
69318e7b0b |
@@ -1,5 +1,48 @@
|
||||
# Changelog
|
||||
|
||||
## 1.4.2
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- **Fixed instructions downloads failing with "No instructions found on Rebrickable or Peeron"** (#171): Rebrickable now blocks scraping behind a Cloudflare challenge, so instructions are fetched from LEGO's own official building-instructions page instead
|
||||
- **Fixed instructions never linking to sets with alphanumeric ids** (#166): Instructions for "Pick a Brick" / promotional builds whose set id begins with letters (e.g. `EG00029-1`) were orphaned and never associated with the set; the matching now handles alphanumeric set ids
|
||||
|
||||
## 1.4.1
|
||||
|
||||
### Enhancements
|
||||
|
||||
- **Added per-column header filters to the Parts table on the set details page**: The main Parts table now has an always-visible filter row under the column headers
|
||||
- Name: case-insensitive substring search
|
||||
- Color: dropdown populated from the colors present in the current results
|
||||
- Missing / Damaged: All / With / Without dropdowns
|
||||
- Checked: All / Checked / Unchecked
|
||||
- Filters combine (AND) and re-evaluate live as missing/damaged values or checkboxes change. Bulk actions (mark all missing, check all, etc.) only affect the rows visible under the active filter. Scoped to the main Parts table only; per-minifigure tables stay sort-only
|
||||
- **"Reset to Defaults" confirmation now uses a Bootstrap modal instead of a browser dialog**: Replaced the native browser `confirm()` popup with a consistent Bootstrap modal matching the style of BrickTracker
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- **Fixed prices on the Statistics page being rounded to whole numbers** (Issue #146): All price values now display with two decimal places (`%.2f`) instead of being rounded to whole numbers (`%.0f`)
|
||||
|
||||
- **Fixed "Reset to Defaults" blanking all settings instead of restoring them** (Issue #149a, branch `bugfix/issue-149a`): "Reset to Defaults" was clearing all fields to empty/false instead of populating them with their actual default values
|
||||
- `resetToDefaults()` now reads from `window.DEFAULT_CONFIG` and restores each field to its proper default, matching the same logic used on initial page load
|
||||
- **Fixed `BK_INSTRUCTIONS_ALLOWED_EXTENSIONS` being treated as a string instead of a list** (Issue #149b, branch `bugfix/issue-149b`): When this setting was saved via the admin panel, it was stored and cast as a plain string rather than a list, causing it to be iterated character by character (e.g. `['.', 'p', 'd', 'f']` instead of `['.pdf']`)
|
||||
- Added `allowed_extensions` to the list-type keyword detection in `_cast_value()`, matching the existing pattern used for `badge_order` settings
|
||||
- **Fixed crash when importing sets containing minifigures or parts with no image on Rebrickable** (Issue #149c, branch `bugfix/issue-149c`): Adding or refreshing a set would fail entirely if any minifigure or part had no image URL, with error `Invalid URL '': No scheme supplied`
|
||||
- Rebrickable returns an empty string (not `None`) for missing images; normalize empty strings to `None` at the point of ingestion in `rebrickable_minifigure.py` and `individual_minifigure.py`, matching the existing pattern in `rebrickable_set.py`
|
||||
- Updated `rebrickable_image.py` to treat empty strings the same as `None` throughout, falling back to the configured nil placeholder image
|
||||
- Note: the originally reported sets could no longer reproduce the crash (images may have since been added on Rebrickable), so this fix is based on assumptions only
|
||||
- **Fixed previously added set being re-added when adding an individual minifigure** (Issue #150, branch `bugfix/issue-150`): After adding a set, entering a `fig-` ID and confirming would add the previous set again instead of the minifigure, if user did not reload inbetween.
|
||||
- `add.js` was creating a second `BrickMinifigureSocket` with its own listeners on the same button and input as `BrickSetSocket`, causing duplicate socket events and cross-socket state confusion
|
||||
- **Fixed purchase date, price, and notes not being saved when adding an individual minifigure** (Issue #151, branch `bugfix/issue-151`): Filling in purchase date, price, or notes before clicking Add had no effect, only purchase location was saved
|
||||
- `BrickMinifigureSocket` was missing references to `#add-purchase-date`, `#add-purchase-price`, and `#add-description`, so those fields were never read or included in the socket emit
|
||||
- The backend already supported all three fields. This was just a frontend error
|
||||
- **Fixed purchase date and price not being converted when adding an individual minifigure** (Issue #151 follow-up): Purchase date was stored as a raw `YYYY/MM/DD` string and price as a raw string instead of a Unix epoch float and float respectively, causing them to be silently dropped from statistics aggregations
|
||||
- `IndividualMinifigure.download()` now mirrors the conversion logic already present in `BrickSet.download()`: date parsed via `datetime.strptime` to timestamp, price cast to `float`
|
||||
- **Fixed a price of 0 being treated as no price** (Issue #153): Setting a purchase price of `0` on sets, individual minifigures, or parts was indistinguishable from having no price set at all
|
||||
- Replaced truthiness checks (`if price`, `price or ''`) with explicit `None` checks throughout badge display, management input fields, and inline price update endpoints
|
||||
- **Fixed deleting a wish with an owner assigned** (Issue #152, branch `bugfix/issue-152`): Resolved foreign key constraint error when removing a set from the wishlist that had an owner assigned
|
||||
- Wish owners are now deleted before the wish itself, respecting the FK constraint
|
||||
|
||||
## 1.4
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
@@ -192,7 +192,7 @@ class ConfigManager:
|
||||
def _cast_value(self, var_name: str, value: Any) -> Any:
|
||||
"""Cast value to appropriate type based on variable name"""
|
||||
# List variables (admin sections, badge order) - Check this FIRST before boolean check
|
||||
if any(keyword in var_name.lower() for keyword in ['sections', 'badge_order']):
|
||||
if any(keyword in var_name.lower() for keyword in ['sections', 'badge_order', 'allowed_extensions']):
|
||||
if isinstance(value, str):
|
||||
return [section.strip() for section in value.split(',') if section.strip()]
|
||||
elif isinstance(value, list):
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import logging
|
||||
import traceback
|
||||
from datetime import datetime
|
||||
from typing import Any, Self, TYPE_CHECKING
|
||||
from uuid import uuid4
|
||||
|
||||
@@ -67,8 +68,25 @@ class IndividualMinifigure(RebrickableMinifigure):
|
||||
self.fields.purchase_location = purchase_location.fields.id if purchase_location else None
|
||||
|
||||
# Save purchase date and price
|
||||
self.fields.purchase_date = data.get('purchase_date', None)
|
||||
self.fields.purchase_price = data.get('purchase_price', None)
|
||||
purchase_date = data.get('purchase_date', None)
|
||||
if purchase_date == '':
|
||||
purchase_date = None
|
||||
if purchase_date is not None:
|
||||
try:
|
||||
purchase_date = datetime.strptime(purchase_date, '%Y/%m/%d').timestamp()
|
||||
except Exception:
|
||||
purchase_date = None
|
||||
self.fields.purchase_date = purchase_date
|
||||
|
||||
purchase_price = data.get('purchase_price', None)
|
||||
if purchase_price == '':
|
||||
purchase_price = None
|
||||
if purchase_price is not None:
|
||||
try:
|
||||
purchase_price = float(purchase_price)
|
||||
except Exception:
|
||||
purchase_price = None
|
||||
self.fields.purchase_price = purchase_price
|
||||
|
||||
# Save quantity and description
|
||||
self.fields.quantity = int(data.get('quantity', 1))
|
||||
@@ -543,6 +561,6 @@ class IndividualMinifigure(RebrickableMinifigure):
|
||||
'figure': str(data['set_num']),
|
||||
'number': int(number),
|
||||
'name': str(data['set_name']),
|
||||
'image': data.get('set_img_url'),
|
||||
'image': str(data['set_img_url']) if data.get('set_img_url') else None,
|
||||
'number_of_parts': int(data.get('num_parts', 0)),
|
||||
}
|
||||
|
||||
@@ -75,10 +75,11 @@ class BrickInstructions(object):
|
||||
|
||||
splits = normalized.split('-', 2)
|
||||
|
||||
if len(splits) >= 2:
|
||||
if len(splits) >= 2 and splits[0]:
|
||||
try:
|
||||
# Trying to make sense of each part as integers
|
||||
int(splits[0])
|
||||
# The set number can be alphanumeric (e.g. Pick-a-Brick
|
||||
# builds like "EG00029-1"); only the version suffix has
|
||||
# to be an integer
|
||||
int(splits[1])
|
||||
|
||||
self.set = '-'.join(splits[:2])
|
||||
@@ -120,18 +121,6 @@ class BrickInstructions(object):
|
||||
'Cache-Control': 'max-age=0'
|
||||
})
|
||||
|
||||
# Visit the set's instructions listing page first to establish session cookies
|
||||
set_number = None
|
||||
if self.rebrickable:
|
||||
set_number = self.rebrickable.fields.set
|
||||
elif self.set:
|
||||
set_number = self.set
|
||||
|
||||
if set_number:
|
||||
instructions_page = f"https://rebrickable.com/instructions/{set_number}/"
|
||||
session.get(instructions_page)
|
||||
session.headers.update({"Referer": instructions_page})
|
||||
|
||||
resp = session.get(path, stream=True, allow_redirects=True)
|
||||
if not resp.ok:
|
||||
raise DownloadException(f"Failed to download: HTTP {resp.status_code}")
|
||||
@@ -269,10 +258,13 @@ class BrickInstructions(object):
|
||||
@staticmethod
|
||||
def find_instructions(set: str, /) -> list[Tuple[str, str]]:
|
||||
"""
|
||||
Scrape Rebrickable's HTML and return a list of
|
||||
(filename_slug, download_url). Duplicate slugs get _1, _2, …
|
||||
Scrape LEGO's official building-instructions page and return a list
|
||||
of (filename_slug, download_url). Duplicate slugs get _1, _2, …
|
||||
"""
|
||||
page_url = f"https://rebrickable.com/instructions/{set}/"
|
||||
# LEGO's page wants the bare set number, no "-1" version suffix
|
||||
number, _, _version = set.partition('-')
|
||||
|
||||
page_url = f"https://www.lego.com/en-us/service/building-instructions/{number}" # noqa: E501
|
||||
logger.debug(f"[find_instructions] fetching HTML from {page_url!r}")
|
||||
|
||||
# Use plain requests instead of cloudscraper
|
||||
@@ -295,23 +287,29 @@ class BrickInstructions(object):
|
||||
raise ErrorException(f'Failed to load instructions page for {set}. HTTP {resp.status_code}')
|
||||
|
||||
soup = BeautifulSoup(resp.content, 'html.parser')
|
||||
# Match download links with or without query parameters (e.g., ?cfe=timestamp&cfk=key)
|
||||
link_re = re.compile(r'^/instructions/\d+/.+/download/')
|
||||
|
||||
# Each booklet is a "bi-card" div. Attribute order on this page is
|
||||
# not stable between requests, so every lookup has to stay scoped
|
||||
# inside its own card rather than collecting all h3s/links
|
||||
# page-wide and pairing them up by position, that can silently
|
||||
# mismatch a label with the wrong link.
|
||||
raw: list[tuple[str, str]] = []
|
||||
for a in soup.find_all('a', href=link_re):
|
||||
img = a.find('img', alt=True) # type: ignore
|
||||
if not img or set not in img['alt']: # type: ignore
|
||||
for card in soup.find_all('div', attrs={'data-test': 'bi-card'}):
|
||||
label = card.find('h3')
|
||||
link = card.find('a', attrs={'data-test': 'bi-card-link'})
|
||||
|
||||
if label is None or link is None or not link.get('href'):
|
||||
continue
|
||||
|
||||
# Turn the alt text into a slug
|
||||
alt_text = img['alt'].removeprefix('LEGO Building Instructions for ') # type: ignore
|
||||
slug = re.sub(r'[^A-Za-z0-9]+', '-', alt_text).strip('-')
|
||||
# Prefix with the set number: filenames are how a downloaded
|
||||
# instruction later gets matched back to its set (see
|
||||
# BrickInstructions.__init__), and LEGO's own card labels never
|
||||
# mention the set number, only the product name and booklet.
|
||||
card_slug = re.sub(r'[^A-Za-z0-9]+', '-', label.get_text(strip=True)).strip('-') # noqa: E501
|
||||
slug = f'{set}-{card_slug}'
|
||||
download_url = urljoin('https://www.lego.com', link['href'])
|
||||
|
||||
# Build the absolute download URL - this preserves query parameters
|
||||
# BeautifulSoup's a['href'] includes the full href with ?cfe=...&cfk=... params
|
||||
download_url = urljoin('https://rebrickable.com', a['href']) # type: ignore
|
||||
logger.debug(f"[find_instructions] Found download link: {download_url}")
|
||||
logger.debug(f"[find_instructions] Found download link: {download_url}") # noqa: E501
|
||||
raw.append((slug, download_url))
|
||||
|
||||
if not raw:
|
||||
|
||||
@@ -9,6 +9,7 @@ from flask import Flask
|
||||
# - f: flag name (str, optional=None)
|
||||
NAVBAR: Final[list[dict[str, Any]]] = [
|
||||
{'e': 'set.list', 't': 'Sets', 'i': 'grid-line', 'f': 'HIDE_ALL_SETS'}, # noqa: E501
|
||||
{'e': 'set.table', 't': 'Sets table', 'i': 'table-line', 'f': 'HIDE_ALL_SETS'}, # noqa: E501
|
||||
{'e': 'add.add', 't': 'Add', 'i': 'add-circle-line', 'f': 'HIDE_ADD_SET'}, # noqa: E501
|
||||
{'e': 'part.list', 't': 'Parts', 'i': 'shapes-line', 'f': 'HIDE_ALL_PARTS'}, # noqa: E501
|
||||
{'e': 'part.problem', 't': 'Problems', 'i': 'error-warning-line', 'f': 'HIDE_ALL_PROBLEMS_PARTS'}, # noqa: E501
|
||||
|
||||
+22
-5
@@ -288,7 +288,14 @@ class BrickPart(RebrickablePart):
|
||||
)
|
||||
|
||||
# Update a problematic part
|
||||
def update_problem(self, problem: str, json: Any | None, /) -> int:
|
||||
def update_problem(
|
||||
self,
|
||||
problem: str,
|
||||
json: Any | None,
|
||||
/,
|
||||
*,
|
||||
commit: bool = True,
|
||||
) -> int:
|
||||
amount: str | int = json.get('value', '') # type: ignore
|
||||
|
||||
# We need a positive integer
|
||||
@@ -310,10 +317,20 @@ class BrickPart(RebrickablePart):
|
||||
|
||||
setattr(self.fields, problem, amount)
|
||||
|
||||
BrickSQL().execute_and_commit(
|
||||
'part/update/{problem}'.format(problem=problem),
|
||||
parameters=self.sql_parameters()
|
||||
)
|
||||
if commit:
|
||||
BrickSQL().execute_and_commit(
|
||||
'part/update/{problem}'.format(problem=problem),
|
||||
parameters=self.sql_parameters()
|
||||
)
|
||||
else:
|
||||
# Queue the update without committing, so a caller updating many
|
||||
# parts at once (e.g. a bulk operation) can run every update in
|
||||
# a single transaction with one final commit.
|
||||
BrickSQL().execute(
|
||||
'part/update/{problem}'.format(problem=problem),
|
||||
parameters=self.sql_parameters(),
|
||||
defer=True,
|
||||
)
|
||||
|
||||
return amount
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ class RebrickableImage(object):
|
||||
|
||||
# Get the URL (this handles nil images via url() method)
|
||||
url = self.url()
|
||||
if url is None:
|
||||
if not url:
|
||||
return
|
||||
|
||||
# Grab the image
|
||||
@@ -88,7 +88,7 @@ class RebrickableImage(object):
|
||||
return self.part.fields.image_id
|
||||
|
||||
if self.minifigure is not None:
|
||||
if self.minifigure.fields.image is None:
|
||||
if not self.minifigure.fields.image:
|
||||
return RebrickableImage.nil_minifigure_name()
|
||||
else:
|
||||
return self.minifigure.fields.figure
|
||||
@@ -113,13 +113,13 @@ class RebrickableImage(object):
|
||||
# Return the url depending on the objects provided
|
||||
def url(self, /) -> str:
|
||||
if self.part is not None:
|
||||
if self.part.fields.image is None:
|
||||
if not self.part.fields.image:
|
||||
return current_app.config['REBRICKABLE_IMAGE_NIL']
|
||||
else:
|
||||
return self.part.fields.image
|
||||
|
||||
if self.minifigure is not None:
|
||||
if self.minifigure.fields.image is None:
|
||||
if not self.minifigure.fields.image:
|
||||
return current_app.config['REBRICKABLE_IMAGE_NIL_MINIFIGURE']
|
||||
else:
|
||||
return self.minifigure.fields.image
|
||||
|
||||
@@ -110,5 +110,5 @@ class RebrickableMinifigure(BrickRecord):
|
||||
'number': int(number),
|
||||
'name': str(data['set_name']),
|
||||
'quantity': int(data['quantity']),
|
||||
'image': data['set_img_url'],
|
||||
'image': str(data['set_img_url']) if data['set_img_url'] else None,
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ SELECT
|
||||
"bricktracker_individual_minifigures"."description",
|
||||
"bricktracker_individual_minifigures"."storage",
|
||||
"bricktracker_individual_minifigures"."purchase_location",
|
||||
"bricktracker_individual_minifigures"."purchase_date",
|
||||
"bricktracker_individual_minifigures"."purchase_price",
|
||||
"rebrickable_minifigures"."number",
|
||||
"rebrickable_minifigures"."name",
|
||||
"rebrickable_minifigures"."image",
|
||||
|
||||
@@ -6,6 +6,8 @@ SELECT
|
||||
"bricktracker_individual_minifigures"."description",
|
||||
"bricktracker_individual_minifigures"."storage",
|
||||
"bricktracker_individual_minifigures"."purchase_location",
|
||||
"bricktracker_individual_minifigures"."purchase_date",
|
||||
"bricktracker_individual_minifigures"."purchase_price",
|
||||
"rebrickable_minifigures"."number",
|
||||
"rebrickable_minifigures"."name",
|
||||
"rebrickable_minifigures"."image",
|
||||
|
||||
@@ -6,6 +6,8 @@ SELECT
|
||||
"bricktracker_individual_minifigures"."description",
|
||||
"bricktracker_individual_minifigures"."storage",
|
||||
"bricktracker_individual_minifigures"."purchase_location",
|
||||
"bricktracker_individual_minifigures"."purchase_date",
|
||||
"bricktracker_individual_minifigures"."purchase_price",
|
||||
"rebrickable_minifigures"."number",
|
||||
"rebrickable_minifigures"."name",
|
||||
"rebrickable_minifigures"."image",
|
||||
|
||||
@@ -6,6 +6,8 @@ SELECT
|
||||
"bricktracker_individual_minifigures"."description",
|
||||
"bricktracker_individual_minifigures"."storage",
|
||||
"bricktracker_individual_minifigures"."purchase_location",
|
||||
"bricktracker_individual_minifigures"."purchase_date",
|
||||
"bricktracker_individual_minifigures"."purchase_price",
|
||||
"rebrickable_minifigures"."number",
|
||||
"rebrickable_minifigures"."name",
|
||||
"rebrickable_minifigures"."image",
|
||||
|
||||
@@ -6,6 +6,8 @@ SELECT
|
||||
"bricktracker_individual_minifigures"."description",
|
||||
"bricktracker_individual_minifigures"."storage",
|
||||
"bricktracker_individual_minifigures"."purchase_location",
|
||||
"bricktracker_individual_minifigures"."purchase_date",
|
||||
"bricktracker_individual_minifigures"."purchase_price",
|
||||
"rebrickable_minifigures"."number",
|
||||
"rebrickable_minifigures"."name",
|
||||
"rebrickable_minifigures"."image",
|
||||
|
||||
@@ -17,9 +17,9 @@ SELECT
|
||||
{% block total_sets %}
|
||||
NULL AS "total_sets" -- dummy for order: total_sets
|
||||
{% endblock %}
|
||||
FROM "rebrickable_minifigures"
|
||||
FROM "bricktracker_minifigures"
|
||||
|
||||
LEFT JOIN "bricktracker_minifigures"
|
||||
INNER JOIN "rebrickable_minifigures"
|
||||
ON "rebrickable_minifigures"."figure" IS NOT DISTINCT FROM "bricktracker_minifigures"."figure"
|
||||
|
||||
{% block join %}{% endblock %}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
{% extends 'set/base/base.sql' %}
|
||||
|
||||
{% block id %}
|
||||
"bricktracker_sets"."id",
|
||||
{% endblock %}
|
||||
@@ -100,6 +100,23 @@ part_lot_stats AS (
|
||||
FROM "bricktracker_individual_part_lots"
|
||||
),
|
||||
|
||||
-- Combined min/max price across all item types (separate CTE to avoid scalar subquery issues in SQLite)
|
||||
all_prices AS (
|
||||
SELECT "purchase_price" AS price FROM "bricktracker_sets" WHERE "purchase_price" IS NOT NULL AND "purchase_price" != ''
|
||||
UNION ALL
|
||||
SELECT "purchase_price" FROM "bricktracker_individual_parts" WHERE "purchase_price" IS NOT NULL AND "purchase_price" != '' AND "lot_id" IS NULL
|
||||
UNION ALL
|
||||
SELECT "purchase_price" FROM "bricktracker_individual_minifigures" WHERE "purchase_price" IS NOT NULL AND "purchase_price" != ''
|
||||
UNION ALL
|
||||
SELECT "purchase_price" FROM "bricktracker_individual_part_lots" WHERE "purchase_price" IS NOT NULL AND "purchase_price" != ''
|
||||
),
|
||||
price_range AS (
|
||||
SELECT
|
||||
MIN(price) AS combined_minimum_cost,
|
||||
MAX(price) AS combined_maximum_cost
|
||||
FROM all_prices
|
||||
),
|
||||
|
||||
-- Rebrickable sets count (for sets we actually own)
|
||||
rebrickable_stats AS (
|
||||
SELECT COUNT(*) AS unique_rebrickable_sets
|
||||
@@ -140,26 +157,9 @@ financial_stats AS (
|
||||
END AS combined_average_cost,
|
||||
|
||||
-- Min/Max price across all item types
|
||||
(SELECT MIN(price) FROM (
|
||||
SELECT "purchase_price" AS price FROM "bricktracker_sets" WHERE "purchase_price" IS NOT NULL
|
||||
UNION ALL
|
||||
SELECT "purchase_price" FROM "bricktracker_individual_parts" WHERE "purchase_price" IS NOT NULL AND "lot_id" IS NULL
|
||||
UNION ALL
|
||||
SELECT "purchase_price" FROM "bricktracker_individual_minifigures" WHERE "purchase_price" IS NOT NULL
|
||||
UNION ALL
|
||||
SELECT "purchase_price" FROM "bricktracker_individual_part_lots" WHERE "purchase_price" IS NOT NULL
|
||||
)) AS combined_minimum_cost,
|
||||
|
||||
(SELECT MAX(price) FROM (
|
||||
SELECT "purchase_price" AS price FROM "bricktracker_sets" WHERE "purchase_price" IS NOT NULL
|
||||
UNION ALL
|
||||
SELECT "purchase_price" FROM "bricktracker_individual_parts" WHERE "purchase_price" IS NOT NULL AND "lot_id" IS NULL
|
||||
UNION ALL
|
||||
SELECT "purchase_price" FROM "bricktracker_individual_minifigures" WHERE "purchase_price" IS NOT NULL
|
||||
UNION ALL
|
||||
SELECT "purchase_price" FROM "bricktracker_individual_part_lots" WHERE "purchase_price" IS NOT NULL
|
||||
)) AS combined_maximum_cost
|
||||
FROM set_stats, individual_part_stats, individual_minifig_stats, part_lot_stats
|
||||
price_range.combined_minimum_cost,
|
||||
price_range.combined_maximum_cost
|
||||
FROM set_stats, individual_part_stats, individual_minifig_stats, part_lot_stats, price_range
|
||||
)
|
||||
|
||||
-- Final select combining all statistics
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
DELETE FROM "bricktracker_wishes"
|
||||
WHERE "bricktracker_wishes"."set" IS NOT DISTINCT FROM '{{ set }}';
|
||||
|
||||
DELETE FROM "bricktracker_wish_owners"
|
||||
WHERE "bricktracker_wish_owners"."set" IS NOT DISTINCT FROM '{{ set }}';
|
||||
|
||||
DELETE FROM "bricktracker_wishes"
|
||||
WHERE "bricktracker_wishes"."set" IS NOT DISTINCT FROM '{{ set }}';
|
||||
|
||||
COMMIT;
|
||||
@@ -49,4 +49,6 @@ class BrickSQLMigration(object):
|
||||
))
|
||||
)
|
||||
|
||||
return relative
|
||||
# Jinja2 template names always use forward slashes, regardless
|
||||
# of the OS path separator (os.path.relpath uses '\' on Windows)
|
||||
return relative.replace(os.sep, '/')
|
||||
|
||||
@@ -58,8 +58,8 @@ class BrickStatistics:
|
||||
return {
|
||||
'total_cost': overview.get('combined_total_cost') or 0,
|
||||
'average_cost': overview.get('combined_average_cost') or 0,
|
||||
'minimum_cost': overview.get('combined_minimum_cost') or 0,
|
||||
'maximum_cost': overview.get('combined_maximum_cost') or 0,
|
||||
'minimum_cost': float(overview['combined_minimum_cost']) if overview.get('combined_minimum_cost') not in (None, '') else None,
|
||||
'maximum_cost': float(overview['combined_maximum_cost']) if overview.get('combined_maximum_cost') not in (None, '') else None,
|
||||
'items_with_price': overview.get('total_items_with_price') or 0,
|
||||
'sets_with_price': overview.get('sets_with_price') or 0,
|
||||
'total_sets': overview.get('total_sets') or 0,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from typing import Final
|
||||
|
||||
__version__: Final[str] = '1.4.0'
|
||||
__version__: Final[str] = '1.4.2'
|
||||
__database_version__: Final[int] = 27
|
||||
|
||||
@@ -304,6 +304,13 @@ def update_purchase_date(*, id: str):
|
||||
def update_purchase_price(*, id: str):
|
||||
item = IndividualMinifigure().select_by_id(id)
|
||||
purchase_price = request.json.get('value')
|
||||
if purchase_price is not None and str(purchase_price).strip() != '':
|
||||
try:
|
||||
purchase_price = float(purchase_price)
|
||||
except (ValueError, TypeError):
|
||||
purchase_price = None
|
||||
else:
|
||||
purchase_price = None
|
||||
|
||||
BrickSQL().execute_and_commit(
|
||||
'individual_minifigure/update',
|
||||
@@ -314,7 +321,7 @@ def update_purchase_price(*, id: str):
|
||||
'storage': item.fields.storage,
|
||||
'purchase_location': item.fields.purchase_location if hasattr(item.fields, 'purchase_location') else None,
|
||||
'purchase_date': item.fields.purchase_date if hasattr(item.fields, 'purchase_date') else None,
|
||||
'purchase_price': purchase_price if purchase_price else None,
|
||||
'purchase_price': purchase_price,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -311,7 +311,7 @@ def update_purchase_price(*, id: str):
|
||||
purchase_price = request.json.get('value', '')
|
||||
|
||||
# Convert to float if provided, otherwise None
|
||||
if purchase_price and str(purchase_price).strip():
|
||||
if purchase_price is not None and str(purchase_price).strip() != '':
|
||||
try:
|
||||
price = float(purchase_price)
|
||||
item.update_field('purchase_price', price)
|
||||
@@ -662,7 +662,14 @@ def update_lot_purchase_price(*, lot_id: str):
|
||||
|
||||
from ..sql import BrickSQL
|
||||
sql = BrickSQL()
|
||||
sql.execute_and_commit('individual_part_lot/update/purchase_price', parameters={'purchase_price': purchase_price if purchase_price else None, 'id': lot_id})
|
||||
if purchase_price is not None and str(purchase_price).strip() != '':
|
||||
try:
|
||||
purchase_price = float(purchase_price)
|
||||
except (ValueError, TypeError):
|
||||
purchase_price = None
|
||||
else:
|
||||
purchase_price = None
|
||||
sql.execute_and_commit('individual_part_lot/update/purchase_price', parameters={'purchase_price': purchase_price, 'id': lot_id})
|
||||
|
||||
logger.info('Updated lot {lot_id} purchase_price to: {price}'.format(lot_id=lot_id, price=purchase_price))
|
||||
return jsonify({'success': True})
|
||||
|
||||
@@ -147,7 +147,7 @@ def do_upload() -> Response:
|
||||
return redirect(url_for('instructions.list'))
|
||||
|
||||
|
||||
# Download instructions from Rebrickable
|
||||
# Download instructions from LEGO.com
|
||||
@instructions_page.route('/download/', methods=['GET'])
|
||||
@login_required
|
||||
@exception_handler(__file__)
|
||||
@@ -185,11 +185,11 @@ def do_download() -> str:
|
||||
if request.args.get('peeron_loaded'):
|
||||
return _render_peeron_select_page(set)
|
||||
|
||||
# Try Rebrickable first
|
||||
# Try LEGO.com first
|
||||
try:
|
||||
from .instructions import BrickInstructions
|
||||
rebrickable_instructions = BrickInstructions.find_instructions(set)
|
||||
# Standard Rebrickable instructions found
|
||||
# Standard LEGO.com instructions found
|
||||
return render_template(
|
||||
'instructions.html',
|
||||
download=True,
|
||||
@@ -200,7 +200,7 @@ def do_download() -> str:
|
||||
messages=MESSAGES
|
||||
)
|
||||
except Exception:
|
||||
# Rebrickable failed, check if Peeron has instructions (without caching thumbnails yet)
|
||||
# LEGO.com failed, check if Peeron has instructions (without caching thumbnails yet)
|
||||
try:
|
||||
peeron = PeeronInstructions(set)
|
||||
# Just check if pages exist, don't cache thumbnails yet
|
||||
@@ -223,7 +223,7 @@ def do_download() -> str:
|
||||
download=True,
|
||||
instructions=[],
|
||||
set=set,
|
||||
error='No instructions found on Rebrickable or Peeron',
|
||||
error='No instructions found on LEGO.com or Peeron',
|
||||
path=current_app.config['SOCKET_PATH'],
|
||||
namespace=current_app.config['SOCKET_NAMESPACE'],
|
||||
messages=MESSAGES
|
||||
|
||||
+174
-1
@@ -1,4 +1,7 @@
|
||||
import builtins
|
||||
import logging
|
||||
from datetime import datetime
|
||||
from typing import Any
|
||||
|
||||
from flask import (
|
||||
Blueprint,
|
||||
@@ -13,7 +16,7 @@ from flask_login import login_required
|
||||
from werkzeug.wrappers.response import Response
|
||||
|
||||
from .exceptions import exception_handler
|
||||
from ..exceptions import ErrorException
|
||||
from ..exceptions import ErrorException, NotFoundException
|
||||
from ..minifigure import BrickMinifigure
|
||||
from ..pagination_helper import get_pagination_config, build_pagination_context, get_request_params
|
||||
from ..part import BrickPart
|
||||
@@ -26,6 +29,8 @@ from ..set_status_list import BrickSetStatusList
|
||||
from ..set_storage_list import BrickSetStorageList
|
||||
from ..set_tag_list import BrickSetTagList
|
||||
from ..socket import MESSAGES
|
||||
from ..sql import BrickSQL
|
||||
from ..theme_list import BrickThemeList
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -115,6 +120,98 @@ def list() -> str:
|
||||
return render_template('sets.html', **template_context)
|
||||
|
||||
|
||||
# Spreadsheet-style (Tabulator) view of all sets
|
||||
@set_page.route('/table', methods=['GET'])
|
||||
@exception_handler(__file__)
|
||||
def table() -> str:
|
||||
storages = [
|
||||
{'id': item.fields.id, 'name': item.fields.name}
|
||||
for item in BrickSetStorageList.list(as_class=False)
|
||||
]
|
||||
|
||||
purchase_locations = [
|
||||
{'id': item.fields.id, 'name': item.fields.name}
|
||||
for item in BrickSetPurchaseLocationList.list(as_class=False)
|
||||
]
|
||||
|
||||
return render_template(
|
||||
'sets_table.html',
|
||||
brickset_storages=storages,
|
||||
brickset_purchase_locations=purchase_locations,
|
||||
)
|
||||
|
||||
|
||||
# JSON data backing the Tabulator view. Read-only listing: edits are saved
|
||||
# through the existing per-field endpoints (update_storage,
|
||||
# update_purchase_location, update_purchase_date, update_purchase_price,
|
||||
# update_description), the same ones BrickChanger already uses elsewhere.
|
||||
@set_page.route('/table/data', methods=['GET'])
|
||||
@exception_handler(__file__, json=True)
|
||||
def table_data() -> Response:
|
||||
rows = BrickSQL().fetchall(
|
||||
'set/list/tabulator',
|
||||
order='"rebrickable_sets"."name"',
|
||||
)
|
||||
|
||||
themes = BrickThemeList()
|
||||
|
||||
data: builtins.list[dict[str, Any]] = []
|
||||
|
||||
for row in rows:
|
||||
storage_id = row['storage']
|
||||
purchase_location_id = row['purchase_location']
|
||||
theme_id = row['theme_id']
|
||||
|
||||
theme_name = ''
|
||||
if theme_id is not None:
|
||||
try:
|
||||
theme_name = themes.get(int(theme_id)).name
|
||||
except (TypeError, ValueError):
|
||||
theme_name = ''
|
||||
|
||||
storage_name = ''
|
||||
if storage_id:
|
||||
try:
|
||||
storage_name = BrickSetStorageList.get(storage_id).fields.name # noqa: E501
|
||||
except NotFoundException:
|
||||
storage_name = ''
|
||||
|
||||
purchase_location_name = ''
|
||||
if purchase_location_id:
|
||||
try:
|
||||
purchase_location_name = BrickSetPurchaseLocationList.get(
|
||||
purchase_location_id
|
||||
).fields.name
|
||||
except NotFoundException:
|
||||
purchase_location_name = ''
|
||||
|
||||
purchase_date = ''
|
||||
if row['purchase_date']:
|
||||
purchase_date = datetime.fromtimestamp(
|
||||
row['purchase_date']
|
||||
).strftime('%Y/%m/%d')
|
||||
|
||||
data.append({
|
||||
'id': row['id'],
|
||||
'set': row['set'],
|
||||
'name': row['name'],
|
||||
'year': row['year'],
|
||||
'theme_id': theme_id,
|
||||
'theme': theme_name,
|
||||
'number_of_parts': row['number_of_parts'],
|
||||
'image': row['image'],
|
||||
'description': row['description'] or '',
|
||||
'storage_id': storage_id or '',
|
||||
'storage_name': storage_name,
|
||||
'purchase_location_id': purchase_location_id or '',
|
||||
'purchase_location_name': purchase_location_name,
|
||||
'purchase_date': purchase_date,
|
||||
'purchase_price': row['purchase_price'],
|
||||
})
|
||||
|
||||
return jsonify(data)
|
||||
|
||||
|
||||
# Change the value of purchase date
|
||||
@set_page.route('/<id>/purchase_date', methods=['POST'])
|
||||
@login_required
|
||||
@@ -357,6 +454,82 @@ def problem_part(
|
||||
return jsonify({problem: amount})
|
||||
|
||||
|
||||
# Bulk update problematic pieces of a set (e.g. "mark all missing")
|
||||
# Body: {"items": [{"figure": str|None, "part": str, "color": int,
|
||||
# "spare": int, "value": int}, ...]}
|
||||
# All updates run in a single database transaction (one commit for the
|
||||
# whole batch), instead of a fetch per part.
|
||||
@set_page.route('/<id>/parts/bulk/<problem>', methods=['POST'])
|
||||
@login_required
|
||||
@exception_handler(__file__, json=True)
|
||||
def bulk_problem_parts(*, id: str, problem: str) -> Response:
|
||||
brickset = BrickSet().select_specific(id)
|
||||
|
||||
items = (request.json or {}).get('items', []) # type: ignore
|
||||
|
||||
if not isinstance(items, builtins.list):
|
||||
raise ErrorException('"items" must be a list')
|
||||
|
||||
# Cache minifigure lookups so we don't re-select the same one per part
|
||||
minifigure_cache: dict[str, BrickMinifigure] = {}
|
||||
updated: builtins.list[dict[str, Any]] = []
|
||||
|
||||
for item in items:
|
||||
part = item.get('part')
|
||||
color = item.get('color')
|
||||
spare = item.get('spare')
|
||||
figure = item.get('figure')
|
||||
|
||||
if part is None or color is None or spare is None:
|
||||
continue
|
||||
|
||||
if figure is not None:
|
||||
if figure not in minifigure_cache:
|
||||
minifigure_cache[figure] = BrickMinifigure().select_specific(
|
||||
brickset, figure
|
||||
)
|
||||
|
||||
brickminifigure = minifigure_cache[figure]
|
||||
else:
|
||||
brickminifigure = None
|
||||
|
||||
brickpart = BrickPart().select_specific(
|
||||
brickset,
|
||||
part,
|
||||
int(color),
|
||||
int(spare),
|
||||
minifigure=brickminifigure,
|
||||
)
|
||||
|
||||
# Queue the update (commit=False) rather than committing per part
|
||||
amount = brickpart.update_problem(
|
||||
problem,
|
||||
{'value': item.get('value')},
|
||||
commit=False,
|
||||
)
|
||||
|
||||
updated.append({
|
||||
'figure': figure,
|
||||
'part': part,
|
||||
'color': color,
|
||||
'spare': spare,
|
||||
'value': amount,
|
||||
})
|
||||
|
||||
# Commit every queued update in a single transaction
|
||||
BrickSQL().commit()
|
||||
|
||||
# Info
|
||||
logger.info('Set {set} ({id}): bulk updated {count} part(s) {problem}'.format( # noqa: E501
|
||||
set=brickset.fields.set,
|
||||
id=brickset.fields.id,
|
||||
count=len(updated),
|
||||
problem=problem,
|
||||
))
|
||||
|
||||
return jsonify({'updated': updated})
|
||||
|
||||
|
||||
# Update checked state of parts during walkthrough
|
||||
@set_page.route('/<id>/parts/<part>/<int:color>/<int:spare>/checked', defaults={'figure': None}, methods=['POST']) # noqa: E501
|
||||
@set_page.route('/<id>/minifigures/<figure>/parts/<part>/<int:color>/<int:spare>/checked', methods=['POST']) # noqa: E501
|
||||
|
||||
+6
-64
@@ -1,6 +1,6 @@
|
||||
// Add page - handles both sets and individual minifigures
|
||||
// Server auto-routes fig- numbers to IndividualMinifigure via LOAD_SET / IMPORT_SET
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
// Initialize date pickers
|
||||
document.querySelectorAll('[data-add-date="true"]').forEach(el => {
|
||||
new Datepicker(el, {
|
||||
buttonClass: 'btn',
|
||||
@@ -8,81 +8,23 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
});
|
||||
});
|
||||
|
||||
// Get template data from data attributes
|
||||
const addContainer = document.getElementById('add-set');
|
||||
if (!addContainer) return;
|
||||
|
||||
// Read data from data attributes
|
||||
const templateData = {
|
||||
path: addContainer.dataset.path,
|
||||
namespace: addContainer.dataset.namespace,
|
||||
messages: {
|
||||
new BrickSetSocket(
|
||||
'add',
|
||||
addContainer.dataset.path,
|
||||
addContainer.dataset.namespace,
|
||||
{
|
||||
COMPLETE: addContainer.dataset.msgComplete,
|
||||
FAIL: addContainer.dataset.msgFail,
|
||||
IMPORT_SET: addContainer.dataset.msgImportSet,
|
||||
LOAD_SET: addContainer.dataset.msgLoadSet,
|
||||
PROGRESS: addContainer.dataset.msgProgress,
|
||||
SET_LOADED: addContainer.dataset.msgSetLoaded,
|
||||
IMPORT_MINIFIGURE: addContainer.dataset.msgImportMinifigure,
|
||||
LOAD_MINIFIGURE: addContainer.dataset.msgLoadMinifigure,
|
||||
MINIFIGURE_LOADED: addContainer.dataset.msgMinifigureLoaded,
|
||||
}
|
||||
};
|
||||
|
||||
// Default: create set socket
|
||||
const setSocket = new BrickSetSocket(
|
||||
'add',
|
||||
templateData.path,
|
||||
templateData.namespace,
|
||||
{
|
||||
COMPLETE: templateData.messages.COMPLETE,
|
||||
FAIL: templateData.messages.FAIL,
|
||||
IMPORT_SET: templateData.messages.IMPORT_SET,
|
||||
LOAD_SET: templateData.messages.LOAD_SET,
|
||||
PROGRESS: templateData.messages.PROGRESS,
|
||||
SET_LOADED: templateData.messages.SET_LOADED,
|
||||
},
|
||||
false,
|
||||
false
|
||||
);
|
||||
|
||||
// Override the execute method to check for minifigures
|
||||
const originalExecute = setSocket.execute.bind(setSocket);
|
||||
let minifigSocket = null;
|
||||
|
||||
setSocket.execute = function() {
|
||||
const inputValue = document.getElementById('add-set').value.trim();
|
||||
|
||||
if (inputValue.startsWith('fig-') || inputValue.match(/^fig\d/i)) {
|
||||
// It's a minifigure - create minifig socket if needed and execute when ready
|
||||
if (!minifigSocket) {
|
||||
minifigSocket = new BrickMinifigureSocket(
|
||||
'add',
|
||||
templateData.path,
|
||||
templateData.namespace,
|
||||
{
|
||||
COMPLETE: templateData.messages.COMPLETE,
|
||||
FAIL: templateData.messages.FAIL,
|
||||
IMPORT_MINIFIGURE: templateData.messages.IMPORT_MINIFIGURE,
|
||||
LOAD_MINIFIGURE: templateData.messages.LOAD_MINIFIGURE,
|
||||
MINIFIGURE_LOADED: templateData.messages.MINIFIGURE_LOADED,
|
||||
PROGRESS: templateData.messages.PROGRESS,
|
||||
}
|
||||
);
|
||||
|
||||
// Wait for socket to connect before executing
|
||||
const checkConnection = setInterval(() => {
|
||||
if (minifigSocket.socket && minifigSocket.socket.connected) {
|
||||
clearInterval(checkConnection);
|
||||
minifigSocket.execute();
|
||||
}
|
||||
}, 100);
|
||||
} else {
|
||||
minifigSocket.execute();
|
||||
}
|
||||
} else {
|
||||
// It's a set - use original execute
|
||||
originalExecute();
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
@@ -204,14 +204,20 @@ function setupButtonHandlers() {
|
||||
});
|
||||
}
|
||||
|
||||
// Reset button
|
||||
// Reset button. Opens Bootstrap modal instead of browser confirm()
|
||||
const resetBtn = document.getElementById('config-reset');
|
||||
if (resetBtn) {
|
||||
resetBtn.addEventListener('click', () => {
|
||||
console.log('Reset clicked');
|
||||
if (confirm('Are you sure you want to reset all settings to default values? This action cannot be undone.')) {
|
||||
resetToDefaults();
|
||||
}
|
||||
const modal = new bootstrap.Modal(document.getElementById('resetDefaultsModal'));
|
||||
modal.show();
|
||||
});
|
||||
}
|
||||
|
||||
// Confirm reset inside the modal
|
||||
const confirmResetBtn = document.getElementById('confirm-reset-defaults');
|
||||
if (confirmResetBtn) {
|
||||
confirmResetBtn.addEventListener('click', () => {
|
||||
resetToDefaults();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -285,18 +291,21 @@ function saveLiveConfiguration() {
|
||||
function resetToDefaults() {
|
||||
console.log('Resetting to defaults');
|
||||
|
||||
// Reset all form inputs
|
||||
document.querySelectorAll('.config-toggle, .config-number, .config-text').forEach(input => {
|
||||
if (input.type === 'checkbox') {
|
||||
input.checked = false;
|
||||
} else {
|
||||
input.value = '';
|
||||
}
|
||||
});
|
||||
Object.keys(window.DEFAULT_CONFIG).forEach(varName => {
|
||||
const defaultValue = window.DEFAULT_CONFIG[varName];
|
||||
|
||||
// Update badges
|
||||
Object.keys(window.CURRENT_CONFIG).forEach(varName => {
|
||||
updateConfigBadge(varName, null);
|
||||
const toggle = document.getElementById(varName);
|
||||
if (toggle && toggle.type === 'checkbox') {
|
||||
toggle.checked = defaultValue === true;
|
||||
}
|
||||
|
||||
document.querySelectorAll(`input[data-var="${varName}"]:not(.config-static)`).forEach(input => {
|
||||
if (input.type !== 'checkbox') {
|
||||
input.value = defaultValue !== null && defaultValue !== undefined ? defaultValue : '';
|
||||
}
|
||||
});
|
||||
|
||||
updateConfigBadge(varName, defaultValue);
|
||||
});
|
||||
|
||||
// Show status message
|
||||
|
||||
@@ -55,6 +55,10 @@ class BrickChanger {
|
||||
this.html_clear.addEventListener("click", ((changer) => (e) => {
|
||||
changer.html_element.value = "";
|
||||
changer.change();
|
||||
// change() only POSTs to the server; dispatch an input event so
|
||||
// client-side listeners (e.g. the parts table filter) react to
|
||||
// the programmatic clear the same way they do to typing.
|
||||
changer.html_element.dispatchEvent(new Event("input", { bubbles: true }));
|
||||
})(this));
|
||||
}
|
||||
|
||||
|
||||
@@ -103,43 +103,132 @@ class PartsBulkOperations {
|
||||
modalInstance.show();
|
||||
}
|
||||
|
||||
markAllMissing() {
|
||||
// Parses BrickChanger's per-row "missing" URL to recover the pieces
|
||||
// needed to build a bulk request: the leading path prefix (for
|
||||
// subpath deployments), the set id, and the part's identity
|
||||
// (figure/part/color/spare). Returns null if the URL doesn't match.
|
||||
//
|
||||
// Matches URLs generated by url_for('set.problem_part', ...), e.g.
|
||||
// /sets/<id>/parts/<part>/<color>/<spare>/missing
|
||||
// /sets/<id>/minifigures/<figure>/parts/<part>/<color>/<spare>/missing
|
||||
static MISSING_URL_PATTERN = /^(.*?)\/sets\/([^/]+)\/(?:minifigures\/([^/]+)\/)?parts\/([^/]+)\/([^/]+)\/([^/]+)\/missing$/;
|
||||
|
||||
// Send one bulk request updating every part's missing count in a
|
||||
// single call, instead of one fetch per row. Reloads the page once
|
||||
// the save is confirmed; shows an alert and does NOT reload on
|
||||
// failure, so a failed save is never silently discarded.
|
||||
_bulkUpdateMissing(items, urlPrefix, setId, actionLabel) {
|
||||
if (!items.length || !setId) return;
|
||||
|
||||
fetch(`${urlPrefix}/sets/${setId}/parts/bulk/missing`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ items }),
|
||||
})
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
throw new Error(`Response status: ${response.status} (${response.statusText})`);
|
||||
}
|
||||
return response.json();
|
||||
})
|
||||
.then(json => {
|
||||
// The app's error handler returns HTTP 200 with an "error"
|
||||
// key for validation/application errors, not a 4xx status.
|
||||
if (json && 'error' in json) {
|
||||
throw new Error(json.error);
|
||||
}
|
||||
|
||||
// Only refresh once the save is confirmed, so all derived
|
||||
// totals (missing counts, etc.) reflect the new state.
|
||||
window.location.reload();
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(`Bulk ${actionLabel} failed:`, error);
|
||||
alert(`Failed to save "${actionLabel}": ${error.message}`);
|
||||
});
|
||||
}
|
||||
|
||||
// Walks the rows of this accordion, calling collect(missingInput,
|
||||
// quantityCell) for each visible row that has both a quantity cell
|
||||
// and a "missing" input. collect should return the desired new value
|
||||
// (a number) to set, or null/undefined to skip that row.
|
||||
_collectMissingItems(collect) {
|
||||
const accordionElement = document.getElementById(this.accordionId);
|
||||
if (!accordionElement) return;
|
||||
if (!accordionElement) return { items: [], urlPrefix: '', setId: null };
|
||||
|
||||
// Find all rows in this accordion
|
||||
const rows = accordionElement.querySelectorAll('tbody tr');
|
||||
const items = [];
|
||||
let setId = null;
|
||||
let urlPrefix = '';
|
||||
|
||||
rows.forEach(row => {
|
||||
// Skip rows hidden by an active header filter
|
||||
if (row.classList.contains('parts-filtered-out')) return;
|
||||
|
||||
// Find the quantity cell (usually 4th column)
|
||||
const quantityCell = row.cells[3]; // Index 3 for quantity column
|
||||
const missingInput = row.querySelector('input[id*="-missing-"]');
|
||||
|
||||
if (quantityCell && missingInput) {
|
||||
// Extract quantity from cell text content
|
||||
const quantityText = quantityCell.textContent.trim();
|
||||
const quantity = parseInt(quantityText) || 1; // Default to 1 if can't parse
|
||||
if (!quantityCell || !missingInput) return;
|
||||
|
||||
if (missingInput.value !== quantity.toString()) {
|
||||
missingInput.value = quantity.toString();
|
||||
// Trigger change event to activate BrickChanger
|
||||
missingInput.dispatchEvent(new Event('change', { bubbles: true }));
|
||||
}
|
||||
const newValue = collect(missingInput, quantityCell);
|
||||
|
||||
if (newValue === null || newValue === undefined) return;
|
||||
|
||||
// Pull (id, figure, part, color, spare) straight out of the
|
||||
// per-row URL that BrickChanger already uses, so we don't need
|
||||
// any new data attributes in the template.
|
||||
const match = (missingInput.dataset.changerUrl || '').match(
|
||||
PartsBulkOperations.MISSING_URL_PATTERN
|
||||
);
|
||||
|
||||
if (!match) {
|
||||
console.warn('Could not parse changer URL for a row, skipping it', missingInput);
|
||||
return;
|
||||
}
|
||||
|
||||
const [, prefix, id, figure, part, color, spare] = match;
|
||||
setId = id;
|
||||
urlPrefix = prefix;
|
||||
|
||||
// Reflect the new value in the UI immediately
|
||||
missingInput.value = newValue.toString();
|
||||
|
||||
items.push({
|
||||
figure: figure || null,
|
||||
part: part,
|
||||
color: parseInt(color, 10),
|
||||
spare: parseInt(spare, 10),
|
||||
value: newValue,
|
||||
});
|
||||
});
|
||||
|
||||
return { items, urlPrefix, setId };
|
||||
}
|
||||
|
||||
markAllMissing() {
|
||||
const { items, urlPrefix, setId } = this._collectMissingItems((missingInput, quantityCell) => {
|
||||
const quantityText = quantityCell.textContent.trim();
|
||||
const quantity = parseInt(quantityText) || 1; // Default to 1 if can't parse
|
||||
|
||||
if (missingInput.value === quantity.toString()) return null;
|
||||
|
||||
return quantity;
|
||||
});
|
||||
|
||||
this._bulkUpdateMissing(items, urlPrefix, setId, 'mark all missing');
|
||||
}
|
||||
|
||||
clearAllMissing() {
|
||||
const accordionElement = document.getElementById(this.accordionId);
|
||||
if (!accordionElement) return;
|
||||
const { items, urlPrefix, setId } = this._collectMissingItems((missingInput) => {
|
||||
if (missingInput.value === '' || missingInput.value === '0') return null;
|
||||
|
||||
const missingInputs = accordionElement.querySelectorAll('input[id*="-missing-"]');
|
||||
missingInputs.forEach(input => {
|
||||
if (input.value !== '') {
|
||||
input.value = '';
|
||||
// Trigger change event to activate BrickChanger
|
||||
input.dispatchEvent(new Event('change', { bubbles: true }));
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
this._bulkUpdateMissing(items, urlPrefix, setId, 'clear all missing');
|
||||
}
|
||||
|
||||
checkAll() {
|
||||
@@ -148,6 +237,7 @@ class PartsBulkOperations {
|
||||
|
||||
const checkboxes = accordionElement.querySelectorAll('input[id*="-checked-"][type="checkbox"]');
|
||||
checkboxes.forEach(checkbox => {
|
||||
if (checkbox.closest('tr')?.classList.contains('parts-filtered-out')) return;
|
||||
if (!checkbox.checked) {
|
||||
checkbox.checked = true;
|
||||
// Trigger change event to activate BrickChanger
|
||||
@@ -162,6 +252,7 @@ class PartsBulkOperations {
|
||||
|
||||
const checkboxes = accordionElement.querySelectorAll('input[id*="-checked-"][type="checkbox"]');
|
||||
checkboxes.forEach(checkbox => {
|
||||
if (checkbox.closest('tr')?.classList.contains('parts-filtered-out')) return;
|
||||
if (checkbox.checked) {
|
||||
checkbox.checked = false;
|
||||
// Trigger change event to activate BrickChanger
|
||||
|
||||
@@ -0,0 +1,186 @@
|
||||
// Per-column header filters for the accordion parts tables on the set details page.
|
||||
class PartsTableFilter {
|
||||
constructor(table) {
|
||||
this.table = table;
|
||||
this.body = table.querySelector('tbody');
|
||||
this.rows = Array.from(this.body ? this.body.querySelectorAll('tr') : []);
|
||||
|
||||
this.nameInput = table.querySelector('[data-parts-filter="name"]');
|
||||
this.colorSelect = table.querySelector('[data-parts-filter="color"]');
|
||||
this.missingSelect = table.querySelector('[data-parts-filter="missing"]');
|
||||
this.damagedSelect = table.querySelector('[data-parts-filter="damaged"]');
|
||||
this.checkedSelect = table.querySelector('[data-parts-filter="checked"]');
|
||||
this.clearButton = table.querySelector('[data-parts-filter-clear]');
|
||||
|
||||
this.setupListeners();
|
||||
this.apply();
|
||||
}
|
||||
|
||||
setupListeners() {
|
||||
const debouncedApply = this.debounce(() => this.apply(), 150);
|
||||
|
||||
// Name search is debounced so typing stays smooth on big tables.
|
||||
if (this.nameInput) {
|
||||
this.nameInput.addEventListener('input', debouncedApply);
|
||||
}
|
||||
|
||||
// Dropdowns re-filter immediately.
|
||||
[this.colorSelect, this.missingSelect, this.damagedSelect, this.checkedSelect].forEach(select => {
|
||||
if (select) {
|
||||
select.addEventListener('change', () => this.apply());
|
||||
}
|
||||
});
|
||||
|
||||
if (this.clearButton) {
|
||||
this.clearButton.addEventListener('click', (e) => {
|
||||
e.stopPropagation();
|
||||
this.clear();
|
||||
});
|
||||
}
|
||||
|
||||
// Live re-evaluation: editing a missing/damaged value or toggling a
|
||||
// checkbox in the body should re-run the active filter.
|
||||
if (this.body) {
|
||||
this.body.addEventListener('change', () => this.apply());
|
||||
this.body.addEventListener('input', debouncedApply);
|
||||
}
|
||||
}
|
||||
|
||||
cellText(row, col) {
|
||||
const cell = row.querySelector(`[data-col="${col}"]`);
|
||||
if (!cell) {
|
||||
return '';
|
||||
}
|
||||
const sort = cell.getAttribute('data-sort');
|
||||
return (sort !== null ? sort : cell.textContent).trim().toLowerCase();
|
||||
}
|
||||
|
||||
// Numeric value for missing/damaged, reading the live input when present.
|
||||
cellNumber(row, col) {
|
||||
const cell = row.querySelector(`[data-col="${col}"]`);
|
||||
if (!cell) {
|
||||
return 0;
|
||||
}
|
||||
const input = cell.querySelector('input');
|
||||
const raw = input ? input.value : (cell.getAttribute('data-sort') || cell.textContent);
|
||||
const value = parseInt(raw, 10);
|
||||
return Number.isNaN(value) ? 0 : value;
|
||||
}
|
||||
|
||||
rowChecked(row) {
|
||||
const cell = row.querySelector('[data-col="checked"]');
|
||||
if (!cell) {
|
||||
return false;
|
||||
}
|
||||
const checkbox = cell.querySelector('input[type="checkbox"]');
|
||||
if (checkbox) {
|
||||
return checkbox.checked;
|
||||
}
|
||||
return cell.getAttribute('data-sort') === '1';
|
||||
}
|
||||
|
||||
matchesNumberFilter(value, mode) {
|
||||
if (mode === 'with') {
|
||||
return value > 0;
|
||||
}
|
||||
if (mode === 'without') {
|
||||
return value === 0;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
apply() {
|
||||
const nameTerm = (this.nameInput ? this.nameInput.value : '').trim().toLowerCase();
|
||||
const colorValue = (this.colorSelect ? this.colorSelect.value : '').trim().toLowerCase();
|
||||
const missingMode = this.missingSelect ? this.missingSelect.value : '';
|
||||
const damagedMode = this.damagedSelect ? this.damagedSelect.value : '';
|
||||
const checkedValue = this.checkedSelect ? this.checkedSelect.value : '';
|
||||
|
||||
// Colors available among rows that pass every filter except color, so
|
||||
// the picker only offers colors still present in the current results.
|
||||
const availableColors = new Set();
|
||||
let visibleCount = 0;
|
||||
|
||||
this.rows.forEach(row => {
|
||||
const passNonColor =
|
||||
(!nameTerm || this.cellText(row, 'name').includes(nameTerm)) &&
|
||||
this.matchesNumberFilter(this.cellNumber(row, 'missing'), missingMode) &&
|
||||
this.matchesNumberFilter(this.cellNumber(row, 'damaged'), damagedMode) &&
|
||||
(checkedValue === '' ||
|
||||
(checkedValue === '1' ? this.rowChecked(row) : !this.rowChecked(row)));
|
||||
|
||||
if (passNonColor) {
|
||||
const colorCell = row.querySelector('[data-col="color"]');
|
||||
if (colorCell) {
|
||||
const name = colorCell.textContent.trim();
|
||||
if (name) {
|
||||
availableColors.add(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const passColor = !colorValue || this.cellText(row, 'color') === colorValue;
|
||||
const visible = passNonColor && passColor;
|
||||
row.classList.toggle('parts-filtered-out', !visible);
|
||||
if (visible) {
|
||||
visibleCount += 1;
|
||||
}
|
||||
});
|
||||
|
||||
this.updateColorOptions(availableColors);
|
||||
this.updateEmptyState(visibleCount);
|
||||
}
|
||||
|
||||
// Rebuild the color dropdown from the colors currently in the results,
|
||||
// keeping the user's current selection if it is still available.
|
||||
updateColorOptions(colors) {
|
||||
if (!this.colorSelect) {
|
||||
return;
|
||||
}
|
||||
const current = this.colorSelect.value;
|
||||
const sorted = Array.from(colors).sort((a, b) => a.localeCompare(b));
|
||||
const options = ['<option value="">All colors</option>']
|
||||
.concat(sorted.map(name => `<option value="${name.toLowerCase()}">${name}</option>`));
|
||||
this.colorSelect.innerHTML = options.join('');
|
||||
// Restore selection (the <option> values are lowercased to match).
|
||||
this.colorSelect.value = sorted.some(n => n.toLowerCase() === current) ? current : '';
|
||||
}
|
||||
|
||||
updateEmptyState(visibleCount) {
|
||||
if (!this.body) {
|
||||
return;
|
||||
}
|
||||
if (!this.emptyRow) {
|
||||
const columns = this.table.querySelectorAll('thead tr:first-child th').length || 1;
|
||||
this.emptyRow = document.createElement('tr');
|
||||
this.emptyRow.className = 'parts-filter-empty no-sort';
|
||||
this.emptyRow.innerHTML = `<td colspan="${columns}" class="text-center text-body-secondary py-3">No matching parts</td>`;
|
||||
this.body.appendChild(this.emptyRow);
|
||||
}
|
||||
this.emptyRow.style.display = visibleCount === 0 ? '' : 'none';
|
||||
}
|
||||
|
||||
clear() {
|
||||
if (this.nameInput) { this.nameInput.value = ''; }
|
||||
[this.colorSelect, this.missingSelect, this.damagedSelect, this.checkedSelect].forEach(select => {
|
||||
if (select) {
|
||||
select.value = '';
|
||||
}
|
||||
});
|
||||
this.apply();
|
||||
}
|
||||
|
||||
debounce(fn, wait) {
|
||||
let timer = null;
|
||||
return (...args) => {
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(() => fn.apply(this, args), wait);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
document.querySelectorAll('table[data-parts-filterable="true"]').forEach(table => {
|
||||
new PartsTableFilter(table);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,254 @@
|
||||
// Tabulator-based spreadsheet view for sets
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const tableElement = document.getElementById('sets-table');
|
||||
if (!tableElement) return;
|
||||
|
||||
const urls = JSON.parse(document.getElementById('sets-table-urls').textContent);
|
||||
const storages = JSON.parse(document.getElementById('sets-table-storages').textContent);
|
||||
const purchaseLocations = JSON.parse(document.getElementById('sets-table-purchase-locations').textContent);
|
||||
|
||||
// id -> name lookups, used by both the cell formatter and the select editor
|
||||
const storageNames = Object.fromEntries(storages.map(s => [s.id, s.name]));
|
||||
const purchaseLocationNames = Object.fromEntries(purchaseLocations.map(p => [p.id, p.name]));
|
||||
|
||||
// Tabulator's "list" editor wants {value, label} pairs. The actual
|
||||
// "no storage"/"no purchase location" data value is '', but Tabulator's
|
||||
// list HEADER FILTER treats an empty-string filter value as "cleared"
|
||||
// (i.e. no filter applied), so that option would be indistinguishable
|
||||
// from clearing the filter. Use a non-empty sentinel for filtering
|
||||
// instead, paired with a custom headerFilterFunc below.
|
||||
const NONE_SENTINEL = '__none__';
|
||||
|
||||
const storageOptions = [
|
||||
{ value: '', label: 'No storage' },
|
||||
...storages.map(s => ({ value: s.id, label: s.name })),
|
||||
];
|
||||
const purchaseLocationOptions = [
|
||||
{ value: '', label: 'No purchase location' },
|
||||
...purchaseLocations.map(p => ({ value: p.id, label: p.name })),
|
||||
];
|
||||
const storageFilterOptions = [
|
||||
{ value: NONE_SENTINEL, label: 'No storage' },
|
||||
...storages.map(s => ({ value: s.id, label: s.name })),
|
||||
];
|
||||
const purchaseLocationFilterOptions = [
|
||||
{ value: NONE_SENTINEL, label: 'No purchase location' },
|
||||
...purchaseLocations.map(p => ({ value: p.id, label: p.name })),
|
||||
];
|
||||
|
||||
// Matches the sentinel against an empty row value, otherwise exact match
|
||||
function noneAwareFilter(headerValue, rowValue) {
|
||||
if (headerValue === NONE_SENTINEL) return !rowValue;
|
||||
return rowValue === headerValue;
|
||||
}
|
||||
|
||||
// Column field names (storage_id, purchase_location_id, ...) don't
|
||||
// always match the URL keys (storage, purchase_location, ...), so map
|
||||
// between them explicitly instead of assuming they're identical.
|
||||
const fieldToUrlKey = {
|
||||
description: 'description',
|
||||
storage_id: 'storage',
|
||||
purchase_location_id: 'purchase_location',
|
||||
purchase_date: 'purchase_date',
|
||||
purchase_price: 'purchase_price',
|
||||
};
|
||||
|
||||
// Build the save URL for a field on a given row (swap in the real id)
|
||||
function urlFor(urlKey, id) {
|
||||
return urls[urlKey].replace('ID_PLACEHOLDER', id);
|
||||
}
|
||||
|
||||
// Save one field for one row. On failure, revert the cell and alert -
|
||||
// never silently keep an edit that didn't actually persist.
|
||||
function saveField(cell) {
|
||||
const field = cell.getColumn().getField();
|
||||
const urlKey = fieldToUrlKey[field];
|
||||
const row = cell.getRow().getData();
|
||||
const id = row.id;
|
||||
const value = cell.getValue();
|
||||
|
||||
if (!urlKey || !(urlKey in urls)) {
|
||||
console.warn(`No save URL configured for field "${field}", skipping save`);
|
||||
return;
|
||||
}
|
||||
|
||||
fetch(urlFor(urlKey, id), {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ value: value }),
|
||||
})
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
throw new Error(`Response status: ${response.status} (${response.statusText})`);
|
||||
}
|
||||
return response.json();
|
||||
})
|
||||
.then(json => {
|
||||
// The app's error handler returns HTTP 200 with an "error"
|
||||
// key for validation/application errors, not a 4xx status.
|
||||
if (json && 'error' in json) {
|
||||
throw new Error(json.error);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(`Failed to save "${field}":`, error);
|
||||
alert(`Failed to save "${field}": ${error.message}`);
|
||||
cell.restoreOldValue();
|
||||
});
|
||||
}
|
||||
|
||||
const table = new Tabulator('#sets-table', {
|
||||
ajaxURL: urls.data,
|
||||
layout: 'fitDataFill',
|
||||
height: '75vh',
|
||||
variableHeight: true,
|
||||
pagination: true,
|
||||
paginationSize: 50,
|
||||
paginationSizeSelector: [25, 50, 100, 250, true],
|
||||
movableColumns: true,
|
||||
columns: [
|
||||
{
|
||||
title: '',
|
||||
field: 'image',
|
||||
width: 80,
|
||||
minWidth: 40,
|
||||
resizable: true,
|
||||
hozAlign: 'center',
|
||||
headerSort: false,
|
||||
frozen: true,
|
||||
formatter: (cell) => {
|
||||
const url = cell.getValue();
|
||||
if (!url) return '';
|
||||
return `<img src="${url}" alt="" style="width: 100%; height: auto; display: block;">`;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'Set',
|
||||
field: 'set',
|
||||
width: 100,
|
||||
headerFilter: 'input',
|
||||
formatter: (cell) => {
|
||||
const row = cell.getRow().getData();
|
||||
const url = urlFor('details', row.id);
|
||||
const value = cell.getValue() ?? '';
|
||||
return `<a href="${url}">${value}</a>`;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'Name',
|
||||
field: 'name',
|
||||
width: 250,
|
||||
headerFilter: 'input',
|
||||
},
|
||||
{
|
||||
title: 'Year',
|
||||
field: 'year',
|
||||
width: 90,
|
||||
hozAlign: 'right',
|
||||
headerFilter: 'list',
|
||||
headerFilterParams: { valuesLookup: true, clearable: true },
|
||||
headerFilterFunc: '=',
|
||||
},
|
||||
{
|
||||
title: 'Theme',
|
||||
field: 'theme',
|
||||
width: 150,
|
||||
headerFilter: 'list',
|
||||
headerFilterParams: { valuesLookup: true, clearable: true },
|
||||
headerFilterFunc: '=',
|
||||
},
|
||||
{
|
||||
title: 'Parts',
|
||||
field: 'number_of_parts',
|
||||
width: 90,
|
||||
hozAlign: 'right',
|
||||
headerFilter: 'input',
|
||||
},
|
||||
{
|
||||
title: 'Description',
|
||||
field: 'description',
|
||||
width: 220,
|
||||
editor: 'input',
|
||||
headerFilter: 'input',
|
||||
cellEdited: saveField,
|
||||
},
|
||||
{
|
||||
title: 'Storage',
|
||||
field: 'storage_id',
|
||||
width: 160,
|
||||
editor: 'list',
|
||||
editorParams: { values: storageOptions },
|
||||
headerFilter: 'list',
|
||||
headerFilterParams: { values: storageFilterOptions, clearable: true },
|
||||
headerFilterFunc: noneAwareFilter,
|
||||
formatter: (cell) => storageNames[cell.getValue()] || '',
|
||||
cellEdited: saveField,
|
||||
},
|
||||
{
|
||||
title: 'Purchase location',
|
||||
field: 'purchase_location_id',
|
||||
width: 160,
|
||||
editor: 'list',
|
||||
editorParams: { values: purchaseLocationOptions },
|
||||
headerFilter: 'list',
|
||||
headerFilterParams: { values: purchaseLocationFilterOptions, clearable: true },
|
||||
headerFilterFunc: noneAwareFilter,
|
||||
formatter: (cell) => purchaseLocationNames[cell.getValue()] || '',
|
||||
cellEdited: saveField,
|
||||
},
|
||||
{
|
||||
title: 'Purchase date',
|
||||
field: 'purchase_date',
|
||||
width: 130,
|
||||
editor: 'input',
|
||||
editorParams: { elementAttributes: { placeholder: 'YYYY/MM/DD' } },
|
||||
cellEdited: saveField,
|
||||
},
|
||||
{
|
||||
title: 'Purchase price',
|
||||
field: 'purchase_price',
|
||||
width: 130,
|
||||
hozAlign: 'right',
|
||||
editor: 'number',
|
||||
editorParams: { step: 0.01 },
|
||||
cellEdited: saveField,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const clearFiltersButton = document.getElementById('sets-table-clear-filters');
|
||||
if (clearFiltersButton) {
|
||||
clearFiltersButton.addEventListener('click', () => {
|
||||
table.clearHeaderFilter();
|
||||
});
|
||||
}
|
||||
|
||||
table.on('columnResized', (column) => {
|
||||
if (column.getField() === 'image') {
|
||||
table.getRows().forEach((row) => row.normalizeHeight());
|
||||
}
|
||||
});
|
||||
|
||||
table.on('renderComplete', () => {
|
||||
const images = tableElement.querySelectorAll('.tabulator-cell img');
|
||||
const pending = [];
|
||||
|
||||
images.forEach((img) => {
|
||||
if (!img.complete) {
|
||||
pending.push(new Promise((resolve) => {
|
||||
img.addEventListener('load', resolve, { once: true });
|
||||
img.addEventListener('error', resolve, { once: true }); // don't hang forever on a broken thumbnail
|
||||
}));
|
||||
}
|
||||
});
|
||||
|
||||
if (pending.length) {
|
||||
Promise.all(pending).then(() => {
|
||||
table.getRows().forEach((row) => row.normalizeHeight());
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
@@ -13,9 +13,12 @@ class BrickMinifigureSocket extends BrickSocket {
|
||||
this.html_input = document.getElementById(`${id}-set`);
|
||||
this.html_no_confim = document.getElementById(`${id}-no-confirm`);
|
||||
this.html_owners = document.getElementById(`${id}-owners`);
|
||||
this.html_purchase_date = document.getElementById(`${id}-purchase-date`);
|
||||
this.html_purchase_price = document.getElementById(`${id}-purchase-price`);
|
||||
this.html_purchase_location = document.getElementById(`${id}-purchase-location`);
|
||||
this.html_storage = document.getElementById(`${id}-storage`);
|
||||
this.html_tags = document.getElementById(`${id}-tags`);
|
||||
this.html_description = document.getElementById(`${id}-description`);
|
||||
|
||||
// Card elements
|
||||
this.html_card = document.getElementById(`${id}-card`);
|
||||
@@ -98,12 +101,28 @@ class BrickMinifigureSocket extends BrickSocket {
|
||||
});
|
||||
}
|
||||
|
||||
// Grab the purchase location
|
||||
// Grab the purchase info
|
||||
let purchase_date = null;
|
||||
if (this.html_purchase_date) {
|
||||
purchase_date = this.html_purchase_date.value || null;
|
||||
}
|
||||
|
||||
let purchase_price = null;
|
||||
if (this.html_purchase_price) {
|
||||
purchase_price = this.html_purchase_price.value || null;
|
||||
}
|
||||
|
||||
let purchase_location = null;
|
||||
if (this.html_purchase_location) {
|
||||
purchase_location = this.html_purchase_location.value;
|
||||
}
|
||||
|
||||
// Grab the description (notes)
|
||||
let description = '';
|
||||
if (this.html_description) {
|
||||
description = this.html_description.value || '';
|
||||
}
|
||||
|
||||
// Grab the storage
|
||||
let storage = null;
|
||||
if (this.html_storage) {
|
||||
@@ -129,9 +148,12 @@ class BrickMinifigureSocket extends BrickSocket {
|
||||
this.socket.emit(this.messages.IMPORT_MINIFIGURE, {
|
||||
figure: (figure !== undefined) ? figure : this.html_input.value,
|
||||
owners: owners,
|
||||
purchase_date: purchase_date,
|
||||
purchase_price: purchase_price,
|
||||
purchase_location: purchase_location,
|
||||
storage: storage,
|
||||
tags: tags,
|
||||
description: description,
|
||||
quantity: 1
|
||||
});
|
||||
} else {
|
||||
@@ -235,10 +257,22 @@ class BrickMinifigureSocket extends BrickSocket {
|
||||
this.html_owners.querySelectorAll('input').forEach(input => input.disabled = !enabled);
|
||||
}
|
||||
|
||||
if (this.html_purchase_date) {
|
||||
this.html_purchase_date.disabled = !enabled;
|
||||
}
|
||||
|
||||
if (this.html_purchase_price) {
|
||||
this.html_purchase_price.disabled = !enabled;
|
||||
}
|
||||
|
||||
if (this.html_purchase_location) {
|
||||
this.html_purchase_location.disabled = !enabled;
|
||||
}
|
||||
|
||||
if (this.html_description) {
|
||||
this.html_description.disabled = !enabled;
|
||||
}
|
||||
|
||||
if (this.html_storage) {
|
||||
this.html_storage.disabled = !enabled;
|
||||
}
|
||||
|
||||
@@ -331,3 +331,18 @@
|
||||
background-color: #e9ecef;
|
||||
border-color: #dee2e6;
|
||||
}
|
||||
|
||||
/* Accordion parts table header filters */
|
||||
.parts-filter-row > th {
|
||||
padding: 0.35rem 0.5rem;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.parts-filter-row .parts-filter-input,
|
||||
.parts-filter-row .parts-filter-select {
|
||||
min-width: 6rem;
|
||||
}
|
||||
|
||||
tr.parts-filtered-out {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@@ -1019,6 +1019,32 @@
|
||||
</div>
|
||||
{{ accordion.footer() }}
|
||||
|
||||
<!-- Reset to Defaults Confirmation Modal -->
|
||||
<div class="modal fade" id="resetDefaultsModal" tabindex="-1" aria-labelledby="resetDefaultsModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header bg-warning">
|
||||
<h5 class="modal-title" id="resetDefaultsModalLabel">
|
||||
<i class="ri-restart-line"></i> Reset to Defaults
|
||||
</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>This will reset all live settings to their default values.</p>
|
||||
<p class="text-muted small"><i class="ri-information-line"></i> Changes are not saved until you click <strong>Save All Changes</strong>.</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">
|
||||
<i class="ri-close-line"></i> Cancel
|
||||
</button>
|
||||
<button type="button" class="btn btn-warning" id="confirm-reset-defaults" data-bs-dismiss="modal">
|
||||
<i class="ri-restart-line"></i> Reset to Defaults
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Initialize Configuration Data -->
|
||||
<script type="text/javascript">
|
||||
window.CURRENT_CONFIG = {
|
||||
|
||||
@@ -10,9 +10,11 @@
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/simple-datatables@9.2.1/dist/style.min.css">
|
||||
<link href="https://cdn.jsdelivr.net/npm/remixicon@4.6.0/fonts/remixicon.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/vanillajs-datepicker@1.3.4/dist/css/datepicker-bs5.min.css">
|
||||
<link href="https://cdn.jsdelivr.net/npm/tabulator-tables@6.4.0/dist/css/tabulator.min.css" rel="stylesheet">
|
||||
<link href="{{ url_for('static', filename='styles.css') }}" rel="stylesheet">
|
||||
<link rel="icon" type="image/png" sizes="48x48" href="{{ url_for('static', filename='brick.png') }}">
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.5.0/dist/chart.umd.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/tabulator-tables@6.4.0/dist/js/tabulator.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark sticky-top">
|
||||
@@ -190,7 +192,11 @@
|
||||
{% if request.endpoint == 'set.list' %}
|
||||
<script src="{{ url_for('static', filename='scripts/sets.js') }}"></script>
|
||||
{% endif %}
|
||||
{% if request.endpoint == 'set.table' %}
|
||||
<script src="{{ url_for('static', filename='scripts/sets-table.js') }}"></script>
|
||||
{% endif %}
|
||||
{% if request.endpoint == 'set.details' %}
|
||||
<script src="{{ url_for('static', filename='scripts/parts-table-filter.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='scripts/parts-bulk-operations.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='scripts/set-details.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='scripts/quick-add-individual-part.js') }}"></script>
|
||||
|
||||
@@ -35,12 +35,12 @@
|
||||
{% if management_read_only %}
|
||||
<div class="input-group">
|
||||
<span class="input-group-text px-1"><i class="ri-wallet-3-line me-1"></i><span class="ms-1 d-none d-md-inline"> Price</span></span>
|
||||
<input class="form-control form-control-sm flex-shrink-1 px-1" type="text" value="{{ item.fields.purchase_price or '' }}" disabled autocomplete="off">
|
||||
<input class="form-control form-control-sm flex-shrink-1 px-1" type="text" value="{{ (item.fields.purchase_price if item.fields.purchase_price is not none else '') }}" disabled autocomplete="off">
|
||||
<span class="input-group-text d-none d-md-inline px-1">{{ config['PURCHASE_CURRENCY'] }}</span>
|
||||
<span class="input-group-text ri-prohibited-line px-1"></span>
|
||||
</div>
|
||||
{% else %}
|
||||
{{ form.input('Price', item.fields.id, 'purchase_price', url_for('individual_minifigure.update_purchase_price', id=item.fields.id), item.fields.purchase_price or '', suffix=config['PURCHASE_CURRENCY'], icon='wallet-3-line') }}
|
||||
{{ form.input('Price', item.fields.id, 'purchase_price', url_for('individual_minifigure.update_purchase_price', id=item.fields.id), (item.fields.purchase_price if item.fields.purchase_price is not none else ''), suffix=config['PURCHASE_CURRENCY'], icon='wallet-3-line') }}
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="col-12 flex-grow-1">
|
||||
|
||||
@@ -53,12 +53,12 @@
|
||||
{% if management_read_only %}
|
||||
<div class="input-group">
|
||||
<span class="input-group-text px-1"><i class="ri-wallet-3-line me-1"></i><span class="ms-1 d-none d-md-inline"> Price</span></span>
|
||||
<input class="form-control form-control-sm flex-shrink-1 px-1" type="text" value="{{ item.fields.purchase_price or '' }}" disabled autocomplete="off">
|
||||
<input class="form-control form-control-sm flex-shrink-1 px-1" type="text" value="{{ (item.fields.purchase_price if item.fields.purchase_price is not none else '') }}" disabled autocomplete="off">
|
||||
<span class="input-group-text d-none d-md-inline px-1">{{ config['PURCHASE_CURRENCY'] }}</span>
|
||||
<span class="input-group-text ri-prohibited-line px-1"></span>
|
||||
</div>
|
||||
{% else %}
|
||||
{{ form.input('Price', item.fields.id, 'purchase_price', url_for('individual_part.update_lot_purchase_price', lot_id=item.fields.id), item.fields.purchase_price or '', suffix=config['PURCHASE_CURRENCY'], icon='wallet-3-line') }}
|
||||
{{ form.input('Price', item.fields.id, 'purchase_price', url_for('individual_part.update_lot_purchase_price', lot_id=item.fields.id), (item.fields.purchase_price if item.fields.purchase_price is not none else ''), suffix=config['PURCHASE_CURRENCY'], icon='wallet-3-line') }}
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="col-12 flex-grow-1">
|
||||
@@ -112,12 +112,12 @@
|
||||
{% if management_read_only %}
|
||||
<div class="input-group">
|
||||
<span class="input-group-text px-1"><i class="ri-wallet-3-line me-1"></i><span class="ms-1 d-none d-md-inline"> Price</span></span>
|
||||
<input class="form-control form-control-sm flex-shrink-1 px-1" type="text" value="{{ item.fields.purchase_price or '' }}" disabled autocomplete="off">
|
||||
<input class="form-control form-control-sm flex-shrink-1 px-1" type="text" value="{{ (item.fields.purchase_price if item.fields.purchase_price is not none else '') }}" disabled autocomplete="off">
|
||||
<span class="input-group-text d-none d-md-inline px-1">{{ config['PURCHASE_CURRENCY'] }}</span>
|
||||
<span class="input-group-text ri-prohibited-line px-1"></span>
|
||||
</div>
|
||||
{% else %}
|
||||
{{ form.input('Price', item.fields.id, 'purchase_price', item.url_for_purchase_price(), item.fields.purchase_price or '', suffix=config['PURCHASE_CURRENCY'], icon='wallet-3-line') }}
|
||||
{{ form.input('Price', item.fields.id, 'purchase_price', item.url_for_purchase_price(), (item.fields.purchase_price if item.fields.purchase_price is not none else ''), suffix=config['PURCHASE_CURRENCY'], icon='wallet-3-line') }}
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="col-12 flex-grow-1">
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro table(table_collection, title, id, parent, target, quantity=none, icon=none, image=none, alt=none, details=none, read_only=none, hamburger_menu=none) %}
|
||||
{% macro table(table_collection, title, id, parent, target, quantity=none, icon=none, image=none, alt=none, details=none, read_only=none, hamburger_menu=none, filters=false) %}
|
||||
{% set size=table_collection | length %}
|
||||
{% if size %}
|
||||
{{ header(title, id, parent, quantity=quantity, icon=icon, class='p-0', image=image, alt=alt, hamburger_menu=hamburger_menu) }}
|
||||
@@ -57,7 +57,7 @@
|
||||
<a class="btn border bg-secondary-text" href="{{ details }}">{% if icon %}<i class="ri-{{ icon }}"></i>{% endif %} Details</a>
|
||||
</p>
|
||||
{% endif %}
|
||||
{% with solo=true, all=false, accordion_id=id, read_only=read_only, hamburger_menu=hamburger_menu %}
|
||||
{% with solo=true, all=false, accordion_id=id, read_only=read_only, hamburger_menu=hamburger_menu, filters=filters %}
|
||||
{% include target %}
|
||||
{% endwith %}
|
||||
{{ footer() }}
|
||||
|
||||
@@ -118,12 +118,14 @@
|
||||
{% endmacro %}
|
||||
|
||||
{% macro purchase_price(price, solo=false, last=false) %}
|
||||
{% if last %}
|
||||
{% set tooltip=price %}
|
||||
{% else %}
|
||||
{% set text=price %}
|
||||
{% if price is not none %}
|
||||
{% if last %}
|
||||
{% set tooltip = price | string %}
|
||||
{% else %}
|
||||
{% set text = price | string %}
|
||||
{% endif %}
|
||||
{{ badge(check=true, solo=solo, last=last, color='light border', icon='wallet-3-line', text=text, tooltip=tooltip, collapsible='Price:') }}
|
||||
{% endif %}
|
||||
{{ badge(check=price, solo=solo, last=last, color='light border', icon='wallet-3-line', text=text, tooltip=tooltip, collapsible='Price:') }}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro set(set, solo=false, last=false, url=None, id=None) %}
|
||||
@@ -294,7 +296,7 @@
|
||||
{% if not last %}
|
||||
{% if item.purchase_price is defined and item.purchase_price is callable %}
|
||||
{{ purchase_price(item.purchase_price(), solo=solo, last=last) }}
|
||||
{% elif item.fields.purchase_price is defined and item.fields.purchase_price %}
|
||||
{% elif item.fields.purchase_price is defined and item.fields.purchase_price is not none %}
|
||||
{{ purchase_price(item.fields.purchase_price, solo=solo, last=last) }}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<label class="visually-hidden" for="{{ prefix }}-{{ id }}">{{ name }}</label>
|
||||
<div class="input-group">
|
||||
{% if icon %}<span class="input-group-text px-1"><i class="ri-{{ icon }} me-1"></i><span class="ms-1 d-none d-md-inline"> {{ name }}</span></span>{% endif %}
|
||||
<input class="form-control form-control-sm flex-shrink-1 px-1" type="text" id="{{ prefix }}-{{ id }}" value="{% if value %}{{ value }}{% endif %}"
|
||||
<input class="form-control form-control-sm flex-shrink-1 px-1" type="text" id="{{ prefix }}-{{ id }}" value="{% if value is not none and value != '' %}{{ value }}{% endif %}"
|
||||
{% if g.login.is_authenticated() %}
|
||||
data-changer-id="{{ id }}" data-changer-prefix="{{ prefix }}" data-changer-url="{{ url }}"
|
||||
{% if date %}data-changer-date="true"{% endif %}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% macro header(image=true, color=false, parts=false, quantity=false, missing=true, missing_parts=false, damaged=true, damaged_parts=false, sets=false, minifigures=false, checked=false, hamburger_menu=false, accordion_id='') %}
|
||||
{% macro header(image=true, color=false, parts=false, quantity=false, missing=true, missing_parts=false, damaged=true, damaged_parts=false, sets=false, minifigures=false, checked=false, hamburger_menu=false, accordion_id='', filters=false) %}
|
||||
<thead>
|
||||
<tr>
|
||||
{% if image %}
|
||||
@@ -59,6 +59,72 @@
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% if filters %}
|
||||
<tr class="parts-filter-row">
|
||||
{% if image %}
|
||||
<th class="no-sort"></th>
|
||||
{% endif %}
|
||||
<th class="no-sort">
|
||||
<input type="search" class="form-control form-control-sm parts-filter-input" data-parts-filter="name" placeholder="Search…" aria-label="Filter by name" autocomplete="off">
|
||||
</th>
|
||||
{% if color %}
|
||||
<th class="no-sort">
|
||||
<select class="form-select form-select-sm parts-filter-select" data-parts-filter="color" aria-label="Filter by color">
|
||||
<option value="">All colors</option>
|
||||
</select>
|
||||
</th>
|
||||
{% endif %}
|
||||
{% if parts %}
|
||||
<th class="no-sort"></th>
|
||||
{% endif %}
|
||||
{% if quantity %}
|
||||
<th class="no-sort"></th>
|
||||
{% endif %}
|
||||
{% if missing and not config['HIDE_TABLE_MISSING_PARTS'] %}
|
||||
<th class="no-sort">
|
||||
<select class="form-select form-select-sm parts-filter-select" data-parts-filter="missing" aria-label="Filter by missing">
|
||||
<option value="">All</option>
|
||||
<option value="with">With missing</option>
|
||||
<option value="without">Without missing</option>
|
||||
</select>
|
||||
</th>
|
||||
{% endif %}
|
||||
{% if damaged and not config['HIDE_TABLE_DAMAGED_PARTS'] %}
|
||||
<th class="no-sort">
|
||||
<select class="form-select form-select-sm parts-filter-select" data-parts-filter="damaged" aria-label="Filter by damaged">
|
||||
<option value="">All</option>
|
||||
<option value="with">With damaged</option>
|
||||
<option value="without">Without damaged</option>
|
||||
</select>
|
||||
</th>
|
||||
{% endif %}
|
||||
{% if sets %}
|
||||
<th class="no-sort"></th>
|
||||
{% endif %}
|
||||
{% if minifigures %}
|
||||
<th class="no-sort"></th>
|
||||
{% endif %}
|
||||
{% if checked and not config['HIDE_TABLE_CHECKED_PARTS'] %}
|
||||
<th class="no-sort">
|
||||
<select class="form-select form-select-sm parts-filter-select" data-parts-filter="checked" aria-label="Filter by checked">
|
||||
<option value="">All</option>
|
||||
<option value="1">Checked</option>
|
||||
<option value="0">Unchecked</option>
|
||||
</select>
|
||||
</th>
|
||||
{% endif %}
|
||||
{% if hamburger_menu and g.login.is_authenticated() %}
|
||||
{% set show_missing_menu = not config['HIDE_TABLE_MISSING_PARTS'] %}
|
||||
{% set show_checked_menu = not config['HIDE_TABLE_CHECKED_PARTS'] %}
|
||||
{% set show_quick_add = not config['DISABLE_QUICK_ADD_INDIVIDUAL_PARTS'] and not config['HIDE_INDIVIDUAL_PARTS'] %}
|
||||
{% if show_missing_menu or show_checked_menu or show_quick_add %}
|
||||
<th class="no-sort text-end">
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary parts-filter-clear" data-parts-filter-clear title="Clear filters"><i class="ri-filter-off-line"></i></button>
|
||||
</th>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% endif %}
|
||||
</thead>
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
{% import 'macro/table.html' as table %}
|
||||
|
||||
<div class="table-responsive-sm">
|
||||
<table data-table="{% if all %}true{% endif %}" class="table table-striped align-middle {% if not all %}sortable mb-0{% endif %}" {% if all %}id="parts"{% endif %}>
|
||||
{{ table.header(color=true, quantity=not no_quantity, sets=all, minifigures=all, checked=not all and not read_only, hamburger_menu=not all and not read_only, accordion_id=accordion_id|default('')) }}
|
||||
<table data-table="{% if all %}true{% endif %}" class="table table-striped align-middle {% if not all %}sortable mb-0{% endif %}" {% if all %}id="parts"{% endif %} {% if filters %}data-parts-filterable="true"{% endif %}>
|
||||
{{ table.header(color=true, quantity=not no_quantity, sets=all, minifigures=all, checked=not all and not read_only, hamburger_menu=not all and not read_only, accordion_id=accordion_id|default(''), filters=filters|default(false)) }}
|
||||
<tbody>
|
||||
{% for item in table_collection %}
|
||||
<tr>
|
||||
{{ table.image(item.url_for_image(), caption=item.fields.name, alt=item.fields.part, accordion=solo) }}
|
||||
<td data-sort="{{ item.fields.name }}">
|
||||
<td data-sort="{{ item.fields.name }}" data-col="name">
|
||||
<a class="text-reset" href="{{ item.url() }}">{{ item.fields.name }}</a>
|
||||
{% if item.fields.spare %}<span class="badge rounded-pill text-bg-warning fw-normal"><i class="ri-loop-left-line"></i> Spare</span>{% endif %}
|
||||
{% if all %}
|
||||
@@ -16,7 +16,7 @@
|
||||
{{ table.bricklink(item) }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td data-sort="{{ item.fields.color_name }}">
|
||||
<td data-sort="{{ item.fields.color_name }}" data-col="color">
|
||||
{% if item.fields.color_rgb %}<span class="color-rgb color-rgb-table {% if item.fields.color == 9999 %}color-any{% endif %} align-middle border border-black" {% if item.fields.color != 9999 %}style="background-color: #{{ item.fields.color_rgb }};"{% endif %}></span>{% endif %}
|
||||
<span class="align-middle">{{ item.fields.color_name }}</span>
|
||||
</td>
|
||||
@@ -28,12 +28,12 @@
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if not config['HIDE_TABLE_MISSING_PARTS'] %}
|
||||
<td data-sort="{{ item.fields.total_missing }}" class="table-td-input">
|
||||
<td data-sort="{{ item.fields.total_missing }}" data-col="missing" class="table-td-input">
|
||||
{{ form.input('Missing', item.fields.id, item.html_id('missing'), item.url_for_problem('missing'), item.fields.total_missing, all=all, read_only=read_only) }}
|
||||
</td>
|
||||
{% endif %}
|
||||
{% if not config['HIDE_TABLE_DAMAGED_PARTS'] %}
|
||||
<td data-sort="{{ item.fields.total_damaged }}" class="table-td-input">
|
||||
<td data-sort="{{ item.fields.total_damaged }}" data-col="damaged" class="table-td-input">
|
||||
{{ form.input('Damaged', item.fields.id, item.html_id('damaged'), item.url_for_problem('damaged'), item.fields.total_damaged, all=all, read_only=read_only) }}
|
||||
</td>
|
||||
{% endif %}
|
||||
@@ -42,7 +42,7 @@
|
||||
<td>{{ item.fields.total_minifigures }}</td>
|
||||
{% else %}
|
||||
{% if not config['HIDE_TABLE_CHECKED_PARTS'] and not read_only %}
|
||||
<td data-sort="{{ item.fields.checked | default(0) | int }}" class="table-td-input">
|
||||
<td data-sort="{{ item.fields.checked | default(0) | int }}" data-col="checked" class="table-td-input">
|
||||
<center>{{ form.checkbox('', item.fields.id, item.html_id('checked'), item.url_for_checked(), item.fields.checked | default(false), parent='part', delete=read_only) }}</center>
|
||||
</td>
|
||||
{% endif %}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<form method="POST" action="{{ url_for('instructions.do_download') }}">
|
||||
<div class="card mb-3">
|
||||
<div class="card-header">
|
||||
<h5 class="mb-0"><i class="ri-download-line"></i> Download instructions from Rebrickable</h5>
|
||||
<h5 class="mb-0"><i class="ri-download-line"></i> Download instructions from LEGO.com</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="mb-3">
|
||||
@@ -25,7 +25,7 @@
|
||||
</form>
|
||||
{% if loading_peeron %}
|
||||
<div class="alert alert-info" role="alert">
|
||||
<i class="ri-information-line"></i> <strong>Found on Peeron:</strong> {{ set }} was not available on Rebrickable, loading instruction pages from Peeron...
|
||||
<i class="ri-information-line"></i> <strong>Found on Peeron:</strong> {{ set }} was not available on LEGO.com, loading instruction pages from Peeron...
|
||||
</div>
|
||||
|
||||
<!-- Socket elements for peeron-loader -->
|
||||
@@ -55,7 +55,7 @@
|
||||
|
||||
{% if pages %}
|
||||
<div id="peeron-loading-alert" class="alert alert-info" role="alert">
|
||||
<i class="ri-information-line"></i> <strong>Instructions found on Peeron:</strong> {{ set }} was not available on Rebrickable, but {{ pages|length }} instruction pages were found on Peeron.
|
||||
<i class="ri-information-line"></i> <strong>Instructions found on Peeron:</strong> {{ set }} was not available on LEGO.com, but {{ pages|length }} instruction pages were found on Peeron.
|
||||
<div id="peeron-cache-progress" class="mt-2 d-none">
|
||||
<div class="progress" role="progressbar" aria-label="Caching thumbnails" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">
|
||||
<div id="peeron-cache-progress-bar" class="progress-bar" style="width: 0%"></div>
|
||||
|
||||
@@ -130,7 +130,7 @@
|
||||
</div>
|
||||
{{ accordion.footer() }}
|
||||
{% endif %}
|
||||
{{ accordion.table(item.parts(), 'Parts', 'parts-inventory', 'set-details', 'part/table.html', icon='shapes-line', hamburger_menu=g.login.is_authenticated())}}
|
||||
{{ accordion.table(item.parts(), 'Parts', 'parts-inventory', 'set-details', 'part/table.html', icon='shapes-line', hamburger_menu=g.login.is_authenticated(), filters=true)}}
|
||||
{% for minifigure in item.minifigures() %}
|
||||
{{ accordion.table(minifigure.parts(), minifigure.fields.name, minifigure.fields.figure, 'set-details', 'part/table.html', quantity=minifigure.fields.quantity, icon='group-line', image=minifigure.url_for_image(), alt=minifigure.fields.figure, details=minifigure.url(), hamburger_menu=g.login.is_authenticated())}}
|
||||
{% endfor %}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block title %} - Sets table{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
<div class="container-fluid">
|
||||
<h2 class="border-bottom lh-base pb-1">
|
||||
<i class="ri-table-line"></i> Sets table
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary ms-1" id="sets-table-clear-filters">
|
||||
<i class="ri-filter-off-line"></i> Clear filters
|
||||
</button>
|
||||
</h2>
|
||||
|
||||
<div id="sets-table"></div>
|
||||
</div>
|
||||
|
||||
<!-- Data for building the storage/purchase location select editors -->
|
||||
<script type="application/json" id="sets-table-storages">
|
||||
{{ brickset_storages | tojson }}
|
||||
</script>
|
||||
<script type="application/json" id="sets-table-purchase-locations">
|
||||
{{ brickset_purchase_locations | tojson }}
|
||||
</script>
|
||||
|
||||
<!-- URL templates: the literal string ID_PLACEHOLDER is swapped for the -->
|
||||
<!-- real set id client-side, so the JS never has to hardcode paths -->
|
||||
<script type="application/json" id="sets-table-urls">
|
||||
{{
|
||||
{
|
||||
'data': url_for('set.table_data'),
|
||||
'description': url_for('set.update_description', id='ID_PLACEHOLDER'),
|
||||
'storage': url_for('set.update_storage', id='ID_PLACEHOLDER'),
|
||||
'purchase_location': url_for('set.update_purchase_location', id='ID_PLACEHOLDER'),
|
||||
'purchase_date': url_for('set.update_purchase_date', id='ID_PLACEHOLDER'),
|
||||
'purchase_price': url_for('set.update_purchase_price', id='ID_PLACEHOLDER'),
|
||||
'details': url_for('set.details', id='ID_PLACEHOLDER'),
|
||||
} | tojson
|
||||
}}
|
||||
</script>
|
||||
{% endblock %}
|
||||
+16
-12
@@ -99,7 +99,11 @@
|
||||
<div class="col-6">
|
||||
<div class="text-center">
|
||||
<div class="text-dark small">Range</div>
|
||||
{% if financial_summary.minimum_cost is not none and financial_summary.maximum_cost is not none %}
|
||||
<div class="fw-bold">{{ config['PURCHASE_CURRENCY'] }}{{ "%.2f"|format(financial_summary.minimum_cost) }} - {{ config['PURCHASE_CURRENCY'] }}{{ "%.2f"|format(financial_summary.maximum_cost) }}</div>
|
||||
{% else %}
|
||||
<div class="fw-bold">-</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -245,7 +249,7 @@
|
||||
</td>
|
||||
<td class="text-center">
|
||||
{% if theme.total_spent %}
|
||||
<small class="text-dark">{{ config['PURCHASE_CURRENCY'] }}{{ "%.0f"|format(theme.total_spent) }}</small>
|
||||
<small class="text-dark">{{ config['PURCHASE_CURRENCY'] }}{{ "%.2f"|format(theme.total_spent) }}</small>
|
||||
{% else %}
|
||||
<small class="text-dark">-</small>
|
||||
{% endif %}
|
||||
@@ -309,8 +313,8 @@
|
||||
<small class="text-dark">{{ storage.total_minifigures }}{% if storage.individual_minifig_count %} ({{ storage.individual_minifig_count }} individual){% endif %}</small>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
{% if storage.total_value %}
|
||||
<small class="text-dark">{{ config['PURCHASE_CURRENCY'] }}{{ "%.0f"|format(storage.total_value) }}</small>
|
||||
{% if storage.total_value is not none %}
|
||||
<small class="text-dark">{{ config['PURCHASE_CURRENCY'] }}{{ "%.2f"|format(storage.total_value) }}</small>
|
||||
{% else %}
|
||||
<small class="text-dark">-</small>
|
||||
{% endif %}
|
||||
@@ -380,15 +384,15 @@
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="text-center">
|
||||
{% if location.avg_price %}
|
||||
{% if location.avg_price is not none %}
|
||||
<small class="text-dark">{{ config['PURCHASE_CURRENCY'] }}{{ "%.2f"|format(location.avg_price) }}</small>
|
||||
{% else %}
|
||||
<small class="text-dark">-</small>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="text-center">
|
||||
{% if location.min_price and location.max_price %}
|
||||
<small class="text-dark">{{ config['PURCHASE_CURRENCY'] }}{{ "%.0f"|format(location.min_price) }}-{{ "%.0f"|format(location.max_price) }}</small>
|
||||
{% if location.min_price is not none and location.max_price is not none %}
|
||||
<small class="text-dark">{{ config['PURCHASE_CURRENCY'] }}{{ "%.2f"|format(location.min_price) }}-{{ "%.2f"|format(location.max_price) }}</small>
|
||||
{% else %}
|
||||
<small class="text-dark">-</small>
|
||||
{% endif %}
|
||||
@@ -460,14 +464,14 @@
|
||||
</td>
|
||||
<td class="text-center">
|
||||
{% if year.total_spent %}
|
||||
<small class="text-dark">{{ config['PURCHASE_CURRENCY'] }}{{ "%.0f"|format(year.total_spent) }}</small>
|
||||
<small class="text-dark">{{ config['PURCHASE_CURRENCY'] }}{{ "%.2f"|format(year.total_spent) }}</small>
|
||||
{% else %}
|
||||
<small class="text-dark">-</small>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="text-center">
|
||||
{% if year.avg_price_per_set %}
|
||||
<small class="text-dark">{{ config['PURCHASE_CURRENCY'] }}{{ "%.0f"|format(year.avg_price_per_set) }}</small>
|
||||
{% if year.avg_price_per_set is not none %}
|
||||
<small class="text-dark">{{ config['PURCHASE_CURRENCY'] }}{{ "%.2f"|format(year.avg_price_per_set) }}</small>
|
||||
{% else %}
|
||||
<small class="text-dark">-</small>
|
||||
{% endif %}
|
||||
@@ -542,8 +546,8 @@
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="text-center">
|
||||
{% if year.avg_price_per_set %}
|
||||
<small class="text-dark">{{ config['PURCHASE_CURRENCY'] }}{{ "%.0f"|format(year.avg_price_per_set) }}</small>
|
||||
{% if year.avg_price_per_set is not none %}
|
||||
<small class="text-dark">{{ config['PURCHASE_CURRENCY'] }}{{ "%.2f"|format(year.avg_price_per_set) }}</small>
|
||||
{% else %}
|
||||
<small class="text-dark">-</small>
|
||||
{% endif %}
|
||||
@@ -560,7 +564,7 @@
|
||||
<small class="text-dark">Peak Year</small><br>
|
||||
{% if year_summary.peak_spending_year %}
|
||||
<strong>{{ year_summary.peak_spending_year }}</strong>
|
||||
<small class="text-success d-block">{{ config['PURCHASE_CURRENCY'] }}{{ "%.0f"|format(year_summary.max_spending) }}</small>
|
||||
<small class="text-success d-block">{{ config['PURCHASE_CURRENCY'] }}{{ "%.2f"|format(year_summary.max_spending) }}</small>
|
||||
{% else %}
|
||||
<small class="text-dark">N/A</small>
|
||||
{% endif %}
|
||||
|
||||
Reference in New Issue
Block a user