diff --git a/Changes b/Changes index 1ae02f83..042350df 100644 --- a/Changes +++ b/Changes @@ -4,6 +4,7 @@ * Native copy of the Netdisco sort_port routine (#17) * Refactor begin hooks (closes #16) + * Icon to copy Navbar search text to Device Search Options field (closes #11) [BUG FIXES] diff --git a/Netdisco/public/css/netdisco.css b/Netdisco/public/css/netdisco.css index 23b619a8..518a7ef9 100644 --- a/Netdisco/public/css/netdisco.css +++ b/Netdisco/public/css/netdisco.css @@ -229,17 +229,18 @@ td { width: 152px; } -/* little sweep brush inside of port filter input field */ -.field_clear_icon { +/* little icon inside of search input fields */ +.field_clear_icon, .field_copy_icon { position: absolute; margin-left: 132px; z-index: 1; + padding: 6px; } -/* make the sweep icon fill the height of the input field -so that its tooltip takes prescedence over the field tooltip */ -.field_clear_icon > img { - padding: 6px; +/* nudge when icon inside the search field is a bootstrap glyph */ +.field_clear_icon > i { + margin-top: 1px; + margin-left: 4px; } /* change highlighting for form fields which are being used in a search */ diff --git a/Netdisco/public/images/vaga_copy.png b/Netdisco/public/images/vaga_copy.png new file mode 100644 index 00000000..9faae101 Binary files /dev/null and b/Netdisco/public/images/vaga_copy.png differ diff --git a/Netdisco/views/js/search.js b/Netdisco/views/js/search.js index a37697dc..1f7f5a55 100644 --- a/Netdisco/views/js/search.js +++ b/Netdisco/views/js/search.js @@ -10,13 +10,22 @@ // and strikethrough the navbar search function device_form_state(e) { if (e.is('[value!=""]')) { + $('.field_copy_icon').hide(); + e.parent(".clearfix").addClass('success'); $('#nq').css('text-decoration', 'line-through'); + + var id = '#' + e.attr('name') + '_clear_btn'; + $(id).show(); } else { e.parent(".clearfix").removeClass('success'); + var id = '#' + e.attr('name') + '_clear_btn'; + $(id).hide(); + if (! d_inputs.is('[value!=""]') ) { $('#nq').css('text-decoration', 'none'); + $('.field_copy_icon').show(); } } } @@ -35,6 +44,25 @@ // on load, check initial Device Search Options form state, // and on each change to the form fields $(document).ready(function() { + $('.field_copy_icon').hide(); + $('.field_clear_icon').hide(); + d_inputs.each(function() {device_form_state($(this))}); d_inputs.change(function() {device_form_state($(this))}); + + // handler for copy icon in search option + $('.field_copy_icon').click(function() { + var name = $(this).data('btn-for'); + var input = $('#device_form [name=' + name + ']'); + input.val( $('#nq').val() ); + device_form_state(input); // will hide copy icons + }); + + // handler for bin icon in search option + $('.field_clear_icon').click(function() { + var name = $(this).data('btn-for'); + var input = $('#device_form [name=' + name + ']'); + input.val(''); + device_form_state(input); + }); }); diff --git a/Netdisco/views/sidebar/search/device.tt b/Netdisco/views/sidebar/search/device.tt index d4936d35..008013ba 100644 --- a/Netdisco/views/sidebar/search/device.tt +++ b/Netdisco/views/sidebar/search/device.tt @@ -2,26 +2,46 @@
Device Search Options