mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-70279 tool_templatelibrary: preserve component search field value.
This commit is contained in:
parent
627e14727e
commit
377da86151
5 changed files with 23 additions and 8 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-field=\"search\"]").val();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-field=\"search\"]",k);a("[data-field=\"search\"]").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-field=\"search\"]").val();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-field=\"search\"]",k);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
|
@ -48,8 +48,6 @@ define(['jquery', 'core/ajax', 'core/log', 'core/notification', 'core/templates'
|
||||||
var searchStr = $('[data-field="search"]').val();
|
var searchStr = $('[data-field="search"]').val();
|
||||||
|
|
||||||
// Trigger the search.
|
// Trigger the search.
|
||||||
document.location.hash = searchStr;
|
|
||||||
|
|
||||||
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},
|
||||||
|
@ -86,7 +84,6 @@ define(['jquery', 'core/ajax', 'core/log', 'core/notification', 'core/templates'
|
||||||
$('[data-region="list-templates"]').on('change', '[data-field="component"]', changeHandler);
|
$('[data-region="list-templates"]').on('change', '[data-field="component"]', changeHandler);
|
||||||
$('[data-region="list-templates"]').on('input', '[data-field="search"]', changeHandler);
|
$('[data-region="list-templates"]').on('input', '[data-field="search"]', changeHandler);
|
||||||
|
|
||||||
$('[data-field="search"]').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 {
|
||||||
|
|
|
@ -36,10 +36,10 @@
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label for="selectcomponent" class="control-label">{{#str}}component, tool_templatelibrary{{/str}}</label>
|
<label for="selectcomponent" class="control-label">{{#str}}component, tool_templatelibrary{{/str}}</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<select id="selectcomponent" data-field="component">
|
<select id="selectcomponent" name="component" 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>
|
||||||
</div>
|
</div>
|
||||||
|
@ -47,7 +47,7 @@
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label for="search" class="control-label">{{#str}}search, tool_templatelibrary{{/str}}</label>
|
<label for="search" class="control-label">{{#str}}search, tool_templatelibrary{{/str}}</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<input type="text" id="search" data-field="search"/>
|
<input type="text" id="search" name="search" value="{{ search }}" data-field="search"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue