[Posting] Fix posting form name and css

This commit is contained in:
Hugo Sales 2020-09-04 19:36:37 +00:00 committed by Hugo Sales
parent 07078414bb
commit 26f01c4c92
Signed by: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0
7 changed files with 73 additions and 72 deletions

View File

@ -61,7 +61,7 @@ class Posting extends Module
['attachments', FileType::class, ['label' => ' ', 'data' => null, 'multiple' => true, 'required' => false]], ['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']]], ['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]], ['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); $form->handleRequest($request);

View File

@ -41,28 +41,28 @@ class Favourite extends Module
['note_id', HiddenType::class, ['data' => $note->getId()]], ['note_id', HiddenType::class, ['data' => $note->getId()]],
['favourite', SubmitType::class, ['label' => ' ']], ['favourite', SubmitType::class, ['label' => ' ']],
]); ]);
$form->handleRequest($request);
if ($form->isSubmitted()) { if ('POST' === $request->getMethod() && $request->request->has('favourite')) {
$data = $form->getData(); $form->handleRequest($request);
var_dump($data); if ($form->isSubmitted()) {
$data = $form->getData();
$fave = DB::find('favourite', $opts); $fave = DB::find('favourite', $opts);
if ($data['note_id'] == $note->getId() && $form->isValid()) { if ($data['note_id'] == $note->getId() && $form->isValid()) {
// Loose comparison // Loose comparison
if (!$data['is_set'] && ($fave == null)) { if (!$data['is_set'] && ($fave == null)) {
DB::persist(Fave::create($opts)); DB::persist(Fave::create($opts));
DB::flush(); DB::flush();
} else {
DB::remove($fave);
DB::flush();
}
} else { } else {
DB::remove($fave); // TODO display errors
DB::flush();
} }
} else {
// TODO display errors
} }
} }
$actions['post_fav'] = $form->createView(); $actions['post_fav'] = $form->createView();
return Event::next; return Event::next;
} }
} }

View File

@ -39,27 +39,29 @@ class Repeat extends Module
['note_id', HiddenType::class, ['data' => $note->getId()]], ['note_id', HiddenType::class, ['data' => $note->getId()]],
['repeat', SubmitType::class, ['label' => ' ']], ['repeat', SubmitType::class, ['label' => ' ']],
]); ]);
$form->handleRequest($request);
if ($form->isSubmitted()) { if ('POST' === $request->getMethod() && $request->request->has('repeat')) {
$data = $form->getData(); $form->handleRequest($request);
if ($data['note_id'] == $to_repeat && $form->isValid()) { if ($form->isSubmitted()) {
// Loose comparison $data = $form->getData();
if (!$data['is_set']) { if ($data['note_id'] == $to_repeat && $form->isValid()) {
var_dump($note); // Loose comparison
die(); if (!$data['is_set']) {
DB::persist(Note::create(['repeat_of' => $note->getId(), 'content' => $note->getContent(), 'is_local' => true])); var_dump($note);
DB::flush(); 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 { } else {
DB::remove($to_repeat); // TODO display errors
DB::flush();
} }
} else {
// TODO display errors
} }
} }
$actions['post_repeat'] = $form->createView(); $actions[] = $form->createView();
return Event::next; return Event::next;
} }
} }

View File

@ -244,11 +244,11 @@
font-weight: 800; font-weight: 800;
font-family: var(--head-font); font-family: var(--head-font);
} }
.target #form_to { .target #post_to {
font-weight: 400; font-weight: 400;
font-family: var(--main-font); font-family: var(--main-font);
} }
.target #form_to label { .target #post_to label {
margin-left: 0.2em; margin-left: 0.2em;
} }
@ -275,13 +275,13 @@
font-weight: 800; font-weight: 800;
font-family: var(--head-font); font-family: var(--head-font);
} }
#form_visibility .required { #post_visibility .required {
font-family: var(--main-font); font-family: var(--main-font);
font-weight: 400; font-weight: 400;
margin-left: 0.1em; margin-left: 0.1em;
margin-right: 1em; margin-right: 1em;
} }
.scope #form_scope { .scope #post_scope {
order: 2; order: 2;
flex-grow: 1; flex-grow: 1;
flex-shrink: 1; flex-shrink: 1;
@ -300,7 +300,7 @@
flex-grow: 1; flex-grow: 1;
flex-shrink: 0; flex-shrink: 0;
} }
#form_content { #post_content {
background-color: var(--bg3); background-color: var(--bg3);
padding: var(--unit-size); padding: var(--unit-size);
color: var(--fg); color: var(--fg);
@ -322,16 +322,16 @@
background-color: var(--bg3); background-color: var(--bg3);
border-radius: 0 0 var(--unit-size) 0; border-radius: 0 0 var(--unit-size) 0;
} }
.send { .post {
order: 2; order: 2;
width: calc(100% - var(--main-size)); width: calc(100% - var(--main-size));
} }
.send div { .post div {
float: right; float: right;
vertical-align: middle; vertical-align: middle;
} }
#form_attachments { #post_attachments {
width: 0.1px; width: 0.1px;
height: 0.1px; height: 0.1px;
opacity: 0; opacity: 0;
@ -339,11 +339,11 @@
position: absolute; position: absolute;
z-index: -1; z-index: -1;
} }
#form_attachments + label { #post_attachments + label {
cursor: pointer; cursor: pointer;
} }
#form_attachments:focus + label, #post_attachments:focus + label,
#form_attachments + label:hover { #post_attachments + label:hover {
border-radius: var(--unit-size); border-radius: var(--unit-size);
box-shadow: 0 0px 8px var(--accent); box-shadow: 0 0px 8px var(--accent);
} }
@ -361,4 +361,4 @@
margin-bottom: -0.5em; margin-bottom: -0.5em;
cursor: pointer; cursor: pointer;
z-index: 0; z-index: 0;
} }

View File

@ -219,11 +219,11 @@
font-weight: 800; font-weight: 800;
font-family: var(--head-font); font-family: var(--head-font);
} }
.target #form_to { .target #post_to {
font-weight: 400; font-weight: 400;
font-family: var(--main-font); font-family: var(--main-font);
} }
.target #form_to label { .target #post_to label {
margin-left: 0.2em; margin-left: 0.2em;
} }
@ -250,13 +250,13 @@
font-weight: 800; font-weight: 800;
font-family: var(--head-font); font-family: var(--head-font);
} }
#form_visibility .required { #post_visibility .required {
font-family: var(--main-font); font-family: var(--main-font);
font-weight: 400; font-weight: 400;
margin-left: 0.1em; margin-left: 0.1em;
margin-right: 1em; margin-right: 1em;
} }
.scope #form_scope { .scope #post_scope {
order: 2; order: 2;
flex-grow: 1; flex-grow: 1;
flex-shrink: 1; flex-shrink: 1;
@ -275,7 +275,7 @@
flex-grow: 1; flex-grow: 1;
flex-shrink: 0; flex-shrink: 0;
} }
#form_content { #post_content {
background-color: var(--bg3); background-color: var(--bg3);
padding: var(--unit-size); padding: var(--unit-size);
color: var(--fg); color: var(--fg);
@ -297,16 +297,16 @@
background-color: var(--bg3); background-color: var(--bg3);
border-radius: 0 0 var(--unit-size) 0; border-radius: 0 0 var(--unit-size) 0;
} }
.send { .post {
order: 2; order: 2;
width: calc(100% - var(--main-size)); width: calc(100% - var(--main-size));
} }
.send div { .post div {
float: right; float: right;
vertical-align: middle; vertical-align: middle;
} }
#form_attachments { #post_attachments {
width: 0.1px; width: 0.1px;
height: 0.1px; height: 0.1px;
opacity: 0; opacity: 0;
@ -314,11 +314,11 @@
position: absolute; position: absolute;
z-index: -1; z-index: -1;
} }
#form_attachments + label { #post_attachments + label {
cursor: pointer; cursor: pointer;
} }
#form_attachments:focus + label, #post_attachments:focus + label,
#form_attachments + label:hover { #post_attachments + label:hover {
border-radius: var(--unit-size); border-radius: var(--unit-size);
box-shadow: 0 0px 8px var(--accent); box-shadow: 0 0px 8px var(--accent);
} }
@ -343,7 +343,6 @@
height: var(--main-size); height: var(--main-size);
display: flex; display: flex;
margin-left: var(--unit-size); margin-left: var(--unit-size);
} }
#form_repeat { #form_repeat {
cursor: pointer; cursor: pointer;
@ -362,4 +361,4 @@
background-size: 100%; background-size: 100%;
width: 100%; width: 100%;
height: 100%; height: 100%;
} }

View File

@ -246,11 +246,11 @@
font-weight: 800; font-weight: 800;
font-family: var(--head-font); font-family: var(--head-font);
} }
.target #form_to { .target #post_to {
font-weight: 400; font-weight: 400;
font-family: var(--main-font); font-family: var(--main-font);
} }
.target #form_to label { .target #post_to label {
margin-left: 0.2em; margin-left: 0.2em;
} }
@ -277,13 +277,13 @@
font-weight: 800; font-weight: 800;
font-family: var(--head-font); font-family: var(--head-font);
} }
#form_visibility .required { #post_visibility .required {
font-family: var(--main-font); font-family: var(--main-font);
font-weight: 400; font-weight: 400;
margin-left: 0.1em; margin-left: 0.1em;
margin-right: 1em; margin-right: 1em;
} }
.scope #form_scope { .scope #post_scope {
order: 2; order: 2;
flex-grow: 1; flex-grow: 1;
flex-shrink: 1; flex-shrink: 1;
@ -302,7 +302,7 @@
flex-grow: 1; flex-grow: 1;
flex-shrink: 0; flex-shrink: 0;
} }
#form_content { #post_content {
background-color: var(--bg3); background-color: var(--bg3);
padding: var(--unit-size); padding: var(--unit-size);
color: var(--fg); color: var(--fg);
@ -324,16 +324,16 @@
background-color: var(--bg3); background-color: var(--bg3);
border-radius: 0 0 var(--unit-size) 0; border-radius: 0 0 var(--unit-size) 0;
} }
.send { .post {
order: 2; order: 2;
width: calc(100% - var(--main-size)); width: calc(100% - var(--main-size));
} }
.send div { .post div {
float: right; float: right;
vertical-align: middle; vertical-align: middle;
} }
#form_attachments { #post_attachments {
width: 0.1px; width: 0.1px;
height: 0.1px; height: 0.1px;
opacity: 0; opacity: 0;
@ -341,11 +341,11 @@
position: absolute; position: absolute;
z-index: -1; z-index: -1;
} }
#form_attachments + label { #post_attachments + label {
cursor: pointer; cursor: pointer;
} }
#form_attachments:focus + label, #post_attachments:focus + label,
#form_attachments + label:hover { #post_attachments + label:hover {
border-radius: var(--unit-size); border-radius: var(--unit-size);
box-shadow: 0 0px 8px var(--accent); box-shadow: 0 0px 8px var(--accent);
} }
@ -363,4 +363,4 @@
margin-bottom: -0.5em; margin-bottom: -0.5em;
cursor: pointer; cursor: pointer;
z-index: 0; z-index: 0;
} }

View File

@ -55,8 +55,8 @@
</svg> </svg>
</label> </label>
</div> </div>
<div class="send"> <div class="post">
{{ form_row(post_form.send) }} {{ form_row(post_form.post) }}
</div> </div>
</div> </div>
</div> </div>