Menixis Claude Opus 4.8 (1M context) commited on
Commit
2becdbf
·
1 Parent(s): 59262ca

Auto-form: lock coming-soon options, soft-orange arrows, always-show extra data, smart doc-type default

Browse files

- Grey out + disable (unclickable) the coming-soon form options in the
dropdown via a DOM MutationObserver (matched by the lock marker).
- Dropdown arrows -> soft orange (#F58A52, deepen on hover) with a
pointer cursor.
- Replace the 'ดูข้อมูลอื่น ๆ' expander with an always-visible section.
- Default ประเภทเอกสาร from the PO's procurement type via _is_jang:
งานจ้าง -> แจ้งให้เริ่มเข้าทำงาน, งานซื้อ -> แจ้งให้เริ่มส่งมอบสินค้า
(applied once per looked-up PO; user can still override).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Files changed (1) hide show
  1. streamlit_app.py +63 -15
streamlit_app.py CHANGED
@@ -836,15 +836,28 @@ st.markdown("""
836
  border: 1.5px solid rgba(242, 106, 58, 0.25) !important;
837
  border-radius: 12px !important;
838
  color: #3E2A1E !important;
 
839
  }
840
  [data-baseweb="select"] *,
841
  [data-baseweb="select"] span,
842
  [data-baseweb="select"] div {
843
  color: #3E2A1E !important;
844
  }
 
845
  [data-testid="stSelectbox"] svg,
846
  [data-baseweb="select"] svg {
847
- fill: #C25A1E !important;
 
 
 
 
 
 
 
 
 
 
 
848
  }
849
 
850
  /* Selectbox dropdown popover (portaled outside main DOM — needs high
@@ -1264,6 +1277,31 @@ with left_col:
1264
  selected_form = _form_by_label[form_choice]
1265
  coming_soon = selected_form["id"] in COMING_SOON_IDS
1266
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1267
  st.markdown("<div style='height: 0.5rem;'></div>", unsafe_allow_html=True)
1268
 
1269
  if coming_soon:
@@ -1343,20 +1381,21 @@ with left_col:
1343
  </div>
1344
  """, unsafe_allow_html=True)
1345
 
1346
- with st.expander("📋 ดูข้อมูลอื่น ๆ"):
1347
- for col, label in DISPLAY_FIELDS:
1348
- if col in ("VendorName", "title"):
1349
- continue
1350
- val = st.session_state.lookup_data.get(col)
1351
- if val not in (None, ""):
1352
- st.markdown(f"**{label}:** {val}")
1353
- # กำหนดส่งมอบ (การส่งมอบงาน) — pulled live from the PR's TOR via the SMP fetch
1354
- delivery = signer_lookup.pick_delivery(resolved_signers)
1355
- if delivery:
1356
- st.markdown("**กำหนดส่งมอบ:**")
1357
- st.markdown(delivery.replace("\n", " \n"))
1358
- elif resolved_signers is None:
1359
- st.caption(":material/hourglass_top: กำลังดึงกำหนดส่งมอบ…")
 
1360
  else:
1361
  st.markdown("""
1362
  <div class="empty-state">
@@ -1402,6 +1441,15 @@ with right_col:
1402
  disabled=not step1_done)
1403
 
1404
  if selected_form["uses_doc_type"]:
 
 
 
 
 
 
 
 
 
1405
  doc_type = st.radio("ประเภทเอกสาร",
1406
  DOC_TYPE_OPTIONS,
1407
  horizontal=True,
 
836
  border: 1.5px solid rgba(242, 106, 58, 0.25) !important;
837
  border-radius: 12px !important;
838
  color: #3E2A1E !important;
839
+ cursor: pointer !important;
840
  }
841
  [data-baseweb="select"] *,
842
  [data-baseweb="select"] span,
843
  [data-baseweb="select"] div {
844
  color: #3E2A1E !important;
845
  }
846
+ /* Dropdown arrow — soft orange, with a pointer cursor on hover */
847
  [data-testid="stSelectbox"] svg,
848
  [data-baseweb="select"] svg {
849
+ fill: #F58A52 !important;
850
+ cursor: pointer !important;
851
+ }
852
+ [data-baseweb="select"] [role="button"],
853
+ [data-baseweb="select"] [aria-label*="open" i],
854
+ [data-testid="stSelectbox"] svg:hover,
855
+ [data-baseweb="select"] svg:hover {
856
+ cursor: pointer !important;
857
+ }
858
+ [data-testid="stSelectbox"] svg:hover,
859
+ [data-baseweb="select"] svg:hover {
860
+ fill: #F26A3A !important;
861
  }
862
 
863
  /* Selectbox dropdown popover (portaled outside main DOM — needs high
 
1277
  selected_form = _form_by_label[form_choice]
1278
  coming_soon = selected_form["id"] in COMING_SOON_IDS
1279
 
1280
+ # The "coming soon" form types stay visible in the dropdown but must read as
1281
+ # disabled — greyed out and unclickable. Streamlit's selectbox can't disable
1282
+ # individual options, so style + lock them in the DOM (matched by the 🔒 marker
1283
+ # in the label). A MutationObserver re-applies it each time the menu re-opens.
1284
+ components.html("""
1285
+ <script>
1286
+ const doc = window.parent.document;
1287
+ const lockOptions = () => {
1288
+ doc.querySelectorAll('li[role="option"]').forEach(li => {
1289
+ if (li.textContent.includes('🔒')) {
1290
+ li.style.opacity = '0.4';
1291
+ li.style.pointerEvents = 'none';
1292
+ li.style.cursor = 'not-allowed';
1293
+ li.setAttribute('aria-disabled', 'true');
1294
+ }
1295
+ });
1296
+ };
1297
+ if (doc.__formLockObs) doc.__formLockObs.disconnect();
1298
+ const obs = new MutationObserver(lockOptions);
1299
+ obs.observe(doc.body, {childList: true, subtree: true});
1300
+ doc.__formLockObs = obs;
1301
+ lockOptions();
1302
+ </script>
1303
+ """, height=0)
1304
+
1305
  st.markdown("<div style='height: 0.5rem;'></div>", unsafe_allow_html=True)
1306
 
1307
  if coming_soon:
 
1381
  </div>
1382
  """, unsafe_allow_html=True)
1383
 
1384
+ st.markdown('<div class="section-title">ข้อมูลอื่น ๆ</div>',
1385
+ unsafe_allow_html=True)
1386
+ for col, label in DISPLAY_FIELDS:
1387
+ if col in ("VendorName", "title"):
1388
+ continue
1389
+ val = st.session_state.lookup_data.get(col)
1390
+ if val not in (None, ""):
1391
+ st.markdown(f"**{label}:** {val}")
1392
+ # กำหนดส่งมอบ (การส่งมอบงาน) — pulled live from the PR's TOR via the SMP fetch
1393
+ delivery = signer_lookup.pick_delivery(resolved_signers)
1394
+ if delivery:
1395
+ st.markdown("**กำหนดส่งมอบ:**")
1396
+ st.markdown(delivery.replace("\n", " \n"))
1397
+ elif resolved_signers is None:
1398
+ st.caption(":material/hourglass_top: กำลังดึงกำหนดส่งมอบ…")
1399
  else:
1400
  st.markdown("""
1401
  <div class="empty-state">
 
1441
  disabled=not step1_done)
1442
 
1443
  if selected_form["uses_doc_type"]:
1444
+ # Auto-pick the default ประเภทเอกสาร from the PO's procurement type:
1445
+ # งานจ้าง → แจ้งให้เริ่มเข้าทำงาน, งานซื้อ → แจ้งให้เริ่มส่งมอบสินค้า.
1446
+ # Applied once per looked-up PO; the user can still change it afterwards.
1447
+ if st.session_state.lookup_data and \
1448
+ st.session_state.get("doc_type_auto_for") != st.session_state.last_po:
1449
+ _ptype = st.session_state.lookup_data.get("procurementType")
1450
+ st.session_state.doc_type_widget = (
1451
+ DOC_TYPE_OPTIONS[0] if ai_clean._is_jang(_ptype) else DOC_TYPE_OPTIONS[1])
1452
+ st.session_state.doc_type_auto_for = st.session_state.last_po
1453
  doc_type = st.radio("ประเภทเอกสาร",
1454
  DOC_TYPE_OPTIONS,
1455
  horizontal=True,