From 9bb1a33078d93a15cbdf4459074bee9e1f5f001d Mon Sep 17 00:00:00 2001 From: Thomas Skerbis Date: Thu, 17 Sep 2026 19:44:02 +0200 Subject: [PATCH 1/3] Add YForm live search overlay to the YForm button (#187) Extends the existing YForm table dropdown with a Spotlight-style search across datasets of all permitted YForm tables, addressing the inline pjax search issues reported in yform_usability#187 (broken addon-page tab navigation, wrong edit links). - Global overlay opened from the header YForm button; the table dropdown stays visible next to the search field at all times (bootstrap-select, container: body so it isn't clipped) and can be changed mid-search without losing the current term - Field-type-aware, collapsible filters per table (select for choice/checkbox, date/datetime inputs, number input) - Result preview reuses YForm's own getListValue() formatting: choice values as label badges, checkboxes as colored yes/no badges, fields_tagging values as colored tag badges, and yform_lang_fields JSON columns as per-language chips instead of raw JSON/HTML - name/title/cat/category (plus admin-configurable extra columns in the addon settings) are shown first and highlighted as the result title - Edit links reuse the currently open addon page when it already shows the same table, otherwise fall back to rex_yform_manager::url() (correct CSRF handling either way) - Keyboard navigation between the search field and the table/result list (arrows, tab, enter) - Table rows show the table's configured icon - Custom database+magnifier icon for the trigger button - All 8 REDAXO-core-supported languages shipped in full Co-Authored-By: Claude Sonnet 5 --- CHANGELOG.md | 15 + README.de.md | 4 +- README.md | 4 +- assets/yform-live-search.css | 508 ++++++++++++++++++++++++++++ assets/yform-live-search.js | 390 +++++++++++++++++++++ boot.php | 4 + lang/de_de.lang | 7 + lang/en_gb.lang | 7 + lang/es_es.lang | 41 +++ lang/it_it.lang | 55 +++ lang/nl_nl.lang | 55 +++ lang/pt_br.lang | 52 +++ lang/ru_ru.lang | 55 +++ lang/sv_se.lang | 40 +++ lib/ApiFunction/YformSearch.php | 86 +++++ lib/Button/YformButton.php | 163 ++++++--- lib/Yform/Search.php | 582 ++++++++++++++++++++++++++++++++ package.yml | 2 +- pages/config.php | 19 ++ 19 files changed, 2040 insertions(+), 49 deletions(-) create mode 100644 assets/yform-live-search.css create mode 100644 assets/yform-live-search.js create mode 100644 lang/it_it.lang create mode 100644 lang/nl_nl.lang create mode 100644 lang/ru_ru.lang create mode 100644 lib/ApiFunction/YformSearch.php create mode 100644 lib/Yform/Search.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d4e105e..a861dc1c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,20 @@ # Changelog +## 9.2.0 – 2026-09-17 + +### Neu: YForm Live-Suche im YForm-Button + +- Der bestehende YForm-Button (Tabellenübersicht) öffnet jetzt zusätzlich ein Spotlight-artiges Overlay mit einer Live-Suche über Datensätze aller berechtigten YForm-Tabellen +- Tabellenauswahl über ein permanent sichtbares Dropdown neben dem Suchfeld (bootstrap-select) – auch während/nach einer Suche jederzeit wechselbar, ohne den Suchbegriff zu verlieren +- Feldtyp-abhängige, aufklappbare Filter je Tabelle (Dropdown für choice/checkbox, Datum für date/datetime, Zahl für number) +- Ergebnis-Vorschau nutzt YForms eigene `getListValue()`-Formatierung: choice-Werte als Label-Badges, checkbox-Felder als farbige Ja/Nein-Badges, `fields_tagging`-Werte als farbige Tag-Badges, mehrsprachige `yform_lang_fields`-Spalten als Sprachcode-Chips (statt rohem JSON) +- Spalten `name`/`title`/`cat`/`category` (plus über die Addon-Einstellungen admin-konfigurierbare weitere Spalten) werden automatisch als Titel hervorgehoben und zuerst angezeigt +- Bearbeiten-Links nutzen `rex_yform_manager::url()` bzw. die aktuell geöffnete Addon-Seite (statt immer auf die YForm-Standardseite zu verweisen), inklusive korrektem CSRF-Handling +- Tastatur-Navigation: Pfeiltasten/Tab zwischen Suchfeld und Ergebnis-/Tabellenliste, Enter öffnet den fokussierten Eintrag +- Tabellenzeilen zeigen das in der Tabellenverwaltung konfigurierte Icon +- Eigenes Such-Icon (Datenbank + Lupe) statt des generischen Datenbank-Symbols +- Alle 8 von REDAXO-Core unterstützten Sprachen vollständig ausgeliefert (`de_de`, `en_gb`, `es_es`, `it_it`, `nl_nl`, `pt_br`, `ru_ru`, `sv_se`) + ## 9.1.0 – 2026-03-31 ### Neu: Sprachschalter (CLANG) in der Linkmap diff --git a/README.de.md b/README.de.md index 2725bb05..1b2585ba 100644 --- a/README.de.md +++ b/README.de.md @@ -1,4 +1,4 @@ -# Quick Navigation 8 für Redaxo +# Quick Navigation für REDAXO ![Screenshot](https://raw.githubusercontent.com/FriendsOfREDAXO/quick_navigation/assets/quickbar.png) @@ -12,7 +12,7 @@ Funktionen: - Button-Registry zur einfachen Registrierung von Schaltflächen, sortiert nach Priorität in der Strukturansicht - Erweiterungspunkte zum Hinzufügen klassischer Schaltflächen zu Struktur, Linkmap, Mediapool - Kategoriefavoriten mit Hinzufügen-Schaltflächen für Kategorien und Artikel -- YForm-Schnellnavigation +- YForm-Schnellnavigation: Tabellen-Dropdown plus eine Spotlight-artige Live-Suche über Datensätze aller berechtigten YForm-Tabellen, mit feldtyp-abhängigen Filtern, farbigen Badges/Tags in der Ergebnisvorschau und Unterstützung mehrsprachiger Felder ## Beschreibung diff --git a/README.md b/README.md index 6bae9165..adeb2cf0 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -# Quick Navigation 8 for Redaxo +# Quick Navigation for REDAXO ![Screenshot](https://raw.githubusercontent.com/FriendsOfREDAXO/quick_navigation/assets/quickbar.png) @@ -13,7 +13,7 @@ Features: - Buttonregistry to easy register buttons sorted by prio in structure view - extension points to add classic buttons to structure, linkmap, mediapool - Category favorites with add buttons for categories and articles -- YForm quick navigation +- YForm quick navigation: table dropdown plus a Spotlight-style live search across datasets of all permitted YForm tables, with field-type-aware filters, colored badges/tags in the result preview, and multi-language field support ## Description diff --git a/assets/yform-live-search.css b/assets/yform-live-search.css new file mode 100644 index 00000000..200d8782 --- /dev/null +++ b/assets/yform-live-search.css @@ -0,0 +1,508 @@ +.qn-yform-overlay { + position: fixed; + inset: 0; + z-index: 10500; + display: flex; + align-items: flex-start; + justify-content: center; + padding-top: 10vh; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; + font-size: 15px; + line-height: 1.46667; + animation: qnYformFadeIn 0.12s ease-out; +} + +.qn-yform-overlay[hidden] { + display: none; +} + +@keyframes qnYformFadeIn { + from { opacity: 0; } + to { opacity: 1; } +} + +@keyframes qnYformPanelIn { + from { opacity: 0; transform: translateY(-6px); } + to { opacity: 1; transform: translateY(0); } +} + +.qn-yform-overlay-backdrop { + position: absolute; + inset: 0; + background: rgba(15, 18, 22, 0.5); +} + +.qn-yform-overlay-panel { + position: relative; + width: 680px; + max-width: calc(100vw - 32px); + max-height: 72vh; + display: flex; + flex-direction: column; + background: #fff; + color: #324050; + border-radius: 0; + box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3); + overflow: hidden; + animation: qnYformPanelIn 0.14s ease-out; +} + +body.rex-theme-dark .qn-yform-overlay-panel { + background: #2b2f33; + color: #eee; +} + +.qn-yform-overlay-header { + display: flex; + align-items: center; + gap: 10px; + padding: 10px 12px; + border-bottom: 1px solid #c1c9d4; +} + +body.rex-theme-dark .qn-yform-overlay-header { + border-bottom-color: rgba(255, 255, 255, 0.15); +} + +.qn-yform-overlay-icon { + color: #8a97a8; + font-size: 15px; + flex-shrink: 0; + display: inline-flex; +} + +.qn-yform-icon-svg { + display: inline-block; + vertical-align: middle; + color: inherit; +} + +#quick-navigation-yform-trigger .qn-yform-icon-svg { + width: 18px; + height: 18px; +} + +.qn-yform-overlay-icon .qn-yform-icon-svg { + width: 18px; + height: 18px; +} + +.qn-yform-overlay-input { + flex: 1; + min-width: 0; + border: 0; + outline: none; + font-size: 15px; + font-family: inherit; + background: transparent; + color: inherit; + height: 30px; +} + +.qn-yform-overlay-input::placeholder { + color: #8a97a8; +} + +.qn-yform-overlay-close, +.qn-yform-overlay-filters-toggle { + border: 0; + background: transparent; + color: #8a97a8; + cursor: pointer; + padding: 5px 8px; + border-radius: 0; + flex-shrink: 0; + font-size: 14px; + line-height: 1.46667; +} + +.qn-yform-overlay-close:hover, +.qn-yform-overlay-filters-toggle:hover { + color: #324050; + background: rgba(0, 0, 0, 0.05); +} + +body.rex-theme-dark .qn-yform-overlay-close:hover, +body.rex-theme-dark .qn-yform-overlay-filters-toggle:hover { + color: #fff; + background: rgba(255, 255, 255, 0.1); +} + +.qn-yform-overlay-filters-toggle.active { + color: #fff; + background: #556d8c; +} + +.qn-yform-overlay-filters-toggle.hidden { + display: none; +} + +.qn-yform-overlay-header .qn-yform-overlay-table-select.btn-group { + flex-shrink: 0; +} + +.qn-yform-overlay-header .qn-yform-overlay-table-select .btn { + height: 30px; + padding: 4px 10px; + font-size: 13px; + border-radius: 0; + border-color: #c1c9d4; + background: #f3f6fb; + color: #324050; +} + +body.rex-theme-dark .qn-yform-overlay-header .qn-yform-overlay-table-select .btn { + background: rgba(255, 255, 255, 0.08); + border-color: rgba(255, 255, 255, 0.15); + color: #eee; +} + +.qn-yform-overlay-table-scope { + border: 0; + background: transparent; + color: #8a97a8; + cursor: pointer; + padding: 6px 9px; + border-radius: 0; + flex-shrink: 0; + font-size: 13px; +} + +.qn-yform-overlay-table-scope:hover { + color: #324050; + background: rgba(0, 0, 0, 0.05); +} + +.qn-yform-overlay-filters { + padding: 10px 12px; + border-bottom: 1px solid #c1c9d4; + display: flex; + flex-wrap: wrap; + gap: 10px 14px; + background: #f3f6fb; +} + +body.rex-theme-dark .qn-yform-overlay-filters { + border-bottom-color: rgba(255, 255, 255, 0.15); + background: rgba(255, 255, 255, 0.04); +} + +.qn-yform-filter-field { + display: flex; + flex-direction: column; + gap: 2px; + min-width: 150px; +} + +.qn-yform-filter-field.form-group { + margin-bottom: 0; +} + +.qn-yform-filter-field label.control-label { + font-size: 12px; + font-weight: 700; + margin-bottom: 1px; + color: #324050; +} + +body.rex-theme-dark .qn-yform-filter-field label.control-label { + color: #eee; +} + +.qn-yform-filter-field .form-control { + height: 30px; + padding: 4px 8px; + font-size: 13px; + line-height: 1.46667; + border-radius: 0; +} + +.qn-yform-filters-empty { + color: #8a97a8; + font-size: 13px; + font-style: italic; +} + +.qn-yform-overlay-body { + overflow-y: auto; + font-size: 14px; +} + +.qn-yform-overlay-tables { + padding: 0; +} + +.qn-yform-overlay-item-row { + display: flex; + align-items: center; + justify-content: space-between; + gap: 4px; + border-bottom: 1px solid #dfe3e9; +} + +.qn-yform-overlay-tables .qn-yform-overlay-item-row:last-child { + border-bottom: 0; +} + +body.rex-theme-dark .qn-yform-overlay-item-row { + border-bottom-color: rgba(255, 255, 255, 0.1); +} + +.qn-yform-overlay-item-row:hover { + background: rgba(0, 0, 0, 0.035); +} + +body.rex-theme-dark .qn-yform-overlay-item-row:hover { + background: rgba(255, 255, 255, 0.05); +} + +.qn-yform-overlay-table-link { + flex: 1; + min-width: 0; + display: flex; + align-items: center; + gap: 8px; + padding: 8px 14px; + color: #4b9ad9; + text-decoration: none; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + font-size: 14px; +} + +.qn-yform-overlay-table-icon { + color: #8a97a8; + font-size: 13px; + width: 16px; + text-align: center; + flex-shrink: 0; +} + +.qn-yform-overlay-table-link:hover, +.qn-yform-overlay-table-link:focus { + color: #3183c8; + text-decoration: none; + outline: none; +} + +.qn-yform-overlay-table-link:focus { + background: rgba(0, 0, 0, 0.035); +} + +body.rex-theme-dark .qn-yform-overlay-table-link:focus { + background: rgba(255, 255, 255, 0.05); +} + +.qn-yform-overlay-item-row a[title^="Datensatz"], +.qn-yform-overlay-item-row a[title^="Add dataset"] { + padding: 7px 12px; + color: #8a97a8; + flex-shrink: 0; + font-size: 13px; +} + +.qn-yform-overlay-item-row a[title^="Datensatz"]:hover, +.qn-yform-overlay-item-row a[title^="Add dataset"]:hover { + color: #324050; + background: rgba(0, 0, 0, 0.05); +} + +.qn-yform-search-loading { + padding: 20px; + text-align: center; + color: #8a97a8; + font-size: 16px; +} + +.qn-yform-search-empty { + padding: 20px; + color: #8a97a8; + font-style: italic; + text-align: center; + font-size: 13px; +} + +.qn-yform-search-group-label { + padding: 8px 14px 4px; + font-weight: 700; + font-size: 11px; + text-transform: uppercase; + letter-spacing: 0.03em; + color: #8a97a8; +} + +.qn-yform-search-item { + display: flex; + flex-direction: column; + gap: 2px; + padding: 8px 14px; + color: inherit; + text-decoration: none; + border-left: 3px solid transparent; + border-bottom: 1px solid #dfe3e9; +} + +.qn-yform-search-group .qn-yform-search-item:last-child { + border-bottom: 0; +} + +body.rex-theme-dark .qn-yform-search-item { + border-bottom-color: rgba(255, 255, 255, 0.08); +} + +.qn-yform-search-item:hover, +.qn-yform-search-item:focus { + background: #f3f6fb; + border-left-color: #556d8c; + color: inherit; + text-decoration: none; +} + +body.rex-theme-dark .qn-yform-search-item:hover, +body.rex-theme-dark .qn-yform-search-item:focus { + background: rgba(255, 255, 255, 0.06); +} + +.qn-yform-search-item-head { + display: flex; + align-items: baseline; + justify-content: space-between; + gap: 10px; +} + +.qn-yform-search-title { + font-size: 14px; + font-weight: 600; + color: #4b9ad9; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.qn-yform-search-item:hover .qn-yform-search-title, +.qn-yform-search-item:focus .qn-yform-search-title { + color: #3183c8; +} + +.qn-yform-search-id { + font-size: 11px; + color: #8a97a8; + font-variant-numeric: tabular-nums; + flex-shrink: 0; +} + +.qn-yform-search-preview { + font-size: 12px; + margin-top: 2px; +} + +.qn-yform-search-field-grid { + display: grid; + grid-template-columns: minmax(70px, max-content) 1fr; + column-gap: 10px; + row-gap: 3px; + align-items: start; +} + +.qn-yform-search-field-label { + color: #8a97a8; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + padding-top: 1px; +} + +.qn-yform-search-field-value { + min-width: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +/* Value badges */ +.qn-badge { + display: inline-flex; + align-items: center; + gap: 4px; + padding: 1px 6px; + border-radius: 2px; + font-size: 11px; + font-weight: 600; +} + +.qn-badge-on { + background: rgba(76, 175, 80, 0.15); + color: #3d9140; +} + +.qn-badge-off { + background: rgba(0, 0, 0, 0.06); + color: #8a97a8; +} + +body.rex-theme-dark .qn-badge-off { + background: rgba(255, 255, 255, 0.1); + color: #aaa; +} + +.qn-badge-choice { + background: #eef1f5; + color: #556d8c; +} + +body.rex-theme-dark .qn-badge-choice { + background: rgba(255, 255, 255, 0.1); + color: #cfd8e3; +} + +.qn-badge-tag { + color: #fff; + border-radius: 10px; +} + +/* Language chips (yform_lang_fields preview): one row per language, aligned + into their own two-column grid so the code and text line up vertically. */ +.qn-lang-stack { + display: grid; + grid-template-columns: max-content 1fr; + column-gap: 6px; + row-gap: 2px; + white-space: normal; +} + +.qn-lang-chip { + display: contents; +} + +.qn-lang-code { + display: inline-block; + align-self: start; + padding: 0 4px; + border-radius: 2px; + background: rgba(0, 0, 0, 0.07); + color: #8a97a8; + font-size: 10px; + font-weight: 700; + text-transform: uppercase; + letter-spacing: 0.02em; + line-height: 1.6; +} + +body.rex-theme-dark .qn-lang-code { + background: rgba(255, 255, 255, 0.12); + color: #ccc; +} + +.qn-lang-text { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +/* bootstrap-select is detached to (container:'body') so it is never + clipped by the overlay panel's overflow:hidden — it then needs a z-index + above the overlay itself to render on top of it. */ +body > .bootstrap-select.qn-yform-overlay-table-select.dropdown { + z-index: 10600; +} diff --git a/assets/yform-live-search.js b/assets/yform-live-search.js new file mode 100644 index 00000000..22adf3d0 --- /dev/null +++ b/assets/yform-live-search.js @@ -0,0 +1,390 @@ +/** + * Quick Navigation YForm Spotlight + * Global overlay (opened from the header "YForm" button) combining the + * per-table list with a live dataset search across permitted YForm tables, + * plus optional table-scoping and field-type-aware filters. + */ +$(document).on('rex:ready quick-navigation:ready', function () { + initQuickNavigationYformOverlay(); +}); + +function initQuickNavigationYformOverlay() { + var trigger = $('#quick-navigation-yform-trigger'); + var overlay = $('#quick-navigation-yform-overlay'); + + if (trigger.length === 0 || overlay.length === 0 || overlay.data('qn-yform-initialized')) { + return; + } + overlay.data('qn-yform-initialized', true); + + var input = overlay.find('#quick-navigation-yform-input'); + var tablesPane = overlay.find('.qn-yform-overlay-tables'); + var resultsPane = overlay.find('.qn-yform-overlay-results'); + var tableSelect = overlay.find('#quick-navigation-yform-table-select'); + var filtersToggleBtn = overlay.find('#quick-navigation-yform-filters-toggle'); + var filtersPane = overlay.find('#quick-navigation-yform-filters'); + var initialTable = overlay.data('current-table') || ''; + + if (tableSelect.length && typeof tableSelect.selectpicker === 'function') { + tableSelect.selectpicker({ container: 'body' }); + } + + var scopedTable = ''; + var activeFilters = {}; + var searchTimer = null; + var currentRequest = null; + var currentFiltersRequest = null; + + trigger.on('click', function (e) { + e.preventDefault(); + openOverlay(); + }); + + overlay.on('click', '[data-qn-yform-close]', function (e) { + e.preventDefault(); + closeOverlay(); + }); + + $(document).on('keydown.qnyformoverlay', function (e) { + if (overlay.prop('hidden')) { + return; + } + if (e.keyCode === 27) { + closeOverlay(); + } + }); + + // Arrow-key/Tab navigation between the search input and the currently + // visible list (tables or results), Spotlight-style. + input.on('keydown.qnyformnav', function (e) { + var activeList = tablesPane.prop('hidden') ? resultsPane : tablesPane; + var items = activeList.find('a.qn-yform-overlay-table-link, a.qn-yform-search-item'); + + if ((e.key === 'Tab' && !e.shiftKey) || e.key === 'ArrowDown') { + if (items.length) { + e.preventDefault(); + items.first().trigger('focus'); + } + } else if (e.key === 'Enter') { + if (items.length) { + e.preventDefault(); + window.location.href = items.first().attr('href'); + } + } + }); + + overlay.on('keydown.qnyformnav', 'a.qn-yform-overlay-table-link, a.qn-yform-search-item', function (e) { + var items = $(this).closest('.qn-yform-overlay-tables, .qn-yform-overlay-results') + .find('a.qn-yform-overlay-table-link, a.qn-yform-search-item'); + var index = items.index(this); + + if (e.key === 'ArrowDown') { + e.preventDefault(); + items.eq(Math.min(index + 1, items.length - 1)).trigger('focus'); + } else if (e.key === 'ArrowUp') { + e.preventDefault(); + if (index === 0) { + input.trigger('focus'); + } else { + items.eq(index - 1).trigger('focus'); + } + } else if (e.key === 'Tab' && e.shiftKey && index === 0) { + e.preventDefault(); + input.trigger('focus'); + } + }); + + input.on('input', function () { + var term = $(this).val().trim(); + + if (searchTimer) { + clearTimeout(searchTimer); + } + abortSearch(); + + if (term.length === 0 && isFiltersEmpty()) { + showTables(); + return; + } + + if (term.length > 0 && term.length < 2) { + return; + } + + showLoading(); + searchTimer = setTimeout(function () { + performSearch(term); + }, 300); + }); + + // Table-name click: normal navigation (unchanged behaviour). + // The dedicated magnifier button next to it scopes the search instead + // (and keeps the always-visible table select in sync). + overlay.on('click', '[data-quick-navigation-yform-scope]', function (e) { + e.preventDefault(); + var tableName = $(this).data('quick-navigation-yform-scope'); + setTableSelectValue(tableName); + setScope(tableName); + input.trigger('focus'); + }); + + tableSelect.on('change', function () { + setScope($(this).val() || ''); + input.trigger('focus'); + }); + + filtersToggleBtn.on('click', function (e) { + e.preventDefault(); + filtersPane.prop('hidden', !filtersPane.prop('hidden')); + filtersToggleBtn.toggleClass('active', !filtersPane.prop('hidden')); + }); + + filtersPane.on('change', 'input, select', function () { + var name = $(this).data('filter-name'); + var value = $(this).val(); + if (value) { + activeFilters[name] = value; + } else { + delete activeFilters[name]; + } + var term = input.val().trim(); + if (term.length >= 2 || !isFiltersEmpty()) { + showLoading(); + performSearch(term); + } else { + showTables(); + } + }); + + function isFiltersEmpty() { + return Object.keys(activeFilters).length === 0; + } + + function openOverlay() { + overlay.prop('hidden', false); + input.val(''); + setTableSelectValue(initialTable); + setScope(initialTable); + setTimeout(function () { + input.trigger('focus'); + }, 30); + } + + function closeOverlay() { + overlay.prop('hidden', true); + } + + function setTableSelectValue(tableName) { + tableSelect.val(tableName || ''); + if (typeof tableSelect.selectpicker === 'function') { + tableSelect.selectpicker('refresh'); + } + } + + function setScope(tableName) { + scopedTable = tableName || ''; + activeFilters = {}; + filtersPane.prop('hidden', true).empty(); + filtersToggleBtn.removeClass('active'); + + if (scopedTable) { + filtersToggleBtn.removeClass('hidden'); + loadFilters(scopedTable); + } else { + filtersToggleBtn.addClass('hidden'); + } + + var term = input.val().trim(); + if (term.length >= 2) { + showLoading(); + performSearch(term); + } else { + showTables(); + } + } + + function showTables() { + abortSearch(); + resultsPane.prop('hidden', true).empty(); + tablesPane.prop('hidden', false); + } + + function showLoading() { + tablesPane.prop('hidden', true); + resultsPane.prop('hidden', false).html('
'); + } + + function abortSearch() { + if (currentRequest) { + currentRequest.abort(); + currentRequest = null; + } + } + + function loadFilters(tableName) { + if (currentFiltersRequest) { + currentFiltersRequest.abort(); + } + currentFiltersRequest = $.ajax({ + url: window.location.pathname + window.location.search, + method: 'GET', + cache: false, + data: { + 'rex-api-call': 'quicknavigation_yform_search', + mode: 'filters', + table_name: tableName + }, + dataType: 'json', + success: function (response) { + currentFiltersRequest = null; + renderFilters(response.filters || []); + }, + error: function (xhr, status) { + currentFiltersRequest = null; + } + }); + } + + function renderFilters(filters) { + if (!filters || filters.length === 0) { + filtersPane.html('
Keine Filter verfügbar
'); + return; + } + + var html = ''; + filters.forEach(function (f) { + html += '
'; + html += ''; + + if (f.input === 'select') { + html += ''; + } else if (f.input === 'date' || f.input === 'datetime') { + html += ''; + } else if (f.input === 'number') { + html += ''; + } else { + html += ''; + } + + html += '
'; + }); + + filtersPane.html(html); + } + + function performSearch(term) { + abortSearch(); + currentRequest = $.ajax({ + url: window.location.pathname + window.location.search, + method: 'GET', + cache: false, + data: { + 'rex-api-call': 'quicknavigation_yform_search', + term: term, + table_name: scopedTable || '', + filters: activeFilters + }, + dataType: 'json', + success: function (response) { + currentRequest = null; + if (response.success) { + renderResults(response.groups); + } else { + resultsPane.html('
' + escapeHtml(response.error || 'Fehler') + '
'); + } + }, + error: function (xhr, status) { + currentRequest = null; + if (status !== 'abort') { + resultsPane.html('
Fehler bei der Suche
'); + } + } + }); + } + + function renderResults(groups) { + if (!groups || groups.length === 0) { + resultsPane.html('
Keine Treffer
'); + return; + } + + var html = ''; + groups.forEach(function (group) { + html += '
'; + html += '
' + escapeHtml(group.table_label) + '
'; + group.results.forEach(function (item) { + // Only plain text-like highlighted fields (name/title/...) become the + // bold title line — a highlighted choice/boolean/tag field is still + // shown, but as a normal row below, not glued onto the title text. + var titleFields = (item.preview || []).filter(function (f) { return f.highlighted && f.kind === 'text'; }); + var rest = (item.preview || []).filter(function (f) { return !(f.highlighted && f.kind === 'text'); }); + var titleHtml = renderFieldValue(titleFields); + + html += ''; + html += '
'; + if (titleHtml) { + html += '' + titleHtml + ''; + } + html += '#' + item.id + ''; + html += '
'; + if (rest.length) { + html += '
' + renderPreviewFields(rest) + '
'; + } + html += '
'; + }); + html += '
'; + }); + + resultsPane.html(html); + } + + function renderFieldValue(fields) { + return fields.map(function (field) { + return renderValueOnly(field); + }).filter(Boolean).join(' · '); + } + + function renderValueOnly(field) { + if (field.kind === 'boolean') { + return field.on + ? ' Ja' + : ' Nein'; + } + if (field.kind === 'lang_json') { + return '
' + (field.languages || []).map(function (l) { + return '
' + escapeHtml(l.lang_label) + '' + escapeHtml(l.value) + '
'; + }).join('') + '
'; + } + if (field.kind === 'choice') { + return '' + escapeHtml(field.text) + ''; + } + if (field.kind === 'tags') { + return (field.tags || []).map(function (t) { + var color = /^#[0-9a-fA-F]{3,8}$/.test(t.color) ? t.color : '#7f8c8d'; + return '' + escapeHtml(t.text) + ''; + }).join(' '); + } + return escapeHtml(field.text || ''); + } + + function renderPreviewFields(preview) { + if (!preview || preview.length === 0) { + return ''; + } + + var rows = preview.map(function (field) { + return '
' + escapeHtml(field.label) + '
' + + '
' + renderValueOnly(field) + '
'; + }).join(''); + + return '
' + rows + '
'; + } + + function escapeHtml(str) { + return $('
').text(str == null ? '' : str).html(); + } +} diff --git a/boot.php b/boot.php index b4b35747..96e85ce4 100644 --- a/boot.php +++ b/boot.php @@ -13,6 +13,7 @@ use FriendsOfRedaxo\QuickNavigation\ApiFunction\MediaSearch; use FriendsOfRedaxo\QuickNavigation\ApiFunction\MenuRender; +use FriendsOfRedaxo\QuickNavigation\ApiFunction\YformSearch; use FriendsOfRedaxo\QuickNavigation\Button\ArticleHistoryButton; use FriendsOfRedaxo\QuickNavigation\Button\ArticleNavigationButton; use FriendsOfRedaxo\QuickNavigation\Button\ButtonRegistry; @@ -39,10 +40,13 @@ if (rex::getUser()->hasPerm('quick_navigation[]')) { rex_api_function::register('quicknavigation_api', MenuRender::class); rex_api_function::register('quicknavigation_media_search', MediaSearch::class); + rex_api_function::register('quicknavigation_yform_search', YformSearch::class); rex_view::addCssFile(rex_addon::get('quick_navigation')->getAssetsUrl('quick-navigation.css')); rex_view::addCssFile(rex_addon::get('quick_navigation')->getAssetsUrl('media-live-search.css')); + rex_view::addCssFile(rex_addon::get('quick_navigation')->getAssetsUrl('yform-live-search.css')); rex_view::addJsFile(rex_addon::get('quick_navigation')->getAssetsUrl('quick-navigation.js')); rex_view::addJsFile(rex_addon::get('quick_navigation')->getAssetsUrl('media-live-search.js')); + rex_view::addJsFile(rex_addon::get('quick_navigation')->getAssetsUrl('yform-live-search.js')); // Media Live-Search Einstellung für aktuellen User $userId = rex::getUser()->getId(); diff --git a/lang/de_de.lang b/lang/de_de.lang index 5ba761f8..9ad47d82 100644 --- a/lang/de_de.lang +++ b/lang/de_de.lang @@ -27,6 +27,13 @@ quick_navigation_structure_favs = Struktur quick_navigation_addon_pages_selection = AddOn-Seiten Favoriten quick_navigation_yform = YForm quick_navigation_yform_add = Datensatz hinzufügen in: +quick_navigation_yform_search_placeholder = Datensätze durchsuchen … +quick_navigation_yform_scope = In dieser Tabelle suchen +quick_navigation_yform_all_tables = Alle Tabellen +quick_navigation_yform_filters = Filter +quick_navigation_yform_close = Schließen +quick_navigation_yform_highlight_fields = Zusätzliche hervorgehobene Spalten +quick_navigation_yform_highlight_fields_note = Kommagetrennte Feldnamen (z. B. sku, artnr), die in den Suchergebnissen zusätzlich zu name/title/cat/category immer zuerst und hervorgehoben angezeigt werden, sofern die Tabelle sie hat. # Medienpool-Sortierung (nur die Beschriftungen für den Button beibehalten) quick_navigation_media_sort_alpha = Nach Dateinamen sortieren (A-Z) diff --git a/lang/en_gb.lang b/lang/en_gb.lang index 883bf60b..ee1cf58b 100644 --- a/lang/en_gb.lang +++ b/lang/en_gb.lang @@ -27,6 +27,13 @@ quick_navigation_structure_favs = Structure quick_navigation_addon_pages_selection = AddOn Pages Favorites quick_navigation_yform = YForm quick_navigation_yform_add = Add dataset to: +quick_navigation_yform_search_placeholder = Search datasets … +quick_navigation_yform_scope = Search within this table +quick_navigation_yform_all_tables = All tables +quick_navigation_yform_filters = Filters +quick_navigation_yform_close = Close +quick_navigation_yform_highlight_fields = Additional highlighted columns +quick_navigation_yform_highlight_fields_note = Comma-separated field names (e.g. sku, artnr) that are always shown first and highlighted in search results, in addition to name/title/cat/category, if the table has them. # Media sorting quick_navigation_media_sort_alpha = Sort by filename (A-Z) diff --git a/lang/es_es.lang b/lang/es_es.lang index 21380599..8857a9ce 100644 --- a/lang/es_es.lang +++ b/lang/es_es.lang @@ -5,11 +5,52 @@ quick_navigation_general = En general quick_navigation_placeholder = Filtrar por Categoría, Id o Dominio quick_navigation_config_save = Guardar quick_navigation_config_saved = Favoritos guardados +quick_navigation_info = Ajustes de usuario perm_general_quick_navigation[] = Navegación quick_navigation_categories = Selección de categoría perm_general_quick_navigation[history] = Navegación: Artículos recientes y medios perm_general_quick_navigation[all_changes] = Navegacion: enumera los archivos recientemente editados de todos los usuarios perm_general_quick_navigation[settings] = Navegación: Administrar favoritos y configuraciones title_eye = Abrir en la interfaz +quick_navigation_artdirections = ¿Desactivar la navegación entre artículos? quick_navigation_ignoreoffline = Ignorar categorías sin conexión? quick_navigation_no_entries = No se encontraron entradas +quick_navigation_structure = Estructura +quick_navigation_clang = Idioma +quick_navigation_article_history = Últimos artículos editados +quick_navigation_media_history = Últimos medios editados +quick_navigation_favorite = Favoritos +quick_navigation_manage_favorite = Añadir favoritos +quick_navigation_favorite_article_add = Añadir artículo a: +quick_navigation_favorite_category_add = Añadir categoría a: +quick_navigation_addon_pages = Páginas de AddOn +quick_navigation_structure_favs = Estructura +quick_navigation_addon_pages_selection = Favoritos de páginas AddOn +quick_navigation_yform = YForm +quick_navigation_yform_add = Añadir registro a: +quick_navigation_yform_search_placeholder = Buscar registros … +quick_navigation_yform_scope = Buscar en esta tabla +quick_navigation_yform_all_tables = Todas las tablas +quick_navigation_yform_filters = Filtros +quick_navigation_yform_close = Cerrar +quick_navigation_yform_highlight_fields = Columnas adicionales destacadas +quick_navigation_yform_highlight_fields_note = Nombres de campo separados por comas (p. ej. sku, artnr) que se muestran siempre en primer lugar y destacados en los resultados de búsqueda, además de name/title/cat/category, siempre que la tabla los tenga. + +# Media sorting +quick_navigation_media_sort_alpha = Ordenar por nombre de archivo (A-Z) +quick_navigation_media_sort_date = Ordenar por fecha (más recientes primero) +quick_navigation_media_sort_title = Ordenar por título (A-Z) + +# Media Live-Search +quick_navigation_media_livesearch = ¿Activar la búsqueda en directo del gestor de medios? +quick_navigation_media_live_search_placeholder = Búsqueda en directo... + +# Button Management +quick_navigation_button_management = Ocultar botones (Opt-Out) +quick_navigation_button_management_note = Selecciona los botones que NO quieres ver. El resto de botones permanecerán visibles. +quick_navigation_button_article_navigation = Navegación entre artículos (hojear) +quick_navigation_button_watson = Watson +quick_navigation_button_category = Categoría +quick_navigation_button_article_history = Historial de artículos +quick_navigation_button_yform = YForm +quick_navigation_button_favorite = Favoritos diff --git a/lang/it_it.lang b/lang/it_it.lang new file mode 100644 index 00000000..07f6ecce --- /dev/null +++ b/lang/it_it.lang @@ -0,0 +1,55 @@ +quick_navigation_title = Quick Navigation +quick_navigation_help = Aiuto +quick_navigation_config = Impostazioni +quick_navigation_general = Generale +quick_navigation_placeholder = nome/-id categoria, utente, dominio +quick_navigation_config_save = Salva impostazioni +quick_navigation_config_saved = Preferiti salvati +quick_navigation_info = Impostazioni utente +perm_general_quick_navigation[] = Quick Navi +quick_navigation_categories = Selezione preferiti +perm_general_quick_navigation[history] = Quick Navi: articoli e media modificati di recente +perm_general_quick_navigation[all_changes] = Quick Navi: mostra i dati modificati di recente da tutti gli utenti +perm_general_quick_navigation[settings] = Quick Navi: preferiti e impostazioni +quick_navigation_artdirections = Disattivare la navigazione tra articoli? +quick_navigation_ignoreoffline = Ignorare le categorie offline? +quick_navigation_no_entries = Nessun risultato trovato +quick_navigation_structure = Struttura +quick_navigation_clang = Lingua +quick_navigation_article_history = Ultimi articoli modificati +quick_navigation_media_history = Ultimi media modificati +quick_navigation_favorite = Preferiti +quick_navigation_manage_favorite = Aggiungi preferiti +quick_navigation_favorite_article_add = Aggiungi articolo a: +quick_navigation_favorite_category_add = Aggiungi categoria a: +quick_navigation_addon_pages = Pagine AddOn +quick_navigation_structure_favs = Struttura +quick_navigation_addon_pages_selection = Preferiti pagine AddOn +quick_navigation_yform = YForm +quick_navigation_yform_add = Aggiungi record a: +quick_navigation_yform_search_placeholder = Cerca nei record … +quick_navigation_yform_scope = Cerca in questa tabella +quick_navigation_yform_all_tables = Tutte le tabelle +quick_navigation_yform_filters = Filtri +quick_navigation_yform_close = Chiudi +quick_navigation_yform_highlight_fields = Colonne aggiuntive evidenziate +quick_navigation_yform_highlight_fields_note = Nomi di campo separati da virgola (es. sku, artnr) che vengono sempre mostrati per primi ed evidenziati nei risultati di ricerca, oltre a name/title/cat/category, se la tabella li possiede. + +# Media sorting +quick_navigation_media_sort_alpha = Ordina per nome file (A-Z) +quick_navigation_media_sort_date = Ordina per data (più recenti prima) +quick_navigation_media_sort_title = Ordina per titolo (A-Z) + +# Media Live-Search +quick_navigation_media_livesearch = Attivare la ricerca live nella mediateca? +quick_navigation_media_live_search_placeholder = Ricerca live... + +# Button Management +quick_navigation_button_management = Nascondi pulsanti (Opt-Out) +quick_navigation_button_management_note = Seleziona i pulsanti che NON vuoi vedere. Tutti gli altri pulsanti restano visibili. +quick_navigation_button_article_navigation = Navigazione articoli (Sfoglia) +quick_navigation_button_watson = Watson +quick_navigation_button_category = Categoria +quick_navigation_button_article_history = Cronologia articoli +quick_navigation_button_yform = YForm +quick_navigation_button_favorite = Preferiti diff --git a/lang/nl_nl.lang b/lang/nl_nl.lang new file mode 100644 index 00000000..6552f753 --- /dev/null +++ b/lang/nl_nl.lang @@ -0,0 +1,55 @@ +quick_navigation_title = Quick Navigation +quick_navigation_help = Help +quick_navigation_config = Instellingen +quick_navigation_general = Algemeen +quick_navigation_placeholder = categorienaam/-id, gebruiker, domein +quick_navigation_config_save = Instellingen opslaan +quick_navigation_config_saved = Favorieten opgeslagen +quick_navigation_info = Gebruikersinstellingen +perm_general_quick_navigation[] = Quick Navi +quick_navigation_categories = Favorietenselectie +perm_general_quick_navigation[history] = Quick Navi: recent bewerkte artikelen en media +perm_general_quick_navigation[all_changes] = Quick Navi: toon recent bewerkte gegevens van alle gebruikers +perm_general_quick_navigation[settings] = Quick Navi: favorieten en instellingen +quick_navigation_artdirections = Artikelnavigatie uitschakelen? +quick_navigation_ignoreoffline = Offline categorieën negeren? +quick_navigation_no_entries = Geen resultaten gevonden +quick_navigation_structure = Structuur +quick_navigation_clang = Taal +quick_navigation_article_history = Laatst bewerkte artikelen +quick_navigation_media_history = Laatst bewerkte media +quick_navigation_favorite = Favorieten +quick_navigation_manage_favorite = Favorieten toevoegen +quick_navigation_favorite_article_add = Artikel toevoegen aan: +quick_navigation_favorite_category_add = Categorie toevoegen aan: +quick_navigation_addon_pages = AddOn-pagina's +quick_navigation_structure_favs = Structuur +quick_navigation_addon_pages_selection = AddOn-pagina's favorieten +quick_navigation_yform = YForm +quick_navigation_yform_add = Record toevoegen aan: +quick_navigation_yform_search_placeholder = Records doorzoeken … +quick_navigation_yform_scope = Zoeken binnen deze tabel +quick_navigation_yform_all_tables = Alle tabellen +quick_navigation_yform_filters = Filters +quick_navigation_yform_close = Sluiten +quick_navigation_yform_highlight_fields = Extra gemarkeerde kolommen +quick_navigation_yform_highlight_fields_note = Kommagescheiden veldnamen (bijv. sku, artnr) die in de zoekresultaten altijd als eerste en gemarkeerd worden weergegeven, naast name/title/cat/category, mits de tabel deze bevat. + +# Media sorting +quick_navigation_media_sort_alpha = Sorteren op bestandsnaam (A-Z) +quick_navigation_media_sort_date = Sorteren op datum (nieuwste eerst) +quick_navigation_media_sort_title = Sorteren op titel (A-Z) + +# Media Live-Search +quick_navigation_media_livesearch = Live-zoeken in mediatheek inschakelen? +quick_navigation_media_live_search_placeholder = Live zoeken... + +# Button Management +quick_navigation_button_management = Knoppen verbergen (Opt-Out) +quick_navigation_button_management_note = Selecteer de knoppen die je NIET wilt zien. Alle andere knoppen blijven zichtbaar. +quick_navigation_button_article_navigation = Artikelnavigatie (Bladeren) +quick_navigation_button_watson = Watson +quick_navigation_button_category = Categorie +quick_navigation_button_article_history = Artikelgeschiedenis +quick_navigation_button_yform = YForm +quick_navigation_button_favorite = Favorieten diff --git a/lang/pt_br.lang b/lang/pt_br.lang index 770f9379..ce6dd5d1 100644 --- a/lang/pt_br.lang +++ b/lang/pt_br.lang @@ -1,4 +1,56 @@ +quick_navigation_title = Quick Navigation +quick_navigation_help = Ajuda +quick_navigation_config = Configurações +quick_navigation_general = Geral +quick_navigation_placeholder = nome/-id da categoria, usuário, domínio +quick_navigation_config_save = Salvar configurações +quick_navigation_config_saved = Favoritos salvos +quick_navigation_info = Configurações do usuário perm_general_quick_navigation[] = Quick Navi perm_general_quick_navigation[idinput] = Quick navi: permitir entrada de Ids de artigos +quick_navigation_categories = Seleção de favoritos perm_general_quick_navigation[history] = Quick Navi: artigos e mídias recentemente editados +perm_general_quick_navigation[all_changes] = Quick Navi: exibir dados recentemente editados de todos os usuários +perm_general_quick_navigation[settings] = Quick Navi: gerenciar favoritos e configurações +quick_navigation_artdirections = Desativar a navegação entre artigos? +quick_navigation_ignoreoffline = Ignorar categorias offline? quick_navigation_no_entries = Nenhuma entrada encontrada +quick_navigation_structure = Estrutura +quick_navigation_clang = Idioma +quick_navigation_article_history = Últimos artigos editados +quick_navigation_media_history = Últimas mídias editadas +quick_navigation_favorite = Favoritos +quick_navigation_manage_favorite = Adicionar favoritos +quick_navigation_favorite_article_add = Adicionar artigo em: +quick_navigation_favorite_category_add = Adicionar categoria em: +quick_navigation_addon_pages = Páginas de AddOn +quick_navigation_structure_favs = Estrutura +quick_navigation_addon_pages_selection = Favoritos de páginas AddOn +quick_navigation_yform = YForm +quick_navigation_yform_add = Adicionar registro em: +quick_navigation_yform_search_placeholder = Pesquisar registros … +quick_navigation_yform_scope = Pesquisar nesta tabela +quick_navigation_yform_all_tables = Todas as tabelas +quick_navigation_yform_filters = Filtros +quick_navigation_yform_close = Fechar +quick_navigation_yform_highlight_fields = Colunas adicionais destacadas +quick_navigation_yform_highlight_fields_note = Nomes de campos separados por vírgula (ex.: sku, artnr) que são sempre exibidos primeiro e destacados nos resultados da pesquisa, além de name/title/cat/category, caso a tabela os possua. + +# Media sorting +quick_navigation_media_sort_alpha = Ordenar por nome do arquivo (A-Z) +quick_navigation_media_sort_date = Ordenar por data (mais recentes primeiro) +quick_navigation_media_sort_title = Ordenar por título (A-Z) + +# Media Live-Search +quick_navigation_media_livesearch = Ativar busca em tempo real na mídiateca? +quick_navigation_media_live_search_placeholder = Busca em tempo real... + +# Button Management +quick_navigation_button_management = Ocultar botões (Opt-Out) +quick_navigation_button_management_note = Selecione os botões que você NÃO quer ver. Todos os outros botões permanecem visíveis. +quick_navigation_button_article_navigation = Navegação entre artigos (folhear) +quick_navigation_button_watson = Watson +quick_navigation_button_category = Categoria +quick_navigation_button_article_history = Histórico de artigos +quick_navigation_button_yform = YForm +quick_navigation_button_favorite = Favoritos diff --git a/lang/ru_ru.lang b/lang/ru_ru.lang new file mode 100644 index 00000000..1ede267d --- /dev/null +++ b/lang/ru_ru.lang @@ -0,0 +1,55 @@ +quick_navigation_title = Quick Navigation +quick_navigation_help = Справка +quick_navigation_config = Настройки +quick_navigation_general = Общие +quick_navigation_placeholder = название/ID категории, пользователь, домен +quick_navigation_config_save = Сохранить настройки +quick_navigation_config_saved = Избранное сохранено +quick_navigation_info = Настройки пользователя +perm_general_quick_navigation[] = Quick Navi +quick_navigation_categories = Выбор избранного +perm_general_quick_navigation[history] = Quick Navi: недавно изменённые статьи и медиафайлы +perm_general_quick_navigation[all_changes] = Quick Navi: показывать недавно изменённые данные всех пользователей +perm_general_quick_navigation[settings] = Quick Navi: управление избранным и настройками +quick_navigation_artdirections = Отключить пролистывание статей? +quick_navigation_ignoreoffline = Игнорировать оффлайн-категории? +quick_navigation_no_entries = Записи не найдены +quick_navigation_structure = Структура +quick_navigation_clang = Язык +quick_navigation_article_history = Последние изменённые статьи +quick_navigation_media_history = Последние изменённые медиафайлы +quick_navigation_favorite = Избранное +quick_navigation_manage_favorite = Добавить в избранное +quick_navigation_favorite_article_add = Добавить статью в: +quick_navigation_favorite_category_add = Добавить категорию в: +quick_navigation_addon_pages = Страницы AddOn +quick_navigation_structure_favs = Структура +quick_navigation_addon_pages_selection = Избранные страницы AddOn +quick_navigation_yform = YForm +quick_navigation_yform_add = Добавить запись в: +quick_navigation_yform_search_placeholder = Поиск по записям … +quick_navigation_yform_scope = Искать в этой таблице +quick_navigation_yform_all_tables = Все таблицы +quick_navigation_yform_filters = Фильтры +quick_navigation_yform_close = Закрыть +quick_navigation_yform_highlight_fields = Дополнительные выделенные столбцы +quick_navigation_yform_highlight_fields_note = Имена полей через запятую (например, sku, artnr), которые всегда отображаются первыми и выделяются в результатах поиска, в дополнение к name/title/cat/category, если они есть в таблице. + +# Media sorting +quick_navigation_media_sort_alpha = Сортировать по имени файла (А-Я) +quick_navigation_media_sort_date = Сортировать по дате (сначала новые) +quick_navigation_media_sort_title = Сортировать по названию (А-Я) + +# Media Live-Search +quick_navigation_media_livesearch = Включить живой поиск в медиатеке? +quick_navigation_media_live_search_placeholder = Живой поиск... + +# Button Management +quick_navigation_button_management = Скрыть кнопки (Opt-Out) +quick_navigation_button_management_note = Выберите кнопки, которые вы НЕ хотите видеть. Все остальные кнопки останутся видимыми. +quick_navigation_button_article_navigation = Навигация по статьям (пролистывание) +quick_navigation_button_watson = Watson +quick_navigation_button_category = Категория +quick_navigation_button_article_history = История статей +quick_navigation_button_yform = YForm +quick_navigation_button_favorite = Избранное diff --git a/lang/sv_se.lang b/lang/sv_se.lang index 63492869..ae9219d9 100644 --- a/lang/sv_se.lang +++ b/lang/sv_se.lang @@ -5,6 +5,7 @@ quick_navigation_general = Allmänt quick_navigation_placeholder = Filtrera efter kategori, ID eller domän quick_navigation_config_save = Spara quick_navigation_config_saved = Favoriter sparades +quick_navigation_info = Användarinställningar perm_general_quick_navigation[] = Quick Navi quick_navigation_categories = Kategori-urval perm_general_quick_navigation[history] = Quick Navi: Nyligen redigerade artiklar och media @@ -14,3 +15,42 @@ title_eye = Öppna i frontend: quick_navigation_artdirections = Deaktivera artikelbläddring? quick_navigation_ignoreoffline = Ignorera offline-kategorierna? quick_navigation_no_entries = Inga inlägg hittades +quick_navigation_structure = Struktur +quick_navigation_clang = Språk +quick_navigation_article_history = Senast redigerade artiklar +quick_navigation_media_history = Senast redigerade media +quick_navigation_favorite = Favoriter +quick_navigation_manage_favorite = Lägg till favoriter +quick_navigation_favorite_article_add = Lägg till artikel i: +quick_navigation_favorite_category_add = Lägg till kategori i: +quick_navigation_addon_pages = AddOn-sidor +quick_navigation_structure_favs = Struktur +quick_navigation_addon_pages_selection = AddOn-sidor favoriter +quick_navigation_yform = YForm +quick_navigation_yform_add = Lägg till post i: +quick_navigation_yform_search_placeholder = Sök bland poster … +quick_navigation_yform_scope = Sök i denna tabell +quick_navigation_yform_all_tables = Alla tabeller +quick_navigation_yform_filters = Filter +quick_navigation_yform_close = Stäng +quick_navigation_yform_highlight_fields = Ytterligare markerade kolumner +quick_navigation_yform_highlight_fields_note = Kommaseparerade fältnamn (t.ex. sku, artnr) som alltid visas först och markeras i sökresultaten, utöver name/title/cat/category, om tabellen har dem. + +# Media sorting +quick_navigation_media_sort_alpha = Sortera efter filnamn (A-Ö) +quick_navigation_media_sort_date = Sortera efter datum (nyaste först) +quick_navigation_media_sort_title = Sortera efter titel (A-Ö) + +# Media Live-Search +quick_navigation_media_livesearch = Aktivera livesökning i mediearkivet? +quick_navigation_media_live_search_placeholder = Livesökning... + +# Button Management +quick_navigation_button_management = Dölj knappar (Opt-Out) +quick_navigation_button_management_note = Välj de knappar du INTE vill se. Alla andra knappar förblir synliga. +quick_navigation_button_article_navigation = Artikelnavigering (bläddring) +quick_navigation_button_watson = Watson +quick_navigation_button_category = Kategori +quick_navigation_button_article_history = Artikelhistorik +quick_navigation_button_yform = YForm +quick_navigation_button_favorite = Favoriter diff --git a/lib/ApiFunction/YformSearch.php b/lib/ApiFunction/YformSearch.php new file mode 100644 index 00000000..de8cd4d1 --- /dev/null +++ b/lib/ApiFunction/YformSearch.php @@ -0,0 +1,86 @@ + false, 'error' => 'no permission']); + exit; + } + + $tableName = rex_request('table_name', 'string', ''); + + if ('filters' === rex_request('mode', 'string', '')) { + $table = Search::findTableByName($tableName); + echo json_encode([ + 'success' => null !== $table, + 'table_label' => $table ? rex_i18n::translate($table->getName()) : '', + 'filters' => $table ? Search::filterableFields($table) : [], + ]); + exit; + } + + $term = trim(rex_request('term', 'string', '')); + $filtersRaw = rex_request('filters', 'array', []); + + if ('' === $term && [] === $filtersRaw) { + echo json_encode(['success' => false, 'error' => 'empty term']); + exit; + } + + $filters = []; + foreach ($filtersRaw as $key => $value) { + if (is_string($key) && is_scalar($value) && '' !== (string) $value) { + $filters[$key] = (string) $value; + } + } + + $tables = '' !== $tableName + ? array_filter([Search::findTableByName($tableName)]) + : Search::searchableTables(); + + $groups = []; + $perTableLimit = '' !== $tableName ? 20 : 5; + + foreach ($tables as $table) { + $results = Search::searchTable($table, $term, $filters, $perTableLimit); + if ([] === $results) { + continue; + } + $groups[] = [ + 'table_name' => $table->getTableName(), + 'table_label' => rex_i18n::translate($table->getName()), + 'results' => $results, + ]; + } + + echo json_encode([ + 'success' => true, + 'groups' => $groups, + ]); + exit; + } + + public function requiresCsrfProtection() + { + return false; + } +} diff --git a/lib/Button/YformButton.php b/lib/Button/YformButton.php index 6fe4237a..3c82f742 100644 --- a/lib/Button/YformButton.php +++ b/lib/Button/YformButton.php @@ -4,15 +4,15 @@ use function count; -use rex; +use FriendsOfRedaxo\QuickNavigation\Yform\Search; use rex_addon; use rex_csrf_token; use function rex_escape; -use rex_fragment; use rex_i18n; use rex_plugin; +use rex_request; use rex_string; use rex_url; use rex_yform_manager_table; @@ -32,59 +32,134 @@ public function get(): string return ''; } } - $tables = rex_yform_manager_table::getAll(); - $yperm_suffix = ''; - if (version_compare($yform->getVersion(), '4.0.0-dev', '>=')) { - $yperm_suffix = '_edit'; - } + $tables = Search::searchableTables(); if (count($tables) < 1) { return ''; } - $listItems = []; + $currentTableName = rex_request('table_name', 'string', ''); + + $listItemsHtml = ''; foreach ($tables as $table) { - $_csrf_key = 'table_field-' . $table->getTableName(); - $_csrf_params = rex_csrf_token::factory($_csrf_key)->getUrlParams(); - - if (!$table->isHidden() && $table->isActive() && rex::getUser()->getComplexPerm('yform_manager_table' . $yperm_suffix)->hasPerm($table->getTableName())) { - - $attributes = [ - 'href' => rex_url::backendPage('yform/manager/data_edit', ['page' => 'yform/manager/data_edit', 'table_name' => $table->getTableName()]), - 'title' => $table->getTableName(), - ]; - - - $attributesAdd = [ - 'href' => rex_url::backendPage('yform/manager/data_edit', ['page' => 'yform/manager/data_edit', 'table_name' => $table->getTableName(), 'func' => 'add', '_csrf_token' => $_csrf_params['_csrf_token']]), - 'title' => rex_i18n::msg('quick_navigation_yform_add') . ' ' . $table->getTableName(), - ]; - - $listItem = ' -
- - ' . rex_escape(rex_i18n::translate($table->getName())) . ' - - - - + $listItemsHtml .= $this->buildTableListItem($table, $currentTableName === $table->getTableName()); + } + + $label = rex_i18n::msg('quick_navigation_yform'); + $placeholder = rex_i18n::msg('quick_navigation_yform_search_placeholder'); + + $button = ' +
+ +
+ '; + + $tableSelectHtml = $this->buildTableSelect($tables, $currentTableName); + + $overlay = ' + + '; - $listItems[] = $listItem; - } - } + return $button . $overlay; + } - if (count($listItems) < 1) { - return ''; + /** + * @param list $tables + */ + private function buildTableSelect(array $tables, string $currentTableName): string + { + $options = ''; + + foreach ($tables as $table) { + $customIcon = method_exists($table, 'getCustomIcon') ? $table->getCustomIcon() : null; + $iconClass = $customIcon ? trim($customIcon) : 'rex-icon fa-database'; + $selected = $currentTableName === $table->getTableName() ? ' selected' : ''; + + $options .= ''; } - $fragment = new rex_fragment([ - 'label' => rex_i18n::msg('quick_navigation_yform'), - 'icon' => 'fa fa-database', - 'listItems' => $listItems, - ]); - return $fragment->parse('QuickNavigation/Dropdown.php'); + return ''; + } + + private function buildTableListItem(rex_yform_manager_table $table, bool $isCurrent): string + { + $_csrf_key = 'table_field-' . $table->getTableName(); + $_csrf_params = rex_csrf_token::factory($_csrf_key)->getUrlParams(); + + $attributes = [ + 'href' => rex_url::backendPage('yform/manager/data_edit', ['table_name' => $table->getTableName()]), + 'title' => $table->getTableName(), + 'class' => 'qn-yform-overlay-table-link' . ($isCurrent ? ' quick-navigation-current' : ''), + 'data-quick-navigation-yform-table' => $table->getTableName(), + ]; + + $attributesAdd = [ + 'href' => rex_url::backendPage('yform/manager/data_edit', [ + 'table_name' => $table->getTableName(), + 'func' => 'add', + '_csrf_token' => $_csrf_params['_csrf_token'], + ]), + 'title' => rex_i18n::msg('quick_navigation_yform_add') . ' ' . $table->getTableName(), + ]; + + $customIcon = method_exists($table, 'getCustomIcon') ? $table->getCustomIcon() : null; + $iconClass = $customIcon ? trim($customIcon) : 'rex-icon fa-database'; + $icon = ''; + + return ' +
+ + ' . $icon . rex_escape(rex_i18n::translate($table->getName())) . ' + + + + + +
+ '; + } + + /** + * Custom icon for YForm dataset search: a database cylinder with a + * magnifying glass, distinguishing this trigger from the plain + * fa-database "browse tables" icon used elsewhere. + */ + private static function icon(): string + { + return ''; } } diff --git a/lib/Yform/Search.php b/lib/Yform/Search.php new file mode 100644 index 00000000..29d9d5a8 --- /dev/null +++ b/lib/Yform/Search.php @@ -0,0 +1,582 @@ + + */ + public static function searchableTables(): array + { + $user = rex::getUser(); + if (!$user) { + return []; + } + + $yform = rex_addon::get('yform'); + $yperm_suffix = version_compare($yform->getVersion(), '4.0.0-dev', '>=') ? '_edit' : ''; + + $tables = []; + foreach (rex_yform_manager_table::getAll() as $table) { + if (!$table->isActive()) { + continue; + } + // NOTE: isHidden() only means "no menu entry in YForm manager" — it must NOT + // gate search/access. Access control is solely the permission check below. + if (!$user->isAdmin() && !$user->getComplexPerm('yform_manager_table' . $yperm_suffix)->hasPerm($table->getTableName())) { + continue; + } + $tables[] = $table; + } + + return $tables; + } + + public static function findTableByName(string $tableName): ?rex_yform_manager_table + { + foreach (self::searchableTables() as $table) { + if ($table->getTableName() === $tableName) { + return $table; + } + } + return null; + } + + /** + * Detects whether the currently open backend page already displays the given table, + * so edit links can reuse that addon page instead of always falling back to the + * generic YForm manager page. + */ + public static function currentPageTableName(): ?string + { + $tableName = rex_request('table_name', 'string', ''); + if ($tableName !== '') { + return $tableName; + } + return null; + } + + public static function currentBackendPage(): string + { + return rex_be_controller::getCurrentPage(); + } + + /** + * @return list + */ + public static function searchableFields(rex_yform_manager_table $table): array + { + $langFieldsAvailable = rex_addon::get('yform_lang_fields')->isAvailable(); + $columns = self::realColumnNames($table->getTableName()); + + $fields = []; + foreach ($table->getFields() as $field) { + $typeName = $field->getTypeName(); + $name = $field->getName(); + + // Some field types (e.g. be_manager_relation) report isSearchable()/a db type + // while storing their actual value in a *related* table, not as a physical + // column here — a LIKE against such a "column" would be a fatal SQL error. + if (!in_array($name, $columns, true)) { + continue; + } + + $isNativeSearchable = 'value' === $field->getType() + && $field->isSearchable() + && method_exists('rex_yform_value_' . $typeName, 'getSearchFilter'); + $isLangJson = $langFieldsAvailable && in_array($typeName, self::LANG_JSON_FIELD_TYPES, true); + + if (!$isNativeSearchable && !$isLangJson) { + continue; + } + + $fields[] = [ + 'name' => $name, + 'label' => $field->getLabel(), + 'type' => $typeName, + ]; + } + + return $fields; + } + + /** + * @return list + */ + private static function realColumnNames(string $tableName): array + { + static $cache = []; + if (isset($cache[$tableName])) { + return $cache[$tableName]; + } + + $sql = rex_sql::factory(); + $sql->setQuery('SHOW COLUMNS FROM `' . $tableName . '`'); + + $columns = []; + foreach ($sql->getArray() as $row) { + $columns[] = $row['Field']; + } + + return $cache[$tableName] = $columns; + } + + /** + * Field-type-aware filter descriptors for the optional advanced search UI. + * + * @return list}> + */ + public static function filterableFields(rex_yform_manager_table $table): array + { + $columns = self::realColumnNames($table->getTableName()); + + $filters = []; + foreach ($table->getFields() as $field) { + if (!in_array($field->getName(), $columns, true)) { + continue; + } + + $typeName = $field->getTypeName(); + $definition = $field->toArray(); + + // Multi-value choice fields store CSV ("1,2") in one column — a plain + // equality filter can't match those correctly, so they're excluded here. + $isMultiple = '1' === (string) ($definition['multiple'] ?? '0'); + + $input = match (true) { + $isMultiple => null, + in_array($typeName, ['choice', 'select'], true) => 'select', + 'checkbox' === $typeName => 'select', + in_array($typeName, ['date', 'datetime'], true) => $typeName, + 'be_number' === $typeName || 'number' === $typeName => 'number', + default => null, + }; + + if (null === $input) { + continue; + } + + $entry = [ + 'name' => $field->getName(), + 'label' => $field->getLabel(), + 'input' => $input, + ]; + + if ('select' === $input) { + $entry['options'] = 'checkbox' === $typeName + ? ['1' => rex_i18n::msg('yes'), '0' => rex_i18n::msg('no')] + : self::parseChoiceOptions((string) ($definition['choices'] ?? '')); + + if ([] === $entry['options']) { + continue; + } + } + + $filters[] = $entry; + } + + return $filters; + } + + /** + * Parses YForm's own `choices` element format: comma-separated `Label=value` + * pairs, with `\,`/`\=` as escapes — mirrors + * rex_yform_value_abstract::getArrayFromString() exactly, since that is what + * the choice/select field type itself uses to build its option list. + * + * @return array value => label + */ + private static function parseChoiceOptions(string $raw): array + { + if ('' === trim($raw)) { + return []; + } + + $rawOptions = preg_split('~(? $filters field-name => value, from filterableFields() + * @return list, url: string}> + */ + public static function searchTable(rex_yform_manager_table $table, string $term, array $filters = [], int $limit = 10): array + { + $searchableFields = self::searchableFields($table); + if ($searchableFields === [] && $filters === []) { + return []; + } + + $sql = rex_sql::factory(); + $termLike = '%' . $sql->escapeLikeWildcards($term) . '%'; + + $orConditions = []; + $params = []; + $paramIndex = 0; + + foreach ($searchableFields as $field) { + if ($term === '') { + break; + } + $paramName = 'qnsearch_' . $paramIndex++; + + if (in_array($field['type'], self::LANG_JSON_FIELD_TYPES, true)) { + $langCondition = self::buildLangJsonCondition($table, $field['name'], $term, $paramName, $params); + if ($langCondition !== null) { + $orConditions[] = $langCondition; + } + continue; + } + + $orConditions[] = '`' . $field['name'] . '` LIKE :' . $paramName; + $params[$paramName] = $termLike; + } + + if ($term !== '' && $orConditions === []) { + return []; + } + + $query = $table->query(); + if ($term !== '') { + $query->whereRaw('(' . implode(' OR ', $orConditions) . ')', $params); + } + + $filterableColumns = self::realColumnNames($table->getTableName()); + foreach ($filters as $fieldName => $value) { + if ($value === '' || $value === null || !in_array($fieldName, $filterableColumns, true)) { + continue; + } + $query->where($fieldName, $value); + } + + $query->limit($limit); + + $results = []; + foreach ($query->find() as $dataset) { + $results[] = [ + 'id' => $dataset->getId(), + 'preview' => self::buildPreview($table, $dataset), + 'url' => self::buildEditUrl($table, $dataset->getId()), + ]; + } + + return $results; + } + + /** + * @param array $params written by reference (bound query params) + */ + private static function buildLangJsonCondition(rex_yform_manager_table $table, string $fieldName, string $term, string $paramPrefix, array &$params): ?string + { + $conditions = []; + $i = 0; + foreach (rex_clang::getAllIds() as $clangId) { + $paramName = $paramPrefix . '_' . $i++; + $params[$paramName] = '%' . $term . '%'; + $conditions[] = 'EXISTS (SELECT 1 FROM JSON_TABLE(`' . $fieldName . '`, \'$[*]\' COLUMNS (' + . 'clang_id INT PATH \'$.clang_id\', value TEXT PATH \'$.value\'' . + ')) AS jt WHERE jt.clang_id = ' . (int) $clangId . ' AND jt.value LIKE :' . $paramName . ')'; + } + + return $conditions === [] ? null : '(' . implode(' OR ', $conditions) . ')'; + } + + /** Columns always prioritized + highlighted in the preview, if the table has them. */ + private const DEFAULT_HIGHLIGHT_FIELDS = ['name', 'title', 'cat', 'category']; + + /** Max characters shown per text-ish preview field before truncation ("anreißen"). */ + private const PREVIEW_TEXT_MAX_LENGTH = 90; + + /** Max number of preview fields shown per result. */ + private const PREVIEW_MAX_FIELDS = 5; + + /** + * @return list + */ + private static function highlightFieldNames(): array + { + $configured = (string) rex_addon::get('quick_navigation')->getConfig('quick_navigation_yform_highlight_fields', ''); + $extra = array_filter(array_map('trim', explode(',', $configured))); + + return array_values(array_unique(array_merge(self::DEFAULT_HIGHLIGHT_FIELDS, $extra))); + } + + /** + * @return list}> + */ + private static function buildPreview(rex_yform_manager_table $table, rex_yform_manager_dataset $dataset): array + { + $langFieldsAvailable = rex_addon::get('yform_lang_fields')->isAvailable(); + $highlightNames = self::highlightFieldNames(); + + $preview = []; + foreach ($table->getFields() as $field) { + if ($field->isHiddenInList()) { + continue; + } + + $name = $field->getName(); + $typeName = $field->getTypeName(); + $rawValue = $dataset->getValue($name); + $highlighted = in_array($name, $highlightNames, true); + + if ('checkbox' === $typeName) { + $preview[] = [ + 'name' => $name, + 'label' => $field->getLabel(), + 'kind' => 'boolean', + 'highlighted' => $highlighted, + 'on' => '1' === (string) $rawValue || 1 === $rawValue, + ]; + continue; + } + + if ($langFieldsAvailable && in_array($typeName, self::LANG_JSON_FIELD_TYPES, true)) { + $languages = self::decodeLangJson((string) $rawValue); + if ([] === $languages) { + continue; + } + foreach ($languages as &$lang) { + $lang['value'] = self::truncate($lang['value']); + } + unset($lang); + $preview[] = [ + 'name' => $name, + 'label' => $field->getLabel(), + 'kind' => 'lang_json', + 'highlighted' => $highlighted, + 'languages' => $languages, + ]; + continue; + } + + if (in_array($typeName, ['choice', 'select'], true)) { + $definition = $field->toArray(); + $options = self::parseChoiceOptions((string) ($definition['choices'] ?? '')); + $isMultiple = '1' === (string) ($definition['multiple'] ?? '0'); + $values = $isMultiple + ? array_filter(explode(',', (string) $rawValue)) + : [(string) $rawValue]; + + $labels = array_map(static fn ($v) => $options[trim($v)] ?? trim($v), $values); + $text = trim(implode(', ', array_filter($labels))); + if ('' === $text) { + continue; + } + $preview[] = [ + 'name' => $name, + 'label' => $field->getLabel(), + 'kind' => 'choice', + 'highlighted' => $highlighted, + 'text' => $text, + ]; + continue; + } + + if ('fields_tagging' === $typeName) { + $tags = self::decodeTaggingJson((string) $rawValue); + if ([] === $tags) { + continue; + } + $preview[] = [ + 'name' => $name, + 'label' => $field->getLabel(), + 'kind' => 'tags', + 'highlighted' => $highlighted, + 'tags' => $tags, + ]; + continue; + } + + $className = 'rex_yform_value_' . $typeName; + if (!method_exists($className, 'getListValue')) { + continue; + } + + // Some field types (e.g. fields_tagging) branch into an inline-edit + // rendering path when list_editable=1, which dereferences a real + // rex_yform_list object from params['list'] — force it off here since + // we only ever want the plain read-only rendering for a preview. + $safeFieldDefinition = $field->toArray(); + $safeFieldDefinition['list_editable'] = '0'; + + try { + $formatted = $className::getListValue([ + 'list' => null, + 'field' => $safeFieldDefinition, + 'value' => $rawValue, + 'subject' => $rawValue, + 'format' => 'custom', + 'escape' => false, + 'params' => [ + 'field' => $safeFieldDefinition, + 'fields' => $table->getFields(), + ], + ]); + } catch (\Throwable) { + $formatted = is_scalar($rawValue) ? (string) $rawValue : ''; + } + + $text = html_entity_decode(strip_tags((string) $formatted), ENT_QUOTES, 'UTF-8'); + $text = trim(preg_replace('/\s+/', ' ', $text)); + + if ($text === '') { + continue; + } + + $preview[] = [ + 'name' => $name, + 'label' => $field->getLabel(), + 'kind' => 'text', + 'highlighted' => $highlighted, + 'text' => self::truncate($text), + ]; + } + + // Highlighted fields (name/title/cat/category/admin-configured) always lead. + usort($preview, static fn (array $a, array $b) => (int) $b['highlighted'] <=> (int) $a['highlighted']); + + return array_slice($preview, 0, self::PREVIEW_MAX_FIELDS); + } + + private static function truncate(string $text): string + { + if (mb_strlen($text) <= self::PREVIEW_TEXT_MAX_LENGTH) { + return $text; + } + + return rtrim(mb_substr($text, 0, self::PREVIEW_TEXT_MAX_LENGTH)) . '…'; + } + + /** + * Decodes a yform_lang_fields JSON column into a per-language breakdown, + * skipping languages with an empty value. + * + * @return list + */ + private static function decodeLangJson(string $raw): array + { + if ('' === trim($raw)) { + return []; + } + + $decoded = json_decode($raw, true); + if (!is_array($decoded)) { + return []; + } + + $result = []; + foreach ($decoded as $entry) { + if (!is_array($entry) || !isset($entry['clang_id'])) { + continue; + } + $value = html_entity_decode(strip_tags((string) ($entry['value'] ?? '')), ENT_QUOTES, 'UTF-8'); + $value = trim(preg_replace('/\s+/', ' ', $value)); + if ('' === $value) { + continue; + } + + $clangId = (int) $entry['clang_id']; + $clang = rex_clang::get($clangId); + + $result[] = [ + 'clang_id' => $clangId, + 'lang_label' => $clang ? $clang->getCode() : (string) $clangId, + 'value' => $value, + ]; + } + + return $result; + } + + /** + * Decodes a fields_tagging JSON column ([{"text":..., "color":...}, ...]) + * into plain tag descriptors — mirrors the addon's own + * rex_yform_value_fields_tagging::getListValue() decoding. + * + * @return list + */ + private static function decodeTaggingJson(string $raw): array + { + if ('' === trim($raw)) { + return []; + } + + $decoded = json_decode($raw, true); + if (!is_array($decoded)) { + return []; + } + + $tags = []; + foreach ($decoded as $item) { + if (is_array($item) && isset($item['text']) && '' !== trim((string) $item['text'])) { + $tags[] = [ + 'text' => (string) $item['text'], + 'color' => isset($item['color']) ? (string) $item['color'] : '#7f8c8d', + ]; + } + } + + return $tags; + } + + /** + * Builds an edit link, preferring the currently open addon page if it already + * shows this table, falling back to the YForm manager standard path otherwise. + */ + public static function buildEditUrl(rex_yform_manager_table $table, int $id): string + { + $currentPage = rex_be_controller::getCurrentPage(); + $currentTableName = rex_request('table_name', 'string', ''); + + if ($currentPage !== '' && $currentTableName === $table->getTableName() && $currentPage !== 'yform/manager/data_edit') { + return rex_url::currentBackendPage([ + 'table_name' => $table->getTableName(), + 'data_id' => $id, + 'func' => 'edit', + ] + rex_csrf_token::factory($table->getCSRFKey())->getUrlParams()); + } + + return rex_yform_manager::url($table->getTableName(), $id); + } +} diff --git a/package.yml b/package.yml index 8dff2a7e..2cdbb7c2 100644 --- a/package.yml +++ b/package.yml @@ -1,5 +1,5 @@ package: quick_navigation -version: '9.1.0' +version: '9.2.0' author: 'Friends Of REDAXO' supportpage: https://github.com/FriendsOfREDAXO/quick_navigation perm: quick_navigation[] diff --git a/pages/config.php b/pages/config.php index 7398eff8..be8f435e 100644 --- a/pages/config.php +++ b/pages/config.php @@ -35,6 +35,12 @@ } $package->setConfig($config); + + if (rex::getUser()->isAdmin()) { + $highlightFields = trim(rex_post('quick_navigation_yform_highlight_fields', 'string', '')); + $package->setConfig('quick_navigation_yform_highlight_fields', $highlightFields); + } + echo rex_view::success($package->i18n('quick_navigation_config_saved')); } @@ -164,6 +170,19 @@ $fragment->setVar('elements', $formElements, false); $content .= $fragment->parse('core/form/container.php'); +if (rex::getUser()->isAdmin()) { + // YForm-Suche: zusätzliche, immer priorisierte Vorschau-Spalten (admin-weit) + $formElements = []; + $n = []; + $n['label'] = ''; + $n['field'] = ''; + $n['note'] = $package->i18n('quick_navigation_yform_highlight_fields_note'); + $formElements[] = $n; + $fragment = new rex_fragment(); + $fragment->setVar('elements', $formElements, false); + $content .= $fragment->parse('core/form/container.php'); +} + $content .= ''; // Save-Button From 39fdd0a34c2481ceb31e44d9c8d8a71054dfabef Mon Sep 17 00:00:00 2001 From: Thomas Skerbis Date: Thu, 17 Sep 2026 19:57:09 +0200 Subject: [PATCH 2/3] Style overlay header with REDAXO's navbar blue Matches the search/table-select header bar to REDAXO's own navbar color (#4b9ad9 / #246eaa dark) instead of a neutral gray, so the overlay reads as part of the backend chrome rather than a foreign widget. Co-Authored-By: Claude Sonnet 5 --- assets/yform-live-search.css | 44 ++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/assets/yform-live-search.css b/assets/yform-live-search.css index 200d8782..c1c2c331 100644 --- a/assets/yform-live-search.css +++ b/assets/yform-live-search.css @@ -57,15 +57,17 @@ body.rex-theme-dark .qn-yform-overlay-panel { align-items: center; gap: 10px; padding: 10px 12px; - border-bottom: 1px solid #c1c9d4; + background: #4b9ad9; + border-bottom: 1px solid #308bd3; } body.rex-theme-dark .qn-yform-overlay-header { - border-bottom-color: rgba(255, 255, 255, 0.15); + background: #246eaa; + border-bottom-color: #1e2731; } .qn-yform-overlay-icon { - color: #8a97a8; + color: rgba(255, 255, 255, 0.85); font-size: 15px; flex-shrink: 0; display: inline-flex; @@ -95,19 +97,19 @@ body.rex-theme-dark .qn-yform-overlay-header { font-size: 15px; font-family: inherit; background: transparent; - color: inherit; + color: #fff; height: 30px; } .qn-yform-overlay-input::placeholder { - color: #8a97a8; + color: rgba(255, 255, 255, 0.75); } .qn-yform-overlay-close, .qn-yform-overlay-filters-toggle { border: 0; background: transparent; - color: #8a97a8; + color: rgba(255, 255, 255, 0.85); cursor: pointer; padding: 5px 8px; border-radius: 0; @@ -118,19 +120,13 @@ body.rex-theme-dark .qn-yform-overlay-header { .qn-yform-overlay-close:hover, .qn-yform-overlay-filters-toggle:hover { - color: #324050; - background: rgba(0, 0, 0, 0.05); -} - -body.rex-theme-dark .qn-yform-overlay-close:hover, -body.rex-theme-dark .qn-yform-overlay-filters-toggle:hover { color: #fff; - background: rgba(255, 255, 255, 0.1); + background: rgba(255, 255, 255, 0.15); } .qn-yform-overlay-filters-toggle.active { - color: #fff; - background: #556d8c; + color: #4b9ad9; + background: #fff; } .qn-yform-overlay-filters-toggle.hidden { @@ -146,15 +142,19 @@ body.rex-theme-dark .qn-yform-overlay-filters-toggle:hover { padding: 4px 10px; font-size: 13px; border-radius: 0; - border-color: #c1c9d4; - background: #f3f6fb; - color: #324050; + border-color: rgba(255, 255, 255, 0.4); + background: rgba(255, 255, 255, 0.12); + color: #fff; } -body.rex-theme-dark .qn-yform-overlay-header .qn-yform-overlay-table-select .btn { - background: rgba(255, 255, 255, 0.08); - border-color: rgba(255, 255, 255, 0.15); - color: #eee; +.qn-yform-overlay-header .qn-yform-overlay-table-select .btn:hover, +.qn-yform-overlay-header .qn-yform-overlay-table-select .btn:focus { + background: rgba(255, 255, 255, 0.2); + color: #fff; +} + +.qn-yform-overlay-header .qn-yform-overlay-table-select .caret { + border-top-color: #fff; } .qn-yform-overlay-table-scope { From e9c4a62dcc4156de860971405b043125d900efee Mon Sep 17 00:00:00 2001 From: Thomas Skerbis Date: Thu, 17 Sep 2026 20:21:26 +0200 Subject: [PATCH 3/3] Rework dark mode to match REDAXO's own theme convention MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Switch from scattered body.rex-theme-dark overrides to CSS custom properties, mirroring the pattern already used by this addon's own media-live-search.css: variables on :root (light default), redefined under .rex-theme-dark, .rex-has-theme.rex-theme-dark (explicit dark), and again under @media (prefers-color-scheme: dark) guarded to .rex-has-theme:not(.rex-theme-light):not(.rex-theme-dark) for the "Automatic" theme setting with no explicit choice. Also raises the on/off badge text contrast in dark mode to meet WCAG AA (4.5:1) against the dark panel background — both were previously below it. Co-Authored-By: Claude Sonnet 5 --- assets/yform-live-search.css | 241 +++++++++++++++++++---------------- 1 file changed, 134 insertions(+), 107 deletions(-) diff --git a/assets/yform-live-search.css b/assets/yform-live-search.css index c1c2c331..f8ef8ba7 100644 --- a/assets/yform-live-search.css +++ b/assets/yform-live-search.css @@ -1,3 +1,82 @@ +/* CSS Variables - Standard: Light Theme */ +:root { + --qnyf-backdrop: rgba(15, 18, 22, 0.5); + --qnyf-panel-bg: #fff; + --qnyf-panel-text: #324050; + --qnyf-border: #c1c9d4; + --qnyf-border-soft: #dfe3e9; + --qnyf-header-bg: #4b9ad9; + --qnyf-header-border: #308bd3; + --qnyf-header-fg: #fff; + --qnyf-header-fg-soft: rgba(255, 255, 255, 0.85); + --qnyf-header-fg-softer: rgba(255, 255, 255, 0.75); + --qnyf-header-btn-bg: rgba(255, 255, 255, 0.12); + --qnyf-header-btn-bg-hover: rgba(255, 255, 255, 0.2); + --qnyf-header-btn-border: rgba(255, 255, 255, 0.4); + --qnyf-filters-bg: #f3f6fb; + --qnyf-muted: #8a97a8; + --qnyf-link: #4b9ad9; + --qnyf-link-hover: #3183c8; + --qnyf-row-hover: rgba(0, 0, 0, 0.035); + --qnyf-result-hover-bg: #f3f6fb; + --qnyf-result-hover-border: #556d8c; + --qnyf-badge-off-bg: rgba(0, 0, 0, 0.06); + --qnyf-badge-off-fg: #8a97a8; + --qnyf-badge-choice-bg: #eef1f5; + --qnyf-badge-choice-fg: #556d8c; + --qnyf-lang-code-bg: rgba(0, 0, 0, 0.07); + --qnyf-lang-code-fg: #8a97a8; + --qnyf-badge-on-bg: rgba(76, 175, 80, 0.15); + --qnyf-badge-on-fg: #3d9140; +} + +/* Dark Theme Variables (explicit choice) */ +.rex-theme-dark, +.rex-has-theme.rex-theme-dark { + --qnyf-panel-bg: #2b2f33; + --qnyf-panel-text: #eee; + --qnyf-border: rgba(255, 255, 255, 0.15); + --qnyf-border-soft: rgba(255, 255, 255, 0.1); + --qnyf-header-bg: #246eaa; + --qnyf-header-border: #1e2731; + --qnyf-filters-bg: rgba(255, 255, 255, 0.04); + --qnyf-muted: #9aa5b1; + --qnyf-row-hover: rgba(255, 255, 255, 0.05); + --qnyf-result-hover-bg: rgba(255, 255, 255, 0.06); + --qnyf-badge-off-bg: rgba(255, 255, 255, 0.1); + --qnyf-badge-off-fg: #b8bfc7; + --qnyf-badge-choice-bg: rgba(255, 255, 255, 0.1); + --qnyf-badge-choice-fg: #cfd8e3; + --qnyf-lang-code-bg: rgba(255, 255, 255, 0.12); + --qnyf-lang-code-fg: #ccc; + --qnyf-badge-on-bg: rgba(76, 175, 80, 0.25); + --qnyf-badge-on-fg: #8fe09a; +} + +/* Auto Theme (system preference, only when no explicit theme was chosen) */ +@media (prefers-color-scheme: dark) { + .rex-has-theme:not(.rex-theme-light):not(.rex-theme-dark) { + --qnyf-panel-bg: #2b2f33; + --qnyf-panel-text: #eee; + --qnyf-border: rgba(255, 255, 255, 0.15); + --qnyf-border-soft: rgba(255, 255, 255, 0.1); + --qnyf-header-bg: #246eaa; + --qnyf-header-border: #1e2731; + --qnyf-filters-bg: rgba(255, 255, 255, 0.04); + --qnyf-muted: #9aa5b1; + --qnyf-row-hover: rgba(255, 255, 255, 0.05); + --qnyf-result-hover-bg: rgba(255, 255, 255, 0.06); + --qnyf-badge-off-bg: rgba(255, 255, 255, 0.1); + --qnyf-badge-off-fg: #b8bfc7; + --qnyf-badge-choice-bg: rgba(255, 255, 255, 0.1); + --qnyf-badge-choice-fg: #cfd8e3; + --qnyf-lang-code-bg: rgba(255, 255, 255, 0.12); + --qnyf-lang-code-fg: #ccc; + --qnyf-badge-on-bg: rgba(76, 175, 80, 0.25); + --qnyf-badge-on-fg: #8fe09a; + } +} + .qn-yform-overlay { position: fixed; inset: 0; @@ -29,7 +108,7 @@ .qn-yform-overlay-backdrop { position: absolute; inset: 0; - background: rgba(15, 18, 22, 0.5); + background: var(--qnyf-backdrop); } .qn-yform-overlay-panel { @@ -39,35 +118,25 @@ max-height: 72vh; display: flex; flex-direction: column; - background: #fff; - color: #324050; + background: var(--qnyf-panel-bg); + color: var(--qnyf-panel-text); border-radius: 0; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3); overflow: hidden; animation: qnYformPanelIn 0.14s ease-out; } -body.rex-theme-dark .qn-yform-overlay-panel { - background: #2b2f33; - color: #eee; -} - .qn-yform-overlay-header { display: flex; align-items: center; gap: 10px; padding: 10px 12px; - background: #4b9ad9; - border-bottom: 1px solid #308bd3; -} - -body.rex-theme-dark .qn-yform-overlay-header { - background: #246eaa; - border-bottom-color: #1e2731; + background: var(--qnyf-header-bg); + border-bottom: 1px solid var(--qnyf-header-border); } .qn-yform-overlay-icon { - color: rgba(255, 255, 255, 0.85); + color: var(--qnyf-header-fg-soft); font-size: 15px; flex-shrink: 0; display: inline-flex; @@ -97,19 +166,19 @@ body.rex-theme-dark .qn-yform-overlay-header { font-size: 15px; font-family: inherit; background: transparent; - color: #fff; + color: var(--qnyf-header-fg); height: 30px; } .qn-yform-overlay-input::placeholder { - color: rgba(255, 255, 255, 0.75); + color: var(--qnyf-header-fg-softer); } .qn-yform-overlay-close, .qn-yform-overlay-filters-toggle { border: 0; background: transparent; - color: rgba(255, 255, 255, 0.85); + color: var(--qnyf-header-fg-soft); cursor: pointer; padding: 5px 8px; border-radius: 0; @@ -120,13 +189,13 @@ body.rex-theme-dark .qn-yform-overlay-header { .qn-yform-overlay-close:hover, .qn-yform-overlay-filters-toggle:hover { - color: #fff; + color: var(--qnyf-header-fg); background: rgba(255, 255, 255, 0.15); } .qn-yform-overlay-filters-toggle.active { - color: #4b9ad9; - background: #fff; + color: var(--qnyf-header-bg); + background: var(--qnyf-header-fg); } .qn-yform-overlay-filters-toggle.hidden { @@ -142,25 +211,25 @@ body.rex-theme-dark .qn-yform-overlay-header { padding: 4px 10px; font-size: 13px; border-radius: 0; - border-color: rgba(255, 255, 255, 0.4); - background: rgba(255, 255, 255, 0.12); - color: #fff; + border-color: var(--qnyf-header-btn-border); + background: var(--qnyf-header-btn-bg); + color: var(--qnyf-header-fg); } .qn-yform-overlay-header .qn-yform-overlay-table-select .btn:hover, .qn-yform-overlay-header .qn-yform-overlay-table-select .btn:focus { - background: rgba(255, 255, 255, 0.2); - color: #fff; + background: var(--qnyf-header-btn-bg-hover); + color: var(--qnyf-header-fg); } .qn-yform-overlay-header .qn-yform-overlay-table-select .caret { - border-top-color: #fff; + border-top-color: var(--qnyf-header-fg); } .qn-yform-overlay-table-scope { border: 0; background: transparent; - color: #8a97a8; + color: var(--qnyf-muted); cursor: pointer; padding: 6px 9px; border-radius: 0; @@ -169,22 +238,17 @@ body.rex-theme-dark .qn-yform-overlay-header { } .qn-yform-overlay-table-scope:hover { - color: #324050; - background: rgba(0, 0, 0, 0.05); + color: var(--qnyf-panel-text); + background: var(--qnyf-row-hover); } .qn-yform-overlay-filters { padding: 10px 12px; - border-bottom: 1px solid #c1c9d4; + border-bottom: 1px solid var(--qnyf-border); display: flex; flex-wrap: wrap; gap: 10px 14px; - background: #f3f6fb; -} - -body.rex-theme-dark .qn-yform-overlay-filters { - border-bottom-color: rgba(255, 255, 255, 0.15); - background: rgba(255, 255, 255, 0.04); + background: var(--qnyf-filters-bg); } .qn-yform-filter-field { @@ -202,11 +266,7 @@ body.rex-theme-dark .qn-yform-overlay-filters { font-size: 12px; font-weight: 700; margin-bottom: 1px; - color: #324050; -} - -body.rex-theme-dark .qn-yform-filter-field label.control-label { - color: #eee; + color: var(--qnyf-panel-text); } .qn-yform-filter-field .form-control { @@ -218,7 +278,7 @@ body.rex-theme-dark .qn-yform-filter-field label.control-label { } .qn-yform-filters-empty { - color: #8a97a8; + color: var(--qnyf-muted); font-size: 13px; font-style: italic; } @@ -237,23 +297,15 @@ body.rex-theme-dark .qn-yform-filter-field label.control-label { align-items: center; justify-content: space-between; gap: 4px; - border-bottom: 1px solid #dfe3e9; + border-bottom: 1px solid var(--qnyf-border-soft); } .qn-yform-overlay-tables .qn-yform-overlay-item-row:last-child { border-bottom: 0; } -body.rex-theme-dark .qn-yform-overlay-item-row { - border-bottom-color: rgba(255, 255, 255, 0.1); -} - .qn-yform-overlay-item-row:hover { - background: rgba(0, 0, 0, 0.035); -} - -body.rex-theme-dark .qn-yform-overlay-item-row:hover { - background: rgba(255, 255, 255, 0.05); + background: var(--qnyf-row-hover); } .qn-yform-overlay-table-link { @@ -263,7 +315,7 @@ body.rex-theme-dark .qn-yform-overlay-item-row:hover { align-items: center; gap: 8px; padding: 8px 14px; - color: #4b9ad9; + color: var(--qnyf-link); text-decoration: none; overflow: hidden; text-overflow: ellipsis; @@ -272,7 +324,7 @@ body.rex-theme-dark .qn-yform-overlay-item-row:hover { } .qn-yform-overlay-table-icon { - color: #8a97a8; + color: var(--qnyf-muted); font-size: 13px; width: 16px; text-align: center; @@ -281,43 +333,39 @@ body.rex-theme-dark .qn-yform-overlay-item-row:hover { .qn-yform-overlay-table-link:hover, .qn-yform-overlay-table-link:focus { - color: #3183c8; + color: var(--qnyf-link-hover); text-decoration: none; outline: none; } .qn-yform-overlay-table-link:focus { - background: rgba(0, 0, 0, 0.035); -} - -body.rex-theme-dark .qn-yform-overlay-table-link:focus { - background: rgba(255, 255, 255, 0.05); + background: var(--qnyf-row-hover); } .qn-yform-overlay-item-row a[title^="Datensatz"], .qn-yform-overlay-item-row a[title^="Add dataset"] { padding: 7px 12px; - color: #8a97a8; + color: var(--qnyf-muted); flex-shrink: 0; font-size: 13px; } .qn-yform-overlay-item-row a[title^="Datensatz"]:hover, .qn-yform-overlay-item-row a[title^="Add dataset"]:hover { - color: #324050; - background: rgba(0, 0, 0, 0.05); + color: var(--qnyf-panel-text); + background: var(--qnyf-row-hover); } .qn-yform-search-loading { padding: 20px; text-align: center; - color: #8a97a8; + color: var(--qnyf-muted); font-size: 16px; } .qn-yform-search-empty { padding: 20px; - color: #8a97a8; + color: var(--qnyf-muted); font-style: italic; text-align: center; font-size: 13px; @@ -329,7 +377,7 @@ body.rex-theme-dark .qn-yform-overlay-table-link:focus { font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; - color: #8a97a8; + color: var(--qnyf-muted); } .qn-yform-search-item { @@ -340,30 +388,21 @@ body.rex-theme-dark .qn-yform-overlay-table-link:focus { color: inherit; text-decoration: none; border-left: 3px solid transparent; - border-bottom: 1px solid #dfe3e9; + border-bottom: 1px solid var(--qnyf-border-soft); } .qn-yform-search-group .qn-yform-search-item:last-child { border-bottom: 0; } -body.rex-theme-dark .qn-yform-search-item { - border-bottom-color: rgba(255, 255, 255, 0.08); -} - .qn-yform-search-item:hover, .qn-yform-search-item:focus { - background: #f3f6fb; - border-left-color: #556d8c; + background: var(--qnyf-result-hover-bg); + border-left-color: var(--qnyf-result-hover-border); color: inherit; text-decoration: none; } -body.rex-theme-dark .qn-yform-search-item:hover, -body.rex-theme-dark .qn-yform-search-item:focus { - background: rgba(255, 255, 255, 0.06); -} - .qn-yform-search-item-head { display: flex; align-items: baseline; @@ -374,7 +413,7 @@ body.rex-theme-dark .qn-yform-search-item:focus { .qn-yform-search-title { font-size: 14px; font-weight: 600; - color: #4b9ad9; + color: var(--qnyf-link); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; @@ -382,12 +421,12 @@ body.rex-theme-dark .qn-yform-search-item:focus { .qn-yform-search-item:hover .qn-yform-search-title, .qn-yform-search-item:focus .qn-yform-search-title { - color: #3183c8; + color: var(--qnyf-link-hover); } .qn-yform-search-id { font-size: 11px; - color: #8a97a8; + color: var(--qnyf-muted); font-variant-numeric: tabular-nums; flex-shrink: 0; } @@ -406,7 +445,7 @@ body.rex-theme-dark .qn-yform-search-item:focus { } .qn-yform-search-field-label { - color: #8a97a8; + color: var(--qnyf-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; @@ -432,32 +471,25 @@ body.rex-theme-dark .qn-yform-search-item:focus { } .qn-badge-on { - background: rgba(76, 175, 80, 0.15); - color: #3d9140; + background: var(--qnyf-badge-on-bg); + color: var(--qnyf-badge-on-fg); } .qn-badge-off { - background: rgba(0, 0, 0, 0.06); - color: #8a97a8; -} - -body.rex-theme-dark .qn-badge-off { - background: rgba(255, 255, 255, 0.1); - color: #aaa; + background: var(--qnyf-badge-off-bg); + color: var(--qnyf-badge-off-fg); } .qn-badge-choice { - background: #eef1f5; - color: #556d8c; -} - -body.rex-theme-dark .qn-badge-choice { - background: rgba(255, 255, 255, 0.1); - color: #cfd8e3; + background: var(--qnyf-badge-choice-bg); + color: var(--qnyf-badge-choice-fg); } .qn-badge-tag { + /* Background color is admin-controlled (fields_tagging), can be any hue — + the text shadow keeps white text readable even on light tag colors. */ color: #fff; + text-shadow: 0 0 2px rgba(0, 0, 0, 0.6); border-radius: 10px; } @@ -480,8 +512,8 @@ body.rex-theme-dark .qn-badge-choice { align-self: start; padding: 0 4px; border-radius: 2px; - background: rgba(0, 0, 0, 0.07); - color: #8a97a8; + background: var(--qnyf-lang-code-bg); + color: var(--qnyf-lang-code-fg); font-size: 10px; font-weight: 700; text-transform: uppercase; @@ -489,11 +521,6 @@ body.rex-theme-dark .qn-badge-choice { line-height: 1.6; } -body.rex-theme-dark .qn-lang-code { - background: rgba(255, 255, 255, 0.12); - color: #ccc; -} - .qn-lang-text { overflow: hidden; text-overflow: ellipsis;