diff --git a/changelog/62_UNRELEASED_xxxx-xx-xx.md b/changelog/62_UNRELEASED_xxxx-xx-xx.md index 24c7277d..0396bcf4 100644 --- a/changelog/62_UNRELEASED_xxxx-xx-xx.md +++ b/changelog/62_UNRELEASED_xxxx-xx-xx.md @@ -42,6 +42,7 @@ - Recipe printing improvements (thanks @Ape) - Calories are now always displayed per single serving (on the recipe and meal plan page) - Fixed that "Only check if any amount is in stock" (recipe ingredient option) didn't work for stock amounts < 1 +- Fixed that when adding missing items to the shopping list, on the popup deselected items got also added ### Chores fixes - Fixed that tracking chores with "Done by" a different user was not possible @@ -49,6 +50,7 @@ ### Userfield fixes - Fixed that numeric Userfields were initialised with `1.0` - Fixed that shortcuts (up/down key) and the format did not work correctly when using multiple date/time Userfields per object +- Fixed that Userfields were not saved when adding a product or a recipe (only on editing) ### General & other improvements/fixes - LDAP authentication improvements / OpenLDAP support (thanks @tank0226) @@ -63,3 +65,4 @@ ### API fixes - Fixed that due soon products with `due_type` = "Expiration date" were missing in `due_products` of the `/stock/volatile` endpoint +- Fixed that `PUT/DELETE /objects/{entity}/{objectId}` produced an internal server error when the given object id was invalid (now returns `400 Bad Request`) diff --git a/controllers/BaseController.php b/controllers/BaseController.php index 81442d4b..e2556d50 100644 --- a/controllers/BaseController.php +++ b/controllers/BaseController.php @@ -220,11 +220,12 @@ class BaseController } $requestBody = $request->getParsedBody(); + return $requestBody; foreach ($requestBody as $key => &$value) { - // HTMLPurifier removes boolean values (true/false), so explicitly keep them + // HTMLPurifier removes boolean values (true/false) and arrays, so explicitly keep them // Maybe also possible through HTMLPurifier config (http://htmlpurifier.org/live/configdoc/plain.html) - if (!is_bool($value)) + if (!is_bool($value) && !is_array($value)) { $value = self::$htmlPurifierInstance->purify($value); } diff --git a/controllers/GenericEntityApiController.php b/controllers/GenericEntityApiController.php index c23d5091..f9a5da40 100644 --- a/controllers/GenericEntityApiController.php +++ b/controllers/GenericEntityApiController.php @@ -58,6 +58,11 @@ class GenericEntityApiController extends BaseApiController } $row = $this->getDatabase()->{$args['entity']}($args['objectId']); + if ($row == null) + { + return $this->GenericErrorResponse($response, 'Object not found', 400); + } + $row->delete(); $success = $row->isClean(); @@ -90,6 +95,11 @@ class GenericEntityApiController extends BaseApiController } $row = $this->getDatabase()->{$args['entity']}($args['objectId']); + if ($row == null) + { + return $this->GenericErrorResponse($response, 'Object not found', 400); + } + $row->update($requestBody); $success = $row->isClean(); diff --git a/controllers/OpenApiController.php b/controllers/OpenApiController.php index 63716ce5..45ea0a38 100644 --- a/controllers/OpenApiController.php +++ b/controllers/OpenApiController.php @@ -36,6 +36,12 @@ class OpenApiController extends BaseApiController $spec->info->description = str_replace('PlaceHolderManageApiKeysUrl', $this->AppContainer->get('UrlManager')->ConstructUrl('/manageapikeys'), $spec->info->description); $spec->servers[0]->url = $this->AppContainer->get('UrlManager')->ConstructUrl('/api'); + $spec->components->internalSchemas->ExposedEntity_IncludingUserEntities = clone $spec->components->internalSchemas->ExposedEntity; + foreach ($this->getUserfieldsService()->GetEntities() as $userEntity) + { + array_push($spec->components->internalSchemas->ExposedEntity_IncludingUserEntities->enum, $userEntity); + } + $spec->components->internalSchemas->ExposedEntity_NotIncludingNotEditable = clone $spec->components->internalSchemas->StringEnumTemplate; foreach ($spec->components->internalSchemas->ExposedEntity->enum as $value) { @@ -45,6 +51,15 @@ class OpenApiController extends BaseApiController } } + $spec->components->internalSchemas->ExposedEntity_IncludingUserEntities_NotIncludingNotEditable = clone $spec->components->internalSchemas->StringEnumTemplate; + foreach ($spec->components->internalSchemas->ExposedEntity_IncludingUserEntities->enum as $value) + { + if (!in_array($value, $spec->components->internalSchemas->ExposedEntityNoEdit->enum)) + { + array_push($spec->components->internalSchemas->ExposedEntity_IncludingUserEntities_NotIncludingNotEditable->enum, $value); + } + } + $spec->components->internalSchemas->ExposedEntity_NotIncludingNotDeletable = clone $spec->components->internalSchemas->StringEnumTemplate; foreach ($spec->components->internalSchemas->ExposedEntity->enum as $value) { diff --git a/grocy.openapi.json b/grocy.openapi.json index bff9d093..4cf50bc6 100644 --- a/grocy.openapi.json +++ b/grocy.openapi.json @@ -609,7 +609,7 @@ "required": true, "description": "A valid entity name", "schema": { - "$ref": "#/components/internalSchemas/ExposedEntity" + "$ref": "#/components/internalSchemas/ExposedEntity_IncludingUserEntities" } }, { @@ -658,7 +658,7 @@ "required": true, "description": "A valid entity name", "schema": { - "$ref": "#/components/internalSchemas/ExposedEntity_NotIncludingNotEditable" + "$ref": "#/components/internalSchemas/ExposedEntity_IncludingUserEntities_NotIncludingNotEditable" } }, { diff --git a/migrations/0131.sql b/migrations/0131.sql new file mode 100644 index 00000000..2a3e3b3a --- /dev/null +++ b/migrations/0131.sql @@ -0,0 +1,2 @@ +DELETE FROM userfield_values +WHERE object_id = 'undefined'; diff --git a/package.json b/package.json index e21c0b7f..e4738510 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "dependencies": { "@danielfarrell/bootstrap-combobox": "https://github.com/berrnd/bootstrap-combobox.git#master", "@ericblade/quagga2": "^1.2.1", + "@fontsource/noto-sans": "^4.4.5", "@fortawesome/fontawesome-free": "^5.14.0", "animate.css": "^3.7.2", "bootbox": "^5.3.2", diff --git a/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-700.eot b/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-700.eot deleted file mode 100644 index 88752ab8..00000000 Binary files a/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-700.eot and /dev/null differ diff --git a/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-700.svg b/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-700.svg deleted file mode 100644 index 925fe474..00000000 --- a/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-700.svg +++ /dev/null @@ -1,336 +0,0 @@ - - - diff --git a/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-700.ttf b/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-700.ttf deleted file mode 100644 index e5b16dd3..00000000 Binary files a/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-700.ttf and /dev/null differ diff --git a/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-700.woff b/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-700.woff deleted file mode 100644 index fb528bf9..00000000 Binary files a/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-700.woff and /dev/null differ diff --git a/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-700.woff2 b/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-700.woff2 deleted file mode 100644 index 1f16cc33..00000000 Binary files a/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-700.woff2 and /dev/null differ diff --git a/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-700italic.eot b/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-700italic.eot deleted file mode 100644 index 6b674540..00000000 Binary files a/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-700italic.eot and /dev/null differ diff --git a/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-700italic.svg b/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-700italic.svg deleted file mode 100644 index abdafc0f..00000000 --- a/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-700italic.svg +++ /dev/null @@ -1,334 +0,0 @@ - - - diff --git a/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-700italic.ttf b/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-700italic.ttf deleted file mode 100644 index 3f30d3ab..00000000 Binary files a/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-700italic.ttf and /dev/null differ diff --git a/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-700italic.woff b/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-700italic.woff deleted file mode 100644 index c43b01a4..00000000 Binary files a/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-700italic.woff and /dev/null differ diff --git a/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-700italic.woff2 b/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-700italic.woff2 deleted file mode 100644 index c357f24f..00000000 Binary files a/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-700italic.woff2 and /dev/null differ diff --git a/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-italic.eot b/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-italic.eot deleted file mode 100644 index 94d62201..00000000 Binary files a/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-italic.eot and /dev/null differ diff --git a/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-italic.svg b/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-italic.svg deleted file mode 100644 index dcd8fc89..00000000 --- a/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-italic.svg +++ /dev/null @@ -1,337 +0,0 @@ - - - diff --git a/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-italic.ttf b/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-italic.ttf deleted file mode 100644 index fcb3daf1..00000000 Binary files a/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-italic.ttf and /dev/null differ diff --git a/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-italic.woff b/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-italic.woff deleted file mode 100644 index eff2f6ae..00000000 Binary files a/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-italic.woff and /dev/null differ diff --git a/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-italic.woff2 b/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-italic.woff2 deleted file mode 100644 index e29f4d84..00000000 Binary files a/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-italic.woff2 and /dev/null differ diff --git a/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-regular.eot b/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-regular.eot deleted file mode 100644 index 78e0578b..00000000 Binary files a/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-regular.eot and /dev/null differ diff --git a/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-regular.svg b/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-regular.svg deleted file mode 100644 index bd2894d6..00000000 --- a/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-regular.svg +++ /dev/null @@ -1,335 +0,0 @@ - - - diff --git a/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-regular.ttf b/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-regular.ttf deleted file mode 100644 index 0ce9e1ca..00000000 Binary files a/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-regular.ttf and /dev/null differ diff --git a/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-regular.woff b/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-regular.woff deleted file mode 100644 index 4f1dd100..00000000 Binary files a/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-regular.woff and /dev/null differ diff --git a/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-regular.woff2 b/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-regular.woff2 deleted file mode 100644 index cf2b74a6..00000000 Binary files a/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin-regular.woff2 and /dev/null differ diff --git a/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin.css b/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin.css deleted file mode 100644 index fce7b9a1..00000000 --- a/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin.css +++ /dev/null @@ -1,55 +0,0 @@ -/* noto-sans-regular - latin */ -@font-face { - font-family: 'Noto Sans'; - font-style: normal; - font-weight: 400; - src: url('noto-sans-v11-latin-regular.eot'); /* IE9 Compat Modes */ - src: local(''), - url('noto-sans-v11-latin-regular.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */ - url('noto-sans-v11-latin-regular.woff2') format('woff2'), /* Super Modern Browsers */ - url('noto-sans-v11-latin-regular.woff') format('woff'), /* Modern Browsers */ - url('noto-sans-v11-latin-regular.ttf') format('truetype'), /* Safari, Android, iOS */ - url('noto-sans-v11-latin-regular.svg#NotoSans') format('svg'); /* Legacy iOS */ -} - -/* noto-sans-italic - latin */ -@font-face { - font-family: 'Noto Sans'; - font-style: italic; - font-weight: 400; - src: url('noto-sans-v11-latin-italic.eot'); /* IE9 Compat Modes */ - src: local(''), - url('noto-sans-v11-latin-italic.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */ - url('noto-sans-v11-latin-italic.woff2') format('woff2'), /* Super Modern Browsers */ - url('noto-sans-v11-latin-italic.woff') format('woff'), /* Modern Browsers */ - url('noto-sans-v11-latin-italic.ttf') format('truetype'), /* Safari, Android, iOS */ - url('noto-sans-v11-latin-italic.svg#NotoSans') format('svg'); /* Legacy iOS */ -} - -/* noto-sans-700 - latin */ -@font-face { - font-family: 'Noto Sans'; - font-style: normal; - font-weight: 700; - src: url('noto-sans-v11-latin-700.eot'); /* IE9 Compat Modes */ - src: local(''), - url('noto-sans-v11-latin-700.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */ - url('noto-sans-v11-latin-700.woff2') format('woff2'), /* Super Modern Browsers */ - url('noto-sans-v11-latin-700.woff') format('woff'), /* Modern Browsers */ - url('noto-sans-v11-latin-700.ttf') format('truetype'), /* Safari, Android, iOS */ - url('noto-sans-v11-latin-700.svg#NotoSans') format('svg'); /* Legacy iOS */ -} - -/* noto-sans-700italic - latin */ -@font-face { - font-family: 'Noto Sans'; - font-style: italic; - font-weight: 700; - src: url('noto-sans-v11-latin-700italic.eot'); /* IE9 Compat Modes */ - src: local(''), - url('noto-sans-v11-latin-700italic.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */ - url('noto-sans-v11-latin-700italic.woff2') format('woff2'), /* Super Modern Browsers */ - url('noto-sans-v11-latin-700italic.woff') format('woff'), /* Modern Browsers */ - url('noto-sans-v11-latin-700italic.ttf') format('truetype'), /* Safari, Android, iOS */ - url('noto-sans-v11-latin-700italic.svg#NotoSans') format('svg'); /* Legacy iOS */ -} diff --git a/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin.min.css b/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin.min.css deleted file mode 100644 index 73ebb06d..00000000 --- a/public/components_unmanaged/noto-sans-v11-latin/noto-sans-v11-latin.min.css +++ /dev/null @@ -1 +0,0 @@ -@font-face{font-family:'Noto Sans';font-style:normal;font-weight:400;src:url(noto-sans-v11-latin-regular.eot);src:local(''),url(noto-sans-v11-latin-regular.eot?#iefix) format('embedded-opentype'),url(noto-sans-v11-latin-regular.woff2) format('woff2'),url(noto-sans-v11-latin-regular.woff) format('woff'),url(noto-sans-v11-latin-regular.ttf) format('truetype'),url(noto-sans-v11-latin-regular.svg#NotoSans) format('svg')}@font-face{font-family:'Noto Sans';font-style:italic;font-weight:400;src:url(noto-sans-v11-latin-italic.eot);src:local(''),url(noto-sans-v11-latin-italic.eot?#iefix) format('embedded-opentype'),url(noto-sans-v11-latin-italic.woff2) format('woff2'),url(noto-sans-v11-latin-italic.woff) format('woff'),url(noto-sans-v11-latin-italic.ttf) format('truetype'),url(noto-sans-v11-latin-italic.svg#NotoSans) format('svg')}@font-face{font-family:'Noto Sans';font-style:normal;font-weight:700;src:url(noto-sans-v11-latin-700.eot);src:local(''),url(noto-sans-v11-latin-700.eot?#iefix) format('embedded-opentype'),url(noto-sans-v11-latin-700.woff2) format('woff2'),url(noto-sans-v11-latin-700.woff) format('woff'),url(noto-sans-v11-latin-700.ttf) format('truetype'),url(noto-sans-v11-latin-700.svg#NotoSans) format('svg')}@font-face{font-family:'Noto Sans';font-style:italic;font-weight:700;src:url(noto-sans-v11-latin-700italic.eot);src:local(''),url(noto-sans-v11-latin-700italic.eot?#iefix) format('embedded-opentype'),url(noto-sans-v11-latin-700italic.woff2) format('woff2'),url(noto-sans-v11-latin-700italic.woff) format('woff'),url(noto-sans-v11-latin-700italic.ttf) format('truetype'),url(noto-sans-v11-latin-700italic.svg#NotoSans) format('svg')} \ No newline at end of file diff --git a/public/viewjs/components/userfieldsform.js b/public/viewjs/components/userfieldsform.js index ee18b690..655fbca6 100644 --- a/public/viewjs/components/userfieldsform.js +++ b/public/viewjs/components/userfieldsform.js @@ -89,7 +89,7 @@ Grocy.Components.UserfieldsForm.Save = function(success, error) Grocy.Components.UserfieldsForm.Load = function() { - if (!$("#userfields-form").length) + if (!$("#userfields-form").length || typeof Grocy.EditObjectId == "undefined") { return; } diff --git a/public/viewjs/productform.js b/public/viewjs/productform.js index 87bc3c28..25de95ea 100644 --- a/public/viewjs/productform.js +++ b/public/viewjs/productform.js @@ -1,6 +1,7 @@ function saveProductPicture(result, location, jsonData) { var productId = Grocy.EditObjectId || result.created_object_id; + Grocy.EditObjectId = productId; // Grocy.EditObjectId is not yet set when adding a product Grocy.Components.UserfieldsForm.Save(() => { diff --git a/public/viewjs/recipeform.js b/public/viewjs/recipeform.js index 2bd1d569..a9a987c8 100644 --- a/public/viewjs/recipeform.js +++ b/public/viewjs/recipeform.js @@ -1,6 +1,8 @@ function saveRecipePicture(result, location, jsonData) { var recipeId = Grocy.EditObjectId || result.created_object_id; + Grocy.EditObjectId = recipeId; // Grocy.EditObjectId is not yet set when adding a recipe + Grocy.Components.UserfieldsForm.Save(() => { if (jsonData.hasOwnProperty("picture_file_name") && !Grocy.DeleteRecipePictureOnSave) diff --git a/views/layout/default.blade.php b/views/layout/default.blade.php index 7684cbcc..c3c0f225 100644 --- a/views/layout/default.blade.php +++ b/views/layout/default.blade.php @@ -71,7 +71,7 @@ rel="stylesheet"> - @@ -97,8 +97,8 @@ Grocy.FeatureFlags = {!! json_encode($featureFlags) !!}; Grocy.Webhooks = { @if(GROCY_FEATURE_FLAG_LABELPRINTER && !GROCY_LABEL_PRINTER_RUN_SERVER) - "labelprinter" : { - "hook" : "{{ GROCY_LABEL_PRINTER_WEBHOOK}}", + "labelprinter" : { + "hook" : "{{ GROCY_LABEL_PRINTER_WEBHOOK}}", "extra_data" : {!! json_encode(GROCY_LABEL_PRINTER_PARAMS) !!} } @endif diff --git a/views/stockentrylabel.blade.php b/views/stockentrylabel.blade.php index 036c198c..b0852d00 100644 --- a/views/stockentrylabel.blade.php +++ b/views/stockentrylabel.blade.php @@ -2,7 +2,7 @@
-
{{ $product->name }}
diff --git a/yarn.lock b/yarn.lock
index 7cfd0472..56e3495d 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -29,6 +29,11 @@
ndarray-linear-interpolate "^1.0.0"
snyk "^1.419.0"
+"@fontsource/noto-sans@^4.4.5":
+ version "4.4.5"
+ resolved "https://registry.yarnpkg.com/@fontsource/noto-sans/-/noto-sans-4.4.5.tgz#0053bf374f8d5222908c825aa1db6a3078a79cf6"
+ integrity sha512-1P+AMhUvjfpMwuDsLHG1F95ij1SULGM8IiW/4RmdP7+ZHJuvBsSG465Ujps34IDio5bcv6OaLpGyU1YBVTTe+Q==
+
"@fortawesome/fontawesome-free@^5.14.0":
version "5.15.1"
resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-free/-/fontawesome-free-5.15.1.tgz#ccfef6ddbe59f8fe8f694783e1d3eb88902dc5eb"