From 970ccf08ba1dc212d38f6d10c528a63fe8376983 Mon Sep 17 00:00:00 2001 From: Randy Frank <89219420+randallfrank@users.noreply.github.com> Date: Thu, 28 Dec 2023 13:58:00 -0500 Subject: [PATCH] Feat/new user template (#82) --- .../core/utils/report_objects.py | 56 +++++++++++++++++++ tests/test_report_objects.py | 11 ++++ 2 files changed, 67 insertions(+) diff --git a/src/ansys/dynamicreporting/core/utils/report_objects.py b/src/ansys/dynamicreporting/core/utils/report_objects.py index cbbd3dae..84f47086 100644 --- a/src/ansys/dynamicreporting/core/utils/report_objects.py +++ b/src/ansys/dynamicreporting/core/utils/report_objects.py @@ -3379,3 +3379,59 @@ def filter_numeric_step(self, value): props = self.get_property() props["filter_numeric_step"] = value self.set_property(props) + + +class userdefinedREST(LayoutREST): + """ + Representation of the User Defined Layout Template. + + This layout inserts a tagged div into the HTML output. This div can be easily found + via Javascript and can host user-supplied HTML content. + """ + + @property + def interactive_only(self) -> int: + """ + "Controls if the template is rendered in 'export' situations (e.g. PDF, PPTX and + offline HTML). + + If non-zero (the default), this template will not be rendered in such + situations. Note: Children are always rendered. + """ + return self.get_property().get("interactive_only") + + @interactive_only.setter + def interactive_only(self, value: int) -> None: + props = self.get_property() + props["interactive_only"] = value + self.set_property(props) + + @property + def before_children(self) -> int: + """ + Controls if the user-defined div is rendered before or after any children. + + If zero (the default), the div comes after the children. + """ + return self.get_property().get("before_children") + + @before_children.setter + def before_children(self, value: int) -> None: + props = self.get_property() + props["before_children"] = value + self.set_property(props) + + @property + def userdef_name(self) -> str: + """ + The value of the adr_userdefined_template attribute on the user-defined div. + + For example:
+ """ + return self.get_property().get("userdef_name") + + @userdef_name.setter + def userdef_name(self, value: str) -> None: + props = self.get_property() + props["userdef_name"] = value + self.set_property(props) diff --git a/tests/test_report_objects.py b/tests/test_report_objects.py index 2710b553..f61fa17c 100755 --- a/tests/test_report_objects.py +++ b/tests/test_report_objects.py @@ -1725,6 +1725,17 @@ def test_datafilter() -> bool: assert a.filter_single_dropdown == "g" +@pytest.mark.ado_test +def test_userdefined() -> bool: + a = ro.userdefinedREST() + a.interactive_only = 1 + assert a.interactive_only == 1 + a.before_children = 1 + assert a.before_children == 1 + a.userdef_name = "Hello" + assert a.userdef_name == "Hello" + + @pytest.mark.ado_test def test_unit_template() -> bool: a = ro.Template()