Made barcode search globally available [SCI-6022]

This commit is contained in:
Martin Artnik 2021-08-30 14:41:31 +02:00
parent 9b50d208f0
commit 6d92af4b2f
5 changed files with 40 additions and 39 deletions

View file

@ -41,6 +41,7 @@
//= require repository_columns/index
//= require perfect-scrollbar.min
//= require shared/inline_editing
//= require shared/barcode_search
//= require activestorage
//= require global_activities/side_pane
//= require protocols/header

View file

@ -172,6 +172,7 @@ var MyModuleRepositories = (function() {
var dataTableWrapper = $(tableContainer).closest('.dataTables_wrapper');
DataTableHelpers.initLengthApearance(dataTableWrapper);
DataTableHelpers.initSearchField(dataTableWrapper, I18n.t('repositories.show.filter_inventory_items'));
$('<img class="barcode-scanner" src="/images/icon_small/barcode.png"></img>').appendTo($('.search-container'));
dataTableWrapper.find('.main-actions, .pagination-row').removeClass('hidden');
if (options.assign_mode) {
renderFullViewAssignButtons();

View file

@ -174,27 +174,6 @@
$('.create-new-repository').initSubmitModal('#create-repo-modal', 'repository');
$('.repository-show').on('click', '.barcode-scanner', function() {
var search = $('.search-container .search-field');
var input = $('<input>').attr('type', 'text').css('opacity', 0).appendTo('body');
search.val('');
search.attr('disabled', true).addClass('barcode-mode');
input.focus();
input.one('change', function() {
search.val($(this).val());
search.trigger('keyup');
$(document).click();
});
setTimeout(function() {
$(document).one('click', function() {
search.attr('disabled', false).removeClass('barcode-mode');
input.remove();
});
});
});
function initArchivingActionsInDropdown() {
$('.archive-repository-option').on('click', function(event) {
event.preventDefault();

View file

@ -0,0 +1,20 @@
$(document).on('click', '.barcode-scanner', function() {
var search = $('.search-container .search-field');
var input = $('<input>').attr('type', 'text').css('opacity', 0).appendTo('body');
search.val('');
search.attr('disabled', true).addClass('barcode-mode');
input.focus();
input.one('change', function() {
search.val($(this).val());
search.trigger('keyup');
$(document).click();
});
setTimeout(function() {
$(document).one('click', function() {
search.attr('disabled', false).removeClass('barcode-mode');
input.remove();
});
});
});

View file

@ -127,24 +127,6 @@
}
}
.barcode-scanner {
cursor: pointer;
position: absolute;
right: 12px;
top: 12px;
}
.search-container {
.search-field {
padding-right: 32px;
&.barcode-mode {
background-color: $brand-primary;
opacity: .3;
}
}
}
.main-actions {
align-items: center;
background-color: $color-white;
@ -597,3 +579,21 @@
max-height: 290px;
}
}
.barcode-scanner {
cursor: pointer;
position: absolute;
right: 12px;
top: 12px;
}
.search-container {
.search-field {
padding-right: 32px;
&.barcode-mode {
background-color: $brand-primary;
opacity: .3;
}
}
}