Bug 29010: fix pattern in search_field.weight
authorThomas Klausner <domm@plix.at>
Tue, 14 Sep 2021 09:13:11 +0000 (11:13 +0200)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 22 Nov 2021 10:13:10 +0000 (11:13 +0100)
commit0673c73c5f6fcb03ebab045cc2b93ec99ef25d6e
tree0d9a46372744ad8ec45fa82f7e00a1be87c39eb8
parentdf87d3ab2378e413b032f274a928daae9f90ebac
Bug 29010: fix pattern in search_field.weight

search_field.weight is of type NUMERIC(5,2) in the database, and values
are rendered as floats in /admin/searchengine/elasticsearch/mappings.pl

But the field validation only accepts INTs. This patch fixes the pattern
to accept NUMERIC(ish) values

- Enable Elasticsearch (but no need to actually index anyting)
- go to cgi-bin/koha/admin/searchengine/elasticsearch/mappings.pl
- Enter an integer (eg "8") into any "weight" column and click save
- Koha now displays the value as NUMERIC, eg. "8.00"
- Change nothing, and click save again
- Save does not work, you get a warning by the browser that the input
  does not match the requested format (because in the html field only
  ints are allowed, but the DB stored the value as numeric and returns
  it as such)
- Workaround: Change all the values back to ints (i.e. remove ".00"),
  but this is very cumbersome if you have several weights

- Apply the patch
- Now try to save again (without changing eg "8.00" to "8". It works
- Add a new weight (eg "4"), save, it's turned into "4.00", but saving
  again still works

Sponsored-by: Steiermärkische Landesbibliothek
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt