Skip to content

Commit

Permalink
Merge branch 'MDL-70279' of git://github.com/paulholden/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
stronk7 committed Dec 22, 2020
2 parents 4598041 + 1cef02d commit 2d37d7f
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 11 deletions.
2 changes: 1 addition & 1 deletion admin/tool/templatelibrary/amd/build/search.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion admin/tool/templatelibrary/amd/build/search.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions admin/tool/templatelibrary/amd/src/search.js
Expand Up @@ -52,9 +52,8 @@ define(['jquery', 'core/ajax', 'core/log', 'core/notification', 'core/templates'
} else {
$('[data-region="list-templates"] [data-action="clearsearch"]').addClass('d-none');
}
// Trigger the search.
document.location.hash = searchStr;

// Trigger the search.
ajax.call([
{methodname: 'tool_templatelibrary_list_templates',
args: {component: componentStr, search: searchStr, themename: themename},
Expand Down Expand Up @@ -96,7 +95,6 @@ define(['jquery', 'core/ajax', 'core/log', 'core/notification', 'core/templates'
$(this).addClass('d-none');
});

$('[data-region="input"]').val(document.location.hash.replace('#', ''));
refreshSearch(config.theme);
return {};
});
18 changes: 18 additions & 0 deletions admin/tool/templatelibrary/classes/output/list_templates_page.php
Expand Up @@ -40,6 +40,22 @@
*/
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.
*
Expand Down Expand Up @@ -75,6 +91,7 @@ public function export_for_template(renderer_base $output) {
$components[$type]->plugins[$component] = (object) [
'name' => $pluginname,
'component' => $component,
'selected' => ($component === $this->component),
];
}

Expand All @@ -87,6 +104,7 @@ public function export_for_template(renderer_base $output) {

return (object) [
'allcomponents' => array_values($components),
'search' => $this->search,
];
}
}
Expand Up @@ -72,12 +72,12 @@
{{/label}}

{{$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>
{{#allcomponents}}
<optgroup label="{{type}}">
{{#plugins}}
<option value="{{component}}">{{name}}</option>
<option value="{{component}}" {{#selected}}selected{{/selected}}>{{name}}</option>
{{/plugins}}
</optgroup>
{{/allcomponents}}
Expand All @@ -88,10 +88,10 @@
{{< core_form/element-template }}
{{$element}}
{{< core/search_input_auto }}
{{$label}}{{{ searchstring }}}{{/label}}
{{$placeholder}}{{#str}}
search, core
{{/str}}{{/placeholder}}
{{$label}}
{{#str}} search, tool_templatelibrary {{/str}}
{{/label}}
{{$value}}{{ search }}{{/value}}
{{/ core/search_input_auto }}
{{/element}}
{{/ core_form/element-template }}
Expand Down
1 change: 1 addition & 0 deletions lib/templates/search_input_auto.mustache
Expand Up @@ -49,6 +49,7 @@
class="form-control withclear"
placeholder="{{$placeholder}}{{#str}} search, core {{/str}}{{/placeholder}}"
name="search"
value="{{$value}}{{/value}}"
autocomplete="off"
>
<button
Expand Down

0 comments on commit 2d37d7f

Please sign in to comment.