Skip to content

Commit

Permalink
Refactoring auto-complete functionality for alias editor and auto tagger
Browse files Browse the repository at this point in the history
  • Loading branch information
myname committed Nov 17, 2023
1 parent 6664c2e commit 46fce1e
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 10 deletions.
33 changes: 33 additions & 0 deletions core/imageboard/autocomplete_column.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
declare(strict_types=1);

namespace Shimmie2;

use MicroCRUD\TextColumn;
use function MicroHTML\INPUT;

class AutoCompleteColumn extends TextColumn
{
public function read_input(array $inputs)
{
return INPUT([
"type" => "text",
"name" => "r_{$this->name}",
"class" => "autocomplete_tags",
"placeholder" => $this->title,
"value" => @$inputs["r_{$this->name}"]
]);
}

public function create_input(array $inputs)
{
return INPUT([
"type" => "text",
"name" => "c_{$this->name}",
"class" => "autocomplete_tags",
"placeholder" => $this->title,
"value" => @$inputs["c_{$this->name}"]
]);
}
}
?>
4 changes: 2 additions & 2 deletions ext/alias_editor/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public function __construct(\FFSPHP\PDO $db)
$this->size = 100;
$this->limit = 1000000;
$this->set_columns([
new TextColumn("oldtag", "Old Tag"),
new TextColumn("newtag", "New Tag"),
new AutoCompleteColumn("oldtag", "Old Tag"),
new AutoCompleteColumn("newtag", "New Tag"),
new ActionColumn("oldtag"),
]);
$this->order_by = ["oldtag"];
Expand Down
3 changes: 0 additions & 3 deletions ext/alias_editor/theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ public function display_aliases(HTMLElement $table, HTMLElement $paginator): voi
$page->set_heading("Alias List");
$page->add_block(new NavBlock());
$block = new Block("Aliases", $html);
$block->body = str_replace(array("name='c_oldtag'", "name='c_newtag'"),
array("name='c_oldtag' class='autocomplete_tags'", "name='c_newtag' class='autocomplete_tags'"),
$block->body);
$page->add_block($block);

if ($user->can(Permissions::MANAGE_ALIAS_LIST)) {
Expand Down
4 changes: 2 additions & 2 deletions ext/auto_tagger/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public function __construct(\FFSPHP\PDO $db)
$this->size = 100;
$this->limit = 1000000;
$this->set_columns([
new TextColumn("tag", "Tag"),
new TextColumn("additional_tags", "Additional Tags"),
new AutoCompleteColumn("tag", "Tag"),
new AutoCompleteColumn("additional_tags", "Additional Tags"),
new ActionColumn("tag"),
]);
$this->order_by = ["tag"];
Expand Down
3 changes: 0 additions & 3 deletions ext/auto_tagger/theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ public function display_auto_tagtable($table, $paginator): void
$page->set_heading("Auto-Tag List");
$page->add_block(new NavBlock());
$block = new Block("Auto-Tag", $html);
$block->body = str_replace(array("name='c_tag'", "name='c_additional_tags'"),
array("name='c_tag' class='autocomplete_tags'", "name='c_additional_tags' class='autocomplete_tags'"),
$block->body);
$page->add_block($block);
if ($can_manage) {
$page->add_block(new Block("Bulk Upload", $bulk_html, "main", 51));
Expand Down

0 comments on commit 46fce1e

Please sign in to comment.