Skip to content

Commit

Permalink
Admin report: autocomplete pages
Browse files Browse the repository at this point in the history
  • Loading branch information
annda committed Nov 30, 2023
1 parent 19b8327 commit 524b6ab
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
21 changes: 16 additions & 5 deletions action.php
Expand Up @@ -90,12 +90,23 @@ public function handleAjaxAutocomplete(Event $event)
/** @var helper_plugin_acknowledge $hlp */
$hlp = $this->loadHelper('acknowledge');

$knownUsers = $hlp->getUsers();
$found = [];

if ($INPUT->has('user')) {
$search = $INPUT->str('user');
$knownUsers = $hlp->getUsers();
$found = array_filter($knownUsers, function ($user) use ($search) {
return (strstr(strtolower($user['label']), strtolower($search))) !== false ? $user : null;
});
}

$search = $INPUT->str('user');
$found = array_filter($knownUsers, function ($user) use ($search) {
return (strstr(strtolower($user['label']), strtolower($search))) !== false ? $user : null;
});
if ($INPUT->has('pg')) {
$search = $INPUT->str('pg');
$pages = ft_pageLookup($search);
$found = array_map(function ($id, $title) {
return ['value' => $id, 'label' => $title ?? $id];
}, array_keys($pages), array_values($pages));
}

header('Content-Type: application/json');

Expand Down
10 changes: 10 additions & 0 deletions script.js
Expand Up @@ -15,6 +15,16 @@ jQuery(function () {
},
minLength: 1
});
$form.find('input[name="pg"]')
.autocomplete({
source: function (request, response) {
jQuery.getJSON(DOKU_BASE + 'lib/exe/ajax.php?call=plugin_acknowledge_autocomplete', {
pg: request.term,
sectok: $form.find('input[name="sectok"]').val()
}, response);
},
minLength: 3
});
}

const $form = jQuery('.dokuwiki.mode_admin div.plugin_acknowledgement_admin form#acknowledge__user-autocomplete');
Expand Down

0 comments on commit 524b6ab

Please sign in to comment.