implemented creating new poll and managing poll options

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2026-02-23 23:46:52 +01:00
parent e5ab655787
commit cbc6ce188d
7 changed files with 182 additions and 24 deletions

View File

@@ -1,14 +1,28 @@
<script>
import { onMount } from 'svelte';
import LineEditor from '../../Components/LineEditor.svelte';
import { useTinyRouter } from 'svelte-tiny-router';
import { api, get } from '../../urls.svelte';
import { api, get, post } from '../../urls.svelte';
import { error, yikes } from '../../warn.svelte';
import { t } from '../../translations.svelte';
import { user } from '../../user.svelte.js';
let polls = [];
let polls = $state([]);
let router = useTinyRouter();
async function create_poll(name){
const url = api('poll');
const res = await post(url,{name});
if (res.ok) {
yikes();
const json = await res.json();
polls.push(json);
}
error(res);
}
function edit(poll){
router.navigate(`/poll/${poll.id}/edit`);
}
@@ -61,6 +75,12 @@
</td>
</tr>
{/each}
<tr>
<td>
<LineEditor simple={true} onSet={create_poll}/>
</td>
<td colspan="3">{t('Enter name to create new')}</td>
</tr>
</tbody>
</table>
</fieldset>