Skip to content

feat: Add reuse for multiple dialog #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions viur/scriptor/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ async def _wait_for_result():
while manager.resultValue is None:
await manager.sleep(250)
res = manager.resultValue
if res == "__exit__":
import sys
sys.exit(0)
manager.reset()
manager.resultValue = None
return res
Expand Down
10 changes: 7 additions & 3 deletions viur/scriptor/dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,17 +643,21 @@ async def table(header: list[str], rows: list[list[str]], select: bool = None, m

if is_pyodide_context():
@staticmethod
async def multiple(title: str, components: list):
async def multiple(title: str, components: list, reuse: bool = False):
"""
:param title: the header of the component
:param components: list of components
:param reuse: If True, the components are not sent to the JS.
"""
msg = {
"type": "multiple-dialog",
"title": title,
"components": json.dumps(components)
}
js.self.postMessage(**msg)


if not reuse:
js.self.postMessage(**msg)
res = await _wait_for_result()
if isinstance(res,str):
return json.loads(res)
Expand All @@ -662,5 +666,5 @@ async def multiple(title: str, components: list):

else:
@staticmethod
async def multiple(title: str, components: list):
async def multiple(title: str, components: list, reuse: bool = False):
return components