Comment 1 for bug 1861732

Revision history for this message
Josh Stompro (u-launchpad-stompro-org) wrote :

Here is a branch that treats stat cat values of -1 just like null and blank lines. In my testing this allows the stat cats that were saved with an unset value in the XUL client to work correctly once converted to the webstaff client copy templates.

Branch at: lp1861732_copy_template_unset_statcat_values

https://git.evergreen-ils.org/?p=working/Evergreen.git;a=shortlog;h=refs/heads/user/stompro/lp1861732_copy_template_unset_statcat_values

Commit message:

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.

Josh