Skip to content

Commit 970ccf0

Browse files
authored
Feat/new user template (#82)
1 parent ccac268 commit 970ccf0

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

src/ansys/dynamicreporting/core/utils/report_objects.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3379,3 +3379,59 @@ def filter_numeric_step(self, value):
33793379
props = self.get_property()
33803380
props["filter_numeric_step"] = value
33813381
self.set_property(props)
3382+
3383+
3384+
class userdefinedREST(LayoutREST):
3385+
"""
3386+
Representation of the User Defined Layout Template.
3387+
3388+
This layout inserts a tagged div into the HTML output. This div can be easily found
3389+
via Javascript and can host user-supplied HTML content.
3390+
"""
3391+
3392+
@property
3393+
def interactive_only(self) -> int:
3394+
"""
3395+
"Controls if the template is rendered in 'export' situations (e.g. PDF, PPTX and
3396+
offline HTML).
3397+
3398+
If non-zero (the default), this template will not be rendered in such
3399+
situations. Note: Children are always rendered.
3400+
"""
3401+
return self.get_property().get("interactive_only")
3402+
3403+
@interactive_only.setter
3404+
def interactive_only(self, value: int) -> None:
3405+
props = self.get_property()
3406+
props["interactive_only"] = value
3407+
self.set_property(props)
3408+
3409+
@property
3410+
def before_children(self) -> int:
3411+
"""
3412+
Controls if the user-defined div is rendered before or after any children.
3413+
3414+
If zero (the default), the div comes after the children.
3415+
"""
3416+
return self.get_property().get("before_children")
3417+
3418+
@before_children.setter
3419+
def before_children(self, value: int) -> None:
3420+
props = self.get_property()
3421+
props["before_children"] = value
3422+
self.set_property(props)
3423+
3424+
@property
3425+
def userdef_name(self) -> str:
3426+
"""
3427+
The value of the adr_userdefined_template attribute on the user-defined div.
3428+
3429+
For example: <div adr_userdefined_template='userdef_name'>
3430+
"""
3431+
return self.get_property().get("userdef_name")
3432+
3433+
@userdef_name.setter
3434+
def userdef_name(self, value: str) -> None:
3435+
props = self.get_property()
3436+
props["userdef_name"] = value
3437+
self.set_property(props)

tests/test_report_objects.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1725,6 +1725,17 @@ def test_datafilter() -> bool:
17251725
assert a.filter_single_dropdown == "g"
17261726

17271727

1728+
@pytest.mark.ado_test
1729+
def test_userdefined() -> bool:
1730+
a = ro.userdefinedREST()
1731+
a.interactive_only = 1
1732+
assert a.interactive_only == 1
1733+
a.before_children = 1
1734+
assert a.before_children == 1
1735+
a.userdef_name = "Hello"
1736+
assert a.userdef_name == "Hello"
1737+
1738+
17281739
@pytest.mark.ado_test
17291740
def test_unit_template() -> bool:
17301741
a = ro.Template()

0 commit comments

Comments
 (0)