LP#1861732 - Allow copy template stat cat unset value (-1) user/stompro/lp1861732_copy_template_unset_statcat_values
authorJosh Stompro <stompro@stompro.org>
Tue, 4 Feb 2020 15:30:28 +0000 (09:30 -0600)
committerJosh Stompro <stompro@stompro.org>
Tue, 4 Feb 2020 15:30:28 +0000 (09:30 -0600)
commit36f143cf013f012c57d2045ed976bfd97cc9caf4
tree6fece2a8805cef822c4fbd819947cdc0cbad97d1
parent851572686b9d3c827bca282449d66299cc929e2e
LP#1861732 - Allow copy template stat cat unset value (-1)

Xul copy templates allowed the user to save an unset value for a stat_cat,
which was stored as -1 in the xul copy template.  When those values are migrated
to the webstaff client copy templates, the -1 value is preserved.  But that value
is passed directly to the database when saving a record, and -1 isn't a valid
value.

This change treats -1 the same as null or a blank line when applying the template, which
allows the template to unset a stat cat value like before in the XUL client.

Testing Notes:

1. Create some copy stat cats if they don't exist.
2. Clear out actor.usr_settings for the testing user, mainly the webstaff copy template key
  of 'webstaff.cat.copy.templates'.
3. In XUL client, create a copy template that includes setting a stat cat to the "<Remove Stat Cat>"
  value.
4. In the webstaff client, edit an item and try to apply the migrated copy template.

Before fix - you won't be able to save the copy after applying the template, it will
just silently fail.  If you check the postgres logs you will see an error about trying
to set the stat cat value to -1.

After fix - You will be able to save the copy after applying the template, and if a value
for that stat cat was already set, it will be unset by the template.

Signed-off-by: Josh Stompro <stompro@stompro.org>
Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js