Skip to content

Commit

Permalink
Merge branch 'MDL-70279-39' of git://github.com/paulholden/moodle int…
Browse files Browse the repository at this point in the history
…o MOODLE_39_STABLE
  • Loading branch information
stronk7 committed Dec 22, 2020
2 parents 29f7630 + 377da86 commit fa35b95
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 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.

3 changes: 0 additions & 3 deletions admin/tool/templatelibrary/amd/src/search.js
Expand Up @@ -48,8 +48,6 @@ define(['jquery', 'core/ajax', 'core/log', 'core/notification', 'core/templates'
var searchStr = $('[data-field="search"]').val();

// Trigger the search.
document.location.hash = searchStr;

ajax.call([
{methodname: 'tool_templatelibrary_list_templates',
args: {component: componentStr, search: searchStr, themename: themename},
Expand Down Expand Up @@ -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('input', '[data-field="search"]', changeHandler);

$('[data-field="search"]').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 @@ -38,6 +38,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 All @@ -46,6 +62,7 @@ class list_templates_page implements renderable, templatable {
public function export_for_template(renderer_base $output) {
$data = new stdClass();
$data->allcomponents = array();
$data->search = $this->search;
$fulltemplatenames = api::list_templates();
$pluginmanager = core_plugin_manager::instance();
$components = array();
Expand All @@ -59,6 +76,7 @@ public function export_for_template(renderer_base $output) {
foreach ($components as $component) {
$info = new stdClass();
$info->component = $component;
$info->selected = ($component === $this->component);
if (strpos($component, 'core') === 0) {
$info->name = get_string('coresubsystem', 'tool_templatelibrary', $component);
} else {
Expand Down
Expand Up @@ -36,18 +36,18 @@
<div class="control-group">
<label for="selectcomponent" class="control-label">{{#str}}component, tool_templatelibrary{{/str}}</label>
<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>
{{#allcomponents}}
<option value="{{component}}">{{name}}</option>
<option value="{{component}}" {{#selected}}selected{{/selected}}>{{name}}</option>
{{/allcomponents}}
</select>
</div>
</div>
<div class="control-group">
<label for="search" class="control-label">{{#str}}search, tool_templatelibrary{{/str}}</label>
<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>
</form>
Expand Down

0 comments on commit fa35b95

Please sign in to comment.