From 92e8d6ac335707b6409a69c45faae2f163b01f35 Mon Sep 17 00:00:00 2001
From: Benjamin Bertrand <benjamin.bertrand@esss.se>
Date: Fri, 22 Dec 2017 20:48:32 +0100
Subject: [PATCH] Remove prefix from ics_id in item form

Allow to scan a label to enter an ICS id via the web interface
---
 app/static/js/items.js | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/app/static/js/items.js b/app/static/js/items.js
index 1fcc4eb..850696e 100644
--- a/app/static/js/items.js
+++ b/app/static/js/items.js
@@ -22,6 +22,15 @@ $(document).ready(function() {
     $(this).html(converter.makeHtml(raw));
   });
 
+  // remove 'CSE:ics_id:' prefix from ICS id
+  // allow to scan a label
+  $("#ics_id").keyup(function(event) {
+    var value = $(this).val();
+    if( value.length == 17 ) {
+      $(this).val(value.replace('CSE:ics_id:', ''));
+    }
+  });
+
   $("#clear").click(function() {
     // clear all select fields
     $("select").val('');
-- 
GitLab