Sanjana Vekhande commited on
Commit
fb0fe0f
·
1 Parent(s): d8f4f5a

fix: accumulate multiple files across uploads, add remove × button

Browse files
Files changed (1) hide show
  1. frontend/index.html +20 -4
frontend/index.html CHANGED
@@ -490,7 +490,7 @@ input[type="range"]::-webkit-slider-thumb {
490
  <div class="drop-text">
491
  <strong>Drop model file here</strong>
492
  or click to browse
493
- <small>.xlsx only · one file per species</small>
494
  </div>
495
  </div>
496
  <div class="file-chips" id="chipsModel"></div>
@@ -509,7 +509,7 @@ input[type="range"]::-webkit-slider-thumb {
509
  <div class="drop-text">
510
  <strong>Drop mapping file here</strong>
511
  or click to browse
512
- <small>.xlsx only · one file per species, same order as model</small>
513
  </div>
514
  </div>
515
  <div class="file-chips" id="chipsMapping"></div>
@@ -616,15 +616,31 @@ function checkPrefixMatch() {
616
  }
617
 
618
  function handleFiles(type, files) {
619
- state[type] = Array.from(files);
 
 
 
 
 
 
620
  const key = { model: 'chipsModel', mapping: 'chipsMapping', expr: 'chipsExpr' }[type];
621
  const num = { model: 'num1', mapping: 'num2', expr: 'num3' }[type];
622
  document.getElementById(key).innerHTML =
623
- state[type].map(f => `<div class="chip">✓ ${f.name}</div>`).join('');
624
  document.getElementById(num).classList.add('done');
625
  checkPrefixMatch();
626
  }
627
 
 
 
 
 
 
 
 
 
 
 
628
  ['dropModel','dropMapping','dropExpr'].forEach(id => {
629
  const el = document.getElementById(id);
630
  el.addEventListener('dragover', e => { e.preventDefault(); el.style.borderColor = 'var(--teal)'; });
 
490
  <div class="drop-text">
491
  <strong>Drop model file here</strong>
492
  or click to browse
493
+ <small>.xlsx only · one per species, select multiple</small>
494
  </div>
495
  </div>
496
  <div class="file-chips" id="chipsModel"></div>
 
509
  <div class="drop-text">
510
  <strong>Drop mapping file here</strong>
511
  or click to browse
512
+ <small>.xlsx only · one per species, select multiple</small>
513
  </div>
514
  </div>
515
  <div class="file-chips" id="chipsMapping"></div>
 
616
  }
617
 
618
  function handleFiles(type, files) {
619
+ const newFiles = Array.from(files);
620
+ // Accumulate — skip duplicates by name
621
+ newFiles.forEach(f => {
622
+ if (!state[type].find(e => e.name === f.name)) {
623
+ state[type].push(f);
624
+ }
625
+ });
626
  const key = { model: 'chipsModel', mapping: 'chipsMapping', expr: 'chipsExpr' }[type];
627
  const num = { model: 'num1', mapping: 'num2', expr: 'num3' }[type];
628
  document.getElementById(key).innerHTML =
629
+ state[type].map(f => `<div class="chip">✓ ${f.name} <span style="cursor:pointer;margin-left:3px" onclick="removeFile('${type}','${f.name}')">×</span></div>`).join('');
630
  document.getElementById(num).classList.add('done');
631
  checkPrefixMatch();
632
  }
633
 
634
+ function removeFile(type, name) {
635
+ state[type] = state[type].filter(f => f.name !== name);
636
+ const key = { model: 'chipsModel', mapping: 'chipsMapping', expr: 'chipsExpr' }[type];
637
+ const num = { model: 'num1', mapping: 'num2', expr: 'num3' }[type];
638
+ document.getElementById(key).innerHTML =
639
+ state[type].map(f => `<div class="chip">✓ ${f.name} <span style="cursor:pointer;margin-left:3px" onclick="removeFile('${type}','${f.name}')">×</span></div>`).join('');
640
+ if (!state[type].length) document.getElementById(num).classList.remove('done');
641
+ checkPrefixMatch();
642
+ }
643
+
644
  ['dropModel','dropMapping','dropExpr'].forEach(id => {
645
  const el = document.getElementById(id);
646
  el.addEventListener('dragover', e => { e.preventDefault(); el.style.borderColor = 'var(--teal)'; });