diogo.rodrigues.silva commited on
Commit
395d057
·
1 Parent(s): 8822049

Add row navigation

Browse files
Files changed (2) hide show
  1. app.py +35 -5
  2. tests/test_app.py +3 -0
app.py CHANGED
@@ -36,6 +36,26 @@ SYSTEM_PROMPT_PATH = PROMPTS_DIR / "system_prompt.txt"
36
  USER_PROMPT_TEMPLATE_PATH = PROMPTS_DIR / "user_prompt_template.json"
37
  SYSTEM_CRITERIA_PROMPT_PATH = PROMPTS_DIR / "system_criteria_prompt.txt"
38
  USER_CRITERIA_TEMPLATE_PATH = PROMPTS_DIR / "user_criteria_template.json"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
 
40
 
41
  def patch_asyncio_invalid_fd_cleanup() -> None:
@@ -1741,18 +1761,27 @@ with gr.Blocks(title="Scientific Article Screener") as demo:
1741
 
1742
  # WORKSPACE (previous middle + right, wider)
1743
  with gr.Column(scale=2):
1744
- with gr.Row():
 
 
 
 
1745
  row_number_input = gr.Number(
1746
- label="Row",
1747
  value=None,
 
 
1748
  minimum=1,
1749
  step=1,
1750
  precision=0,
1751
  interactive=True,
1752
- scale=1,
1753
- min_width=100,
 
 
 
 
 
1754
  )
1755
- row_counter = gr.Markdown("No row selected.")
1756
  go_to_row_btn = gr.Button("Go", scale=0, min_width=70)
1757
  article_url_md = gr.Markdown("")
1758
  article_details_md = gr.Markdown("")
@@ -1976,6 +2005,7 @@ if __name__ == "__main__":
1976
  auth_config = get_auth_config()
1977
  demo.launch(
1978
  auth=auth_config,
 
1979
  allowed_paths=[
1980
  str(APP_STORAGE_ROOT.resolve()),
1981
  ],
 
36
  USER_PROMPT_TEMPLATE_PATH = PROMPTS_DIR / "user_prompt_template.json"
37
  SYSTEM_CRITERIA_PROMPT_PATH = PROMPTS_DIR / "system_criteria_prompt.txt"
38
  USER_CRITERIA_TEMPLATE_PATH = PROMPTS_DIR / "user_criteria_template.json"
39
+ ROW_NAVIGATION_CSS = """
40
+ .row-navigation {
41
+ align-items: center !important;
42
+ gap: 0.5rem !important;
43
+ }
44
+ .row-navigation-label,
45
+ .row-navigation-context {
46
+ flex: 0 0 auto !important;
47
+ min-width: max-content !important;
48
+ }
49
+ .row-navigation-label p,
50
+ .row-navigation-context p {
51
+ margin: 0 !important;
52
+ }
53
+ .row-navigation-input {
54
+ flex: 0 0 4.5rem !important;
55
+ min-width: 4.5rem !important;
56
+ max-width: 4.5rem !important;
57
+ }
58
+ """
59
 
60
 
61
  def patch_asyncio_invalid_fd_cleanup() -> None:
 
1761
 
1762
  # WORKSPACE (previous middle + right, wider)
1763
  with gr.Column(scale=2):
1764
+ with gr.Row(elem_classes="row-navigation"):
1765
+ gr.Markdown(
1766
+ "**Row**",
1767
+ elem_classes="row-navigation-label",
1768
+ )
1769
  row_number_input = gr.Number(
 
1770
  value=None,
1771
+ show_label=False,
1772
+ container=False,
1773
  minimum=1,
1774
  step=1,
1775
  precision=0,
1776
  interactive=True,
1777
+ scale=0,
1778
+ min_width=70,
1779
+ elem_classes="row-navigation-input",
1780
+ )
1781
+ row_counter = gr.Markdown(
1782
+ "No row selected.",
1783
+ elem_classes="row-navigation-context",
1784
  )
 
1785
  go_to_row_btn = gr.Button("Go", scale=0, min_width=70)
1786
  article_url_md = gr.Markdown("")
1787
  article_details_md = gr.Markdown("")
 
2005
  auth_config = get_auth_config()
2006
  demo.launch(
2007
  auth=auth_config,
2008
+ css=ROW_NAVIGATION_CSS,
2009
  allowed_paths=[
2010
  str(APP_STORAGE_ROOT.resolve()),
2011
  ],
tests/test_app.py CHANGED
@@ -95,6 +95,9 @@ class ReviewFieldsTests(unittest.TestCase):
95
  self.assertTrue(app.decision_box.interactive)
96
  self.assertTrue(app.inclusion_rationale_box.interactive)
97
  self.assertTrue(all(component.interactive for component in app.extracted_inputs))
 
 
 
98
 
99
  labels = {
100
  component.get("props", {}).get("label")
 
95
  self.assertTrue(app.decision_box.interactive)
96
  self.assertTrue(app.inclusion_rationale_box.interactive)
97
  self.assertTrue(all(component.interactive for component in app.extracted_inputs))
98
+ self.assertFalse(app.row_number_input.show_label)
99
+ self.assertFalse(app.row_number_input.container)
100
+ self.assertEqual(app.row_number_input.min_width, 70)
101
 
102
  labels = {
103
  component.get("props", {}).get("label")