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>
|
></textarea>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button class="primary">
|
<div id="files_list" class="flex gap-2 flex-wrap"></div>
|
||||||
{{ text "communities:action.create" }}
|
|
||||||
</button>
|
<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>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -62,16 +71,29 @@
|
||||||
window.answer_question_from_form = async (e, answering) => {
|
window.answer_question_from_form = async (e, answering) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
await trigger("atto::debounce", ["posts::create"]);
|
await trigger("atto::debounce", ["posts::create"]);
|
||||||
fetch("/api/v1/posts", {
|
|
||||||
method: "POST",
|
// create body
|
||||||
headers: {
|
const body = new FormData();
|
||||||
"Content-Type": "application/json",
|
|
||||||
},
|
if (e.target.file_picker) {
|
||||||
body: JSON.stringify({
|
for (const file of e.target.file_picker.files) {
|
||||||
|
body.append(file.name, file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
body.append(
|
||||||
|
"body",
|
||||||
|
JSON.stringify({
|
||||||
content: e.target.content.value,
|
content: e.target.content.value,
|
||||||
community: community ? community : "{{ config.town_square }}",
|
community: community ? community : "{{ config.town_square }}",
|
||||||
answering,
|
answering,
|
||||||
}),
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
// ...
|
||||||
|
fetch("/api/v1/posts", {
|
||||||
|
method: "POST",
|
||||||
|
body,
|
||||||
})
|
})
|
||||||
.then((res) => res.json())
|
.then((res) => res.json())
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue