2016-06-10 15:38:55 -04:00
|
|
|
<?xml version="1.0"?>
|
|
|
|
<!--
|
2021-07-22 15:00:15 -04:00
|
|
|
Copyright (C) 2014-2021 Ryan Specialty Group, LLC.
|
2016-06-10 15:38:55 -04:00
|
|
|
|
|
|
|
This file is part of tame-core.
|
|
|
|
|
|
|
|
tame-core is free software: you can redistribute it and/or modify it
|
2018-01-26 11:13:33 -05:00
|
|
|
under the terms of the GNU General Public License as
|
2016-06-10 15:38:55 -04:00
|
|
|
published by the Free Software Foundation, either version 3 of the
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program 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 General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
-->
|
|
|
|
<package xmlns="http://www.lovullo.com/rater"
|
|
|
|
xmlns:c="http://www.lovullo.com/calc"
|
|
|
|
xmlns:t="http://www.lovullo.com/rater/apply-template"
|
|
|
|
title="UI Integration">
|
|
|
|
|
|
|
|
<import package="base" />
|
|
|
|
|
|
|
|
<!-- contains template dependencies -->
|
2019-11-27 09:17:04 -05:00
|
|
|
<import package="vector/cmatch" export="true" />
|
2016-06-10 15:38:55 -04:00
|
|
|
|
|
|
|
|
|
|
|
This package provides elementary integration with the UI through
|
|
|
|
mystical knowledge of the naming conventions that the compiler uses
|
|
|
|
when generating the UI package.
|
|
|
|
|
|
|
|
You should \emph{never} reference generated values yourself without
|
|
|
|
an abstraction.
|
|
|
|
|
|
|
|
|
|
|
|
<section title="Applicability">
|
|
|
|
An object in the UI is considered to be \dfn{applicable} if the
|
|
|
|
predicate defined by its {\tt @when} attribute matches. These
|
|
|
|
predicates are generated, and should not be referenced directly;
|
|
|
|
instead, \ref{_match-ui-applicable_} should be used with the
|
|
|
|
question id.
|
|
|
|
|
|
|
|
The term ``applicable'' is used instead of ``visible'' because
|
|
|
|
object can be hidden by other means; a predicate might be true
|
|
|
|
while a field is actually hidden. Further, a non-matching
|
|
|
|
predicate inhibits other behavior, like running of assertions.
|
|
|
|
|
|
|
|
Note that this template will only be useful with an object
|
|
|
|
(question, display, static, etc) that has a predicate defined;
|
|
|
|
otherwise, compilation will fail.
|
|
|
|
|
|
|
|
<template name="_match-ui-applicable_"
|
|
|
|
desc="Match whether a UI question is visible">
|
|
|
|
<param name="@on@" desc="Question id" />
|
|
|
|
|
|
|
|
<param name="@value@" desc="Value to match">
|
|
|
|
<text>TRUE</text>
|
|
|
|
</param>
|
|
|
|
|
|
|
|
<param name="@__vis_class@" desc="Generated visibility class name">
|
|
|
|
<text>--vis-</text>
|
|
|
|
<param-value name="@on@" dash="true" />
|
|
|
|
</param>
|
|
|
|
|
|
|
|
|
|
|
|
<t:match-class name="@__vis_class@" value="@value@" />
|
|
|
|
</template>
|
2018-02-22 14:02:10 -05:00
|
|
|
|
|
|
|
|
|
|
|
\ref{_match-ui-set_} determines whether a UI field has a truthful value,
|
|
|
|
which is non-empty and non-zero.
|
|
|
|
|
|
|
|
<template name="_match-ui-set_"
|
|
|
|
desc="Match whether a UI question is set">
|
|
|
|
<param name="@on@" desc="Question id" />
|
|
|
|
|
|
|
|
<param name="@value@" desc="Whether set">
|
|
|
|
<text>TRUE</text>
|
|
|
|
</param>
|
|
|
|
|
|
|
|
<param name="@__set_class@" desc="Generated set class name">
|
|
|
|
<text>--set-</text>
|
|
|
|
<param-value name="@on@" dash="true" />
|
|
|
|
</param>
|
|
|
|
|
|
|
|
|
2019-07-30 14:35:04 -04:00
|
|
|
<all>
|
|
|
|
<t:match-ui-applicable on="@on@" />
|
|
|
|
<t:match-class name="@__set_class@" value="@value@" />
|
|
|
|
</all>
|
2018-02-22 14:02:10 -05:00
|
|
|
</template>
|
2019-08-13 16:45:16 -04:00
|
|
|
|
|
|
|
|
|
|
|
The templates below are analogous to the generic match templates,
|
|
|
|
but they translate \tt{@on@} to the question param
|
|
|
|
and also check that the question is applicable (using
|
|
|
|
\ref{_match-ui-applicable_}).
|
|
|
|
|
|
|
|
<inline-template>
|
|
|
|
<for-each>
|
|
|
|
<set cmp="eq" />
|
|
|
|
<set cmp="ne" />
|
|
|
|
<set cmp="gt" />
|
|
|
|
<set cmp="gte" />
|
|
|
|
<set cmp="lt" />
|
|
|
|
<set cmp="lte" />
|
|
|
|
</for-each>
|
|
|
|
|
|
|
|
<template name="_match-ui-{@cmp@}_"
|
|
|
|
desc="Match UI value {@cmp@}">
|
|
|
|
<param name="@on@" desc="Question id" />
|
|
|
|
|
|
|
|
<!-- pick one -->
|
|
|
|
<param name="@value@" desc="Match against variable" />
|
|
|
|
|
|
|
|
<all>
|
|
|
|
<t:match-ui-applicable on="@on@" />
|
|
|
|
|
|
|
|
<match on="ui_q_{@on@}">
|
|
|
|
<dyn-node name="c:{@cmp@}">
|
|
|
|
<c:value-of name="@value@" />
|
|
|
|
</dyn-node>
|
|
|
|
</match>
|
|
|
|
</all>
|
|
|
|
</template>
|
2020-01-29 13:51:57 -05:00
|
|
|
|
|
|
|
<template name="_match-extern-ui-{@cmp@}_"
|
|
|
|
desc="Match UI value {@cmp@} - using externs">
|
|
|
|
<param name="@on@" desc="Question id" />
|
|
|
|
<param name="@value@" desc="Match against variable" />
|
|
|
|
|
|
|
|
<param name="@__yields@" desc="Generated visibility yields name">
|
|
|
|
<text>__isvis</text>
|
|
|
|
<param-value name="@on@" rmunderscore="true" lower="true" />
|
|
|
|
</param>
|
|
|
|
|
2020-03-25 15:36:55 -04:00
|
|
|
<!-- TODO: this default is transitionary, since there's no
|
|
|
|
meaningful default -->
|
|
|
|
<param name="@vis-dim@" desc="Classification dimensions (default 2)">
|
|
|
|
<text>2</text>
|
|
|
|
</param>
|
|
|
|
|
2020-01-29 13:51:57 -05:00
|
|
|
<extern name="ui_q_{@on@}" type="param" dtype="integer" dim="1" />
|
2020-03-25 15:36:55 -04:00
|
|
|
<extern name="@__yields@" type="cgen" dtype="boolean" dim="@vis-dim@" />
|
2020-01-29 13:51:57 -05:00
|
|
|
|
|
|
|
<all>
|
|
|
|
<match on="@__yields@" />
|
|
|
|
|
|
|
|
<match on="ui_q_{@on@}">
|
|
|
|
<dyn-node name="c:{@cmp@}">
|
|
|
|
<c:value-of name="@value@" />
|
|
|
|
</dyn-node>
|
|
|
|
</match>
|
|
|
|
</all>
|
|
|
|
</template>
|
2019-08-13 16:45:16 -04:00
|
|
|
</inline-template>
|
2016-06-10 15:38:55 -04:00
|
|
|
</section>
|
|
|
|
</package>
|
2020-01-29 13:51:57 -05:00
|
|
|
|