Enable searching via config

Only the ServerEventDataSource supports this for now. This is purely to satisfy https://github.com/rainlab/translate-plugin/pull/272
Clean up and fix net spam
This commit is contained in:
Samuel Georges 2017-07-15 12:18:11 +10:00
parent 3145611150
commit 4239caf9eb
4 changed files with 10 additions and 11 deletions

View File

@ -121,6 +121,7 @@ class Table extends WidgetBase
$this->vars['recordsPerPage'] = $this->getConfig('recordsPerPage', false) ?: 'false';
$this->vars['postbackHandlerName'] = $this->getConfig('postbackHandlerName', 'onSave');
$this->vars['searching'] = $this->getConfig('searching', true);
$this->vars['adding'] = $this->getConfig('adding', true);
$this->vars['deleting'] = $this->getConfig('deleting', true);
$this->vars['toolbar'] = $this->getConfig('toolbar', true);

View File

@ -569,8 +569,9 @@ this.searchInput=$('.table-search-input',this.searchForm).get(0)}}
Search.prototype.getQuery=function(){return $.trim(this.activeQuery)}
Search.prototype.hasQuery=function(){return this.searchEnabled()&&$.trim(this.activeQuery).length>0}
Search.prototype.searchEnabled=function(){return this.tableObj.options.searching}
Search.prototype.performSearch=function(query,onSuccess){this.activeQuery=query
this.tableObj.updateDataTable(onSuccess)}
Search.prototype.performSearch=function(query,onSuccess){var isDirty=this.activeQuery!=query
this.activeQuery=query
if(isDirty){this.tableObj.updateDataTable(onSuccess)}}
Search.prototype.onKeydown=function(ev){if(ev.keyCode==9){this.onClick(ev)
return}
if(!this.isActive){return}

View File

@ -74,9 +74,13 @@
}
Search.prototype.performSearch = function(query, onSuccess) {
var isDirty = this.activeQuery != query
this.activeQuery = query
this.tableObj.updateDataTable(onSuccess)
if (isDirty) {
this.tableObj.updateDataTable(onSuccess)
}
}
// EVENT HANDLERS

View File

@ -8,6 +8,7 @@
data-field-name="<?= e($this->fieldName) ?>"
data-postback-handler-name="<?= e($postbackHandlerName) ?>"
data-adding="<?= e($adding) ?>"
data-searching="<?= e($searching) ?>"
data-deleting="<?= e($deleting) ?>"
data-toolbar="<?= e($toolbar) ?>"
data-height="<?= e($height) ?>"
@ -34,14 +35,6 @@
</script>
<script type="text/template" data-table-toolbar-search>
<form method="get" class="table-search">
<?php if (!is_null(get('search'))): ?>
<a
href="javascript:;"
data-request="onReset"
class="btn oc-icon-undo"><?= e(trans('rainlab.translate::lang.messages.reset_search')) ?>
</a>
<?php endif ?>
<input
placeholder="<?= e(trans('backend::lang.list.search_prompt')) ?>"
name="search"