diff --git a/.github/actions/deploy/appinfo/info.xml.dist b/.github/actions/deploy/appinfo/info.xml.dist
index f6a4c23c7..9d63263d7 100755
--- a/.github/actions/deploy/appinfo/info.xml.dist
+++ b/.github/actions/deploy/appinfo/info.xml.dist
@@ -20,7 +20,7 @@
https://raw.githubusercontent.com/nextcloud/cookbook/stable/img/screenshot2.png
-
+
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 229cff746..946599859 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
## [Unreleased]
+### Changed
+- Make info block visibility configurable
+ [1404](https://github.com/nextcloud/cookbook/pull/1404) @MarcelRobitaille
+
### Fixed
- Make "None" category string translatable
[#1323](https://github.com/nextcloud/cookbook/pull/1344) @seyfeb
diff --git a/appinfo/info.xml b/appinfo/info.xml
index c55368d0a..e1e347ed8 100644
--- a/appinfo/info.xml
+++ b/appinfo/info.xml
@@ -20,7 +20,7 @@
https://raw.githubusercontent.com/nextcloud/cookbook/stable/img/screenshot2.png
-
+
diff --git a/lib/Controller/Implementation/ConfigImplementation.php b/lib/Controller/Implementation/ConfigImplementation.php
index 25dbb1cf1..d9da0b617 100644
--- a/lib/Controller/Implementation/ConfigImplementation.php
+++ b/lib/Controller/Implementation/ConfigImplementation.php
@@ -31,6 +31,8 @@ public function __construct(
$this->userFolder = $userFolder;
}
+ protected const KEY_VISIBLE_INFO_BLOCKS = 'visibleInfoBlocks';
+
/**
* Get the current configuration of the app
*
@@ -43,6 +45,7 @@ public function list() {
'folder' => $this->userFolder->getPath(),
'update_interval' => $this->dbCacheService->getSearchIndexUpdateInterval(),
'print_image' => $this->service->getPrintImage(),
+ self::KEY_VISIBLE_INFO_BLOCKS => $this->service->getVisibleInfoBlocks(),
], Http::STATUS_OK);
}
@@ -72,6 +75,10 @@ public function config() {
$this->service->setPrintImage((bool)$data['print_image']);
}
+ if (isset($data[self::KEY_VISIBLE_INFO_BLOCKS])) {
+ $this->service->setVisibleInfoBlocks($data[self::KEY_VISIBLE_INFO_BLOCKS]);
+ }
+
$this->dbCacheService->triggerCheck();
return new JSONResponse('OK', Http::STATUS_OK);
diff --git a/lib/Helper/UserConfigHelper.php b/lib/Helper/UserConfigHelper.php
index 980b1b0c7..860bff502 100644
--- a/lib/Helper/UserConfigHelper.php
+++ b/lib/Helper/UserConfigHelper.php
@@ -39,6 +39,7 @@ public function __construct(
protected const KEY_LAST_INDEX_UPDATE = 'last_index_update';
protected const KEY_UPDATE_INTERVAL = 'update_interval';
protected const KEY_PRINT_IMAGE = 'print_image';
+ protected const KEY_VISIBLE_INFO_BLOCKS = 'visible_info_blocks';
protected const KEY_FOLDER = 'folder';
/**
@@ -154,6 +155,38 @@ public function setPrintImage(bool $value): void {
}
}
+ /**
+ * Determines which info blocks are displayed next to the recipe
+ *
+ * @return array keys: info block ids, values: display state
+ * @throws UserNotLoggedInException if no user is logged in
+ */
+ public function getVisibleInfoBlocks(): array {
+ $rawValue = $this->getRawValue(self::KEY_VISIBLE_INFO_BLOCKS);
+
+ if ($rawValue === '') {
+ return [
+ 'preparation-time' => true,
+ 'cooking-time' => true,
+ 'total-time' => true,
+ 'nutrition-information' => true,
+ 'tools' => true,
+ ];
+ }
+
+ return json_decode($rawValue, true);
+ }
+
+ /**
+ * Sets which info blocks are displayed next to the recipe
+ *
+ * @param array keys: info block ids, values: display state
+ * @throws UserNotLoggedInException if no user is logged in
+ */
+ public function setVisibleInfoBlocks(array $visibleInfoBlocks): void {
+ $this->setRawValue(self::KEY_VISIBLE_INFO_BLOCKS, json_encode($visibleInfoBlocks));
+ }
+
/**
* Get the name of the default cookbook.
*
diff --git a/lib/Service/RecipeService.php b/lib/Service/RecipeService.php
index d4020bb56..0ec4c44c9 100755
--- a/lib/Service/RecipeService.php
+++ b/lib/Service/RecipeService.php
@@ -515,6 +515,22 @@ public function getPrintImage() {
return $this->userConfigHelper->getPrintImage();
}
+ /**
+ * Sets which info blocks are displayed next to the recipe
+ * @param array keys: info block ids, values: display state
+ */
+ public function setVisibleInfoBlocks(array $visibleInfoBlocks) {
+ $this->userConfigHelper->setVisibleInfoBlocks($visibleInfoBlocks);
+ }
+
+ /**
+ * Determines which info blocks are displayed next to the recipe
+ * @return array keys: info block ids, values: display state
+ */
+ public function getVisibleInfoBlocks(): array {
+ return $this->userConfigHelper->getVisibleInfoBlocks();
+ }
+
/**
* Get recipe file contents as an array
*
diff --git a/src/components/RecipeView.vue b/src/components/RecipeView.vue
index 2b24a7ff9..b3537ecd5 100644
--- a/src/components/RecipeView.vue
+++ b/src/components/RecipeView.vue
@@ -70,19 +70,27 @@