Skip to content

Commit

Permalink
Review
Browse files Browse the repository at this point in the history
- "grocy" is currently written lower-case everywhere, so let's do this also for "grocycode"
- Unified phrases / capitalization
- Minor UI adjustments (mainly context menu item ordering / ordering/spacing on product edit page)
- Documented API changes for Swagger UI (grocy.openapi.json)
- Reverted German localizations (those are managed via Transifex; would cause conflicts when manually edited - will import them later there)
- Reverted a somehow messed up localization string (productform/help text for `cumulate_min_stock_amount_of_sub_products`)
- Suppress deprecation warnings when generating Datamatrix PNG (otherwise the PNG is invalid, jucksearm/php-barcode#3)
- Default `FEATURE_FLAG_LABELPRINTER` to disabled
  • Loading branch information
Bernd Bestel committed Jun 12, 2021
1 parent f915c76 commit 7a70311
Show file tree
Hide file tree
Showing 12 changed files with 199 additions and 169 deletions.
2 changes: 1 addition & 1 deletion config-dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
Setting('FEATURE_FLAG_BATTERIES', true);
Setting('FEATURE_FLAG_EQUIPMENT', true);
Setting('FEATURE_FLAG_CALENDAR', true);
Setting('FEATURE_FLAG_LABELPRINTER', true);
Setting('FEATURE_FLAG_LABELPRINTER', false);

// Sub feature flags
Setting('FEATURE_FLAG_STOCK_PRICE_TRACKING', true);
Expand Down
4 changes: 2 additions & 2 deletions controllers/StockApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ public function ProductPrintLabel(\Psr\Http\Message\ServerRequestInterface $requ
(new WebhookRunner())->run(GROCY_LABEL_PRINTER_WEBHOOK, $webhookData, GROCY_LABEL_PRINTER_HOOK_JSON);
}

return $this->ApiResponse($response, $webhookData);
return $this->EmptyApiResponse($response);
}

public function StockEntryPrintLabel(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
Expand All @@ -649,7 +649,7 @@ public function StockEntryPrintLabel(\Psr\Http\Message\ServerRequestInterface $r
(new WebhookRunner())->run(GROCY_LABEL_PRINTER_WEBHOOK, $webhookData, GROCY_LABEL_PRINTER_HOOK_JSON);
}

return $this->ApiResponse($response, $webhookData);
return $this->EmptyApiResponse($response);
}

public function RemoveProductFromShoppingList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
Expand Down
11 changes: 9 additions & 2 deletions controllers/StockController.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,14 @@ public function ProductEditForm(\Psr\Http\Message\ServerRequestInterface $reques

public function ProductGrocycodeImage(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$size = $request->getQueryParam('size', null);
$product = $this->getDatabase()->products($args['productId']);

$gc = new Grocycode(Grocycode::PRODUCT, $product->id);
$png = (new DatamatrixFactory())->setCode((string) $gc)->getDatamatrixPngData();

// Explicitly suppress errors, otherwise deprecations warnings would cause invalid PNG data
// See also https://github.com/jucksearm/php-barcode/issues/3
$png = @(new DatamatrixFactory())->setCode((string) $gc)->setSize($size)->getDatamatrixPngData();

$isDownload = $request->getQueryParam('download', false);

Expand Down Expand Up @@ -464,7 +468,10 @@ public function StockEntryGrocycodeImage(\Psr\Http\Message\ServerRequestInterfac

$stockEntry = $this->getDatabase()->stock()->where('id', $args['entryId'])->fetch();
$gc = new Grocycode(Grocycode::PRODUCT, $stockEntry->product_id, [$stockEntry->stock_id]);
$png = (new DatamatrixFactory())->setCode((string) $gc)->setSize($size)->getDatamatrixPngData();

// Explicitly suppress errors, otherwise deprecations warnings would cause invalid PNG data
// See also https://github.com/jucksearm/php-barcode/issues/3
$png = @(new DatamatrixFactory())->setCode((string) $gc)->setSize($size)->getDatamatrixPngData();

$isDownload = $request->getQueryParam('download', false);

Expand Down
18 changes: 9 additions & 9 deletions docs/grocycode.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Grocycode
grocycode
==========

Grocycode is, in essence, a simple way to reference to arbitrary grocy entities.
grocycode is, in essence, a simple way to reference to arbitrary grocy entities.
Each grocycode includes a magic, an entitiy identifier, an id and an ordered set of extra data.
It is supported to be entered anywhere grocy expects one to read a barcode, but can also reference
grocy-internal properties like specific stock entries, or specific batteries.
Expand Down Expand Up @@ -33,22 +33,22 @@ Example

In this example, we encode a *Product* with ID *13*, which results in `grcy:p:13` when serialized.

Product Grocycodes
Product grocycodes
----

Product Grocycodes extend the data format to include an optional stock id, thus may reference a specific stock entry directly.
Product grocycodes extend the data format to include an optional stock id, thus may reference a specific stock entry directly.

Example: `grcy:p:13:60bf8b5244b04`

Battery Grocycodes
Battery grocycodes
----

Currently, Battery Grocycodes do not define any extra fields.
Currently, Battery grocycodes do not define any extra fields.

Chore Grocycodes
Chore grocycodes
----

Currently, Chore Grocycodes do not define any extra fields.
Currently, Chore grocycodes do not define any extra fields.

Visual Encoding
----
Expand All @@ -63,4 +63,4 @@ so that the double colons get entered correctly.

Notes
---
[0]: Obviously, it needs to be encoded into some usable visual representation and then read. So probably you only want to encode stuff that can be typed on a keyboard.
[0]: Obviously, it needs to be encoded into some usable visual representation and then read. So probably you only want to encode stuff that can be typed on a keyboard.
76 changes: 74 additions & 2 deletions grocy.openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1402,7 +1402,7 @@
"in": "path",
"name": "entryId",
"required": true,
"description": "A valid stock row id",
"description": "A valid stock entry id",
"schema": {
"type": "integer"
}
Expand Down Expand Up @@ -1441,7 +1441,7 @@
"in": "path",
"name": "entryId",
"required": true,
"description": "A valid stock row id",
"description": "A valid stock entry id",
"schema": {
"type": "integer"
}
Expand Down Expand Up @@ -1529,6 +1529,40 @@
}
}
},
"/stock/entry/{entryId}/printlabel": {
"get": {
"summary": "Prints the label of the given stock entry",
"tags": [
"Stock"
],
"parameters": [
{
"in": "path",
"name": "entryId",
"required": true,
"description": "A valid stock entry id",
"schema": {
"type": "integer"
}
}
],
"responses": {
"204": {
"description": "The operation was successful"
},
"400": {
"description": "The operation was not successful (possible errors are: Not existing stock entry, error on WebHook execution)",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error400"
}
}
}
}
}
}
},
"/stock/volatile": {
"get": {
"summary": "Returns all products which are due soon, overdue, expired or currently missing",
Expand Down Expand Up @@ -1850,6 +1884,10 @@
"type": "number",
"format": "integer",
"description": "If omitted, no store will be affected"
},
"print_stock_label": {
"type": "boolean",
"description": "True when the stock entry label should be printed"
}
},
"example": {
Expand Down Expand Up @@ -2213,6 +2251,40 @@
}
}
},
"/stock/products/{productId}/printlabel": {
"get": {
"summary": "Prints the product label of the given product",
"tags": [
"Stock"
],
"parameters": [
{
"in": "path",
"name": "productId",
"required": true,
"description": "A valid product id",
"schema": {
"type": "integer"
}
}
],
"responses": {
"204": {
"description": "The operation was successful"
},
"400": {
"description": "The operation was not successful (possible errors are: Not existing product, error on WebHook execution)",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error400"
}
}
}
}
}
}
},
"/stock/products/{productIdToKeep}/merge/{productIdToRemove}": {
"post": {
"summary": "Merges two products into one",
Expand Down
48 changes: 0 additions & 48 deletions localization/de/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -2374,51 +2374,3 @@ msgstr "Druckoptionen"

msgid "A product or a note is required"
msgstr "Ein Produkt oder eine Notiz ist erforderlich"

msgid "Grocycode"
msgstr "Grocycode"

msgid "Download"
msgstr "Herunterladen"

msgid "Download stock entry grocycode"
msgstr "Bestandseingrags-Grocycode herunterladen"

msgid "Download product grocycode"
msgstr "Produkt-Grocycode herunterladen"

msgid "Grocycode is a unique referer to this product in your grocy instance. Print it onto a label and scan it like any other barcode!"
msgstr "Grocycode ist eine eindeutige Referenz zu diesem Produkt in dieser Grocy-Instanz. Ausgedruckt kann es wie jeder andere Barcode gescannt werden!"

msgid "Open print label in new Window"
msgstr "Druck-Label in neuem Fenster öffnen"

msgid "DD"
msgstr "MHD"

msgid "Print stock label"
msgstr "Etikett drucken"

msgid "Print Product Label"
msgstr "Produkt-Etikett drucken"

msgid "Print stock entry label"
msgstr "Etikett drucken"

msgid "Stock label"
msgstr "Etikett"

msgid "No Label"
msgstr "Kein Etikett"

msgid "Single Label"
msgstr "Ein Etikett pro Einkauf"

msgid "Label per Unit"
msgstr "Ein Etikett pro Mengeneinheit"

msgid "Allow label printing per unit"
msgstr "Erlaube Etikettendruck pro Mengeneinheit"

msgid "Allow printing of one label per unit in a purchase (after conversion). E.g. 1 purchased pack adding 10 pieces of stock would print 10 labels."
msgstr "Erlaube Etikettendruck pro Mengeneinheit nach Umrechnung. Beispiel: 1 gekauftes Paket, das 10 Einheiten hinzufügt, druckt 10 Etiketten."
34 changes: 15 additions & 19 deletions localization/strings.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2078,7 +2078,7 @@ msgstr ""
msgid "A product or a note is required"
msgstr ""

msgid "Grocycode"
msgid "grocycode"
msgstr ""

msgid "Download"
Expand All @@ -2090,46 +2090,42 @@ msgstr ""
msgid "Download product grocycode"
msgstr ""

msgid ""
"If enabled, the min. stock amount of sub products will be accumulated into this product, means the sub product will never be \"\n"
"\t\t\t\t\t\t\tmissing\",\n"
"\t\t\t\t\t\t\tonly\n"
"\t\t\t\t\t\t\tthis\n"
"\t\t\t\t\t\t\tproduct"
msgid "grocycode is a unique referer to this product in your grocy instance - print it onto a label and scan it like any other barcode"
msgstr ""

msgid "Grocycode is a unique referer to this product in your grocy instance. Print it onto a label and scan it like any other barcode!"
# Abbreviation for "due date"
msgid "DD"
msgstr ""

msgid "Open print label in new Window"
msgid "Print on label printer"
msgstr ""

msgid "DD"
msgid "Stock entry label"
msgstr ""

msgid "Print stock label"
msgid "No label"
msgstr ""

msgid "Print Product Label"
msgid "Single label"
msgstr ""

msgid "Print stock entry label"
msgid "Label per unit"
msgstr ""

msgid "Stock label"
msgid "Allow label printing per unit"
msgstr ""

msgid "No Label"
msgid "Allow printing of one label per unit on purchase (after conversion) - e.g. 1 purchased pack adding 10 pieces of stock would print 10 labels"
msgstr ""

msgid "Single Label"
msgid "Error while executing WebHook"
msgstr ""

msgid "Label per Unit"
msgid "Print product grocycode on label printer"
msgstr ""

msgid "Allow label printing per unit"
msgid "Print stock entry grocycode on label printer"
msgstr ""

msgid "Allow printing of one label per unit in a purchase (after conversion). E.g. 1 purchased pack adding 10 pieces of stock would print 10 labels."
msgid "Open stock entry print label in new window"
msgstr ""
2 changes: 1 addition & 1 deletion public/js/grocy.js
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ Grocy.FrontendHelpers.RunWebhook = function(webhook, data, repetitions = 1)
if (!hasAlreadyFailed)
{
hasAlreadyFailed = true;
Grocy.FrontendHelpers.ShowGenericError(__t("Unable to connect to webhook.", { "status": status, "errorThrown": errorThrown }));
Grocy.FrontendHelpers.ShowGenericError(__t("Error while executing WebHook", { "status": status, "errorThrown": errorThrown }));
}
});
}
Expand Down
Loading

0 comments on commit 7a70311

Please sign in to comment.