diff options
author | Yorhel <git@yorhel.nl> | 2020-02-23 15:07:31 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2020-02-23 15:17:30 +0100 |
commit | 63c2f525b8e600c3577ce46587137a61635bdf27 (patch) | |
tree | 0b9fb5574c8fca52e84b60d6c9bf377b038d2db2 /lib/VNWeb/Releases | |
parent | c798f672bab6175c0a1db10a57e7cfa60ea48896 (diff) |
v2rw/RelEdit: Instant autocompletion for the engine field
So much more convenient. \o/
Diffstat (limited to 'lib/VNWeb/Releases')
-rw-r--r-- | lib/VNWeb/Releases/Edit.pm | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/lib/VNWeb/Releases/Edit.pm b/lib/VNWeb/Releases/Edit.pm index ffa5c451..271a7d04 100644 --- a/lib/VNWeb/Releases/Edit.pm +++ b/lib/VNWeb/Releases/Edit.pm @@ -31,6 +31,10 @@ my $FORM = { hidden => { anybool => 1 }, locked => { anybool => 1 }, + engines => { _when => 'out', aoh => { + engine => {}, + count => { uint => 1 }, + } }, authmod => { _when => 'out', anybool => 1 }, editsum => { _when => 'in out', editsum => 1 }, }; @@ -49,6 +53,11 @@ TUWF::get qr{/$RE{rrev}/(?<action>edit|copy)} => sub { $e->{authmod} = auth->permDbmod; $e->{editsum} = $e->{chrev} == $e->{maxrev} ? '' : "Reverted to revision r$e->{id}.$e->{chrev}"; + $e->{engines} = tuwf->dbAlli(q{ + SELECT engine, count(*) AS count FROM releases WHERE NOT hidden AND engine <> '' + GROUP BY engine ORDER BY count(*) DESC, engine + }); + my $title = ($copy ? 'Copy ' : 'Edit ').$e->{title}; framework_ title => $title, type => 'r', dbobj => $e, tab => tuwf->capture('action'), sub { @@ -90,16 +99,4 @@ elm_api ReleaseEdit => $FORM_OUT, $FORM_IN, sub { }; -# 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; |