Add SI-prefix-aware sorting column for the parts table

Adds an optional "Name (SI)" column that parses numeric values with SI
prefixes (p, n, u/µ, m, k/K, M, G, T) from part names and sorts by the
resulting physical value. This is useful for electronic components where
alphabetical sorting produces wrong results — e.g. 100nF, 10pF, 1uF
should sort as 10pF < 100nF < 1uF.

Implementation:
- New SiValueSort DQL function with platform-specific SQL generation
  for PostgreSQL (POSIX regex), MySQL/MariaDB (REGEXP_SUBSTR), and
  SQLite (PHP callback registered via the existing middleware).
- The regex is start-anchored: only names beginning with a number are
  matched. Part numbers like "MCP2515" or "Crystal 20MHz" are ignored.
- When SI sort is active, NATSORT is appended as a secondary sort so
  that non-matching parts fall back to natural string ordering instead
  of appearing in arbitrary order.
- The column is opt-in (not in default columns) and displays the parsed
  float value, or an empty cell for non-matching names.
This commit is contained in:
Wieland Schopohl 2026-04-15 02:16:11 +02:00
parent 5b86d6f652
commit 63486782c4
7 changed files with 414 additions and 0 deletions

View file

@ -2780,6 +2780,12 @@ If you have done this incorrectly or if a computer is no longer trusted, you can
<target>Name</target>
</segment>
</unit>
<unit id="sIvAlUe" name="part.table.si_name">
<segment state="translated">
<source>part.table.si_name</source>
<target>Name (SI)</target>
</segment>
</unit>
<unit id="rW_SFJE" name="part.table.id">
<segment state="translated">
<source>part.table.id</source>