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 authored and shish committed Dec 26, 2023
1 parent e5c8bf7 commit 85b1e54
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
34 changes: 34 additions & 0 deletions core/imageboard/autocomplete_column.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?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 @@ -19,8 +19,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
4 changes: 2 additions & 2 deletions ext/auto_tagger/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,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

0 comments on commit 85b1e54

Please sign in to comment.