fix: global question answering
This commit is contained in:
parent
68c3a5d84e
commit
52339e6b98
1 changed files with 31 additions and 9 deletions
|
@ -33,9 +33,18 @@
|
|||
></textarea>
|
||||
</div>
|
||||
|
||||
<button class="primary">
|
||||
{{ text "communities:action.create" }}
|
||||
</button>
|
||||
<div id="files_list" class="flex gap-2 flex-wrap"></div>
|
||||
|
||||
<div class="flex gap-2">
|
||||
{{ components::emoji_picker(element_id="content",
|
||||
render_dialog=true) }} {% if is_supporter %} {{
|
||||
components::file_picker(files_list_id="files_list") }} {% endif
|
||||
%}
|
||||
|
||||
<button class="primary">
|
||||
{{ text "requests:label.answer" }}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
@ -62,16 +71,29 @@
|
|||
window.answer_question_from_form = async (e, answering) => {
|
||||
e.preventDefault();
|
||||
await trigger("atto::debounce", ["posts::create"]);
|
||||
fetch("/api/v1/posts", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
|
||||
// create body
|
||||
const body = new FormData();
|
||||
|
||||
if (e.target.file_picker) {
|
||||
for (const file of e.target.file_picker.files) {
|
||||
body.append(file.name, file);
|
||||
}
|
||||
}
|
||||
|
||||
body.append(
|
||||
"body",
|
||||
JSON.stringify({
|
||||
content: e.target.content.value,
|
||||
community: community ? community : "{{ config.town_square }}",
|
||||
answering,
|
||||
}),
|
||||
);
|
||||
|
||||
// ...
|
||||
fetch("/api/v1/posts", {
|
||||
method: "POST",
|
||||
body,
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then((res) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue