bluenevus commited on
Commit
8d2a944
·
1 Parent(s): ba0c167

Update app.py via AI Editor

Browse files
Files changed (1) hide show
  1. app.py +26 -8
app.py CHANGED
@@ -542,18 +542,36 @@ def handle_dep_upload_to_stores(contents_list, filenames_list):
542
  return stores
543
 
544
  @app.callback(
545
- Output({'type': 'uploaded-doc-name', 'subtype': MATCH, 'index': MATCH}, 'children'),
546
  [
547
- Input({'type': 'upload-doc-type', 'subtype': MATCH, 'index': MATCH}, 'filename')
 
 
 
 
 
548
  ],
549
  prevent_initial_call=True
550
  )
551
- def update_uploaded_doc_name(filename):
552
- if not filename:
553
- return ""
554
- if isinstance(filename, list):
555
- return filename[-1]
556
- return filename
 
 
 
 
 
 
 
 
 
 
 
 
 
 
557
 
558
  @app.callback(
559
  Output('document-preview', 'children'),
 
542
  return stores
543
 
544
  @app.callback(
 
545
  [
546
+ Output({'type': 'uploaded-doc-name', 'subtype': MATCH, 'index': MATCH}, 'children'),
547
+ Output({'type': 'uploaded-doc-name', 'subtype': 'shred', 'index': 'Shred'}, 'children')
548
+ ],
549
+ [
550
+ Input({'type': 'upload-doc-type', 'subtype': MATCH, 'index': MATCH}, 'filename'),
551
+ Input({'type': 'upload-doc-type', 'subtype': 'shred', 'index': 'Shred'}, 'filename')
552
  ],
553
  prevent_initial_call=True
554
  )
555
+ def update_uploaded_doc_name_combined(filename_match, filename_shred):
556
+ ctx = callback_context
557
+ triggered_id = None
558
+ if ctx.triggered and ctx.triggered[0]['prop_id']:
559
+ triggered_id = ctx.triggered[0]['prop_id'].split('.')[0]
560
+ match_value = ""
561
+ shred_value = ""
562
+ if isinstance(filename_match, list):
563
+ match_value = filename_match[-1] if filename_match else ""
564
+ elif filename_match:
565
+ match_value = filename_match
566
+ if isinstance(filename_shred, list):
567
+ shred_value = filename_shred[-1] if filename_shred else ""
568
+ elif filename_shred:
569
+ shred_value = filename_shred
570
+ # Only update the output that was triggered, leave the other as dash.no_update
571
+ if triggered_id and '"subtype":"shred"' in triggered_id and '"index":"Shred"' in triggered_id:
572
+ return dash.no_update, shred_value
573
+ else:
574
+ return match_value, dash.no_update
575
 
576
  @app.callback(
577
  Output('document-preview', 'children'),