mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 01:32:38 +00:00
Simplified "checkboxUncheckedValue" handling
This commit is contained in:
parent
9949f30c2b
commit
9c81fc890b
@ -664,6 +664,9 @@ $.extend(true, $.fn.dataTable.defaults, {
|
||||
}
|
||||
});
|
||||
|
||||
// serializeJSON defaults
|
||||
$.serializeJSON.defaultOptions.checkboxUncheckedValue = "0";
|
||||
|
||||
$(Grocy.UserPermissions).each(function(index, item)
|
||||
{
|
||||
if (item.has_permission == 0)
|
||||
|
@ -2,7 +2,7 @@
|
||||
{
|
||||
e.preventDefault();
|
||||
|
||||
var jsonData = $('#chore-form').serializeJSON({ checkboxUncheckedValue: "0" });
|
||||
var jsonData = $('#chore-form').serializeJSON();
|
||||
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_CHORES_ASSIGNMENTS)
|
||||
{
|
||||
jsonData.assignment_config = $("#assignment_config").val().join(",");
|
||||
|
@ -31,23 +31,26 @@ Grocy.Components.UserfieldsForm.Save = function(success, error)
|
||||
else if (input.attr("type") == "file")
|
||||
{
|
||||
var old_file = input.data('old-file')
|
||||
if (old_file) {
|
||||
if (old_file)
|
||||
{
|
||||
Grocy.Api.Delete('files/userfiles/' + old_file, null, null,
|
||||
function (xhr) {
|
||||
function(xhr)
|
||||
{
|
||||
Grocy.FrontendHelpers.ShowGenericError('Could not delete file', xhr);
|
||||
});
|
||||
jsonData[fieldName] = "";
|
||||
}
|
||||
if (input[0].files.length > 0){
|
||||
if (input[0].files.length > 0)
|
||||
{
|
||||
// Files service requires an extension
|
||||
var fileName = RandomString() + '.' + input[0].files[0].name.split('.').reverse()[0];
|
||||
|
||||
jsonData[fieldName] = btoa(fileName) + '_' + btoa(input[0].files[0].name);
|
||||
Grocy.Api.UploadFile(input[0].files[0], 'userfiles', fileName,
|
||||
function (result)
|
||||
function(result)
|
||||
{
|
||||
},
|
||||
function (xhr)
|
||||
function(xhr)
|
||||
{
|
||||
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
|
||||
}
|
||||
@ -111,7 +114,8 @@ Grocy.Components.UserfieldsForm.Load = function()
|
||||
}
|
||||
if (input.attr('type') == "file")
|
||||
{
|
||||
if (value != null && !value.isEmpty()) {
|
||||
if (value != null && !value.isEmpty())
|
||||
{
|
||||
var file_name = atob(value.split('_')[1]);
|
||||
var file_src = value.split('_')[0];
|
||||
input.hide();
|
||||
@ -123,7 +127,8 @@ Grocy.Components.UserfieldsForm.Load = function()
|
||||
file_info.find('img.userfield-current-file')
|
||||
.attr('src', U('/files/userfiles/' + value + '?force_serve_as=picture&best_fit_width=250&best_fit_height=250'))
|
||||
file_info.find('button.userfield-file-delete').click(
|
||||
function () {
|
||||
function()
|
||||
{
|
||||
file_info.addClass('d-none');
|
||||
input.data('old-file', file_src);
|
||||
input.show();
|
||||
|
@ -65,7 +65,7 @@ $('.save-product-button').on('click', function(e)
|
||||
{
|
||||
e.preventDefault();
|
||||
|
||||
var jsonData = $('#product-form').serializeJSON({ checkboxUncheckedValue: "0" });
|
||||
var jsonData = $('#product-form').serializeJSON();
|
||||
var parentProductId = jsonData.product_id;
|
||||
delete jsonData.product_id;
|
||||
jsonData.parent_product_id = parentProductId;
|
||||
|
@ -4,7 +4,7 @@ $('#save-recipe-pos-button').on('click', function(e)
|
||||
{
|
||||
e.preventDefault();
|
||||
|
||||
var jsonData = $('#recipe-pos-form').serializeJSON({ checkboxUncheckedValue: "0" });
|
||||
var jsonData = $('#recipe-pos-form').serializeJSON();
|
||||
jsonData.recipe_id = Grocy.EditObjectParentId;
|
||||
delete jsonData.display_amount;
|
||||
|
||||
|
@ -205,9 +205,6 @@
|
||||
|
||||
<div class="form-group">
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="hidden"
|
||||
name="track_date_only"
|
||||
value="0">
|
||||
<input @if($mode=='edit'
|
||||
&&
|
||||
$chore->track_date_only == 1) checked @endif class="form-check-input custom-control-input" type="checkbox" id="track_date_only" name="track_date_only" value="1">
|
||||
@ -222,9 +219,6 @@
|
||||
|
||||
<div class="form-group">
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="hidden"
|
||||
name="rollover"
|
||||
value="0">
|
||||
<input @if($mode=='edit'
|
||||
&&
|
||||
$chore->rollover == 1) checked @endif class="form-check-input custom-control-input" type="checkbox" id="rollover" name="rollover" value="1">
|
||||
@ -240,9 +234,6 @@
|
||||
@if(GROCY_FEATURE_FLAG_STOCK)
|
||||
<div class="form-group mt-4 mb-1">
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="hidden"
|
||||
name="consume_product_on_execution"
|
||||
value="0">
|
||||
<input @if($mode=='edit'
|
||||
&&
|
||||
$chore->consume_product_on_execution == 1) checked @endif class="form-check-input custom-control-input" type="checkbox" id="consume_product_on_execution" name="consume_product_on_execution" value="1">
|
||||
|
@ -69,9 +69,6 @@
|
||||
@if(isset($shortcutValue) && isset($shortcutLabel))
|
||||
<div class="form-group mt-n2 mb-0">
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="hidden"
|
||||
name="datetimepicker-shortcut"
|
||||
value="0">
|
||||
<input class="form-check-input custom-control-input"
|
||||
type="checkbox"
|
||||
id="datetimepicker-shortcut"
|
||||
|
@ -67,9 +67,6 @@
|
||||
<div class="
|
||||
custom-control
|
||||
custom-checkbox">
|
||||
<input type="hidden"
|
||||
name="datetimepicker2-shortcut"
|
||||
value="0">
|
||||
<input class="form-check-input custom-control-input"
|
||||
type="checkbox"
|
||||
id="datetimepicker2-shortcut"
|
||||
|
@ -77,12 +77,13 @@
|
||||
@elseif($userfield->type == \Grocy\Services\UserfieldsService::USERFIELD_TYPE_CHECKBOX)
|
||||
<div class="form-group">
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input class="form-check-input userfield-input custom-control-input"
|
||||
<input class="form-check-input custom-control-input userfield-input"
|
||||
type="checkbox"
|
||||
id="userfield-{{ $userfield->name }}"
|
||||
data-userfield-name="{{ $userfield->name }}"
|
||||
value="1">
|
||||
<label class="form-check-label custom-control-label"
|
||||
for="{{ $userfield->name }}">{{ $userfield->caption }}</label>
|
||||
for="userfield-{{ $userfield->name }}">{{ $userfield->caption }}</label>
|
||||
</div>
|
||||
</div>
|
||||
@elseif($userfield->type == \Grocy\Services\UserfieldsService::USERFIELD_TYPE_PRESET_LIST)
|
||||
|
@ -60,9 +60,6 @@
|
||||
<div id="consume-exact-amount-group"
|
||||
class="form-group d-none">
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="hidden"
|
||||
name="consume-exact-amount"
|
||||
value="0">
|
||||
<input class="form-check-input custom-control-input"
|
||||
type="checkbox"
|
||||
id="consume-exact-amount"
|
||||
@ -98,9 +95,6 @@
|
||||
|
||||
<div class="form-group">
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="hidden"
|
||||
name="use_specific_stock_entry"
|
||||
value="0">
|
||||
<input class="form-check-input custom-control-input"
|
||||
type="checkbox"
|
||||
id="use_specific_stock_entry"
|
||||
@ -123,9 +117,6 @@
|
||||
|
||||
<div class="form-group">
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="hidden"
|
||||
name="spoiled"
|
||||
value="0">
|
||||
<input class="form-check-input custom-control-input"
|
||||
type="checkbox"
|
||||
id="spoiled"
|
||||
|
@ -54,9 +54,6 @@
|
||||
@if(GROCY_FEATURE_FLAG_STOCK_PRODUCT_FREEZING)
|
||||
<div class="form-group">
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="hidden"
|
||||
name="is_freezer"
|
||||
value="0">
|
||||
<input @if($mode=='edit'
|
||||
&&
|
||||
$location->is_freezer == 1) checked @endif class="form-check-input custom-control-input" type="checkbox" id="is_freezer" name="is_freezer" value="1">
|
||||
|
@ -64,9 +64,6 @@
|
||||
|
||||
<div class="form-group">
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="hidden"
|
||||
name="active"
|
||||
value="1">
|
||||
<input @if($mode=='create'
|
||||
)
|
||||
checked
|
||||
@ -154,9 +151,6 @@
|
||||
|
||||
<div class="form-group">
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="hidden"
|
||||
name="cumulate_min_stock_amount_of_sub_products"
|
||||
value="0">
|
||||
<input @if($mode=='edit'
|
||||
&&
|
||||
$product->cumulate_min_stock_amount_of_sub_products == 1) checked @endif class="form-check-input custom-control-input" type="checkbox" id="cumulate_min_stock_amount_of_sub_products" name="cumulate_min_stock_amount_of_sub_products" value="1">
|
||||
@ -261,9 +255,6 @@
|
||||
|
||||
<div class="form-group">
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="hidden"
|
||||
name="allow_partial_units_in_stock"
|
||||
value="0">
|
||||
<input @if($mode=='edit'
|
||||
&&
|
||||
$product->allow_partial_units_in_stock == 1) checked @endif class="form-check-input custom-control-input" type="checkbox" id="allow_partial_units_in_stock" name="allow_partial_units_in_stock" value="1">
|
||||
@ -274,9 +265,6 @@
|
||||
|
||||
<div class="form-group mb-1">
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="hidden"
|
||||
name="enable_tare_weight_handling"
|
||||
value="0">
|
||||
<input @if($mode=='edit'
|
||||
&&
|
||||
$product->enable_tare_weight_handling == 1) checked @endif class="form-check-input custom-control-input" type="checkbox" id="enable_tare_weight_handling" name="enable_tare_weight_handling" value="1">
|
||||
@ -306,9 +294,6 @@
|
||||
@if(GROCY_FEATURE_FLAG_RECIPES)
|
||||
<div class="form-group">
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="hidden"
|
||||
name="not_check_stock_fulfillment_for_recipes"
|
||||
value="0">
|
||||
<input @if($mode=='edit'
|
||||
&&
|
||||
$product->not_check_stock_fulfillment_for_recipes == 1) checked @endif class="form-check-input custom-control-input" type="checkbox" id="not_check_stock_fulfillment_for_recipes" name="not_check_stock_fulfillment_for_recipes" value="1">
|
||||
|
@ -96,9 +96,6 @@
|
||||
|
||||
<div class="form-group @if($mode == 'edit') d-none @endif">
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="hidden"
|
||||
name="create_inverse:skip"
|
||||
value="0">
|
||||
<input checked
|
||||
class="form-check-input custom-control-input"
|
||||
type="checkbox"
|
||||
|
@ -74,9 +74,6 @@
|
||||
|
||||
<div class="form-group">
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="hidden"
|
||||
name="not_check_shoppinglist"
|
||||
value="0">
|
||||
<input @if($mode=='edit'
|
||||
&&
|
||||
$recipe->not_check_shoppinglist == 1) checked @endif class="form-check-input custom-control-input" type="checkbox" id="not_check_shoppinglist" name="not_check_shoppinglist" value="1">
|
||||
|
@ -48,9 +48,6 @@
|
||||
|
||||
<div class="form-group mb-1">
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="hidden"
|
||||
name="only_check_single_unit_in_stock"
|
||||
value="0">
|
||||
<input @if($mode=='edit'
|
||||
&&
|
||||
$recipePos->only_check_single_unit_in_stock == 1) checked @endif class="form-check-input custom-control-input" type="checkbox" id="only_check_single_unit_in_stock" name="only_check_single_unit_in_stock" value="1">
|
||||
@ -80,9 +77,6 @@
|
||||
|
||||
<div class="form-group">
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="hidden"
|
||||
name="not_check_stock_fulfillment"
|
||||
value="0">
|
||||
<input @if($mode=='edit'
|
||||
&&
|
||||
($recipePos->not_check_stock_fulfillment == 1 || FindObjectInArrayByPropertyValue($products, 'id', $recipePos->product_id)->not_check_stock_fulfillment_for_recipes == 1)) checked @endif class="form-check-input custom-control-input" type="checkbox" id="not_check_stock_fulfillment" name="not_check_stock_fulfillment" value="1">
|
||||
|
@ -124,9 +124,6 @@
|
||||
|
||||
<div class="form-group">
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="hidden"
|
||||
name="open"
|
||||
value="1">
|
||||
<input @if($stockEntry->open == 1) checked @endif class="form-check-input custom-control-input" type="checkbox" id="open" name="open" value="1">
|
||||
<label class="form-check-label custom-control-label"
|
||||
for="open">{{ $__t('Opened') }}</label>
|
||||
|
@ -49,9 +49,6 @@
|
||||
|
||||
<div class="form-group">
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="hidden"
|
||||
name="use_specific_stock_entry"
|
||||
value="0">
|
||||
<input class="form-check-input custom-control-input"
|
||||
type="checkbox"
|
||||
id="use_specific_stock_entry"
|
||||
|
@ -69,9 +69,6 @@
|
||||
|
||||
<div class="form-group">
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="hidden"
|
||||
name="show_in_sidebar_menu"
|
||||
value="0">
|
||||
<input @if($mode=='edit'
|
||||
&&
|
||||
$userentity->show_in_sidebar_menu == 1) checked @endif class="form-check-input custom-control-input" type="checkbox" id="show_in_sidebar_menu" name="show_in_sidebar_menu" value="1">
|
||||
|
@ -98,9 +98,6 @@
|
||||
|
||||
<div class="form-group">
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="hidden"
|
||||
name="show_as_column_in_tables"
|
||||
value="0">
|
||||
<input @if($mode=='edit'
|
||||
&&
|
||||
$userfield->show_as_column_in_tables == 1) checked @endif class="form-check-input custom-control-input" type="checkbox" id="show_as_column_in_tables" name="show_as_column_in_tables" value="1">
|
||||
|
Loading…
x
Reference in New Issue
Block a user