Only show thermal print button when Feature Flag is set

This commit is contained in:
Marc Ole Bulling 2021-01-15 11:12:30 +01:00
parent c58620f898
commit 8e0b995808
No known key found for this signature in database
GPG Key ID: C126AFC2A47B06FF
2 changed files with 78 additions and 72 deletions

View File

@ -428,13 +428,7 @@ $(document).on("click", "#print-shopping-list-button", function(e)
</label> \
</div>';
bootbox.dialog({
message: dialogHtml,
size: 'medium',
backdrop: true,
closeButton: false,
className: "d-print-none",
buttons: {
var printButtons = {
cancel: {
label: __t('Cancel'),
className: 'btn-secondary',
@ -494,6 +488,19 @@ $(document).on("click", "#print-shopping-list-button", function(e)
}
}
}
if (!Grocy.FeatureFlags["GROCY_FEATURE_FLAG_THERMAL_PRINTER"])
{
delete printButtons['printtp'];
}
bootbox.dialog({
message: dialogHtml,
size: 'medium',
backdrop: true,
closeButton: false,
className: "d-print-none",
buttons: printButtons
});
});

View File

@ -14,8 +14,8 @@ class PrintService extends BaseService
/**
* Initialises the printer
* @return Printer handle
* @throws Exception if unable to connect to printer
* @return Printer Printer handle
* @throws Exception If unable to connect to printer, an exception is thrown
*/
private static function getPrinterHandle()
{
@ -29,8 +29,8 @@ class PrintService extends BaseService
/**
* Prints a grocy logo
* @param $printer
* Prints the grocy logo and date
* @param Printer $printer Printer handle
*/
private static function printHeader(Printer $printer)
{
@ -48,17 +48,16 @@ class PrintService extends BaseService
$printer->feed(2);
$printer->text($dateFormatted);
$printer->selectPrintMode();
$printer->feed(3);
$printer->feed(2);
}
/**
* @param bool $printHeader Printing of Grocy logo
* @param string[] $items Items to print
* @return string[]
* @throws Exception
* @param string[] $lines Items to print
* @return string[] Returns array with result OK if no exception
* @throws Exception If unable to print, an exception is thrown
*/
public function printShoppingList(bool $printHeader, array $items): array
public function printShoppingList(bool $printHeader, array $lines): array
{
$printer = self::getPrinterHandle();
if ($printer === false)
@ -69,9 +68,9 @@ class PrintService extends BaseService
self::printHeader($printer);
}
foreach ($items as $item)
foreach ($lines as $line)
{
$printer->text($item);
$printer->text($line);
$printer->feed();
}