Add autocomplete to edit

This commit is contained in:
Damillora 2021-09-11 02:25:09 +07:00
parent 16c9f998d5
commit 2cc9705845

View File

@ -1,5 +1,5 @@
<script> <script>
import { getPost, postUpdate } from "../api.js"; import { getPost, postUpdate, getTagAutocomplete } from "../api.js";
import { navigate } from "svelte-routing"; import { navigate } from "svelte-routing";
import Tags from "svelte-tags-input"; import Tags from "svelte-tags-input";
import { onMount } from "svelte"; import { onMount } from "svelte";
@ -26,6 +26,11 @@
form.tags = value.detail.tags; form.tags = value.detail.tags;
}; };
const onAutocomplete = async () => {
const list = await getTagAutocomplete();
return list;
};
const onSubmit = async () => { const onSubmit = async () => {
const response = await postUpdate(id, form); const response = await postUpdate(id, form);
navigate(`/post/${response.id}`); navigate(`/post/${response.id}`);
@ -71,6 +76,7 @@
tags={form.tags} tags={form.tags}
addKeys={[9, 32]} addKeys={[9, 32]}
on:tags={onTagChange} on:tags={onTagChange}
autoComplete={onAutocomplete}
/> />
</div> </div>
</div> </div>