<!--
  ~ Copyright (C) 2023 Xibo Signage Ltd
  ~
  ~ Xibo - Digital Signage - https://xibosignage.com
  ~
  ~ This file is part of Xibo.
  ~
  ~ Xibo is free software: you can redistribute it and/or modify
  ~ it under the terms of the GNU Affero General Public License as published by
  ~ the Free Software Foundation, either version 3 of the License, or
  ~ any later version.
  ~
  ~ Xibo is distributed in the hope that it will be useful,
  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  ~ GNU Affero General Public License for more details.
  ~
  ~ You should have received a copy of the GNU Affero General Public License
  ~ along with Xibo.  If not, see <http://www.gnu.org/licenses/>.
  -->
<module>
    <id>core-menuboard-product</id>
    <name>Menu Board: Products</name>
    <author>Core</author>
    <description>Display products from a Menu Board</description>
    <icon>fas fa-hamburger</icon>
    <class>\Xibo\Widget\MenuBoardProductProvider</class>
    <dataCacheKey>%menuId%_%categoryId%_%showUnavailable%_%sortField%_%sortDescending%_%lowerLimit%_%upperLimit%_%showUnavailable%</dataCacheKey>
    <type>menuboard-product</type>
    <dataType>product</dataType>
    <showIn>layout</showIn>
    <schemaVersion>1</schemaVersion>
    <assignable>1</assignable>
    <regionSpecific>1</regionSpecific>
    <renderAs>html</renderAs>
    <defaultDuration>60</defaultDuration>
    <settings></settings>
    <properties>
        <property id="menuId" type="menuBoardSelector">
            <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>
                </test>
            </rule>
        </property>
        <property id="categoryId" type="menuBoardCategorySelector">
            <title>Category</title>
            <helpText>Please select the Category to use as a source of data for this template.</helpText>
            <dependsOn>menuId</dependsOn>
            <visibility>
                <test>
                    <condition field="menuId" type="neq"></condition>
                </test>
            </visibility>
        </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>
        </property>
        <property id="sortField" type="dropdown" mode="single">
            <title>Sort by</title>
            <helpText>How should we sort the menu items?</helpText>
            <default>displayOrder</default>
            <options>
                <option name="displayOrder">Display Order</option>
                <option name="name">Name</option>
                <option name="price">Price</option>
                <option name="id">ID</option>
            </options>
        </property>
        <property id="sortDescending" type="checkbox">
            <title>Sort descending?</title>
            <default>0</default>
        </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 type="message">
            <title>Row limits can be used to return a subset of menu items. For example if you wanted the 10th to the 20th item you could put 10 and 20.</title>
        </property>
        <property id="lowerLimit" type="number">
            <title>Lower Row Limit</title>
            <helpText>Provide a Lower Row Limit.</helpText>
            <default>0</default>
            <rule>
                <test message="Lower limit must be 0 or above">
                    <condition type="gte">0</condition>
                </test>
                <test message="Lower limit must be lower than the upper limit">
                    <condition field="upperLimit" type="lte"></condition>
                </test>
            </rule>
        </property>
        <property id="upperLimit" type="number">
            <title>Upper Row Limit</title>
            <helpText>Provide an Upper Row Limit.</helpText>
            <default>15</default>
            <rule>
                <test message="Upper limit must be 0 or above">
                    <condition type="gte">0</condition>
                </test>
                <test type="or" message="When duration is per item the upper limit must be greater than 1">
                    <condition type="gte">1</condition>
                    <condition field="durationIsPerItem" type="eq">0</condition>
                </test>
            </rule>
        </property>
    </properties>
    <preview></preview>
</module>
