Implement rest of basic info editing.
This commit is contained in:
parent
ae6d5bcfa3
commit
5ea5d627bb
|
@ -17,6 +17,12 @@ import * as api from "../api";
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getTextValue = (selector: string) =>
|
||||||
|
document.querySelector<HTMLInputElement>(selector)?.value ?? "";
|
||||||
|
|
||||||
|
const getIntValue = (selector: string) =>
|
||||||
|
parseInt(document.querySelector<HTMLInputElement>(selector)?.value ?? "0")
|
||||||
|
|
||||||
function setupAttributes() {
|
function setupAttributes() {
|
||||||
const attributeInputs = document.querySelectorAll('#attributes input[type="number"]');
|
const attributeInputs = document.querySelectorAll('#attributes input[type="number"]');
|
||||||
|
|
||||||
|
@ -71,15 +77,12 @@ import * as api from "../api";
|
||||||
async function updateInfo() {
|
async function updateInfo() {
|
||||||
const params = new UpdateBasicInfoRequest();
|
const params = new UpdateBasicInfoRequest();
|
||||||
|
|
||||||
const name = document.querySelector<HTMLInputElement>("#characterName")?.value ?? "";
|
|
||||||
console.log("name is", name);
|
|
||||||
|
|
||||||
params.setId(characterId());
|
params.setId(characterId());
|
||||||
params.setName(name);
|
params.setName(getTextValue("#characterName"));
|
||||||
params.setAge(50);
|
params.setAge(getIntValue("#age"));
|
||||||
params.setConcept("cool guy");
|
params.setConcept(getTextValue("#concept"));
|
||||||
params.setChronicle("the best one");
|
params.setChronicle(getTextValue("#chronicle"));
|
||||||
params.setGender("apache attack helicopter");
|
params.setGender(getTextValue("#gender"));
|
||||||
|
|
||||||
let resp = await api.updateBasicInfo(params);
|
let resp = await api.updateBasicInfo(params);
|
||||||
console.log("got a response back", resp);
|
console.log("got a response back", resp);
|
||||||
|
|
|
@ -94,8 +94,29 @@
|
||||||
<label for="characterName">Name:</label>
|
<label for="characterName">Name:</label>
|
||||||
<input type="text" id="characterName" name="characterName" value="{{name}}" />
|
<input type="text" id="characterName" name="characterName" value="{{name}}" />
|
||||||
</h1>
|
</h1>
|
||||||
<p>System: {{data_type}}</p>
|
<div>System: {{data_type}}</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="gender">Gender:</label>
|
||||||
|
<input type="text" id="gender" name="gender" value="{{sheet.gender}}" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="age">Age:</label>
|
||||||
|
<input type="number" id="age" name="age" min="0" value="{{sheet.age}}" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="concept">Concept:</label>
|
||||||
|
<input type="text" id="concept" name="concept" value="{{sheet.concept}}" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="chronicle">Chronicle:</label>
|
||||||
|
<input type="text" id="chronicle" name="chronicle" value="{{sheet.chronicle}}" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="attributes">
|
<div id="attributes">
|
||||||
<div class="attributes-section" id="mentalAttributes">
|
<div class="attributes-section" id="mentalAttributes">
|
||||||
{{ macros::attribute(name="Intelligence", value=sheet.intelligence) }}
|
{{ macros::attribute(name="Intelligence", value=sheet.intelligence) }}
|
||||||
|
|
|
@ -53,6 +53,8 @@ pub(super) async fn update_basic_info<'a>(
|
||||||
sheet.name = req.name.clone();
|
sheet.name = req.name.clone();
|
||||||
sheet.gender = req.gender.clone();
|
sheet.gender = req.gender.clone();
|
||||||
sheet.concept = req.concept.clone();
|
sheet.concept = req.concept.clone();
|
||||||
|
sheet.chronicle = req.chronicle.clone();
|
||||||
|
sheet.age = req.age;
|
||||||
|
|
||||||
character.update_data(&sheet)?;
|
character.update_data(&sheet)?;
|
||||||
conn.update_character(&character).await?;
|
conn.update_character(&character).await?;
|
||||||
|
|
Loading…
Reference in New Issue