Skip to content

feat(ui): structured available-time window in listing form - #32

Merged
argszero merged 1 commit into
mainfrom
feat/ui-available-window
Aug 17, 2026
Merged

argszero merged 1 commit into
mainfrom
feat/ui-available-window

Conversation

@argszero

Copy link
Copy Markdown
Owner

Summary

Make the listing key's availability window a structured field instead of free-text note. The old note placeholder ("如:工作日 9:00-18:00 可用") pushed structured info into text the backend cannot parse/enforce. Now: weekday multi-select chips (周一~周日 + a "每天" shortcut) with start/end time inputs; leaving it empty = 全天 (all-day). The note is pure text again.

Rant reference

Host instruction (rant 2026-08-17T10:54:48, 上架表单"可用时间段"改为结构化字段,备注只作纯备注):

宿主指出:上架 key 的备注 placeholder 是"如:工作日 9:00-18:00 可用"——这是把可用时间段这种结构化信息塞进自由文本备注,后端无法解析生效。正确做法:若支持可用时间段:做成正式字段(有结构、可约束、后端可生效);备注只作纯备注:自由文本,不承载任何逻辑。

Changes

  • ui/index.html: new "可用时间段" field — weekday chips (#sf-days, 周一~周日 + 每天 shortcut) + 开始/结束时间 (type=time); note placeholder changed to "可填写任意说明,不影响生效规则" (pure text)
  • ui/js/app.js:
    • submit reads checked days + start/end; available: { days, start, end } or null (no day selected = all-day); note stored as-is, never parsed
    • "每天" chip toggles all 7 day chips (and disables them while active)
    • listing shows the window via fmtAvailable() (contiguous days compressed to 周一~周五, gaps joined with /; no window → "全天")
  • ui/js/data.js: mock SHARINGS gain available (one 工作日 09:00-18:00, one 周末 10:00-22:00, two null)
  • ui/css/style.css: .chips / .chip styles (checked state highlighted via :has)
  • docs/user-stories.md: bumped to v1.10 — US-8 / US-9 AC updated (structured optional field, note = plain text, listing shows window or 全天)
  • ui/README.md: synced sharing section

Verification

  • node --check ui/js/app.js / ui/js/data.js pass
  • fmtAvailable logic tests: 周一周五 09:00-18:00 / 全天 / 周一/周三/周五 / 周六周日 10:00-22:00 — ALL PASS
  • grep "工作日 9:00-18:00" in ui/ docs/ → zero matches (old placeholder gone)
  • cargo test passes (1 passed)
  • cargo fmt --check passes

The note placeholder suggested putting availability windows into free
text ("如:工作日 9:00-18:00 可用"), which the backend cannot parse.
Make availability a real structured field: weekday multi-select chips
(周一~周日 + 每天 shortcut) with start/end time inputs; empty = 全天
(all-day). The note is now pure text and no longer carries logic. The
listing shows the window when set (e.g. 周一~周五 09:00-18:00) or
"全天" otherwise. Adds SHARINGS.available mock data, chip styles, and
syncs docs (v1.10: US-8/US-9 AC) and ui/README.md.

Refs: rant 2026-08-17T10:54:48 (上架表单"可用时间段"改为结构化字段,备注只作纯备注)
@argszero
argszero merged commit d31641d into main Aug 17, 2026
1 check passed
argszero added a commit that referenced this pull request Sep 30, 2026
…-label rule (#329)

The generic field-label rule `.form label { display:flex; flex-direction:column }`
(specificity 0,1,1) outranked the component layer (0,1,0) for every label that
carries a component class, so the layout the class asked for never applied:

- `.check-line` — the settings notification checkboxes and the table-density
  radios rendered stacked (control above its caption, centred). #157 renamed the
  markup from `class="check"` to the prototype-canonical `.check-line` that #154
  introduced, but left the stylesheet's `.form label.check` rule behind; that
  rule was the only thing turning a checkbox label back into a row, and it
  stopped matching anything.
- `.chip` — the share-form weekday chips were pills; #32 turned them into
  `<label>`s, and the `display:inline-flex` #154 gave them was overridden.

Fix: guard the generic field-label rules with `:not([class])`, so a classed label
takes its box from its own class — the component layer wins as intended. Also
drop the now-dead `.density-options .check` rule (#157 renamed that markup too)
and give `.checkbox, .checkbox-line` back their own `display:flex`, which they
used to borrow from the generic rule.

Adds `src/layout_gate.rs` (test-only, compiled out of release builds, zero new
dependencies) with two derived rules: every class used on a `<label>` in
ui/index.html must declare its own `display`, and any rule that targets a bare
`label` and imposes a layout must carry a guard excluding classed elements.

Measured with jsdom over the whole document on both trees: check-line and chip
go from column to row, while the unclassed field labels stay column in both.

Co-authored-by: argszero <argszero@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant