Skip to content

Commit

Permalink
Feat/new user template (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
randallfrank authored Dec 28, 2023
1 parent ccac268 commit 970ccf0
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
56 changes: 56 additions & 0 deletions src/ansys/dynamicreporting/core/utils/report_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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: <div adr_userdefined_template='userdef_name'>
"""
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)
11 changes: 11 additions & 0 deletions tests/test_report_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 970ccf0

Please sign in to comment.