mirror of
https://github.com/moodle/moodle.git
synced 2025-08-08 02:16:41 +02:00
MDL-70279 tool_templatelibrary: preserve component search field value.
This commit is contained in:
parent
32866a1758
commit
0a62138795
6 changed files with 28 additions and 11 deletions
|
@ -1,2 +1,2 @@
|
||||||
define ("tool_templatelibrary/search",["jquery","core/ajax","core/log","core/notification","core/templates","core/config"],function(a,b,c,d,e,f){var g=function(b){e.render("tool_templatelibrary/search_results",{templates:b}).done(function(b,c){e.replaceNode(a("[data-region=\"searchresults\"]"),b,c)}).fail(d.exception)},h=function(c){var e=a("[data-field=\"component\"]").val(),f=a("[data-region=\"list-templates\"] [data-region=\"input\"]").val();if(""!==f){a("[data-region=\"list-templates\"] [data-action=\"clearsearch\"]").removeClass("d-none")}else{a("[data-region=\"list-templates\"] [data-action=\"clearsearch\"]").addClass("d-none")}document.location.hash=f;b.call([{methodname:"tool_templatelibrary_list_templates",args:{component:e,search:f,themename:c},done:g,fail:d.exception}],!0,!1)},i=null,j=function(a,b){if(null!==i){window.clearTimeout(i)}i=window.setTimeout(function(){a();i=null},b)},k=function(){j(h.bind(this,f.theme),400)};a("[data-region=\"list-templates\"]").on("change","[data-field=\"component\"]",k);a("[data-region=\"list-templates\"]").on("input","[data-region=\"input\"]",k);a("[data-action=\"clearsearch\"]").on("click",function(){a("[data-region=\"input\"]").val("");h(f.theme);a(this).addClass("d-none")});a("[data-region=\"input\"]").val(document.location.hash.replace("#",""));h(f.theme);return{}});
|
define ("tool_templatelibrary/search",["jquery","core/ajax","core/log","core/notification","core/templates","core/config"],function(a,b,c,d,e,f){var g=function(b){e.render("tool_templatelibrary/search_results",{templates:b}).done(function(b,c){e.replaceNode(a("[data-region=\"searchresults\"]"),b,c)}).fail(d.exception)},h=function(c){var e=a("[data-field=\"component\"]").val(),f=a("[data-region=\"list-templates\"] [data-region=\"input\"]").val();if(""!==f){a("[data-region=\"list-templates\"] [data-action=\"clearsearch\"]").removeClass("d-none")}else{a("[data-region=\"list-templates\"] [data-action=\"clearsearch\"]").addClass("d-none")}b.call([{methodname:"tool_templatelibrary_list_templates",args:{component:e,search:f,themename:c},done:g,fail:d.exception}],!0,!1)},i=null,j=function(a,b){if(null!==i){window.clearTimeout(i)}i=window.setTimeout(function(){a();i=null},b)},k=function(){j(h.bind(this,f.theme),400)};a("[data-region=\"list-templates\"]").on("change","[data-field=\"component\"]",k);a("[data-region=\"list-templates\"]").on("input","[data-region=\"input\"]",k);a("[data-action=\"clearsearch\"]").on("click",function(){a("[data-region=\"input\"]").val("");h(f.theme);a(this).addClass("d-none")});h(f.theme);return{}});
|
||||||
//# sourceMappingURL=search.min.js.map
|
//# sourceMappingURL=search.min.js.map
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -52,9 +52,8 @@ define(['jquery', 'core/ajax', 'core/log', 'core/notification', 'core/templates'
|
||||||
} else {
|
} else {
|
||||||
$('[data-region="list-templates"] [data-action="clearsearch"]').addClass('d-none');
|
$('[data-region="list-templates"] [data-action="clearsearch"]').addClass('d-none');
|
||||||
}
|
}
|
||||||
// Trigger the search.
|
|
||||||
document.location.hash = searchStr;
|
|
||||||
|
|
||||||
|
// Trigger the search.
|
||||||
ajax.call([
|
ajax.call([
|
||||||
{methodname: 'tool_templatelibrary_list_templates',
|
{methodname: 'tool_templatelibrary_list_templates',
|
||||||
args: {component: componentStr, search: searchStr, themename: themename},
|
args: {component: componentStr, search: searchStr, themename: themename},
|
||||||
|
@ -96,7 +95,6 @@ define(['jquery', 'core/ajax', 'core/log', 'core/notification', 'core/templates'
|
||||||
$(this).addClass('d-none');
|
$(this).addClass('d-none');
|
||||||
});
|
});
|
||||||
|
|
||||||
$('[data-region="input"]').val(document.location.hash.replace('#', ''));
|
|
||||||
refreshSearch(config.theme);
|
refreshSearch(config.theme);
|
||||||
return {};
|
return {};
|
||||||
});
|
});
|
||||||
|
|
|
@ -38,6 +38,22 @@ use tool_templatelibrary\api;
|
||||||
*/
|
*/
|
||||||
class list_templates_page implements renderable, templatable {
|
class list_templates_page implements renderable, templatable {
|
||||||
|
|
||||||
|
/** @var string $component The currently selected component */
|
||||||
|
protected $component;
|
||||||
|
/** @var string $search The current search */
|
||||||
|
protected $search;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Template page constructor
|
||||||
|
*
|
||||||
|
* @param string $component
|
||||||
|
* @param string $search
|
||||||
|
*/
|
||||||
|
public function __construct(string $component = '', string $search = '') {
|
||||||
|
$this->component = $component;
|
||||||
|
$this->search = $search;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Export this data so it can be used as the context for a mustache template.
|
* Export this data so it can be used as the context for a mustache template.
|
||||||
*
|
*
|
||||||
|
@ -46,6 +62,7 @@ class list_templates_page implements renderable, templatable {
|
||||||
public function export_for_template(renderer_base $output) {
|
public function export_for_template(renderer_base $output) {
|
||||||
$data = new stdClass();
|
$data = new stdClass();
|
||||||
$data->allcomponents = array();
|
$data->allcomponents = array();
|
||||||
|
$data->search = $this->search;
|
||||||
$fulltemplatenames = api::list_templates();
|
$fulltemplatenames = api::list_templates();
|
||||||
$pluginmanager = core_plugin_manager::instance();
|
$pluginmanager = core_plugin_manager::instance();
|
||||||
$components = array();
|
$components = array();
|
||||||
|
@ -59,6 +76,7 @@ class list_templates_page implements renderable, templatable {
|
||||||
foreach ($components as $component) {
|
foreach ($components as $component) {
|
||||||
$info = new stdClass();
|
$info = new stdClass();
|
||||||
$info->component = $component;
|
$info->component = $component;
|
||||||
|
$info->selected = ($component === $this->component);
|
||||||
if (strpos($component, 'core') === 0) {
|
if (strpos($component, 'core') === 0) {
|
||||||
$info->name = get_string('coresubsystem', 'tool_templatelibrary', $component);
|
$info->name = get_string('coresubsystem', 'tool_templatelibrary', $component);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -72,10 +72,10 @@
|
||||||
{{/label}}
|
{{/label}}
|
||||||
|
|
||||||
{{$element}}
|
{{$element}}
|
||||||
<select id="selectcomponent" class="form-control" data-field="component">
|
<select id="selectcomponent" name="component" class="form-control" data-field="component">
|
||||||
<option value="">{{#str}}all, tool_templatelibrary{{/str}}</option>
|
<option value="">{{#str}}all, tool_templatelibrary{{/str}}</option>
|
||||||
{{#allcomponents}}
|
{{#allcomponents}}
|
||||||
<option value="{{component}}">{{name}}</option>
|
<option value="{{component}}" {{#selected}}selected{{/selected}}>{{name}}</option>
|
||||||
{{/allcomponents}}
|
{{/allcomponents}}
|
||||||
</select>
|
</select>
|
||||||
{{/element}}
|
{{/element}}
|
||||||
|
@ -84,10 +84,10 @@
|
||||||
{{< core_form/element-template }}
|
{{< core_form/element-template }}
|
||||||
{{$element}}
|
{{$element}}
|
||||||
{{< core/search_input_auto }}
|
{{< core/search_input_auto }}
|
||||||
{{$label}}{{{ searchstring }}}{{/label}}
|
{{$label}}
|
||||||
{{$placeholder}}{{#str}}
|
{{#str}} search, tool_templatelibrary {{/str}}
|
||||||
search, core
|
{{/label}}
|
||||||
{{/str}}{{/placeholder}}
|
{{$value}}{{ search }}{{/value}}
|
||||||
{{/ core/search_input_auto }}
|
{{/ core/search_input_auto }}
|
||||||
{{/element}}
|
{{/element}}
|
||||||
{{/ core_form/element-template }}
|
{{/ core_form/element-template }}
|
||||||
|
|
|
@ -49,6 +49,7 @@
|
||||||
class="form-control withclear"
|
class="form-control withclear"
|
||||||
placeholder="{{$placeholder}}{{#str}} search, core {{/str}}{{/placeholder}}"
|
placeholder="{{$placeholder}}{{#str}} search, core {{/str}}{{/placeholder}}"
|
||||||
name="search"
|
name="search"
|
||||||
|
value="{{$value}}{{/value}}"
|
||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue