The HF server can't reach the PTT-internal SMP gateway, but the user's PTT-wifi
browser can (gateway sends CORS *). signer_lookup.py builds a client-side fetch
(PO -> SAP PR -> approver + receiving-committee chairman); streamlit-javascript
runs it and returns the names; fetch_signer_name picks by role, with a manual
text-box fallback when off-network. Uses the read-only no-reply token (SMP_TOKEN
Space secret), injected into client JS — Entra-gated.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
When the app is opened from the HF Space page it runs in an iframe, where
st.login()'s redirect is blocked by Microsoft's frame-busting ("nothing
happens"). Add a host-agnostic link (href="/" target="_blank") to reopen the
app top-level where sign-in works.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Harden login gate: graceful message when auth not configured
Instead of letting st.login() raise StreamlitAuthError (raw traceback) when
no [auth] provider is configured, detect configuration and show a clean
"sign-in not set up" notice; also wrap st.login() in try/except.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Gate the whole app behind Streamlit native OIDC sign-in (auth_gate.py),
reusing the existing Azure App Registration. Auth config lives in a
gitignored .streamlit/secrets.toml locally, and is built at container
start from HF Space secrets by entrypoint.sh.
- Retheme to a black + burnt-orange ember palette across the login pass,
hero, stepper, cards, inputs and buttons (+ config.toml).
- requirements: streamlit>=1.42, add Authlib.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Circle (54px, 50% radius, 3px ring) to squircle (44px, 14px radius,
2px ring, softer shadow). All three badges use the step-1 violet
gradient (#7C5CFF -> #A78BFA).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Gate the Step 3 download box on has_generated (file exists AND current inputs
still match the generated snapshot) instead of just generated_file. Editing any
earlier field now flips has_generated False, so the stale download box disappears
- consistent with how the step indicator already regresses.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Auto-scroll to download box after generating a document
- Set one-shot session flag on successful generation, before st.rerun()
- Add #download-anchor in the Step 3 box (scroll-margin-top for badge clearance)
- Render a height-0 components.html iframe whose script smooth-scrolls
window.parent to the anchor, then clear the flag so it fires only once
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Step 3 in its own box; unify badge & header with Steps 1-2
It was not a PLACEHOLDER_* token, so it printed literally in every
generated form1. Sentence is grammatically complete without it.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Rename Excel data section title to "ข้อมูลที่ถูกดึงมา"
- remove the 'category/usage' annotation line (form1 standalone; form2 full
when-to-use paragraph) so the letter starts at the letterhead
- center the signer (name) line on the page; form_logic no longer pads it
with leading spaces (centering via paragraph alignment)
- normalize all text to black (run + paragraph-mark/list-number colors)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add PTT letterhead to form templates (LFS), remove sample markers
- form1-5: embed official PTT letterhead (logo + address) at top-left
- remove leading sample line and form-number page header
- assets/ptt_letterhead.png: letterhead source asset
- .gitattributes: LFS-track templates/*.docx and assets/*.png
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Forms 2-5 were uses_po=False, which forced step1_done=True so Step 2 never locked before a PO lookup. They actually depend on the lookup (vendor already, plus PO + title per the reference line). Set uses_po=True for forms 2-5 so Step 2 gates on the lookup like form1, and fill the work title and PO into the 'อ้างถึง (1) สัญญา...' line.
- form_logic.py: uses_po=True for forms 2-5; fill title/PO in the form2-5 branch.
- templates/form2-5.docx: insert ชื่องาน / PO_No tokens into the reference line.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Update browser tab: title "PTT AUTO FORM" and document favicon
- page_title: "Auto Form Generator" -> "PTT AUTO FORM"
- page_icon: evergreen tree -> document page (matches the app's function)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Reduce sizes: badge 0.78->0.66rem (tighter padding), AUTO FORM 2.75->2.2rem,
subtitle 1.05->0.92rem
- Left-align the PTT badge (was centered) to match the title
- Zero the subtitle's default <p> bottom margin so the body content is truly
vertically centred (was sitting bottom-heavy)
- Re-tune stub/body padding so badge (stub) and title+subtitle (body) stay
centred around the fixed 56px perforation
- Sync note.md (badge now left-aligned)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Restyle hero as a ticket: transparent notch holes, bold perforation, balanced layout
- Edge notches are now TRUE transparent holes (CSS mask, intersected) so the
page background shows through them exactly -- no colour-matching seam
- Bold, evenly-spaced dashed perforation via repeating-linear-gradient
(22px dashes, 16px gaps, 4px thick)
- Centered "PTT DOCUMENTS GENERATOR" pill in the stub; AUTO FORM title and
subtitle left-aligned; all hero content vertically balanced
- Sync note.md theme description
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add flat cream accent palette with purple text/icons
Layer a minimalist flat single-tone cream accent (#EFD2A0) onto the
Indigo Dusk purple base: hero card, primary/download/PO-search buttons,
and active step circle + progress bar. No gradients, no glow auras
(removed golden box-shadows, the active-step pulse glow, and the hero
decorative blobs/dot pattern).
Cream-surface text and icons are purple (#4A3D78). A scoped rule
re-asserts purple on cream-button labels so they beat the global
stMarkdownContainer light-text rule (which had left the PO-search
check_circle icon and the generate-button text white). Swap the
multicolor sparkle emoji on the generate button for a monochrome
:material/auto_awesome: glyph that takes the purple. Update note.md
theme line.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Switch to Indigo Dusk dark theme (purple/lavender)
Recolor the full inline-CSS palette and config.toml from Soft Linen
(cream/coral light) to a deep indigo-purple dark theme: panel-purple
cards, lavender accent, near-white-lavender text, mint success, warm
receipt-sand highlights. Hero readability fixes (uppercase title,
boosted .hero subtitle specificity), transparent-track scrollbar, and
no scrollbar-gutter all preserved. Update note.md theme line.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Restyle to Soft Linen minimalist light theme; fix scrollbar white bars
- Full dark->light recolor (Forest Night -> Soft Linen): warm cream
background, clean white cards, muted-coral accent, warm-charcoal text,
sage "done" step. Softened shadows + stepper animation for a calmer feel.
- Remove scrollbar-gutter reservation that left a white bar on the
non-scrolling edge; use a transparent track + slim coral thumb instead.
- Keep hero text light on the coral hero (the dark recolor had darkened it
to near-invisible); make the hero title uppercase.
- Update .streamlit/config.toml base theme and note.md theme line.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Hero: drop marketing stat boxes (5 / <30s / Free to use) and the promo
tagline, use a functional Thai subtitle, and shorten the badge to
'Auto Form'. Remove the data-source bar, the manual Excel upload button,
and the inline uploader so the UI no longer announces the data origin;
PO data still loads live (load_live_data) with sample fallback. Sync
note.md to match.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Delete auto_form_generator.py (the tkinter desktop GUI) and drop its
references from README.md and the form_logic.py docstring. The Streamlit
web app is now the only entry point.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add note.md: architecture & operations guide for onboarding
Documents the live data flow (Power Automate + Office Script -> OneDrive Excel -> app HTTP GET), the DATA_URL secret, key files/functions, deploy procedure, gotchas, and a self-maintenance section.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Read live data directly from OneDrive anonymous link (no upload/dataset)