|
|
+++
|
|
|
title = "Submit form: author optional (default Anonymous), clarify auth code auto-generation"
|
|
|
priority = 5
|
|
|
status = "done"
|
|
|
ticket_type = "bug"
|
|
|
dependencies = []
|
|
|
+++
|
|
|
## Bug
|
|
|
|
|
|
Two related UX issues on the submit form (`src/bin/ui/pages/submit.rs`):
|
|
|
|
|
|
### 1. Author field should be optional
|
|
|
|
|
|
Currently, `author` is required — the validation at line 53 returns early with `"Text and author are required."` if it is empty, and the field has `required=true` at line 177. Not all quotes have a known author, so it should be optional. When left blank, the API should receive `"Anonymous"` as the author.
|
|
|
|
|
|
### 2. Auth code label should clarify auto-generation
|
|
|
|
|
|
The label currently reads `"Custom auth code (optional)"`. The label itself does not explain what happens if left blank. The placeholder does say `"word-word-word-word (auto-generated if empty)"`, but users may not notice placeholders. The label should make it explicit.
|
|
|
|
|
|
## Expected behaviour
|
|
|
|
|
|
- Author field: leaving it blank submits the quote with author = `"Anonymous"`. The field should not block form submission.
|
|
|
- Auth code label: reads something like `"Custom auth code (optional — one will be generated if left blank)"`.
|
|
|
|
|
|
## How to fix
|
|
|
|
|
|
In `src/bin/ui/pages/submit.rs`:
|
|
|
|
|
|
**Author optional:**
|
|
|
|
|
|
1. Change the validation at line 53:
|
|
|
```rust
|
|
|
// Before
|
|
|
if text_val.is_empty() || author_val.is_empty() {
|
|
|
error.set(Some("Text and author are required.".to_string()));
|
|
|
return;
|
|
|
}
|
|
|
// After
|
|
|
if text_val.is_empty() {
|
|
|
error.set(Some("Quote text is required.".to_string()));
|
|
|
return;
|
|
|
}
|
|
|
```
|
|
|
2. When building `CreateQuoteInput`, default the author to `"Anonymous"` if empty:
|
|
|
```rust
|
|
|
author: if author_val.is_empty() {
|
|
|
"Anonymous".to_string()
|
|
|
} else {
|
|
|
author_val
|
|
|
},
|
|
|
```
|
|
|
3. Remove `required=true` from the author `<input>` (~line 177).
|
|
|
4. Update the label from `"Author *"` to `"Author (optional, defaults to Anonymous)"` or similar.
|
|
|
5. Update the placeholder from `"e.g. Mark Twain"` to `"e.g. Mark Twain (leave blank for Anonymous)"`.
|
|
|
|
|
|
**Auth code label:**
|
|
|
|
|
|
6. Change the label at line 236 from:
|
|
|
```
|
|
|
"Custom auth code (optional)"
|
|
|
```
|
|
|
to:
|
|
|
```
|
|
|
"Auth code (optional — one will be generated if left blank)"
|
|
|
```
|
|
|
|
|
|
## File
|
|
|
|
|
|
- `src/bin/ui/pages/submit.rs` (lines 53–56, 64–66, 163–178, 235–237)
|
|
|
|
|
|
## Validation
|
|
|
|
|
|
```sh
|
|
|
# From quotesdb/ root
|
|
|
cargo fmt && cargo check && cargo clippy && cargo test
|
|
|
trunk build
|
|
|
```
|
|
|
|
|
|
Manually test: submit a quote with author left blank — it should succeed and display `Anonymous` as the author.
|
|
|
|
|
|
## Commit scope
|
|
|
|
|
|
`fix(quotesdb): submit form author optional and auth code label` |