From 26f01c4c929c770e1cfa982697ba1da33c1deb0a Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Fri, 4 Sep 2020 19:36:37 +0000 Subject: [PATCH] [Posting] Fix posting form name and css --- components/Posting/Posting.php | 2 +- plugins/Favourite/Favourite.php | 32 ++++++++++---------- plugins/Repeat/Repeat.php | 34 ++++++++++++---------- public/assets/css/network/public.css | 24 +++++++-------- public/assets/css/network/public_mid.css | 25 ++++++++-------- public/assets/css/network/public_small.css | 24 +++++++-------- templates/network/public.html.twig | 4 +-- 7 files changed, 73 insertions(+), 72 deletions(-) diff --git a/components/Posting/Posting.php b/components/Posting/Posting.php index 7aecec71ac..9b958e837a 100644 --- a/components/Posting/Posting.php +++ b/components/Posting/Posting.php @@ -61,7 +61,7 @@ class Posting extends Module ['attachments', FileType::class, ['label' => ' ', 'data' => null, 'multiple' => true, 'required' => false]], ['visibility', ChoiceType::class, ['label' => _m('Visibility:'), 'expanded' => true, 'choices' => [_m('Public') => 'public', _m('Instance') => 'instance', _m('Private') => 'private']]], ['to', ChoiceType::class, ['label' => _m('To:'), 'multiple' => true, 'expanded' => true, 'choices' => $to_tags]], - ['send', SubmitType::class, ['label' => _m('Send')]], + ['post', SubmitType::class, ['label' => _m('Post')]], ]); $form->handleRequest($request); diff --git a/plugins/Favourite/Favourite.php b/plugins/Favourite/Favourite.php index 4682954095..96357ad89f 100644 --- a/plugins/Favourite/Favourite.php +++ b/plugins/Favourite/Favourite.php @@ -41,28 +41,28 @@ class Favourite extends Module ['note_id', HiddenType::class, ['data' => $note->getId()]], ['favourite', SubmitType::class, ['label' => ' ']], ]); - $form->handleRequest($request); - if ($form->isSubmitted()) { - $data = $form->getData(); - var_dump($data); - - $fave = DB::find('favourite', $opts); - if ($data['note_id'] == $note->getId() && $form->isValid()) { - // Loose comparison - if (!$data['is_set'] && ($fave == null)) { - DB::persist(Fave::create($opts)); - DB::flush(); + if ('POST' === $request->getMethod() && $request->request->has('favourite')) { + $form->handleRequest($request); + if ($form->isSubmitted()) { + $data = $form->getData(); + $fave = DB::find('favourite', $opts); + if ($data['note_id'] == $note->getId() && $form->isValid()) { + // Loose comparison + if (!$data['is_set'] && ($fave == null)) { + DB::persist(Fave::create($opts)); + DB::flush(); + } else { + DB::remove($fave); + DB::flush(); + } } else { - DB::remove($fave); - DB::flush(); + // TODO display errors } - } else { - // TODO display errors } } $actions['post_fav'] = $form->createView(); return Event::next; } -} \ No newline at end of file +} diff --git a/plugins/Repeat/Repeat.php b/plugins/Repeat/Repeat.php index 57a6f9c29e..d403f33a56 100644 --- a/plugins/Repeat/Repeat.php +++ b/plugins/Repeat/Repeat.php @@ -39,27 +39,29 @@ class Repeat extends Module ['note_id', HiddenType::class, ['data' => $note->getId()]], ['repeat', SubmitType::class, ['label' => ' ']], ]); - $form->handleRequest($request); - if ($form->isSubmitted()) { - $data = $form->getData(); - if ($data['note_id'] == $to_repeat && $form->isValid()) { - // Loose comparison - if (!$data['is_set']) { - var_dump($note); - die(); - DB::persist(Note::create(['repeat_of' => $note->getId(), 'content' => $note->getContent(), 'is_local' => true])); - DB::flush(); + if ('POST' === $request->getMethod() && $request->request->has('repeat')) { + $form->handleRequest($request); + if ($form->isSubmitted()) { + $data = $form->getData(); + if ($data['note_id'] == $to_repeat && $form->isValid()) { + // Loose comparison + if (!$data['is_set']) { + var_dump($note); + die(); + DB::persist(Note::create(['repeat_of' => $note->getId(), 'content' => $note->getContent(), 'is_local' => true])); + DB::flush(); + } else { + DB::remove($to_repeat); + DB::flush(); + } } else { - DB::remove($to_repeat); - DB::flush(); + // TODO display errors } - } else { - // TODO display errors } } - $actions['post_repeat'] = $form->createView(); + $actions[] = $form->createView(); return Event::next; } -} \ No newline at end of file +} diff --git a/public/assets/css/network/public.css b/public/assets/css/network/public.css index db7c82a73b..ba15ff6d3a 100644 --- a/public/assets/css/network/public.css +++ b/public/assets/css/network/public.css @@ -244,11 +244,11 @@ font-weight: 800; font-family: var(--head-font); } -.target #form_to { +.target #post_to { font-weight: 400; font-family: var(--main-font); } -.target #form_to label { +.target #post_to label { margin-left: 0.2em; } @@ -275,13 +275,13 @@ font-weight: 800; font-family: var(--head-font); } -#form_visibility .required { +#post_visibility .required { font-family: var(--main-font); font-weight: 400; margin-left: 0.1em; margin-right: 1em; } -.scope #form_scope { +.scope #post_scope { order: 2; flex-grow: 1; flex-shrink: 1; @@ -300,7 +300,7 @@ flex-grow: 1; flex-shrink: 0; } -#form_content { +#post_content { background-color: var(--bg3); padding: var(--unit-size); color: var(--fg); @@ -322,16 +322,16 @@ background-color: var(--bg3); border-radius: 0 0 var(--unit-size) 0; } -.send { +.post { order: 2; width: calc(100% - var(--main-size)); } -.send div { +.post div { float: right; vertical-align: middle; } -#form_attachments { +#post_attachments { width: 0.1px; height: 0.1px; opacity: 0; @@ -339,11 +339,11 @@ position: absolute; z-index: -1; } -#form_attachments + label { +#post_attachments + label { cursor: pointer; } -#form_attachments:focus + label, -#form_attachments + label:hover { +#post_attachments:focus + label, +#post_attachments + label:hover { border-radius: var(--unit-size); box-shadow: 0 0px 8px var(--accent); } @@ -361,4 +361,4 @@ margin-bottom: -0.5em; cursor: pointer; z-index: 0; -} \ No newline at end of file +} diff --git a/public/assets/css/network/public_mid.css b/public/assets/css/network/public_mid.css index 6effb7b818..fb6bfe2095 100644 --- a/public/assets/css/network/public_mid.css +++ b/public/assets/css/network/public_mid.css @@ -219,11 +219,11 @@ font-weight: 800; font-family: var(--head-font); } -.target #form_to { +.target #post_to { font-weight: 400; font-family: var(--main-font); } -.target #form_to label { +.target #post_to label { margin-left: 0.2em; } @@ -250,13 +250,13 @@ font-weight: 800; font-family: var(--head-font); } -#form_visibility .required { +#post_visibility .required { font-family: var(--main-font); font-weight: 400; margin-left: 0.1em; margin-right: 1em; } -.scope #form_scope { +.scope #post_scope { order: 2; flex-grow: 1; flex-shrink: 1; @@ -275,7 +275,7 @@ flex-grow: 1; flex-shrink: 0; } -#form_content { +#post_content { background-color: var(--bg3); padding: var(--unit-size); color: var(--fg); @@ -297,16 +297,16 @@ background-color: var(--bg3); border-radius: 0 0 var(--unit-size) 0; } -.send { +.post { order: 2; width: calc(100% - var(--main-size)); } -.send div { +.post div { float: right; vertical-align: middle; } -#form_attachments { +#post_attachments { width: 0.1px; height: 0.1px; opacity: 0; @@ -314,11 +314,11 @@ position: absolute; z-index: -1; } -#form_attachments + label { +#post_attachments + label { cursor: pointer; } -#form_attachments:focus + label, -#form_attachments + label:hover { +#post_attachments:focus + label, +#post_attachments + label:hover { border-radius: var(--unit-size); box-shadow: 0 0px 8px var(--accent); } @@ -343,7 +343,6 @@ height: var(--main-size); display: flex; margin-left: var(--unit-size); - } #form_repeat { cursor: pointer; @@ -362,4 +361,4 @@ background-size: 100%; width: 100%; height: 100%; -} \ No newline at end of file +} diff --git a/public/assets/css/network/public_small.css b/public/assets/css/network/public_small.css index 626f80d5a5..5741164613 100644 --- a/public/assets/css/network/public_small.css +++ b/public/assets/css/network/public_small.css @@ -246,11 +246,11 @@ font-weight: 800; font-family: var(--head-font); } -.target #form_to { +.target #post_to { font-weight: 400; font-family: var(--main-font); } -.target #form_to label { +.target #post_to label { margin-left: 0.2em; } @@ -277,13 +277,13 @@ font-weight: 800; font-family: var(--head-font); } -#form_visibility .required { +#post_visibility .required { font-family: var(--main-font); font-weight: 400; margin-left: 0.1em; margin-right: 1em; } -.scope #form_scope { +.scope #post_scope { order: 2; flex-grow: 1; flex-shrink: 1; @@ -302,7 +302,7 @@ flex-grow: 1; flex-shrink: 0; } -#form_content { +#post_content { background-color: var(--bg3); padding: var(--unit-size); color: var(--fg); @@ -324,16 +324,16 @@ background-color: var(--bg3); border-radius: 0 0 var(--unit-size) 0; } -.send { +.post { order: 2; width: calc(100% - var(--main-size)); } -.send div { +.post div { float: right; vertical-align: middle; } -#form_attachments { +#post_attachments { width: 0.1px; height: 0.1px; opacity: 0; @@ -341,11 +341,11 @@ position: absolute; z-index: -1; } -#form_attachments + label { +#post_attachments + label { cursor: pointer; } -#form_attachments:focus + label, -#form_attachments + label:hover { +#post_attachments:focus + label, +#post_attachments + label:hover { border-radius: var(--unit-size); box-shadow: 0 0px 8px var(--accent); } @@ -363,4 +363,4 @@ margin-bottom: -0.5em; cursor: pointer; z-index: 0; -} \ No newline at end of file +} diff --git a/templates/network/public.html.twig b/templates/network/public.html.twig index 093f3ede42..8562725182 100644 --- a/templates/network/public.html.twig +++ b/templates/network/public.html.twig @@ -55,8 +55,8 @@ -
- {{ form_row(post_form.send) }} +
+ {{ form_row(post_form.post) }}