prevent list of enabled plugins resetting if saved while in search results

This commit is contained in:
Andrew Dolgov 2021-03-07 12:26:33 +03:00
parent 1dcc36deca
commit 773bad1490
2 changed files with 6 additions and 2 deletions

View File

@ -1009,7 +1009,7 @@ class Pref_Prefs extends Handler_Protected {
function setplugins() { function setplugins() {
$plugins = array_filter($_REQUEST["plugins"], 'clean') ?? []; $plugins = array_filter($_REQUEST["plugins"], 'clean') ?? [];
set_pref(Prefs::_ENABLED_PLUGINS, implode(",", $plugins)); //set_pref(Prefs::_ENABLED_PLUGINS, implode(",", $plugins));
} }
function _get_plugin_version(Plugin $plugin) { function _get_plugin_version(Plugin $plugin) {

View File

@ -356,6 +356,7 @@ const Helpers = {
++results_rendered; ++results_rendered;
// only user-enabled actually counts in the checkbox when saving because system plugin checkboxes are disabled (see below)
container.innerHTML += ` container.innerHTML += `
<li data-row-value="${App.escapeHtml(plugin.name)}" data-plugin-name="${App.escapeHtml(plugin.name)}" title="${plugin.is_system ? __("System plugins are enabled using global configuration.") : ""}"> <li data-row-value="${App.escapeHtml(plugin.name)}" data-plugin-name="${App.escapeHtml(plugin.name)}" title="${plugin.is_system ? __("System plugins are enabled using global configuration.") : ""}">
<label class="checkbox ${plugin.is_system ? "system text-info" : ""}"> <label class="checkbox ${plugin.is_system ? "system text-info" : ""}">
@ -387,11 +388,14 @@ const Helpers = {
<div class='version text-muted'>${plugin.version}</div> <div class='version text-muted'>${plugin.version}</div>
</li> </li>
`; `;
} else {
// if plugin is outside of search scope, keep current value in case of saving (only user-enabled is needed)
container.innerHTML += App.FormFields.checkbox_tag("plugins[]", plugin.user_enabled, plugin.name, {style: 'display : none'});
} }
}); });
if (results_rendered == 0) { if (results_rendered == 0) {
container.innerHTML = `<li class='text-center text-info'>${__("Could not find any plugins for this search query.")}</li>`; container.innerHTML += `<li class='text-center text-info'>${__("Could not find any plugins for this search query.")}</li>`;
} }
dojo.parser.parse(container); dojo.parser.parse(container);