mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 04:12:59 +00:00
Added localization support
This commit is contained in:
@@ -31,13 +31,11 @@
|
||||
});
|
||||
});
|
||||
|
||||
$(function()
|
||||
{
|
||||
$('#batteries-table').DataTable({
|
||||
'pageLength': 50,
|
||||
'order': [[1, 'asc']],
|
||||
'columnDefs': [
|
||||
{ 'orderable': false, 'targets': 0 }
|
||||
]
|
||||
});
|
||||
$('#batteries-table').DataTable({
|
||||
'pageLength': 50,
|
||||
'order': [[1, 'asc']],
|
||||
'columnDefs': [
|
||||
{ 'orderable': false, 'targets': 0 }
|
||||
],
|
||||
'language': JSON.parse(L('datatables_localization'))
|
||||
});
|
||||
|
@@ -1,7 +1,5 @@
|
||||
$(function()
|
||||
{
|
||||
$('#batteries-overview-table').DataTable({
|
||||
'pageLength': 50,
|
||||
'order': [[1, 'desc']]
|
||||
});
|
||||
$('#batteries-overview-table').DataTable({
|
||||
'pageLength': 50,
|
||||
'order': [[1, 'desc']],
|
||||
'language': JSON.parse(L('datatables_localization'))
|
||||
});
|
||||
|
@@ -30,9 +30,6 @@
|
||||
}
|
||||
});
|
||||
|
||||
$(function()
|
||||
{
|
||||
$('#name').focus();
|
||||
$('#battery-form').validator();
|
||||
$('#battery-form').validator('validate');
|
||||
});
|
||||
$('#name').focus();
|
||||
$('#battery-form').validator();
|
||||
$('#battery-form').validator('validate');
|
||||
|
@@ -44,50 +44,47 @@ $('#battery_id').on('change', function(e)
|
||||
}
|
||||
});
|
||||
|
||||
$(function()
|
||||
$('.datetimepicker').datetimepicker(
|
||||
{
|
||||
$('.datetimepicker').datetimepicker(
|
||||
{
|
||||
format: 'YYYY-MM-DD HH:mm:ss',
|
||||
showTodayButton: true,
|
||||
calendarWeeks: true,
|
||||
maxDate: moment()
|
||||
});
|
||||
format: 'YYYY-MM-DD HH:mm:ss',
|
||||
showTodayButton: true,
|
||||
calendarWeeks: true,
|
||||
maxDate: moment()
|
||||
});
|
||||
|
||||
$('#tracked_time').val(moment().format('YYYY-MM-DD HH:mm:ss'));
|
||||
$('#tracked_time').trigger('change');
|
||||
$('#tracked_time').val(moment().format('YYYY-MM-DD HH:mm:ss'));
|
||||
$('#tracked_time').trigger('change');
|
||||
|
||||
$('#tracked_time').on('focus', function(e)
|
||||
$('#tracked_time').on('focus', function(e)
|
||||
{
|
||||
if ($('#battery_id_text_input').val().length === 0)
|
||||
{
|
||||
if ($('#battery_id_text_input').val().length === 0)
|
||||
$('#battery_id_text_input').focus();
|
||||
}
|
||||
});
|
||||
|
||||
$('.combobox').combobox({
|
||||
appendId: '_text_input'
|
||||
});
|
||||
|
||||
$('#battery_id').val('');
|
||||
$('#battery_id_text_input').focus();
|
||||
$('#battery_id_text_input').val('');
|
||||
$('#battery_id_text_input').trigger('change');
|
||||
|
||||
$('#batterytracking-form').validator();
|
||||
$('#batterytracking-form').validator('validate');
|
||||
|
||||
$('#batterytracking-form input').keydown(function(event)
|
||||
{
|
||||
if (event.keyCode === 13) //Enter
|
||||
{
|
||||
if ($('#batterytracking-form').validator('validate').has('.has-error').length !== 0) //There is at least one validation error
|
||||
{
|
||||
$('#battery_id_text_input').focus();
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$('.combobox').combobox({
|
||||
appendId: '_text_input'
|
||||
});
|
||||
|
||||
$('#battery_id').val('');
|
||||
$('#battery_id_text_input').focus();
|
||||
$('#battery_id_text_input').val('');
|
||||
$('#battery_id_text_input').trigger('change');
|
||||
|
||||
$('#batterytracking-form').validator();
|
||||
$('#batterytracking-form').validator('validate');
|
||||
|
||||
$('#batterytracking-form input').keydown(function(event)
|
||||
{
|
||||
if (event.keyCode === 13) //Enter
|
||||
{
|
||||
if ($('#batterytracking-form').validator('validate').has('.has-error').length !== 0) //There is at least one validation error
|
||||
{
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$('#tracked_time').on('change', function(e)
|
||||
|
@@ -6,11 +6,12 @@ Grocy.Components.BatteryCard.Refresh = function(batteryId)
|
||||
function(batteryDetails)
|
||||
{
|
||||
$('#batterycard-battery-name').text(batteryDetails.battery.name);
|
||||
$('#batterycard-battery-used_in').text(batteryDetails.battery.used_in);
|
||||
$('#batterycard-battery-last-charged').text((batteryDetails.last_charged || 'never'));
|
||||
$('#batterycard-battery-last-charged-timeago').text($.timeago(batteryDetails.last_charged || ''));
|
||||
$('#batterycard-battery-charge-cycles-count').text((batteryDetails.charge_cycles_count || '0'));
|
||||
|
||||
EmptyElementWhenMatches('#batterycard-battery-last-charged-timeago', 'NaN years ago');
|
||||
EmptyElementWhenMatches('#batterycard-battery-last-charged-timeago', L('timeago_nan'));
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
|
@@ -9,11 +9,12 @@ $(function()
|
||||
calendarWeeks: true,
|
||||
orientation: 'bottom auto',
|
||||
weekStart: 1,
|
||||
showOnFocus: false
|
||||
showOnFocus: false,
|
||||
language: L('bootstrap_datepicker_locale')
|
||||
});
|
||||
$('.datepicker').trigger('change');
|
||||
|
||||
EmptyElementWhenMatches('#datepicker-timeago', 'NaN years ago');
|
||||
EmptyElementWhenMatches('#datepicker-timeago', L('timeago_nan'));
|
||||
});
|
||||
|
||||
$('.datepicker').on('keydown', function(e)
|
||||
@@ -82,7 +83,7 @@ $('.datepicker').on('change', function(e)
|
||||
}
|
||||
|
||||
$('#datepicker-timeago').text($.timeago($('.datepicker').val()));
|
||||
EmptyElementWhenMatches('#datepicker-timeago', 'NaN years ago');
|
||||
EmptyElementWhenMatches('#datepicker-timeago', L('timeago_nan'));
|
||||
});
|
||||
|
||||
$('#datepicker-button').on('click', function(e)
|
||||
|
@@ -5,6 +5,7 @@ $(function()
|
||||
format: 'YYYY-MM-DD HH:mm:ss',
|
||||
showTodayButton: true,
|
||||
calendarWeeks: true,
|
||||
maxDate: moment()
|
||||
maxDate: moment(),
|
||||
locale: moment.locale('de')
|
||||
});
|
||||
});
|
||||
|
@@ -10,7 +10,7 @@ Grocy.Components.HabitCard.Refresh = function (habitId)
|
||||
$('#habitcard-habit-last-tracked-timeago').text($.timeago(habitDetails.last_tracked || ''));
|
||||
$('#habitcard-habit-tracked-count').text((habitDetails.tracked_count || '0'));
|
||||
|
||||
EmptyElementWhenMatches('#habitcard-habit-last-tracked-timeago', 'NaN years ago');
|
||||
EmptyElementWhenMatches('#habitcard-habit-last-tracked-timeago', L('timeago_nan'));
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
|
@@ -9,13 +9,13 @@ Grocy.Components.ProductCard.Refresh = function(productId)
|
||||
$('#productcard-product-stock-amount').text(productDetails.stock_amount || '0');
|
||||
$('#productcard-product-stock-qu-name').text(productDetails.quantity_unit_stock.name);
|
||||
$('#productcard-product-stock-qu-name2').text(productDetails.quantity_unit_stock.name);
|
||||
$('#productcard-product-last-purchased').text((productDetails.last_purchased || 'never').substring(0, 10));
|
||||
$('#productcard-product-last-purchased').text((productDetails.last_purchased || L('never')).substring(0, 10));
|
||||
$('#productcard-product-last-purchased-timeago').text($.timeago(productDetails.last_purchased || ''));
|
||||
$('#productcard-product-last-used').text((productDetails.last_used || 'never').substring(0, 10));
|
||||
$('#productcard-product-last-used').text((productDetails.last_used || L('never')).substring(0, 10));
|
||||
$('#productcard-product-last-used-timeago').text($.timeago(productDetails.last_used || ''));
|
||||
|
||||
EmptyElementWhenMatches('#productcard-product-last-purchased-timeago', 'NaN years ago');
|
||||
EmptyElementWhenMatches('#productcard-product-last-used-timeago', 'NaN years ago');
|
||||
EmptyElementWhenMatches('#productcard-product-last-purchased-timeago', L('timeago_nan'));
|
||||
EmptyElementWhenMatches('#productcard-product-last-used-timeago', L('timeago_nan'));
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
|
@@ -81,55 +81,52 @@ $('#product_id').on('change', function(e)
|
||||
}
|
||||
});
|
||||
|
||||
$(function()
|
||||
{
|
||||
$('.combobox').combobox({
|
||||
appendId: '_text_input'
|
||||
});
|
||||
|
||||
$('#product_id_text_input').on('change', function(e)
|
||||
{
|
||||
var input = $('#product_id_text_input').val().toString();
|
||||
var possibleOptionElement = $("#product_id option[data-additional-searchdata*='" + input + "']").first();
|
||||
|
||||
if (possibleOptionElement.length > 0)
|
||||
{
|
||||
$('#product_id').val(possibleOptionElement.val());
|
||||
$('#product_id').data('combobox').refresh();
|
||||
$('#product_id').trigger('change');
|
||||
}
|
||||
});
|
||||
|
||||
$('#amount').val(1);
|
||||
$('#product_id').val('');
|
||||
$('#product_id_text_input').focus();
|
||||
$('#product_id_text_input').val('');
|
||||
$('#product_id_text_input').trigger('change');
|
||||
|
||||
$('#consume-form').validator();
|
||||
$('#consume-form').validator('validate');
|
||||
|
||||
$('#amount').on('focus', function(e)
|
||||
{
|
||||
if ($('#product_id_text_input').val().length === 0)
|
||||
{
|
||||
$('#product_id_text_input').focus();
|
||||
}
|
||||
else
|
||||
{
|
||||
$(this).select();
|
||||
}
|
||||
});
|
||||
|
||||
$('#consume-form input').keydown(function(event)
|
||||
{
|
||||
if (event.keyCode === 13) //Enter
|
||||
{
|
||||
if ($('#consume-form').validator('validate').has('.has-error').length !== 0) //There is at least one validation error
|
||||
{
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
$('.combobox').combobox({
|
||||
appendId: '_text_input'
|
||||
});
|
||||
|
||||
$('#product_id_text_input').on('change', function(e)
|
||||
{
|
||||
var input = $('#product_id_text_input').val().toString();
|
||||
var possibleOptionElement = $("#product_id option[data-additional-searchdata*='" + input + "']").first();
|
||||
|
||||
if (possibleOptionElement.length > 0)
|
||||
{
|
||||
$('#product_id').val(possibleOptionElement.val());
|
||||
$('#product_id').data('combobox').refresh();
|
||||
$('#product_id').trigger('change');
|
||||
}
|
||||
});
|
||||
|
||||
$('#amount').val(1);
|
||||
$('#product_id').val('');
|
||||
$('#product_id_text_input').focus();
|
||||
$('#product_id_text_input').val('');
|
||||
$('#product_id_text_input').trigger('change');
|
||||
|
||||
$('#consume-form').validator();
|
||||
$('#consume-form').validator('validate');
|
||||
|
||||
$('#amount').on('focus', function(e)
|
||||
{
|
||||
if ($('#product_id_text_input').val().length === 0)
|
||||
{
|
||||
$('#product_id_text_input').focus();
|
||||
}
|
||||
else
|
||||
{
|
||||
$(this).select();
|
||||
}
|
||||
});
|
||||
|
||||
$('#consume-form input').keydown(function(event)
|
||||
{
|
||||
if (event.keyCode === 13) //Enter
|
||||
{
|
||||
if ($('#consume-form').validator('validate').has('.has-error').length !== 0) //There is at least one validation error
|
||||
{
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@@ -30,12 +30,9 @@
|
||||
}
|
||||
});
|
||||
|
||||
$(function()
|
||||
{
|
||||
$('#name').focus();
|
||||
$('#habit-form').validator();
|
||||
$('#habit-form').validator('validate');
|
||||
});
|
||||
$('#name').focus();
|
||||
$('#habit-form').validator();
|
||||
$('#habit-form').validator('validate');
|
||||
|
||||
$('.input-group-habit-period-type').on('change', function(e)
|
||||
{
|
||||
|
@@ -31,13 +31,11 @@
|
||||
});
|
||||
});
|
||||
|
||||
$(function()
|
||||
{
|
||||
$('#habits-table').DataTable({
|
||||
'pageLength': 50,
|
||||
'order': [[1, 'asc']],
|
||||
'columnDefs': [
|
||||
{ 'orderable': false, 'targets': 0 }
|
||||
]
|
||||
});
|
||||
$('#habits-table').DataTable({
|
||||
'pageLength': 50,
|
||||
'order': [[1, 'asc']],
|
||||
'columnDefs': [
|
||||
{ 'orderable': false, 'targets': 0 }
|
||||
],
|
||||
'language': JSON.parse(L('datatables_localization'))
|
||||
});
|
||||
|
@@ -1,7 +1,5 @@
|
||||
$(function()
|
||||
{
|
||||
$('#habits-overview-table').DataTable({
|
||||
'pageLength': 50,
|
||||
'order': [[1, 'desc']]
|
||||
});
|
||||
$('#habits-overview-table').DataTable({
|
||||
'pageLength': 50,
|
||||
'order': [[1, 'desc']],
|
||||
'language': JSON.parse(L('datatables_localization'))
|
||||
});
|
||||
|
@@ -44,42 +44,39 @@ $('#habit_id').on('change', function(e)
|
||||
}
|
||||
});
|
||||
|
||||
$(function()
|
||||
$('#tracked_time').val(moment().format('YYYY-MM-DD HH:mm:ss'));
|
||||
$('#tracked_time').trigger('change');
|
||||
|
||||
$('#tracked_time').on('focus', function(e)
|
||||
{
|
||||
$('#tracked_time').val(moment().format('YYYY-MM-DD HH:mm:ss'));
|
||||
$('#tracked_time').trigger('change');
|
||||
|
||||
$('#tracked_time').on('focus', function(e)
|
||||
if ($('#habit_id_text_input').val().length === 0)
|
||||
{
|
||||
if ($('#habit_id_text_input').val().length === 0)
|
||||
{
|
||||
$('#habit_id_text_input').focus();
|
||||
}
|
||||
});
|
||||
$('#habit_id_text_input').focus();
|
||||
}
|
||||
});
|
||||
|
||||
$('.combobox').combobox({
|
||||
appendId: '_text_input'
|
||||
});
|
||||
$('.combobox').combobox({
|
||||
appendId: '_text_input'
|
||||
});
|
||||
|
||||
$('#habit_id').val('');
|
||||
$('#habit_id_text_input').focus();
|
||||
$('#habit_id_text_input').val('');
|
||||
$('#habit_id_text_input').trigger('change');
|
||||
$('#habit_id').val('');
|
||||
$('#habit_id_text_input').focus();
|
||||
$('#habit_id_text_input').val('');
|
||||
$('#habit_id_text_input').trigger('change');
|
||||
|
||||
$('#habittracking-form').validator();
|
||||
$('#habittracking-form').validator('validate');
|
||||
$('#habittracking-form').validator();
|
||||
$('#habittracking-form').validator('validate');
|
||||
|
||||
$('#habittracking-form input').keydown(function(event)
|
||||
$('#habittracking-form input').keydown(function(event)
|
||||
{
|
||||
if (event.keyCode === 13) //Enter
|
||||
{
|
||||
if (event.keyCode === 13) //Enter
|
||||
if ($('#habittracking-form').validator('validate').has('.has-error').length !== 0) //There is at least one validation error
|
||||
{
|
||||
if ($('#habittracking-form').validator('validate').has('.has-error').length !== 0) //There is at least one validation error
|
||||
{
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$('#tracked_time').on('keypress', function(e)
|
||||
|
@@ -87,169 +87,166 @@ $('#product_id').on('change', function(e)
|
||||
}
|
||||
});
|
||||
|
||||
$(function()
|
||||
{
|
||||
$('.combobox').combobox({
|
||||
appendId: '_text_input'
|
||||
});
|
||||
$('.combobox').combobox({
|
||||
appendId: '_text_input'
|
||||
});
|
||||
|
||||
$('#product_id_text_input').on('change', function(e)
|
||||
$('#product_id_text_input').on('change', function(e)
|
||||
{
|
||||
var input = $('#product_id_text_input').val().toString();
|
||||
var possibleOptionElement = $("#product_id option[data-additional-searchdata*='" + input + "']").first();
|
||||
|
||||
if (GetUriParam('addbarcodetoselection') === undefined && possibleOptionElement.length > 0)
|
||||
{
|
||||
var input = $('#product_id_text_input').val().toString();
|
||||
var possibleOptionElement = $("#product_id option[data-additional-searchdata*='" + input + "']").first();
|
||||
|
||||
if (GetUriParam('addbarcodetoselection') === undefined && possibleOptionElement.length > 0)
|
||||
$('#product_id').val(possibleOptionElement.val());
|
||||
$('#product_id').data('combobox').refresh();
|
||||
$('#product_id').trigger('change');
|
||||
}
|
||||
else
|
||||
{
|
||||
var optionElement = $("#product_id option:contains('" + input + "')").first();
|
||||
if (input.length > 0 && optionElement.length === 0 && GetUriParam('addbarcodetoselection') === undefined )
|
||||
{
|
||||
$('#product_id').val(possibleOptionElement.val());
|
||||
$('#product_id').data('combobox').refresh();
|
||||
$('#product_id').trigger('change');
|
||||
}
|
||||
else
|
||||
{
|
||||
var optionElement = $("#product_id option:contains('" + input + "')").first();
|
||||
if (input.length > 0 && optionElement.length === 0 && GetUriParam('addbarcodetoselection') === undefined )
|
||||
{
|
||||
bootbox.dialog({
|
||||
message: '<strong>' + input + '</strong> could not be resolved to a product, how do you want to proceed?',
|
||||
title: 'Create or assign product',
|
||||
onEscape: function() { },
|
||||
size: 'large',
|
||||
backdrop: true,
|
||||
buttons: {
|
||||
cancel: {
|
||||
label: 'Cancel',
|
||||
className: 'btn-default',
|
||||
callback: function() { }
|
||||
},
|
||||
addnewproduct: {
|
||||
label: 'Add as new <u><strong>p</strong></u>roduct',
|
||||
className: 'btn-success add-new-product-dialog-button',
|
||||
callback: function()
|
||||
{
|
||||
window.location.href = '/product/new?prefillname=' + encodeURIComponent(input) + '&returnto=' + encodeURIComponent(window.location.pathname);
|
||||
}
|
||||
},
|
||||
addbarcode: {
|
||||
label: 'Add as <u><strong>b</strong></u>arcode to existing product',
|
||||
className: 'btn-info add-new-barcode-dialog-button',
|
||||
callback: function()
|
||||
{
|
||||
window.location.href = '/inventory?addbarcodetoselection=' + encodeURIComponent(input);
|
||||
}
|
||||
},
|
||||
addnewproductwithbarcode: {
|
||||
label: '<u><strong>A</strong></u>dd as new product + prefill barcode',
|
||||
className: 'btn-warning add-new-product-with-barcode-dialog-button',
|
||||
callback: function()
|
||||
{
|
||||
window.location.href = '/product/new?prefillbarcode=' + encodeURIComponent(input) + '&returnto=' + encodeURIComponent(window.location.pathname);
|
||||
}
|
||||
bootbox.dialog({
|
||||
message: '<strong>' + input + '</strong> could not be resolved to a product, how do you want to proceed?',
|
||||
title: 'Create or assign product',
|
||||
onEscape: function() { },
|
||||
size: 'large',
|
||||
backdrop: true,
|
||||
buttons: {
|
||||
cancel: {
|
||||
label: 'Cancel',
|
||||
className: 'btn-default',
|
||||
callback: function() { }
|
||||
},
|
||||
addnewproduct: {
|
||||
label: 'Add as new <u><strong>p</strong></u>roduct',
|
||||
className: 'btn-success add-new-product-dialog-button',
|
||||
callback: function()
|
||||
{
|
||||
window.location.href = '/product/new?prefillname=' + encodeURIComponent(input) + '&returnto=' + encodeURIComponent(window.location.pathname);
|
||||
}
|
||||
},
|
||||
addbarcode: {
|
||||
label: 'Add as <u><strong>b</strong></u>arcode to existing product',
|
||||
className: 'btn-info add-new-barcode-dialog-button',
|
||||
callback: function()
|
||||
{
|
||||
window.location.href = '/inventory?addbarcodetoselection=' + encodeURIComponent(input);
|
||||
}
|
||||
},
|
||||
addnewproductwithbarcode: {
|
||||
label: '<u><strong>A</strong></u>dd as new product + prefill barcode',
|
||||
className: 'btn-warning add-new-product-with-barcode-dialog-button',
|
||||
callback: function()
|
||||
{
|
||||
window.location.href = '/product/new?prefillbarcode=' + encodeURIComponent(input) + '&returnto=' + encodeURIComponent(window.location.pathname);
|
||||
}
|
||||
}
|
||||
}).on('keypress', function(e)
|
||||
{
|
||||
if (e.key === 'B' || e.key === 'b')
|
||||
{
|
||||
$('.add-new-barcode-dialog-button').click();
|
||||
}
|
||||
if (e.key === 'p' || e.key === 'P')
|
||||
{
|
||||
$('.add-new-product-dialog-button').click();
|
||||
}
|
||||
if (e.key === 'a' || e.key === 'A')
|
||||
{
|
||||
$('.add-new-product-with-barcode-dialog-button').click();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$('#new_amount').val('');
|
||||
$('#best_before_date').val('');
|
||||
$('#product_id').val('');
|
||||
$('#product_id_text_input').focus();
|
||||
$('#product_id_text_input').val('');
|
||||
$('#product_id_text_input').trigger('change');
|
||||
|
||||
$('#inventory-form').validator({
|
||||
custom: {
|
||||
'isodate': function($el)
|
||||
{
|
||||
if ($el.val().length !== 0 && !moment($el.val(), 'YYYY-MM-DD', true).isValid())
|
||||
{
|
||||
return 'Wrong date format, needs to be YYYY-MM-DD';
|
||||
}
|
||||
else if (moment($el.val()).isValid())
|
||||
{
|
||||
if (moment($el.val()).isBefore(moment(), 'day'))
|
||||
{
|
||||
return 'This value cannot be before today.';
|
||||
}
|
||||
}
|
||||
},
|
||||
'notequal': function($el)
|
||||
}).on('keypress', function(e)
|
||||
{
|
||||
if ($el.val().length !== 0 && $el.val().toString() === $el.attr('not-equal').toString())
|
||||
if (e.key === 'B' || e.key === 'b')
|
||||
{
|
||||
return 'This value cannot be equal to ' + $el.attr('not-equal').toString();
|
||||
$('.add-new-barcode-dialog-button').click();
|
||||
}
|
||||
}
|
||||
if (e.key === 'p' || e.key === 'P')
|
||||
{
|
||||
$('.add-new-product-dialog-button').click();
|
||||
}
|
||||
if (e.key === 'a' || e.key === 'A')
|
||||
{
|
||||
$('.add-new-product-with-barcode-dialog-button').click();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
$('#inventory-form').validator('validate');
|
||||
|
||||
$('#new_amount').on('focus', function(e)
|
||||
{
|
||||
if ($('#product_id_text_input').val().length === 0)
|
||||
{
|
||||
$('#product_id_text_input').focus();
|
||||
}
|
||||
else
|
||||
{
|
||||
$(this).select();
|
||||
}
|
||||
});
|
||||
|
||||
$('#inventory-form input').keydown(function(event)
|
||||
{
|
||||
if (event.keyCode === 13) //Enter
|
||||
{
|
||||
if ($('#inventory-form').validator('validate').has('.has-error').length !== 0) //There is at least one validation error
|
||||
{
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var prefillProduct = GetUriParam('createdproduct');
|
||||
if (prefillProduct !== undefined)
|
||||
{
|
||||
var possibleOptionElement = $("#product_id option[data-additional-searchdata*='" + prefillProduct + "']").first();
|
||||
if (possibleOptionElement.length === 0)
|
||||
{
|
||||
possibleOptionElement = $("#product_id option:contains('" + prefillProduct + "')").first();
|
||||
}
|
||||
|
||||
if (possibleOptionElement.length > 0)
|
||||
{
|
||||
$('#product_id').val(possibleOptionElement.val());
|
||||
$('#product_id').data('combobox').refresh();
|
||||
$('#product_id').trigger('change');
|
||||
$('#new_amount').focus();
|
||||
}
|
||||
}
|
||||
|
||||
var addBarcode = GetUriParam('addbarcodetoselection');
|
||||
if (addBarcode !== undefined)
|
||||
{
|
||||
$('#addbarcodetoselection').text(addBarcode);
|
||||
$('#flow-info-addbarcodetoselection').removeClass('hide');
|
||||
$('#barcode-lookup-disabled-hint').removeClass('hide');
|
||||
}
|
||||
});
|
||||
|
||||
$('#new_amount').val('');
|
||||
$('#best_before_date').val('');
|
||||
$('#product_id').val('');
|
||||
$('#product_id_text_input').focus();
|
||||
$('#product_id_text_input').val('');
|
||||
$('#product_id_text_input').trigger('change');
|
||||
|
||||
$('#inventory-form').validator({
|
||||
custom: {
|
||||
'isodate': function($el)
|
||||
{
|
||||
if ($el.val().length !== 0 && !moment($el.val(), 'YYYY-MM-DD', true).isValid())
|
||||
{
|
||||
return 'Wrong date format, needs to be YYYY-MM-DD';
|
||||
}
|
||||
else if (moment($el.val()).isValid())
|
||||
{
|
||||
if (moment($el.val()).isBefore(moment(), 'day'))
|
||||
{
|
||||
return 'This value cannot be before today.';
|
||||
}
|
||||
}
|
||||
},
|
||||
'notequal': function($el)
|
||||
{
|
||||
if ($el.val().length !== 0 && $el.val().toString() === $el.attr('not-equal').toString())
|
||||
{
|
||||
return 'This value cannot be equal to ' + $el.attr('not-equal').toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
$('#inventory-form').validator('validate');
|
||||
|
||||
$('#new_amount').on('focus', function(e)
|
||||
{
|
||||
if ($('#product_id_text_input').val().length === 0)
|
||||
{
|
||||
$('#product_id_text_input').focus();
|
||||
}
|
||||
else
|
||||
{
|
||||
$(this).select();
|
||||
}
|
||||
});
|
||||
|
||||
$('#inventory-form input').keydown(function(event)
|
||||
{
|
||||
if (event.keyCode === 13) //Enter
|
||||
{
|
||||
if ($('#inventory-form').validator('validate').has('.has-error').length !== 0) //There is at least one validation error
|
||||
{
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var prefillProduct = GetUriParam('createdproduct');
|
||||
if (prefillProduct !== undefined)
|
||||
{
|
||||
var possibleOptionElement = $("#product_id option[data-additional-searchdata*='" + prefillProduct + "']").first();
|
||||
if (possibleOptionElement.length === 0)
|
||||
{
|
||||
possibleOptionElement = $("#product_id option:contains('" + prefillProduct + "')").first();
|
||||
}
|
||||
|
||||
if (possibleOptionElement.length > 0)
|
||||
{
|
||||
$('#product_id').val(possibleOptionElement.val());
|
||||
$('#product_id').data('combobox').refresh();
|
||||
$('#product_id').trigger('change');
|
||||
$('#new_amount').focus();
|
||||
}
|
||||
}
|
||||
|
||||
var addBarcode = GetUriParam('addbarcodetoselection');
|
||||
if (addBarcode !== undefined)
|
||||
{
|
||||
$('#addbarcodetoselection').text(addBarcode);
|
||||
$('#flow-info-addbarcodetoselection').removeClass('hide');
|
||||
$('#barcode-lookup-disabled-hint').removeClass('hide');
|
||||
}
|
||||
|
||||
$('#new_amount').on('keypress', function(e)
|
||||
{
|
||||
$('#new_amount').trigger('change');
|
||||
|
@@ -30,9 +30,6 @@
|
||||
}
|
||||
});
|
||||
|
||||
$(function()
|
||||
{
|
||||
$('#name').focus();
|
||||
$('#location-form').validator();
|
||||
$('#location-form').validator('validate');
|
||||
});
|
||||
$('#name').focus();
|
||||
$('#location-form').validator();
|
||||
$('#location-form').validator('validate');
|
||||
|
@@ -31,13 +31,11 @@
|
||||
});
|
||||
});
|
||||
|
||||
$(function()
|
||||
{
|
||||
$('#locations-table').DataTable({
|
||||
'pageLength': 50,
|
||||
'order': [[1, 'asc']],
|
||||
'columnDefs': [
|
||||
{ 'orderable': false, 'targets': 0 }
|
||||
]
|
||||
});
|
||||
$('#locations-table').DataTable({
|
||||
'pageLength': 50,
|
||||
'order': [[1, 'asc']],
|
||||
'columnDefs': [
|
||||
{ 'orderable': false, 'targets': 0 }
|
||||
],
|
||||
'language': JSON.parse(L('datatables_localization'))
|
||||
});
|
||||
|
@@ -1,12 +1,9 @@
|
||||
$(function()
|
||||
$('.logout-button').hide();
|
||||
|
||||
$('#username').focus();
|
||||
|
||||
if (GetUriParam('invalid') === 'true')
|
||||
{
|
||||
$('.logout-button').hide();
|
||||
|
||||
$('#username').focus();
|
||||
|
||||
if (GetUriParam('invalid') === 'true')
|
||||
{
|
||||
$('#login-error').text('Invalid credentials, please try again.');
|
||||
$('#login-error').show();
|
||||
}
|
||||
});
|
||||
$('#login-error').text(L('Invalid credentials, please try again'));
|
||||
$('#login-error').show();
|
||||
}
|
||||
|
@@ -37,59 +37,51 @@
|
||||
}
|
||||
});
|
||||
|
||||
$(function()
|
||||
{
|
||||
$('#barcode-taginput').tagsManager({
|
||||
'hiddenTagListName': 'barcode',
|
||||
'tagsContainer': '#barcode-taginput-container'
|
||||
});
|
||||
|
||||
if (Grocy.EditMode === 'edit')
|
||||
{
|
||||
Grocy.FetchJson('/api/get-object/products/' + Grocy.EditObjectId,
|
||||
function (product)
|
||||
{
|
||||
if (product.barcode !== null && product.barcode.length > 0)
|
||||
{
|
||||
product.barcode.split(',').forEach(function(item)
|
||||
{
|
||||
$('#barcode-taginput').tagsManager('pushTag', item);
|
||||
});
|
||||
}
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
$('#qu_factor_purchase_to_stock').trigger('change');
|
||||
$('#name').focus();
|
||||
$('#product-form').validator();
|
||||
$('#product-form').validator('validate');
|
||||
|
||||
var prefillName = GetUriParam('prefillname');
|
||||
if (prefillName !== undefined)
|
||||
{
|
||||
$('#name').val(prefillName);
|
||||
$('#name').focus();
|
||||
}
|
||||
|
||||
var prefillBarcode = GetUriParam('prefillbarcode');
|
||||
if (prefillBarcode !== undefined)
|
||||
{
|
||||
$('#barcode-taginput').tagsManager('pushTag', prefillBarcode);
|
||||
$('#name').focus();
|
||||
}
|
||||
$('#barcode-taginput').tagsManager({
|
||||
'hiddenTagListName': 'barcode',
|
||||
'tagsContainer': '#barcode-taginput-container'
|
||||
});
|
||||
|
||||
if (Grocy.EditMode === 'edit')
|
||||
{
|
||||
Grocy.FetchJson('/api/get-object/products/' + Grocy.EditObjectId,
|
||||
function (product)
|
||||
{
|
||||
if (product.barcode !== null && product.barcode.length > 0)
|
||||
{
|
||||
product.barcode.split(',').forEach(function(item)
|
||||
{
|
||||
$('#barcode-taginput').tagsManager('pushTag', item);
|
||||
});
|
||||
}
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
var prefillName = GetUriParam('prefillname');
|
||||
if (prefillName !== undefined)
|
||||
{
|
||||
$('#name').val(prefillName);
|
||||
$('#name').focus();
|
||||
}
|
||||
|
||||
var prefillBarcode = GetUriParam('prefillbarcode');
|
||||
if (prefillBarcode !== undefined)
|
||||
{
|
||||
$('#barcode-taginput').tagsManager('pushTag', prefillBarcode);
|
||||
$('#name').focus();
|
||||
}
|
||||
|
||||
$('.input-group-qu').on('change', function(e)
|
||||
{
|
||||
var factor = $('#qu_factor_purchase_to_stock').val();
|
||||
if (factor > 1)
|
||||
{
|
||||
$('#qu-conversion-info').text('This means 1 ' + $("#qu_id_purchase option:selected").text() + ' purchased will be converted into ' + (1 * factor).toString() + ' ' + $("#qu_id_stock option:selected").text() + ' in stock.');
|
||||
$('#qu-conversion-info').text(L('This means 1 #1 purchased will be converted into #2 #3 in stock', $("#qu_id_purchase option:selected").text(), (1 * factor).toString(), $("#qu_id_stock option:selected").text()));
|
||||
$('#qu-conversion-info').show();
|
||||
}
|
||||
else
|
||||
@@ -97,3 +89,8 @@ $('.input-group-qu').on('change', function(e)
|
||||
$('#qu-conversion-info').hide();
|
||||
}
|
||||
});
|
||||
|
||||
$('#name').focus();
|
||||
$('#product-form').validator();
|
||||
$('#product-form').validator('validate');
|
||||
$('.input-group-qu').trigger('change');
|
||||
|
@@ -31,13 +31,11 @@
|
||||
});
|
||||
});
|
||||
|
||||
$(function()
|
||||
{
|
||||
$('#products-table').DataTable({
|
||||
'pageLength': 50,
|
||||
'order': [[1, 'asc']],
|
||||
'columnDefs': [
|
||||
{ 'orderable': false, 'targets': 0 }
|
||||
]
|
||||
});
|
||||
$('#products-table').DataTable({
|
||||
'pageLength': 50,
|
||||
'order': [[1, 'asc']],
|
||||
'columnDefs': [
|
||||
{ 'orderable': false, 'targets': 0 }
|
||||
],
|
||||
'language': JSON.parse(L('datatables_localization'))
|
||||
});
|
||||
|
@@ -96,170 +96,167 @@ $('#product_id').on('change', function(e)
|
||||
}
|
||||
});
|
||||
|
||||
$(function()
|
||||
{
|
||||
$('.combobox').combobox({
|
||||
appendId: '_text_input'
|
||||
});
|
||||
$('.combobox').combobox({
|
||||
appendId: '_text_input'
|
||||
});
|
||||
|
||||
$('#product_id_text_input').on('change', function(e)
|
||||
$('#product_id_text_input').on('change', function(e)
|
||||
{
|
||||
var input = $('#product_id_text_input').val().toString();
|
||||
var possibleOptionElement = $("#product_id option[data-additional-searchdata*='" + input + "']").first();
|
||||
|
||||
if (GetUriParam('addbarcodetoselection') === undefined && possibleOptionElement.length > 0)
|
||||
{
|
||||
var input = $('#product_id_text_input').val().toString();
|
||||
var possibleOptionElement = $("#product_id option[data-additional-searchdata*='" + input + "']").first();
|
||||
|
||||
if (GetUriParam('addbarcodetoselection') === undefined && possibleOptionElement.length > 0)
|
||||
$('#product_id').val(possibleOptionElement.val());
|
||||
$('#product_id').data('combobox').refresh();
|
||||
$('#product_id').trigger('change');
|
||||
}
|
||||
else
|
||||
{
|
||||
var optionElement = $("#product_id option:contains('" + input + "')").first();
|
||||
if (input.length > 0 && optionElement.length === 0 && GetUriParam('addbarcodetoselection') === undefined )
|
||||
{
|
||||
$('#product_id').val(possibleOptionElement.val());
|
||||
$('#product_id').data('combobox').refresh();
|
||||
$('#product_id').trigger('change');
|
||||
}
|
||||
else
|
||||
{
|
||||
var optionElement = $("#product_id option:contains('" + input + "')").first();
|
||||
if (input.length > 0 && optionElement.length === 0 && GetUriParam('addbarcodetoselection') === undefined )
|
||||
{
|
||||
bootbox.dialog({
|
||||
message: '<strong>' + input + '</strong> could not be resolved to a product, how do you want to proceed?',
|
||||
title: 'Create or assign product',
|
||||
onEscape: function() { },
|
||||
size: 'large',
|
||||
backdrop: true,
|
||||
buttons: {
|
||||
cancel: {
|
||||
label: 'Cancel',
|
||||
className: 'btn-default',
|
||||
callback: function() { }
|
||||
},
|
||||
addnewproduct: {
|
||||
label: 'Add as new <u><strong>p</strong></u>roduct',
|
||||
className: 'btn-success add-new-product-dialog-button',
|
||||
callback: function()
|
||||
{
|
||||
window.location.href = '/product/new?prefillname=' + encodeURIComponent(input) + '&returnto=' + encodeURIComponent(window.location.pathname);
|
||||
}
|
||||
},
|
||||
addbarcode: {
|
||||
label: 'Add as <u><strong>b</strong></u>arcode to existing product',
|
||||
className: 'btn-info add-new-barcode-dialog-button',
|
||||
callback: function()
|
||||
{
|
||||
window.location.href = '/purchase?addbarcodetoselection=' + encodeURIComponent(input);
|
||||
}
|
||||
},
|
||||
addnewproductwithbarcode: {
|
||||
label: '<u><strong>A</strong></u>dd as new product + prefill barcode',
|
||||
className: 'btn-warning add-new-product-with-barcode-dialog-button',
|
||||
callback: function()
|
||||
{
|
||||
window.location.href = '/product/new?prefillbarcode=' + encodeURIComponent(input) + '&returnto=' + encodeURIComponent(window.location.pathname);
|
||||
}
|
||||
bootbox.dialog({
|
||||
message: '<strong>' + input + '</strong> could not be resolved to a product, how do you want to proceed?',
|
||||
title: 'Create or assign product',
|
||||
onEscape: function() { },
|
||||
size: 'large',
|
||||
backdrop: true,
|
||||
buttons: {
|
||||
cancel: {
|
||||
label: 'Cancel',
|
||||
className: 'btn-default',
|
||||
callback: function() { }
|
||||
},
|
||||
addnewproduct: {
|
||||
label: 'Add as new <u><strong>p</strong></u>roduct',
|
||||
className: 'btn-success add-new-product-dialog-button',
|
||||
callback: function()
|
||||
{
|
||||
window.location.href = '/product/new?prefillname=' + encodeURIComponent(input) + '&returnto=' + encodeURIComponent(window.location.pathname);
|
||||
}
|
||||
},
|
||||
addbarcode: {
|
||||
label: 'Add as <u><strong>b</strong></u>arcode to existing product',
|
||||
className: 'btn-info add-new-barcode-dialog-button',
|
||||
callback: function()
|
||||
{
|
||||
window.location.href = '/purchase?addbarcodetoselection=' + encodeURIComponent(input);
|
||||
}
|
||||
},
|
||||
addnewproductwithbarcode: {
|
||||
label: '<u><strong>A</strong></u>dd as new product + prefill barcode',
|
||||
className: 'btn-warning add-new-product-with-barcode-dialog-button',
|
||||
callback: function()
|
||||
{
|
||||
window.location.href = '/product/new?prefillbarcode=' + encodeURIComponent(input) + '&returnto=' + encodeURIComponent(window.location.pathname);
|
||||
}
|
||||
}
|
||||
}).on('keypress', function(e)
|
||||
{
|
||||
if (e.key === 'B' || e.key === 'b')
|
||||
{
|
||||
$('.add-new-barcode-dialog-button').click();
|
||||
}
|
||||
if (e.key === 'p' || e.key === 'P')
|
||||
{
|
||||
$('.add-new-product-dialog-button').click();
|
||||
}
|
||||
if (e.key === 'a' || e.key === 'A')
|
||||
{
|
||||
$('.add-new-product-with-barcode-dialog-button').click();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$('#amount').val(0);
|
||||
$('#best_before_date').val('');
|
||||
$('#product_id').val('');
|
||||
$('#product_id_text_input').focus();
|
||||
$('#product_id_text_input').val('');
|
||||
$('#product_id_text_input').trigger('change');
|
||||
|
||||
$('#purchase-form').validator({
|
||||
custom: {
|
||||
'isodate': function($el)
|
||||
{
|
||||
if ($el.val().length !== 0 && !moment($el.val(), 'YYYY-MM-DD', true).isValid())
|
||||
{
|
||||
return 'Wrong date format, needs to be YYYY-MM-DD';
|
||||
}
|
||||
else if (moment($el.val()).isValid())
|
||||
{
|
||||
if (moment($el.val()).isBefore(moment(), 'day'))
|
||||
{
|
||||
return 'This value cannot be before today.';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
$('#purchase-form').validator('validate');
|
||||
|
||||
$('#best_before_date').on('focus', function(e)
|
||||
{
|
||||
if ($('#product_id_text_input').val().length === 0)
|
||||
{
|
||||
$('#product_id_text_input').focus();
|
||||
}
|
||||
});
|
||||
|
||||
$('#amount').on('focus', function(e)
|
||||
{
|
||||
if ($('#product_id_text_input').val().length === 0)
|
||||
{
|
||||
$('#product_id_text_input').focus();
|
||||
}
|
||||
else
|
||||
{
|
||||
$(this).select();
|
||||
}
|
||||
});
|
||||
|
||||
$('#purchase-form input').keydown(function(event)
|
||||
{
|
||||
if (event.keyCode === 13) //Enter
|
||||
{
|
||||
if ($('#purchase-form').validator('validate').has('.has-error').length !== 0) //There is at least one validation error
|
||||
}).on('keypress', function(e)
|
||||
{
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}
|
||||
if (e.key === 'B' || e.key === 'b')
|
||||
{
|
||||
$('.add-new-barcode-dialog-button').click();
|
||||
}
|
||||
if (e.key === 'p' || e.key === 'P')
|
||||
{
|
||||
$('.add-new-product-dialog-button').click();
|
||||
}
|
||||
if (e.key === 'a' || e.key === 'A')
|
||||
{
|
||||
$('.add-new-product-with-barcode-dialog-button').click();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
var prefillProduct = GetUriParam('createdproduct');
|
||||
if (prefillProduct !== undefined)
|
||||
{
|
||||
var possibleOptionElement = $("#product_id option[data-additional-searchdata*='" + prefillProduct + "']").first();
|
||||
if (possibleOptionElement.length === 0)
|
||||
{
|
||||
possibleOptionElement = $("#product_id option:contains('" + prefillProduct + "')").first();
|
||||
}
|
||||
|
||||
if (possibleOptionElement.length > 0)
|
||||
{
|
||||
$('#product_id').val(possibleOptionElement.val());
|
||||
$('#product_id').data('combobox').refresh();
|
||||
$('#product_id').trigger('change');
|
||||
$('#best_before_date').focus();
|
||||
}
|
||||
}
|
||||
|
||||
var addBarcode = GetUriParam('addbarcodetoselection');
|
||||
if (addBarcode !== undefined)
|
||||
{
|
||||
$('#addbarcodetoselection').text(addBarcode);
|
||||
$('#flow-info-addbarcodetoselection').removeClass('hide');
|
||||
$('#barcode-lookup-disabled-hint').removeClass('hide');
|
||||
}
|
||||
});
|
||||
|
||||
$('#amount').val(0);
|
||||
$('#best_before_date').val('');
|
||||
$('#product_id').val('');
|
||||
$('#product_id_text_input').focus();
|
||||
$('#product_id_text_input').val('');
|
||||
$('#product_id_text_input').trigger('change');
|
||||
|
||||
$('#purchase-form').validator({
|
||||
custom: {
|
||||
'isodate': function($el)
|
||||
{
|
||||
if ($el.val().length !== 0 && !moment($el.val(), 'YYYY-MM-DD', true).isValid())
|
||||
{
|
||||
return 'Wrong date format, needs to be YYYY-MM-DD';
|
||||
}
|
||||
else if (moment($el.val()).isValid())
|
||||
{
|
||||
if (moment($el.val()).isBefore(moment(), 'day'))
|
||||
{
|
||||
return 'This value cannot be before today.';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
$('#purchase-form').validator('validate');
|
||||
|
||||
$('#best_before_date').on('focus', function(e)
|
||||
{
|
||||
if ($('#product_id_text_input').val().length === 0)
|
||||
{
|
||||
$('#product_id_text_input').focus();
|
||||
}
|
||||
});
|
||||
|
||||
$('#amount').on('focus', function(e)
|
||||
{
|
||||
if ($('#product_id_text_input').val().length === 0)
|
||||
{
|
||||
$('#product_id_text_input').focus();
|
||||
}
|
||||
else
|
||||
{
|
||||
$(this).select();
|
||||
}
|
||||
});
|
||||
|
||||
$('#purchase-form input').keydown(function(event)
|
||||
{
|
||||
if (event.keyCode === 13) //Enter
|
||||
{
|
||||
if ($('#purchase-form').validator('validate').has('.has-error').length !== 0) //There is at least one validation error
|
||||
{
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var prefillProduct = GetUriParam('createdproduct');
|
||||
if (prefillProduct !== undefined)
|
||||
{
|
||||
var possibleOptionElement = $("#product_id option[data-additional-searchdata*='" + prefillProduct + "']").first();
|
||||
if (possibleOptionElement.length === 0)
|
||||
{
|
||||
possibleOptionElement = $("#product_id option:contains('" + prefillProduct + "')").first();
|
||||
}
|
||||
|
||||
if (possibleOptionElement.length > 0)
|
||||
{
|
||||
$('#product_id').val(possibleOptionElement.val());
|
||||
$('#product_id').data('combobox').refresh();
|
||||
$('#product_id').trigger('change');
|
||||
$('#best_before_date').focus();
|
||||
}
|
||||
}
|
||||
|
||||
var addBarcode = GetUriParam('addbarcodetoselection');
|
||||
if (addBarcode !== undefined)
|
||||
{
|
||||
$('#addbarcodetoselection').text(addBarcode);
|
||||
$('#flow-info-addbarcodetoselection').removeClass('hide');
|
||||
$('#barcode-lookup-disabled-hint').removeClass('hide');
|
||||
}
|
||||
|
||||
$('#best_before_date').on('change', function(e)
|
||||
{
|
||||
$('#purchase-form').validator('validate');
|
||||
|
@@ -30,9 +30,6 @@
|
||||
}
|
||||
});
|
||||
|
||||
$(function()
|
||||
{
|
||||
$('#name').focus();
|
||||
$('#quantityunit-form').validator();
|
||||
$('#quantityunit-form').validator('validate');
|
||||
});
|
||||
$('#name').focus();
|
||||
$('#quantityunit-form').validator();
|
||||
$('#quantityunit-form').validator('validate');
|
||||
|
@@ -31,13 +31,11 @@
|
||||
});
|
||||
});
|
||||
|
||||
$(function()
|
||||
{
|
||||
$('#quantityunits-table').DataTable({
|
||||
'pageLength': 50,
|
||||
'order': [[1, 'asc']],
|
||||
'columnDefs': [
|
||||
{ 'orderable': false, 'targets': 0 }
|
||||
]
|
||||
});
|
||||
$('#quantityunits-table').DataTable({
|
||||
'pageLength': 50,
|
||||
'order': [[1, 'asc']],
|
||||
'columnDefs': [
|
||||
{ 'orderable': false, 'targets': 0 }
|
||||
],
|
||||
'language': JSON.parse(L('datatables_localization'))
|
||||
});
|
||||
|
@@ -26,13 +26,11 @@ $(document).on('click', '#add-products-below-min-stock-amount', function(e)
|
||||
);
|
||||
});
|
||||
|
||||
$(function()
|
||||
{
|
||||
$('#shoppinglist-table').DataTable({
|
||||
'pageLength': 50,
|
||||
'order': [[1, 'asc']],
|
||||
'columnDefs': [
|
||||
{ 'orderable': false, 'targets': 0 }
|
||||
]
|
||||
});
|
||||
$('#shoppinglist-table').DataTable({
|
||||
'pageLength': 50,
|
||||
'order': [[1, 'asc']],
|
||||
'columnDefs': [
|
||||
{ 'orderable': false, 'targets': 0 }
|
||||
],
|
||||
'language': JSON.parse(L('datatables_localization'))
|
||||
});
|
||||
|
@@ -36,22 +36,13 @@ $('#product_id').on('change', function(e)
|
||||
|
||||
if (productId)
|
||||
{
|
||||
Grocy.Components.ProductCard.Refresh(productId);
|
||||
|
||||
Grocy.FetchJson('/api/stock/get-product-details/' + productId,
|
||||
function (productDetails)
|
||||
{
|
||||
$('#selected-product-name').text(productDetails.product.name);
|
||||
$('#selected-product-stock-amount').text(productDetails.stock_amount || '0');
|
||||
$('#selected-product-stock-qu-name').text(productDetails.quantity_unit_stock.name);
|
||||
$('#selected-product-stock-qu-name2').text(productDetails.quantity_unit_stock.name);
|
||||
$('#selected-product-last-purchased').text((productDetails.last_purchased || 'never').substring(0, 10));
|
||||
$('#selected-product-last-purchased-timeago').text($.timeago(productDetails.last_purchased || ''));
|
||||
$('#selected-product-last-used').text((productDetails.last_used || 'never').substring(0, 10));
|
||||
$('#selected-product-last-used-timeago').text($.timeago(productDetails.last_used || ''));
|
||||
$('#amount_qu_unit').text(productDetails.quantity_unit_purchase.name);
|
||||
|
||||
EmptyElementWhenMatches('#selected-product-last-purchased-timeago', 'NaN years ago');
|
||||
EmptyElementWhenMatches('#selected-product-last-used-timeago', 'NaN years ago');
|
||||
|
||||
if ($('#product_id').hasClass('suppress-next-custom-validate-event'))
|
||||
{
|
||||
$('#product_id').removeClass('suppress-next-custom-validate-event');
|
||||
@@ -97,53 +88,50 @@ $('#product_id').on('change', function(e)
|
||||
}
|
||||
});
|
||||
|
||||
$(function()
|
||||
$('.combobox').combobox({
|
||||
appendId: '_text_input'
|
||||
});
|
||||
|
||||
$('#product_id_text_input').on('change', function(e)
|
||||
{
|
||||
$('.combobox').combobox({
|
||||
appendId: '_text_input'
|
||||
});
|
||||
var input = $('#product_id_text_input').val().toString();
|
||||
var possibleOptionElement = $("#product_id option[data-additional-searchdata*='" + input + "']").first();
|
||||
|
||||
$('#product_id_text_input').on('change', function(e)
|
||||
{
|
||||
var input = $('#product_id_text_input').val().toString();
|
||||
var possibleOptionElement = $("#product_id option[data-additional-searchdata*='" + input + "']").first();
|
||||
|
||||
if (possibleOptionElement.length > 0 && possibleOptionElement.text().length > 0) {
|
||||
$('#product_id').val(possibleOptionElement.val());
|
||||
$('#product_id').data('combobox').refresh();
|
||||
$('#product_id').trigger('change');
|
||||
}
|
||||
});
|
||||
|
||||
$('#product_id_text_input').focus();
|
||||
$('#product_id_text_input').trigger('change');
|
||||
|
||||
if (Grocy.EditMode === 'edit')
|
||||
{
|
||||
$('#product_id').addClass('suppress-next-custom-validate-event');
|
||||
if (possibleOptionElement.length > 0 && possibleOptionElement.text().length > 0) {
|
||||
$('#product_id').val(possibleOptionElement.val());
|
||||
$('#product_id').data('combobox').refresh();
|
||||
$('#product_id').trigger('change');
|
||||
}
|
||||
|
||||
$('#shoppinglist-form').validator();
|
||||
$('#shoppinglist-form').validator('validate');
|
||||
|
||||
$('#amount').on('focus', function(e)
|
||||
{
|
||||
if ($('#product_id_text_input').val().length === 0)
|
||||
{
|
||||
$('#product_id_text_input').focus();
|
||||
}
|
||||
});
|
||||
|
||||
$('#shoppinglist-form input').keydown(function(event)
|
||||
{
|
||||
if (event.keyCode === 13) //Enter
|
||||
{
|
||||
if ($('#shoppinglist-form').validator('validate').has('.has-error').length !== 0) //There is at least one validation error
|
||||
{
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#product_id_text_input').focus();
|
||||
$('#product_id_text_input').trigger('change');
|
||||
|
||||
if (Grocy.EditMode === 'edit')
|
||||
{
|
||||
$('#product_id').addClass('suppress-next-custom-validate-event');
|
||||
$('#product_id').trigger('change');
|
||||
}
|
||||
|
||||
$('#shoppinglist-form').validator();
|
||||
$('#shoppinglist-form').validator('validate');
|
||||
|
||||
$('#amount').on('focus', function(e)
|
||||
{
|
||||
if ($('#product_id_text_input').val().length === 0)
|
||||
{
|
||||
$('#product_id_text_input').focus();
|
||||
}
|
||||
});
|
||||
|
||||
$('#shoppinglist-form input').keydown(function(event)
|
||||
{
|
||||
if (event.keyCode === 13) //Enter
|
||||
{
|
||||
if ($('#shoppinglist-form').validator('validate').has('.has-error').length !== 0) //There is at least one validation error
|
||||
{
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@@ -1,7 +1,5 @@
|
||||
$(function()
|
||||
{
|
||||
$('#stock-overview-table').DataTable({
|
||||
'pageLength': 50,
|
||||
'order': [[2, 'asc']]
|
||||
});
|
||||
$('#stock-overview-table').DataTable({
|
||||
'pageLength': 50,
|
||||
'order': [[2, 'asc']],
|
||||
'language': JSON.parse(L('datatables_localization'))
|
||||
});
|
||||
|
Reference in New Issue
Block a user