diff --git a/app/static/js/create_item.js b/app/static/js/create_item.js new file mode 100644 index 0000000000000000000000000000000000000000..bd7f848d275ce21b202c050ba6e8a15e603d6415 --- /dev/null +++ b/app/static/js/create_item.js @@ -0,0 +1,22 @@ +$(document).ready(function() { + + // Focus to ICS id when loading the page + $("#ics_id").focus(); + + // 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:', '')); + // Change the focus to the serial number + $("#serial_number").focus(); + } + }); + + $("#clear").click(function() { + // clear all select fields + $("select").val(''); + }); + +}); diff --git a/app/static/js/items.js b/app/static/js/items.js index 017947a717814f39a20207db18d38055af964c86..0574112d2050b53b062d37f912eda1400e7dbfe4 100644 --- a/app/static/js/items.js +++ b/app/static/js/items.js @@ -32,20 +32,6 @@ $(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(''); - }); - var items_table = $("#items_table").DataTable({ "ajax": { "url": $SCRIPT_ROOT + "/inventory/_retrieve_items" diff --git a/app/templates/inventory/create_item.html b/app/templates/inventory/create_item.html index 5cc2e4e2828a542c9f06d0d8cabd54aba0d2c9d4..a42ae78f3f6b199d09c2db45789567f4302f38fc 100644 --- a/app/templates/inventory/create_item.html +++ b/app/templates/inventory/create_item.html @@ -23,3 +23,7 @@ </div> </form> {%- endblock %} + +{% block csentry_scripts %} + <script src="{{ url_for('static', filename='js/create_item.js') }}"></script> +{% endblock %}