bluenevus commited on
Commit
9be275e
·
verified ·
1 Parent(s): 7d72a43

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -64,13 +64,16 @@ app.layout = dbc.Container([
64
  def update_output(contents, filename):
65
  if contents is not None:
66
  logger.info(f"PDF uploaded: {filename}")
67
- initial_range = dbc.Row([
68
- dbc.Col(dbc.Input(id={'type': 'range-input', 'index': 0}, type='text', placeholder='Enter page range (e.g., 1-3)'), width=10),
69
- dbc.Col(dbc.Button("Remove", id={'type': 'remove-range', 'index': 0}, color="danger", size="sm"), width=2),
70
- ], className="mb-2")
71
  return html.Div(f"Uploaded: {filename}"), False, [initial_range]
72
  return "", True, []
73
 
 
 
 
 
 
 
74
  @callback(
75
  Output('ranges-container', 'children', allow_duplicate=True),
76
  Input('add-range', 'n_clicks'),
@@ -80,10 +83,7 @@ def update_output(contents, filename):
80
  def add_range(n_clicks, existing_ranges):
81
  if n_clicks:
82
  new_index = len(existing_ranges)
83
- new_range = dbc.Row([
84
- dbc.Col(dbc.Input(id={'type': 'range-input', 'index': new_index}, type='text', placeholder='Enter page range (e.g., 1-3)'), width=10),
85
- dbc.Col(dbc.Button("Remove", id={'type': 'remove-range', 'index': new_index}, color="danger", size="sm"), width=2),
86
- ], className="mb-2")
87
  existing_ranges.append(new_range)
88
  return existing_ranges
89
 
 
64
  def update_output(contents, filename):
65
  if contents is not None:
66
  logger.info(f"PDF uploaded: {filename}")
67
+ initial_range = create_range_input(0)
 
 
 
68
  return html.Div(f"Uploaded: {filename}"), False, [initial_range]
69
  return "", True, []
70
 
71
+ def create_range_input(index):
72
+ return dbc.Row([
73
+ dbc.Col(dbc.Input(id={'type': 'range-input', 'index': index}, type='text', placeholder='Enter page range (e.g., 1-3)'), width=10),
74
+ dbc.Col(dbc.Button("Remove", id={'type': 'remove-range', 'index': index}, color="danger", size="sm"), width=2),
75
+ ], className="mb-2")
76
+
77
  @callback(
78
  Output('ranges-container', 'children', allow_duplicate=True),
79
  Input('add-range', 'n_clicks'),
 
83
  def add_range(n_clicks, existing_ranges):
84
  if n_clicks:
85
  new_index = len(existing_ranges)
86
+ new_range = create_range_input(new_index)
 
 
 
87
  existing_ranges.append(new_range)
88
  return existing_ranges
89