added microchip and a few fixes
This commit is contained in:
parent
ab4d4f4309
commit
f9398dd251
7 changed files with 105 additions and 31 deletions
|
@ -57,6 +57,7 @@ h1>a {
|
|||
input,
|
||||
select,
|
||||
button,
|
||||
textarea,
|
||||
.btn {
|
||||
border: 2pt solid var(--clr-surface-tonal-a50);
|
||||
border-radius: 4pt;
|
||||
|
@ -67,6 +68,7 @@ button,
|
|||
input,
|
||||
select,
|
||||
button,
|
||||
textarea,
|
||||
.btn,
|
||||
.btn a {
|
||||
color: var(--clr-txt-on-dark);
|
||||
|
@ -80,10 +82,16 @@ p.btn {
|
|||
input:hover,
|
||||
select:hover,
|
||||
button:hover,
|
||||
textarea:hover,
|
||||
.btn:hover {
|
||||
border-color: var(--clr-primary-a0);
|
||||
}
|
||||
|
||||
textarea {
|
||||
resize: vertical;
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
header.padded,
|
||||
main {
|
||||
padding-left: 1em;
|
||||
|
@ -185,13 +193,18 @@ button.submit {
|
|||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
input#ident {
|
||||
input#ident,
|
||||
input#microchip_id {
|
||||
font-family: monospace;
|
||||
width: 6ch;
|
||||
font-size: 1.6em;
|
||||
box-sizing: content-box;
|
||||
}
|
||||
|
||||
input#ident {
|
||||
width: 6ch;
|
||||
}
|
||||
|
||||
|
||||
#pregen_ids>button {
|
||||
font-family: monospace;
|
||||
font-size: 1.6em;
|
||||
|
|
|
@ -22,5 +22,5 @@ create table doll_profiles (
|
|||
|
||||
-- ID'ing
|
||||
behaviour text,
|
||||
microchipped integer not null
|
||||
microchip_id text
|
||||
) strict;
|
||||
|
|
|
@ -8,8 +8,8 @@ pub async fn get(mut db: DollTagsDb, ident: i64) -> sqlx::Result<Option<DollProf
|
|||
DollProfile,
|
||||
r#"
|
||||
select
|
||||
id, name, pronouns, handler_name, handler_url, kind, breed, behaviour, description, chassis_type, chassis_id, chassis_color,
|
||||
microchipped as "microchipped!: bool",
|
||||
id, microchip_id,
|
||||
name, pronouns, handler_name, handler_url, kind, breed, behaviour, description, chassis_type, chassis_id, chassis_color,
|
||||
created_at as "created_at!: chrono::NaiveDateTime", updated_at as "updated_at!: Option<chrono::NaiveDateTime>"
|
||||
from doll_profiles where id = ?
|
||||
"#,
|
||||
|
@ -38,10 +38,11 @@ pub async fn create(mut db: DollTagsDb, doll: CreateDollProfile<'_>) -> sqlx::Re
|
|||
sqlx::query!(
|
||||
r#"
|
||||
insert into doll_profiles
|
||||
(id, name, pronouns, handler_name, handler_url, kind, breed, behaviour, description, chassis_type, chassis_id, chassis_color, microchipped)
|
||||
(id, microchip_id, name, pronouns, handler_name, handler_url, kind, breed, behaviour, description, chassis_type, chassis_id, chassis_color)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
"#,
|
||||
doll.id,
|
||||
doll.microchip_id,
|
||||
doll.name,
|
||||
doll.pronouns,
|
||||
doll.handler_name,
|
||||
|
@ -53,7 +54,6 @@ pub async fn create(mut db: DollTagsDb, doll: CreateDollProfile<'_>) -> sqlx::Re
|
|||
doll.chassis_type,
|
||||
doll.chassis_id,
|
||||
doll.chassis_color,
|
||||
doll.microchipped,
|
||||
).execute(&mut **db).await?;
|
||||
|
||||
Ok(doll.id)
|
||||
|
|
|
@ -12,6 +12,7 @@ pub type DollTagsDb = Connection<DollTags>;
|
|||
#[serde(crate = "rocket::serde")]
|
||||
pub struct DollProfile {
|
||||
pub id: i64,
|
||||
pub microchip_id: Option<String>,
|
||||
pub created_at: chrono::NaiveDateTime,
|
||||
pub updated_at: Option<chrono::NaiveDateTime>,
|
||||
|
||||
|
@ -19,7 +20,6 @@ pub struct DollProfile {
|
|||
pub pronouns: String,
|
||||
pub handler_name: String,
|
||||
pub handler_url: Option<String>,
|
||||
pub microchipped: bool,
|
||||
|
||||
pub kind: Option<String>,
|
||||
pub breed: Option<String>,
|
||||
|
@ -44,12 +44,12 @@ impl DollProfile {
|
|||
#[derive(Debug)]
|
||||
pub struct CreateDollProfile<'a> {
|
||||
pub id: i64,
|
||||
pub microchip_id: Option<&'a str>,
|
||||
|
||||
pub name: &'a str,
|
||||
pub pronouns: &'a str,
|
||||
pub handler_name: &'a str,
|
||||
pub handler_url: Option<&'a str>,
|
||||
pub microchipped: bool,
|
||||
|
||||
pub kind: Option<&'a str>,
|
||||
pub breed: Option<&'a str>,
|
||||
|
|
36
src/main.rs
36
src/main.rs
|
@ -56,6 +56,7 @@ async fn show_register(db: DollTagsDb) -> Template {
|
|||
#[derive(Debug, FromForm)]
|
||||
struct TagForm<'a> {
|
||||
pub ident: &'a str,
|
||||
pub microchip_id: &'a str,
|
||||
|
||||
pub name: &'a str,
|
||||
pub pronoun_subject: &'a str,
|
||||
|
@ -68,6 +69,11 @@ struct TagForm<'a> {
|
|||
pub kind: &'a str,
|
||||
pub breed: &'a str,
|
||||
pub behaviour: &'a str,
|
||||
pub description: &'a str,
|
||||
|
||||
pub chassis_type: &'a str,
|
||||
pub chassis_id: &'a str,
|
||||
pub chassis_color: &'a str,
|
||||
}
|
||||
|
||||
#[post("/register", data = "<tag>")]
|
||||
|
@ -83,6 +89,11 @@ async fn handle_register(db: DollTagsDb, tag: Form<TagForm<'_>>) -> Template {
|
|||
db,
|
||||
CreateDollProfile {
|
||||
id,
|
||||
microchip_id: if tag.microchip_id.len() != 0 {
|
||||
Some(tag.microchip_id)
|
||||
} else {
|
||||
None
|
||||
},
|
||||
name: tag.name,
|
||||
pronouns: pronouns.as_str(),
|
||||
handler_name: tag.handler_name,
|
||||
|
@ -106,11 +117,26 @@ async fn handle_register(db: DollTagsDb, tag: Form<TagForm<'_>>) -> Template {
|
|||
} else {
|
||||
None
|
||||
},
|
||||
description: None,
|
||||
chassis_type: None,
|
||||
chassis_id: None,
|
||||
chassis_color: None,
|
||||
microchipped: false,
|
||||
description: if tag.description.len() != 0 {
|
||||
Some(tag.description)
|
||||
} else {
|
||||
None
|
||||
},
|
||||
chassis_type: if tag.chassis_type.len() != 0 {
|
||||
Some(tag.chassis_type)
|
||||
} else {
|
||||
None
|
||||
},
|
||||
chassis_id: if tag.chassis_id.len() != 0 {
|
||||
Some(tag.chassis_id)
|
||||
} else {
|
||||
None
|
||||
},
|
||||
chassis_color: if tag.chassis_color.len() != 0 {
|
||||
Some(tag.chassis_color)
|
||||
} else {
|
||||
None
|
||||
},
|
||||
},
|
||||
)
|
||||
.await
|
||||
|
|
|
@ -25,10 +25,17 @@
|
|||
</p>
|
||||
|
||||
<div class="split bordered raised">
|
||||
<div>
|
||||
<p><label for="ident">Enter your ID</label></p>
|
||||
<input type="text" inputmode="numeric" pattern="\d{6}" id="ident" name="ident" required size="6"
|
||||
placeholder="000000" />
|
||||
<div class="dual-fields">
|
||||
<div>
|
||||
<p><label for="ident">Enter its ID</label></p>
|
||||
<input type="text" inputmode="numeric" pattern="\d{6}" id="ident" name="ident" required size="6"
|
||||
placeholder="000000" />
|
||||
</div>
|
||||
<div>
|
||||
<p><label for="microchip_id">If it's microchipped,<br />you may enter the chip's ID</label></p>
|
||||
<input type="text" pattern="(0x)?[a-fA-F0-9]+" id="microchip_id" name="microchip_id"
|
||||
placeholder="A hexadecimal ID">
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<p>Or pick one of those pre-generated ones</p>
|
||||
|
@ -89,21 +96,49 @@
|
|||
|
||||
<div class="fields raised">
|
||||
<div class="dual-fields">
|
||||
<div>
|
||||
<label for="kind">What kind of entity?</label>
|
||||
<input type="text" name="kind" id="kind" placeholder="Something" />
|
||||
<div class="fields">
|
||||
<div>
|
||||
<label for="kind">What kind of entity?</label>
|
||||
<input type="text" name="kind" id="kind" placeholder="Something" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="breed">What breed is it?</label>
|
||||
<input type="text" name="breed" id="breed" placeholder="Mutt :3" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="behaviour">Its general behaviour</label>
|
||||
<input type="text" name="behaviour" id="behaviour" placeholder="Totally independent" />
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label for="breed">What breed is it?</label>
|
||||
<input type="text" name="breed" id="breed" placeholder="Mutt :3" />
|
||||
<label for="description">A description about it?</label>
|
||||
<textarea name="description" id="description" rows="10"
|
||||
placeholder="feel free to write a bit about it or not at all"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h4>Chassis info</h4>
|
||||
<p>
|
||||
If it has a chassis of its own, you can fill the info below.
|
||||
All fields are mandatory if you decide to fill it.
|
||||
</p>
|
||||
|
||||
<div class="fields raised">
|
||||
<div class="dual-fields">
|
||||
<div>
|
||||
<label for="behaviour">Its general behaviour</label>
|
||||
<input type="text" name="behaviour" id="behaviour" placeholder="Totally independent" />
|
||||
<label for="chassis_type">The chassis' type</label>
|
||||
<input type="text" name="chassis_type" id="chassis_type" placeholder="Combat Doll" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="chassis_id">Its assigned ID</label>
|
||||
<input type="text" name="chassis_id" id="chassis_id" placeholder="E-249" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="chassis_color">Its dominant color</label>
|
||||
<input type="text" name="chassis_color" id="chassis_color" placeholder="Grey" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
<header>
|
||||
<p class="ident">
|
||||
Tag ID <span class="id">{{profile.id | pretty_id}}</span><br />
|
||||
{% if profile.microchipped %}
|
||||
Microchipped
|
||||
{% if profile.microchip_id %}
|
||||
Microchip ID <span class="id">{{profile.microchip_id}}</span>
|
||||
{% else %}
|
||||
Not microchipped
|
||||
{% endif %}
|
||||
|
@ -34,8 +34,8 @@
|
|||
{% if has_notable_traits or profile.description %}
|
||||
<section>
|
||||
<div class="dual-fields">
|
||||
{% if has_notable_traits %}
|
||||
<div>
|
||||
{% if has_notable_traits %}
|
||||
<h2>Notable traits</h3>
|
||||
<ul>
|
||||
{% if profile.kind %}<li><span class="b">Kind:</span> {{profile.kind}}</li>{% endif %}
|
||||
|
@ -48,15 +48,15 @@
|
|||
<p>{{profile.chassis_type}}-type {{profile.chassis_color}} chassis, ID [<span
|
||||
class="id">{{profile.chassis_id}}</span>]</p>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if profile.description %}
|
||||
<div>
|
||||
{% if profile.description %}
|
||||
<h2>Description</h3>
|
||||
|
||||
<p>{{ profile.description | linebreaksbr }}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</section>
|
||||
{% endif %}
|
||||
|
|
Loading…
Add table
Reference in a new issue