Bug 19595: Clicking plugin link does not fill item's date acquired field
authorOwen Leonard <oleonard@myacpl.org>
Fri, 10 Nov 2017 12:59:58 +0000 (12:59 +0000)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 7 Dec 2017 13:09:51 +0000 (10:09 -0300)
This patch updates the dateaccessioned plugin for the item edit form to
return functionality which was removed in a previous patch.

To test, apply the patch and open an item for editing. Clicking the
"..." link next to the "Date acquired" field should insert the current
date, overwriting the existing date.

Open a blank item add form. Putting the cursor in the "Date acquired"
field should automatically insert the current date.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Added a comment line in set_to_today.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

cataloguing/value_builder/dateaccessioned.pl

index 5fc1c45..7a86e2d 100755 (executable)
@@ -42,13 +42,14 @@ function Focus$function_name(event) {
 }
 
 function Click$function_name(event) {
-    set_to_today(event.data.id);
+    set_to_today(event.data.id, 1);
     return false; // prevent page scroll
 }
 
-function set_to_today( id ) {
+function set_to_today( id, force ) {
+    // The force parameter is used in Click but not in Focus !
     if (! id) { alert(_("Bad id ") + id + _(" sent to set_to_today()")); return 0; }
-    if (\$("#" + id).val() == '' || \$("#" + id).val() == '0000-00-00' ) {
+    if (\$("#" + id).val() == '' || \$("#" + id).val() == '0000-00-00' || force ) {
         \$("#" + id).val("$date");
     }
 }