From a6069caaa47d510da230056f7dbae295bc4fa13b Mon Sep 17 00:00:00 2001 From: flashwave Date: Mon, 19 Sep 2016 20:32:24 +0200 Subject: [PATCH] dynamic post deletion --- app/Controllers/Forum/PostController.php | 6 ---- resources/assets/less/yuuno/dialogue.less | 1 + .../assets/typescript/Sakura/Dialogue.ts | 8 +++++ resources/assets/typescript/Yuuno.ts | 1 - resources/views/yuuno/forum/topic.twig | 29 ++++++++++++++++++- routes.php | 3 +- 6 files changed, 38 insertions(+), 10 deletions(-) diff --git a/app/Controllers/Forum/PostController.php b/app/Controllers/Forum/PostController.php index d3c6a29..221d166 100644 --- a/app/Controllers/Forum/PostController.php +++ b/app/Controllers/Forum/PostController.php @@ -215,15 +215,9 @@ class PostController extends Controller if ($topic->replyCount() === 1) { // Delete the entire topic $topic->delete(); - - $redirect = route('forums.forum', $forum->id); } else { // Just delete the post (replace this with soft deleting) $post->purge(); - - $redirect = route('forums.topic', $topic->id); } - - redirect($redirect); } } diff --git a/resources/assets/less/yuuno/dialogue.less b/resources/assets/less/yuuno/dialogue.less index bff33b4..ab1add4 100644 --- a/resources/assets/less/yuuno/dialogue.less +++ b/resources/assets/less/yuuno/dialogue.less @@ -30,6 +30,7 @@ border: 0 solid transparent; padding: 2px 4px; cursor: pointer; + margin-left: 2px; &:last-child { font-weight: 700; diff --git a/resources/assets/typescript/Sakura/Dialogue.ts b/resources/assets/typescript/Sakura/Dialogue.ts index ad61501..28f7ca9 100644 --- a/resources/assets/typescript/Sakura/Dialogue.ts +++ b/resources/assets/typescript/Sakura/Dialogue.ts @@ -6,6 +6,7 @@ namespace Sakura private Type: DialogueType = DialogueType.Info; private Callbacks: Dictionary = new Dictionary(); public static Container: string = "dialogues"; + public Reference: HTMLDivElement; public SetType(type: DialogueType): void { @@ -62,6 +63,13 @@ namespace Sakura DOM.Append(container, buttonCont); DOM.Append(DOM.ID('dialogues'), container); + this.Reference = container; + } + + public Close(): void + { + DOM.Remove(this.Reference); + this.Reference = null; } } } diff --git a/resources/assets/typescript/Yuuno.ts b/resources/assets/typescript/Yuuno.ts index e693123..9d7da07 100644 --- a/resources/assets/typescript/Yuuno.ts +++ b/resources/assets/typescript/Yuuno.ts @@ -1,6 +1,5 @@ /// /// -/// /// /// /// diff --git a/resources/views/yuuno/forum/topic.twig b/resources/views/yuuno/forum/topic.twig index 7281127..45f1c25 100644 --- a/resources/views/yuuno/forum/topic.twig +++ b/resources/views/yuuno/forum/topic.twig @@ -62,6 +62,33 @@ {% block js %} {% endblock %} @@ -93,7 +120,7 @@ {% endif %} {% if (user.id == post.poster.id and forum.permission(constant('Sakura\\Perms\\Forum::DELETE_OWN'), user.id)) or forum.permission(constant('Sakura\\Perms\\Forum::DELETE_ANY'), user.id) %} - + {% endif %} {% if not (post.poster.permission(constant('Sakura\\Perms\\Site::DEACTIVATED')) or post.poster.permission(constant('Sakura\\Perms\\Site::RESTRICTED')) or user.id == post.poster.id) %} diff --git a/routes.php b/routes.php index 97a14be..5934e60 100644 --- a/routes.php +++ b/routes.php @@ -124,9 +124,8 @@ Routerv1::group(['before' => 'maintenance'], function () { Routerv1::group(['prefix' => 'post'], function () { Routerv1::get('/{id:i}', 'Forum.PostController@find', 'forums.post'); Routerv1::group(['before' => 'loginCheck'], function () { + Routerv1::delete('/{id:i}', 'Forum.PostController@delete', 'forums.post.delete'); Routerv1::get('/{id:i}/raw', 'Forum.PostController@raw', 'forums.post.raw'); - Routerv1::get('/{id:i}/delete', 'Forum.PostController@delete', 'forums.post.delete'); - Routerv1::post('/{id:i}/delete', 'Forum.PostController@delete', 'forums.post.delete'); Routerv1::post('/{id:i}/edit', 'Forum.PostController@edit', 'forums.post.edit'); }); });