[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]],
['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);

View File

@ -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;
}
}
}

View File

@ -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;
}
}
}

View File

@ -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;
}
}

View File

@ -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%;
}
}

View File

@ -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;
}
}

View File

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