field for autocompletion can be set

This commit is contained in:
Uwe Steinmann 2023-01-16 16:03:10 +01:00
parent 9f0df3cabe
commit 321f80f974
2 changed files with 13 additions and 1 deletions

View File

@ -554,6 +554,10 @@ class SeedDMS_ExtPaperless_RestAPI_Controller { /* {{{ */
$fulltextservice = $this->container->fulltextservice; $fulltextservice = $this->container->fulltextservice;
$logger = $this->container->logger; $logger = $this->container->logger;
if(!empty($settings->_extensions['paperless']['autocompletefield']))
$field = $settings->_extensions['paperless']['autocompletefield'];
else
$field = 'title';
$params = $request->getQueryParams(); $params = $request->getQueryParams();
$query = $params['term']; $query = $params['term'];
$logger->log(var_export($params, true), PEAR_LOG_DEBUG); $logger->log(var_export($params, true), PEAR_LOG_DEBUG);
@ -561,7 +565,7 @@ class SeedDMS_ExtPaperless_RestAPI_Controller { /* {{{ */
$list = []; $list = [];
$index = $fulltextservice->Indexer(); $index = $fulltextservice->Indexer();
if($index) { if($index) {
if($terms = $index->terms($query, 'title')) { if($terms = $index->terms($query, $field)) {
foreach($terms as $term) foreach($terms as $term)
$list[] = $term->text; $list[] = $term->text;
} }

View File

@ -42,6 +42,14 @@ $EXT_CONF['paperless'] = array(
'internal'=>'categories', 'internal'=>'categories',
'allow_empty'=>true, 'allow_empty'=>true,
), ),
'autocompletefield' => array(
'title'=>'Field used for autocompletion',
'help'=>'The terms in this field will be used when the autocomplete method is called.',
'type'=>'select',
'multiple'=>false,
'options'=>['title'=>'Title', 'content'=>'Content'],
'allow_empty'=>true,
),
), ),
'constraints' => array( 'constraints' => array(
'depends' => array('php' => '7.4.0-', 'seeddms' => array('5.1.29-5.1.99', '6.0.22-6.0.99')), 'depends' => array('php' => '7.4.0-', 'seeddms' => array('5.1.29-5.1.99', '6.0.22-6.0.99')),