From 11a880e9b821c1bff075cb6fbc406bb8b0e15251 Mon Sep 17 00:00:00 2001
From: Aleisha Amohia <aleishaamohia@hotmail.com>
Date: Thu, 18 Feb 2021 13:50:38 +1300
Subject: [PATCH] Bug 14242: (follow-up) Format copyright date before plugged
 into form

This patch formats the copyright date so that only the year shows before
plugging the formatted version into the form.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
---
 koha-tmpl/opac-tmpl/bootstrap/js/autofill.js | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/koha-tmpl/opac-tmpl/bootstrap/js/autofill.js b/koha-tmpl/opac-tmpl/bootstrap/js/autofill.js
index e76de81fd4..1263d3dde8 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/js/autofill.js
+++ b/koha-tmpl/opac-tmpl/bootstrap/js/autofill.js
@@ -103,6 +103,15 @@
                         if( ! field.$target )
                             continue;
 
+                        /* format copyrightdate */
+                        if ( field.target == 'copyrightdate' ) {
+                            if ( value.indexOf('-') > -1 ) {
+                                var hyphenIndex = value.indexOf('-');
+                                var newval = value.slice(0, hyphenIndex);
+                                value = newval;
+                            }
+                        }
+
                         /* handle differently depending on datatype */
                         switch(typeString(value)) {
                             case 'array':
-- 
2.11.0