From 19a2325a25a0c7b0eb119c03ac2e5692283571ec Mon Sep 17 00:00:00 2001 From: Maxim Leshchenko Date: Sat, 25 Dec 2021 19:47:18 +0200 Subject: [PATCH] Users: Do not reload page when changing status through a popup --- Web/Presenters/UserPresenter.php | 11 ++++++----- Web/Presenters/templates/User/View.xml | 26 +++++++++++++++++++++++--- Web/static/css/style.css | 12 ++++++++++-- 3 files changed, 39 insertions(+), 10 deletions(-) diff --git a/Web/Presenters/UserPresenter.php b/Web/Presenters/UserPresenter.php index 3c559cf3..8066f11e 100644 --- a/Web/Presenters/UserPresenter.php +++ b/Web/Presenters/UserPresenter.php @@ -134,7 +134,7 @@ final class UserPresenter extends OpenVKPresenter $user = $this->users->get($id); if($_SERVER["REQUEST_METHOD"] === "POST") { - $this->willExecuteWriteAction(); + $this->willExecuteWriteAction($_GET['act'] === "status"); if($_GET['act'] === "main" || $_GET['act'] == NULL) { $user->setFirst_Name(empty($this->postParam("first_name")) ? $user->getFirstName() : $this->postParam("first_name")); @@ -196,15 +196,15 @@ final class UserPresenter extends OpenVKPresenter } elseif($_GET['act'] === "status") { if(mb_strlen($this->postParam("status")) > 255) { $statusLength = (string) mb_strlen($this->postParam("status")); - $this->flashFail("err", "Ошибка", "Статус слишком длинный ($statusLength символов вместо 255 символов)"); + $this->flashFail("err", "Ошибка", "Статус слишком длинный ($statusLength символов вместо 255 символов)", NULL, true); } $user->setStatus(empty($this->postParam("status")) ? NULL : $this->postParam("status")); $user->save(); - header("HTTP/1.1 302 Found"); - header("Location: /id" . $user->getId()); - exit; + $this->returnJson([ + "success" => true + ]); } try { @@ -376,6 +376,7 @@ final class UserPresenter extends OpenVKPresenter "menu_grupoj" => "groups", "menu_novajoj" => "news", "menu_ligiloj" => "links", + "menu_audioj" => "audios", ]; foreach($settings as $checkbox => $setting) $user->setLeftMenuItemStatus($setting, $this->checkbox($checkbox)); diff --git a/Web/Presenters/templates/User/View.xml b/Web/Presenters/templates/User/View.xml index 46a50eb6..261a92fa 100644 --- a/Web/Presenters/templates/User/View.xml +++ b/Web/Presenters/templates/User/View.xml @@ -316,12 +316,12 @@
{$alert}
{var thatIsThisUser = isset($thisUser) && $user->getId() == $thisUser->getId()}
@@ -543,7 +543,7 @@ } -
diff --git a/Web/static/css/style.css b/Web/static/css/style.css index 067d4eac..564b850a 100644 --- a/Web/static/css/style.css +++ b/Web/static/css/style.css @@ -416,7 +416,7 @@ table { box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);; padding: 10px; float: right; - margin-top: 5px; + margin-top: 6px; margin-left: -6px; } @@ -440,7 +440,15 @@ table { } .button:hover { - color: #e8e8e8; + color: #e8e8e8; +} + +.button-loading { + display: inline-block; + background-image: url('/assets/packages/static/openvk/img/loading_mini.gif'); + width: 30px; + height: 7px; + margin-left: -3px; } input[class=button] {