Made some forms more convenient (input handling)

This commit is contained in:
Bernd Bestel 2017-11-05 11:29:17 +01:00
parent 05a9406a32
commit dad6322bac
5 changed files with 20 additions and 0 deletions

View File

@ -79,6 +79,7 @@ $('#product_id').on('change', function(e)
$('#product_id_text_input').parent('.input-group').removeClass('has-error');
$('#product_id_text_input').closest('.form-group').removeClass('has-error');
$('#product-error').hide();
$('#amount').focus();
}
},
function(xhr)

View File

@ -47,6 +47,8 @@ $('#habit_id').on('change', function(e)
$('#selected-habit-last-tracked-timeago').text($.timeago(habitDetails.last_tracked || ''));
$('#selected-habit-tracked-count').text((habitDetails.tracked_count || '0'));
$('#tracked_time').focus();
Grocy.EmptyElementWhenMatches('#selected-habit-last-tracked-timeago', 'NaN years ago');
},
function(xhr)

View File

@ -84,6 +84,8 @@ $('#product_id').on('change', function(e)
$('#new_amount').attr('not-equal', productDetails.stock_amount);
$('#new_amount_qu_unit').text(productDetails.quantity_unit_stock.name);
$('#new_amount').focus();
Grocy.EmptyElementWhenMatches('#selected-product-last-purchased-timeago', 'NaN years ago');
Grocy.EmptyElementWhenMatches('#selected-product-last-used-timeago', 'NaN years ago');
},

View File

@ -88,7 +88,12 @@ $('#product_id').on('change', function(e)
{
$('#best_before_date').val(moment().add(productDetails.product.default_best_before_days, 'days').format('YYYY-MM-DD'));
$('#best_before_date').trigger('change');
$('#amount').focus();
}
else
{
$('#best_before_date').focus();
}
Grocy.EmptyElementWhenMatches('#selected-product-last-purchased-timeago', 'NaN years ago');
Grocy.EmptyElementWhenMatches('#selected-product-last-used-timeago', 'NaN years ago');
@ -295,6 +300,14 @@ $('#best_before_date').on('change', function(e)
}
});
$('#best_before_date').on('keydown', function(e)
{
if (e.keyCode === 13) //Enter
{
$('#best_before_date').trigger('change');
}
});
$('#best_before_date').on('keypress', function(e)
{
var element = $(e.target);

View File

@ -78,6 +78,8 @@ $('#product_id').on('change', function(e)
$('#product_id_text_input').parent('.input-group').removeClass('has-error');
$('#product_id_text_input').closest('.form-group').removeClass('has-error');
$('#product-error').hide();
$('#amount').focus();
}
},
function(xhr)