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; var self = this;
this.scope.on('click', selector, function(e) 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({ bootbox.confirm({
message: message, message: message,
closeButton: false, closeButton: false,
@ -415,7 +416,7 @@ class GrocyFrontendHelpers
className: 'btn-danger' 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. // if we need to override UserSettings, we need to copy the object.
// not great, but eh. // not great, but eh.
let tempUs = {}
Object.assign(tempUs, this.config.UserSettings);
Object.assign(this.config.UserSettings, RootGrocy.UserSettings); Object.assign(this.config.UserSettings, RootGrocy.UserSettings);
Object.assign(this.config.UserSettings, tempUs);
this.UserSettings = config.UserSettings; this.UserSettings = config.UserSettings;
} }

View File

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

View File

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

View File

@ -121,9 +121,9 @@
); );
Grocy.FrontendHelpers.MakeYesNoBox( 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) + return __t('Are you sure to put all missing ingredients for recipe "%s" on the shopping list?', objectName) +
"<br><br>" + "<br><br>" +
__t("Uncheck ingredients to not put them on the shopping list") + __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", ""); $scope("#missing-recipe-pos-list")[0].outerHTML.replace("d-none", "");
}, },
'.recipe-shopping-list', '.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) if (result === true)
{ {
Grocy.FrontendHelpers.BeginUiBusy(); Grocy.FrontendHelpers.BeginUiBusy();
@ -160,15 +160,15 @@
); );
Grocy.FrontendHelpers.MakeYesNoBox( 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); 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', '.recipe-consume',
(result, e) => (result, targetElement) =>
{ {
var target = $(e.currentTarget); var target = $(targetElement);
var objectName = target.attr('data-recipe-name'); var objectName = target.attr('data-recipe-name');
var objectId = target.attr('data-recipe-id'); var objectId = target.attr('data-recipe-id');
if (result === true) if (result === true)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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