Stock modal UX fixes [SCI-6714] (#3998)

Co-authored-by: Anton <anton@scinote.net>
This commit is contained in:
aignatov-bio 2022-04-08 11:09:37 +02:00 committed by GitHub
parent f8a598b408
commit 3a4cab9d0a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 9 deletions

View file

@ -45,7 +45,7 @@ var RepositoryStockValues = (function() {
$manageModal.find('form').on('ajax:success', function() {
var dataTable = $('.dataTable').DataTable();
$manageModal.modal('hide');
dataTable.ajax.reload();
dataTable.ajax.reload(null, false);
});
$('.stock-operator-option').click(function() {
@ -60,11 +60,14 @@ var RepositoryStockValues = (function() {
switch ($(this).data('operator')) {
case 'set':
dropdownSelector.enableSelector(UNIT_SELECTOR);
$stockInput.val($stockInput.data('currentAmount'));
break;
case 'add':
$stockInput.val('');
dropdownSelector.disableSelector(UNIT_SELECTOR);
break;
case 'remove':
$stockInput.val('');
dropdownSelector.disableSelector(UNIT_SELECTOR);
break;
default:
@ -114,7 +117,7 @@ var RepositoryStockValues = (function() {
var inputAmount = parseFloat($(this).val());
var newAmount;
if (!inputAmount) return;
if (!(inputAmount >= 0)) return;
switch ($(this).data('operator')) {
case 'set':
@ -159,6 +162,8 @@ var RepositoryStockValues = (function() {
$manageModal.modal('show');
$('#stock-input-amount').focus();
$('#stock-input-amount')[0].selectionStart = $('#stock-input-amount')[0].value.length;
$('#stock-input-amount')[0].selectionEnd = $('#stock-input-amount')[0].value.length;
}
});
});

View file

@ -228,12 +228,6 @@
// Stock
.stock-value-view-render {
&:hover {
text-decoration: none;
};
&.stock-alert {
color: $brand-danger;

View file

@ -49,7 +49,7 @@
data-current-amount="<%= repository_stock_value.amount %>"
data-decimals="<%= repository_stock_column.metadata['decimals'] %>"
value="<%= repository_stock_value.formatted_value %>"
placeholder="<%= t('repository_stock_values.manage_modal.amount_placeholder') %>"
placeholder="<%= t("repository_stock_values.manage_modal.amount_placeholder#{repository_stock_value.new_record? ? '_new' : ''}") %>"
required />
</div>
</div>
@ -105,6 +105,8 @@
tabindex="5"
placeholder="Enter amount"/>
</div>
<span class="units">
</span>
</div>
</div>
</div>

View file

@ -1717,6 +1717,7 @@ en:
set: "Set to"
amount: "Amount"
amount_placeholder: "Enter amount"
amount_placeholder_new: "100, 2000, ..."
amount_error: "Enter an amount"
unit: "Unit"
unit_prompt: "Select unit"