diff options
author | Yorhel <git@yorhel.nl> | 2020-02-23 14:41:43 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2020-02-23 14:41:43 +0100 |
commit | c798f672bab6175c0a1db10a57e7cfa60ea48896 (patch) | |
tree | 8d7a8a9577a8d2c2a8ded4d17958e1387af9c454 /lib/VNWeb/Releases | |
parent | b682b8a1778f3a912943351b062077c33e14a6f5 (diff) |
v2rw/RelEdit: Add engine field with autocompletion
Diffstat (limited to 'lib/VNWeb/Releases')
-rw-r--r-- | lib/VNWeb/Releases/Edit.pm | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/VNWeb/Releases/Edit.pm b/lib/VNWeb/Releases/Edit.pm index cec5bb4e..ffa5c451 100644 --- a/lib/VNWeb/Releases/Edit.pm +++ b/lib/VNWeb/Releases/Edit.pm @@ -27,6 +27,7 @@ my $FORM = { ani_story => { uint => 1, enum => \%ANIMATED }, ani_ero => { uint => 1, enum => \%ANIMATED }, website => { required => 0, default => '', weburl => 1 }, + engine => { required => 0, default => '', maxlength => 50 }, hidden => { anybool => 1 }, locked => { anybool => 1 }, @@ -88,4 +89,17 @@ elm_api ReleaseEdit => $FORM_OUT, $FORM_IN, sub { elm_Redirect "/r$id.$rev"; }; + +# TODO: This API is kind of silly, the entire list of engines can just be sent to the browser for instant autocompletion. +elm_api Engines => undef, { search => {} }, sub { + my $q = $_[0]{search}; + my $qs = $q =~ s/[_%]//gr; + my $r = tuwf->dbAlli( + 'SELECT engine, count(*) AS count FROM releases + WHERE NOT hidden AND engine ILIKE', \"%$qs%", + 'GROUP BY engine ORDER BY count(*) DESC, engine LIMIT 10'); + warn JSON::XS::encode_json $r; + elm_EngineResult $r; +}; + 1; |