Fix modal content width, scan mode in embeds

This commit is contained in:
Katharina Bogad 2021-06-25 23:24:30 +02:00
parent cfff3e568f
commit 45d7febeed
19 changed files with 76 additions and 28 deletions

View File

@ -395,13 +395,14 @@ class GrocyFrontendHelpers
});
}
MakeYesNoBox(message, selector, callback)
MakeYesNoBox(message, selector, cb)
{
var self = this;
this.scope.on('click', selector, function(e)
{
message = message instanceof Function ? message(e) : message;
var target = e.currentTarget;
message = message instanceof Function ? message(target) : message;
bootbox.confirm({
message: message,
closeButton: false,
@ -415,7 +416,7 @@ class GrocyFrontendHelpers
className: 'btn-danger'
}
},
callback: (result) => callback(result, e)
callback: (result) => cb(result, target)
});
});

View File

@ -41,7 +41,10 @@ class GrocyProxy
{
// if we need to override UserSettings, we need to copy the object.
// not great, but eh.
let tempUs = {}
Object.assign(tempUs, this.config.UserSettings);
Object.assign(this.config.UserSettings, RootGrocy.UserSettings);
Object.assign(this.config.UserSettings, tempUs);
this.UserSettings = config.UserSettings;
}

View File

@ -96,7 +96,7 @@ function batteryformView(Grocy, scope = null)
}
});
userfieldsform.UserfieldsForm.Load();
userfieldsform.Load();
$scope('#name').focus();
Grocy.FrontendHelpers.ValidateForm('battery-form');

View File

@ -15,6 +15,7 @@ function productformView(Grocy, scope = null)
// preload some views.
Grocy.PreloadView("productgroupform");
Grocy.PreloadView("productbarcodeform");
Grocy.PreloadView("quantityunitconversionform");
var shoppinglocationpicker = Grocy.Use("shoppinglocationpicker");
var userfields = Grocy.Use("userfieldsform");

View File

@ -121,9 +121,9 @@
);
Grocy.FrontendHelpers.MakeYesNoBox(
(e) =>
(target) =>
{
var objectName = $(e.currentTarget).attr('data-recipe-name');
var objectName = $(target).attr('data-recipe-name');
return __t('Are you sure to put all missing ingredients for recipe "%s" on the shopping list?', objectName) +
"<br><br>" +
__t("Uncheck ingredients to not put them on the shopping list") +
@ -131,9 +131,9 @@
$scope("#missing-recipe-pos-list")[0].outerHTML.replace("d-none", "");
},
'.recipe-shopping-list',
(result, e) =>
(result, target) =>
{
var objectId = $(e.currentTarget).attr('data-recipe-id');
var objectId = $(target).attr('data-recipe-id');
if (result === true)
{
Grocy.FrontendHelpers.BeginUiBusy();
@ -160,15 +160,15 @@
);
Grocy.FrontendHelpers.MakeYesNoBox(
(e) =>
(target) =>
{
var objectName = $(e.currentTarget).attr('data-recipe-name');
var objectName = $(target).attr('data-recipe-name');
return __t('Are you sure to consume all ingredients needed by recipe "%s" (ingredients marked with "only check if any amount is in stock" will be ignored)?', objectName);
},
'.recipe-consume',
(result, e) =>
(result, targetElement) =>
{
var target = $(e.currentTarget);
var target = $(targetElement);
var objectName = target.attr('data-recipe-name');
var objectId = target.attr('data-recipe-id');
if (result === true)

View File

@ -7,7 +7,7 @@ import { WindowMessageBag } from '../helpers/messagebag';
function shoppinglistView(Grocy, scope = null)
{
var $scope = $;
var top = scope != null ? $(scope) : top;
var top = scope != null ? $(scope) : $(document);
var viewport = scope != null ? $(scope) : $(window);
if (scope != null)

View File

@ -24,8 +24,12 @@ EditObjectId: {{ $battery->id }},
<hr class="my-2">
@php
$classes = $embedded ? '' : 'col-lg-6';
@endphp
<div class="row">
<div class="col-lg-6 col-12">
<div class="{{ $classes }} col-12">
<form id="battery-form"
novalidate>

View File

@ -7,13 +7,16 @@ $content = $__env->yieldContent('content');
// to reencode stuff like additional , at the end or
// ' instead of " as field delimter.
$config = "{\n" . $__env->yieldContent('grocyConfigProps') . '}';
$config = preg_replace('/(\n[\t ]*)([a-zA-Z0-9]+):/','${1}"${2}":', $config);
$config = preg_replace('/(\n[\t ]*)([a-zA-Z0-9_]+):/','${1}"${2}":', $config);
$config = preg_replace('/: *\'(.*?)\',?\n/', ':"${1}",', $config);
$config = preg_replace('/,\n?}$/', '}', $config);
$config = preg_replace('/,(\n[\t ]+)?}$/', '}', $config);
$grocy_options = json_decode($config, true);
$usersettings = $__env->yieldContent('forceUserSettings');
$usersettings = json_decode('{' . $usersettings . '}');
$usersettings = "{\n" . $__env->yieldContent('forceUserSettings') . '}';
$usersettings = preg_replace('/(\n[\t ]*)([a-zA-Z0-9_]+):/','${1}"${2}":', $usersettings);
$usersettings = preg_replace('/: *\'(.*?)\',?\n/', ':"${1}",', $usersettings);
$usersettings = preg_replace('/,(\n[\t ]+)?}$/', '}', $usersettings);
$usersettings = json_decode($usersettings, true);
if($usersettings != null)
$grocy_options["UserSettings"] = $usersettings;

View File

@ -24,8 +24,12 @@ EditObjectId: {{ $location->id }},
<hr class="my-2">
@php
$classes = $embedded ? '' : 'col-lg-6';
@endphp
<div class="row">
<div class="col-lg-6 col-12">
<div class="{{ $classes }} col-12">
<form id="location-form"
novalidate>

View File

@ -23,9 +23,12 @@ EditObjectId: {{ $group->id }},
</div>
<hr class="my-2">
@php
$classes = $embedded ? '' : 'col-lg-6';
@endphp
<div class="row">
<div class="col-lg-6 col-12">
<div class="{{ $classes }} col-12">
<form id="product-group-form"
novalidate>

View File

@ -12,7 +12,7 @@
@section('forceUserSettings')
@if($embedded)
scan_mode_consume_enabled: false,
scan_mode_purchase_enabled: false,
@endif
@endsection

View File

@ -34,8 +34,12 @@ EditObjectId: {{ $quConversion->id }},
<hr class="my-2">
@php
$classes = $embedded ? '' : 'col-lg-6';
@endphp
<div class="row">
<div class="col-lg-6 col-12">
<div class="{{ $classes }} col-12">
<form id="quconversion-form"
novalidate>

View File

@ -24,8 +24,12 @@ EditObjectId: {{ $shoppingList->id }},
<hr class="my-2">
@php
$classes = $embedded ? '' : 'col-lg-6';
@endphp
<div class="row">
<div class="col-lg-6 col-12">
<div class="{{ $classes }} col-12">
<form id="shopping-list-form"
novalidate>

View File

@ -24,8 +24,12 @@ EditObjectId: {{ $shoppinglocation->id }},
<hr class="my-2">
@php
$classes = $embedded ? '' : 'col-lg-6';
@endphp
<div class="row">
<div class="col-lg-6 col-12">
<div class="{{ $classes }} col-12">
<form id="shoppinglocation-form"
novalidate>

View File

@ -23,9 +23,12 @@ EditObjectId: {{ $category->id }},
</div>
<hr class="my-2">
@php
$classes = $embedded ? '' : 'col-lg-6';
@endphp
<div class="row">
<div class="col-lg-6 col-12">
<div class="{{ $classes }} col-12">
<form id="task-category-form"
novalidate>

View File

@ -84,6 +84,7 @@
<a class="btn btn-info btn-sm show-as-dialog-link"
href="{{ $U('/userentity/') }}{{ $userentity->id }}?embedded"
data-toggle="tooltip"
data-boundary="viewport"
title="{{ $__t('Edit this item') }}">
<i class="fas fa-edit"></i>
</a>
@ -92,6 +93,7 @@
data-userentity-id="{{ $userentity->id }}"
data-userentity-name="{{ $userentity->name }}"
data-toggle="tooltip"
data-boundary="viewport"
title="{{ $__t('Delete this item') }}">
<i class="fas fa-trash"></i>
</a>

View File

@ -24,8 +24,12 @@ EditObjectId: {{ $userentity->id }},
<hr class="my-2">
@php
$classes = $embedded ? '' : 'col-lg-6';
@endphp
<div class="row">
<div class="col-lg-6 col-12">
<div class="{{ $classes }} col-12">
<form id="userentity-form"
novalidate>

View File

@ -15,6 +15,10 @@ EditObjectId: {{ $userfield->id }},
@endif
@endsection
@php
$classes = $embedded ? '' : 'col-lg-6';
@endphp
@section('content')
<div class="row">
<div class="col">
@ -25,7 +29,7 @@ EditObjectId: {{ $userfield->id }},
<hr class="my-2">
<div class="row">
<div class="col-lg-6 col-12">
<div class="{{ $classes }} col-12">
<form id="userfield-form"
novalidate>

View File

@ -26,8 +26,12 @@ EditObjectId: {{ $userobject->id }},
<hr class="my-2">
@php
$classes = $embedded ? '' : 'col-lg-6';
@endphp
<div class="row">
<div class="col-lg-6 col-12">
<div class="{{ $classes }} col-12">
<form id="userobject-form"
novalidate>