add: ability to upload images while creating a reply or answer
This commit is contained in:
parent
eb95be0f38
commit
68c3a5d84e
2 changed files with 38 additions and 7 deletions
|
@ -108,7 +108,14 @@
|
||||||
></textarea>
|
></textarea>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="files_list" class="flex gap-2 flex-wrap"></div>
|
||||||
|
|
||||||
<div class="flex gap-2">
|
<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>
|
<button class="primary">{{ text "requests:label.answer" }}</button>
|
||||||
<button type="button" class="red quaternary" onclick="trigger('me::remove_question', ['{{ question[0].id }}'])">{{ text "general:action.delete" }}</button>
|
<button type="button" class="red quaternary" onclick="trigger('me::remove_question', ['{{ question[0].id }}'])">{{ text "general:action.delete" }}</button>
|
||||||
<button type="button" class="red quaternary" onclick="trigger('me::ip_block_question', ['{{ question[0].id }}'])">{{ text "auth:action.ip_block" }}</button>
|
<button type="button" class="red quaternary" onclick="trigger('me::ip_block_question', ['{{ question[0].id }}'])">{{ text "auth:action.ip_block" }}</button>
|
||||||
|
@ -166,16 +173,30 @@
|
||||||
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: "{{ config.town_square }}",
|
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) => {
|
||||||
|
|
|
@ -43,9 +43,13 @@
|
||||||
></textarea>
|
></textarea>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="files_list" class="flex gap-2 flex-wrap"></div>
|
||||||
|
|
||||||
<div class="flex gap-2">
|
<div class="flex gap-2">
|
||||||
{{ components::emoji_picker(element_id="content",
|
{{ components::emoji_picker(element_id="content",
|
||||||
render_dialog=true) }}
|
render_dialog=true) }} {% if is_supporter %} {{
|
||||||
|
components::file_picker(files_list_id="files_list") }} {% endif
|
||||||
|
%}
|
||||||
|
|
||||||
<button class="primary">
|
<button class="primary">
|
||||||
{{ text "communities:action.create" }}
|
{{ text "communities:action.create" }}
|
||||||
|
@ -294,6 +298,12 @@
|
||||||
// create body
|
// create body
|
||||||
const body = new FormData();
|
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.append(
|
||||||
"body",
|
"body",
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue