Skip to content

Commit

Permalink
Menu Boards:
Browse files Browse the repository at this point in the history
 - add some rules
 - add "show unavailable" filter
  • Loading branch information
dasgarner committed Jul 27, 2023
1 parent aac8416 commit b9ad3f4
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 3 deletions.
12 changes: 11 additions & 1 deletion lib/Listener/MenuBoardProviderListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,17 @@ public function onProductRequest(MenuBoardProductRequest $event): void
return;
}

$products = $this->menuBoardCategoryFactory->getProductData(null, ['menuId' => $menuId]);
// Build a filter
$filter = [
'menuId' => $menuId,
];

// Show Unavailable?
if ($dataProvider->getProperty('showUnavailable', 0) === 0) {
$filter['availability'] = 0;
}

$products = $this->menuBoardCategoryFactory->getProductData(['name'], $filter);

foreach ($products as $menuBoardProduct) {
$product = $menuBoardProduct->toProduct();
Expand Down
11 changes: 11 additions & 0 deletions modules/menuboard-category.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,21 @@
<property id="menuId" type="number">
<title>Menu</title>
<helpText>Please select the Menu to use as a source of data for this template.</helpText>
<rule>
<test type="and">
<condition type="required"></condition>
<condition type="uri"></condition>
</test>
</rule>
</property>
<property id="categoryId" type="number">
<title>Category</title>
<helpText>Please select the Category to use as a source of data for this template.</helpText>
<visibility>
<test>
<condition field="menuId" type="neq"></condition>
</test>
</visibility>
</property>
</properties>
<preview></preview>
Expand Down
28 changes: 26 additions & 2 deletions modules/menuboard-product.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<author>Core</author>
<description>Display products from a Menu Board</description>
<class>\Xibo\Widget\MenuBoardProductProvider</class>
<dataCacheKey>%menuId%</dataCacheKey>
<dataCacheKey>%menuId%_%showUnavailable%</dataCacheKey>
<type>menuboard-product</type>
<dataType>product</dataType>
<schemaVersion>1</schemaVersion>
Expand All @@ -38,6 +38,30 @@
<title>Menu</title>
<helpText>Please select the Menu to use as a source of data for this template.</helpText>
</property>
<property id="categoryId" type="number">
<title>Category</title>
<helpText>Filter by Category</helpText>
<visibility>
<test>
<condition field="menuId" type="neq"></condition>
</test>
</visibility>
</property>
<property id="showUnavailable" type="checkbox">
<title>Show Unavailable Products?</title>
<helpText>Should the currently unavailable products appear in the menu?</helpText>
<default>0</default>
</property>
<property id="durationIsPerItem" type="checkbox">
<title>Duration is per item</title>
<helpText>The duration specified is per item otherwise it is per menu.</helpText>
<default>0</default>
<visibility>
<test>
<condition field="dataSetId" type="neq"></condition>
</test>
</visibility>
</property>
</properties>
<preview></preview>
</module>
</module>

0 comments on commit b9ad3f4

Please sign in to comment.