working on management of poll weights

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2026-02-25 15:34:01 +01:00
parent 4a2c49c42c
commit 5336384e0d
3 changed files with 20 additions and 8 deletions

View File

@@ -43,9 +43,7 @@
async function patch_option(option, field, newVal){
let url = api(`poll/${id}/option/${option.id}`);
let data = {}
data[field] = newVal;
let res = await patch(url,data);
let res = await patch(url,{[field]: newVal});
if (res.ok) {
yikes();
const json = await res.json();
@@ -64,7 +62,14 @@
if (res.ok) {
yikes();
const json = await res.json();
console.log(json);
const weights = json.weights;
for (let weight of Object.keys(data)){
let desc = data[weight];
console.log(weight, desc);
if (desc) {
poll.weights[weight] = desc;
} else delete poll.weights[weight]; // TODO: this corrupts the display of the following element!
}
return true;
}
error(res);
@@ -153,7 +158,7 @@
<input type="number" value={weight} />
</td>
<td>
<LineEditor value={descr} onSet={desc => patch_weight({weight: desc})} />
<LineEditor editable={true} value={descr} onSet={desc => patch_weight({[weight]: desc})} />
</td>
</tr>
{/each}