From d48f75890f3444e08ad9972fb1fa7cccd75d1816 Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 9 Aug 2019 17:11:59 +0200 Subject: [PATCH] Allow to display media --- src/Form/ComposeType.php | 2 ++ src/SocialEntity/Compose.php | 20 +++++++++++ templates/fediplan/schedule.html.twig | 52 +++++++++++++++++++++------ 3 files changed, 64 insertions(+), 10 deletions(-) diff --git a/src/Form/ComposeType.php b/src/Form/ComposeType.php index 352cbee..3f059b2 100644 --- a/src/Form/ComposeType.php +++ b/src/Form/ComposeType.php @@ -11,6 +11,7 @@ namespace App\Form; use App\SocialEntity\Compose; use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\Extension\Core\Type\CheckboxType; use Symfony\Component\Form\Extension\Core\Type\CollectionType; use Symfony\Component\Form\Extension\Core\Type\FileType; use Symfony\Component\Form\Extension\Core\Type\TextareaType; @@ -44,6 +45,7 @@ class ComposeType extends AbstractType { 'status.visibility.direct' => 'direct', ] ]); + $builder->add('sensitive', CheckboxType::class); $builder->add('scheduled_at', \Symfony\Component\Form\Extension\Core\Type\DateTimeType::class,[ 'widget' => 'single_text', ]); diff --git a/src/SocialEntity/Compose.php b/src/SocialEntity/Compose.php index 5edf960..a9bfe3a 100644 --- a/src/SocialEntity/Compose.php +++ b/src/SocialEntity/Compose.php @@ -27,6 +27,8 @@ class Compose private $sent_at; + private $sensitive; + private $social_account; private $in_reply_to_id; @@ -91,6 +93,24 @@ class Compose return $this; } + + + /** + * @return boolean + */ + public function getSensitive() + { + return $this->sensitive; + } + + /** + * @param mixed $sensitive + */ + public function setSensitive(bool $sensitive): void + { + $this->sensitive = $sensitive; + } + /** * @return Collection|Media[] */ diff --git a/templates/fediplan/schedule.html.twig b/templates/fediplan/schedule.html.twig index 4a07e08..737418d 100644 --- a/templates/fediplan/schedule.html.twig +++ b/templates/fediplan/schedule.html.twig @@ -48,6 +48,7 @@ +
@@ -65,7 +66,21 @@
- +
+
+
+ {{ form_label(form.sensitive) }} + {{ form_widget(form.sensitive) }} + {% if not form.sensitive.vars.errors is empty %} + + {% for errorItem in form.sensitive.vars.errors %} + {{ errorItem.message }} + {% endfor %} + + {% endif %} +
+
+
@@ -85,21 +100,17 @@
+ +
+
- -
@@ -107,7 +118,7 @@ Add files... - +
+ {% endblock %} @@ -319,6 +331,25 @@ }, success: function (data) { + var content; + content = '
\n' + + '
\n' + + ' \n' + + '
\n' + + '
\n' + + ' \n' + + '
\n' + + ' \n' + + '
\n' + + ' \n' + + '
\n' + + '
' + + $('#media_container').html($('#media_container').html() + content); + }, url: 'https://{{ instance }}/api/v1/media' }); @@ -351,6 +382,7 @@ }); var setHeader = function (xhr) { xhr.setRequestHeader('Authorization', '{{ token }}'); + xhr.setRequestHeader('Accept', 'application/json, text/plain, */*'); };