fix settings-search

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2022-03-07 10:37:00 +01:00
parent 958e783e77
commit 3c20fe4202
5 changed files with 34 additions and 14 deletions

View File

@@ -16,10 +16,12 @@
* @package Panel * @package Panel
* *
*/ */
use Froxlor\Database\Database; use Froxlor\Database\Database;
use Froxlor\Settings; use Froxlor\Settings;
use Froxlor\Api\Commands\Froxlor; use Froxlor\Api\Commands\Froxlor;
use Froxlor\UI\Panel\UI; use Froxlor\UI\Panel\UI;
use Froxlor\UI\Request;
const AREA = 'admin'; const AREA = 'admin';
require __DIR__ . '/lib/init.php'; require __DIR__ . '/lib/init.php';
@@ -91,7 +93,8 @@ if ($page == 'overview' && $userinfo['change_serversettings'] == '1') {
if ($_part == '' || $_part == 'all') { if ($_part == '' || $_part == 'all') {
UI::twigBuffer('settings/index.html.twig', ['fields' => $fields]); UI::twigBuffer('settings/index.html.twig', ['fields' => $fields]);
} else { } else {
UI::twigBuffer('settings/detailpart.html.twig', ['fields' => $fields]); $em = Request::get('em', '');
UI::twigBuffer('settings/detailpart.html.twig', ['fields' => $fields, 'em' => $em]);
} }
UI::twigOutputBuffer(); UI::twigOutputBuffer();
@@ -274,7 +277,7 @@ if ($page == 'overview' && $userinfo['change_serversettings'] == '1') {
eval("echo \"" . \Froxlor\UI\Template::getTemplate("settings/integritycheck") . "\";"); eval("echo \"" . \Froxlor\UI\Template::getTemplate("settings/integritycheck") . "\";");
} elseif ($page == 'importexport' && $userinfo['change_serversettings'] == '1') { } elseif ($page == 'importexport' && $userinfo['change_serversettings'] == '1') {
// check for json-stuff // check for json-stuff
if (! extension_loaded('json')) { if (!extension_loaded('json')) {
\Froxlor\UI\Response::standard_error('jsonextensionnotfound'); \Froxlor\UI\Response::standard_error('jsonextensionnotfound');
} }
@@ -359,7 +362,7 @@ if ($page == 'overview' && $userinfo['change_serversettings'] == '1') {
$_mailerror = true; $_mailerror = true;
} }
if (! $_mailerror) { if (!$_mailerror) {
// success // success
$mail->ClearAddresses(); $mail->ClearAddresses();
\Froxlor\UI\Response::standard_success('testmailsent', '', array( \Froxlor\UI\Response::standard_success('testmailsent', '', array(

View File

@@ -254,10 +254,12 @@ class Ajax
if (!array_key_exists($settingkey, $processed_setting)) { if (!array_key_exists($settingkey, $processed_setting)) {
$processed_setting[$settingkey] = true; $processed_setting[$settingkey] = true;
$sresult = $settings_data[$pk[0]][$pk[1]][$pk[2]][$pk[3]]; $sresult = $settings_data[$pk[0]][$pk[1]][$pk[2]][$pk[3]];
$result[] = [ if ($sresult['type'] != 'hidden') {
'title' => (is_array($sresult['label']) ? $sresult['label']['title'] : $sresult['label']), $result[] = [
'href' => 'admin_settings.php?page=overview&part=' . $pk[1] . '&em=' . $pk[3] . '&s=' . $this->session, 'title' => (is_array($sresult['label']) ? $sresult['label']['title'] : $sresult['label']),
]; 'href' => 'admin_settings.php?page=overview&part=' . $pk[1] . '&em=' . $pk[3] . '&s=' . $this->session,
];
}
} }
} }
} }

View File

@@ -1,14 +1,28 @@
{% macro fieldrow(id, field, norow = false, nohide = false) %} {% macro fieldrow(id, field, norow = false, nohide = false, em = false) %}
{% if field.visible is not defined or (field.visible is defined and field.visible) or nohide == true %} {% if field.visible is not defined or (field.visible is defined and field.visible) or nohide == true %}
{% if norow == false and field.type != 'hidden' %} {% if norow == false and field.type != 'hidden' %}
<div class="row mb-3 pb-3 border-bottom"> <div class="row mb-3 pb-3 border-bottom">
{% if field.label is iterable %} {% if field.label is iterable %}
<label for="{{ id }}" class="col-sm-4 col-form-label">{{ field.label.title|raw }} <label for="{{ id }}" class="col-sm-4 col-form-label">
{% if em %}
<mark>
{% endif %}
{{ field.label.title|raw }}
{% if em %}
</mark>
{% endif %}
{% if field.label.description is defined and field.label.description is not empty %}<br><small>{{ field.label.description|raw }}</small> {% if field.label.description is defined and field.label.description is not empty %}<br><small>{{ field.label.description|raw }}</small>
{% endif %} {% endif %}
</label> </label>
{% else %} {% else %}
<label for="{{ id }}" class="col-sm-4 col-form-label">{{ field.label|raw }} <label for="{{ id }}" class="col-sm-4 col-form-label">
{% if em %}
<mark>
{% endif %}
{{ field.label|raw }}
{% if em %}
</mark>
{% endif %}
{% if field.desc is defined and field.desc is not empty %}<br><small>{{ field.desc|raw }}</small> {% if field.desc is defined and field.desc is not empty %}<br><small>{{ field.desc|raw }}</small>
{% endif %} {% endif %}
</label> </label>

View File

@@ -8,7 +8,8 @@
<div class="card-body"> <div class="card-body">
{% for id,setting in fields %} {% for id,setting in fields %}
{% if id != '_group' %} {% if id != '_group' %}
{{ formfields.fieldrow(id, setting, false, (get_setting('system.hide_incompatible_settings') == '0')) }} {% set isEm = em is defined and em == id %}
{{ formfields.fieldrow(id, setting, false, (get_setting('system.hide_incompatible_settings') == '0'), isEm) }}
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</div> </div>

View File

@@ -5,8 +5,8 @@ $(document).ready(function () {
input: '.js-typeahead-search_v1', input: '.js-typeahead-search_v1',
order: "desc", order: "desc",
dynamic: true, dynamic: true,
display: ['data.title'], display: ['title'],
href: "{{url}}", href: "{{href}}",
emptyTemplate: "No results for {{query}}", emptyTemplate: "No results for {{query}}",
debug: true, debug: true,
source: { source: {
@@ -14,7 +14,7 @@ $(document).ready(function () {
ajax: { ajax: {
method: "post", method: "post",
url: "lib/ajax.php?action=searchsetting&theme=" + window.$theme + "&s=" + window.$session, url: "lib/ajax.php?action=searchsetting&theme=" + window.$theme + "&s=" + window.$session,
path: "title", path: "settings",
data: { data: {
searchtext: '{{query}}' searchtext: '{{query}}'
}, },