From 0874a48727b08acd8ce6e16a78a4f615a80de5fb Mon Sep 17 00:00:00 2001 From: Yuriy Bakhtin Date: Thu, 4 Feb 2021 18:12:50 +0300 Subject: [PATCH 1/2] Close modal window on click link with url in href (#4812) --- CHANGELOG.md | 1 + static/js/humhub/humhub.ui.modal.js | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b0adc0de20..70a1ed9189 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ HumHub Changelog - Fix #4793: Form labels (HForm) are not displayed correctly - Fix #4569: Prevent double module registration - Fix #4389: Require to check a checkbox if the profile field is required +- Fix #2950: Close modal window on click link with url in href - Fix #3687: Disable profile field type for existing record - Fix #4819: Fixed some PHP8 issues. (Updated to Yii 2.0.40 / Imagine 1.0+) - Fix #4825: Ensure unique setting values (Added unique table index) diff --git a/static/js/humhub/humhub.ui.modal.js b/static/js/humhub/humhub.ui.modal.js index a5362c5903..2ecb4d1bde 100644 --- a/static/js/humhub/humhub.ui.modal.js +++ b/static/js/humhub/humhub.ui.modal.js @@ -696,6 +696,15 @@ humhub.module('ui.modal', function (module, require, $) { }); }; + var unload = function() { + $('.modal').each(function () { + var modal = Modal.instance(this); + if (modal && typeof modal.close === 'function') { + modal.close(); + } + }); + } + var post = function (evt, options) { var id = evt.$trigger.data('modal-id'); if (!id) { @@ -756,6 +765,7 @@ humhub.module('ui.modal', function (module, require, $) { get: get, post: post, load: load, + unload: unload, show: show, submit: submit }); From 09cdaf37cfa5f2229cfa31e015868f13de6b6c67 Mon Sep 17 00:00:00 2001 From: Yuriy Bakhtin Date: Mon, 8 Feb 2021 15:47:13 +0300 Subject: [PATCH 2/2] Update space chooser after following a space (#4815) --- CHANGELOG.md | 1 + .../resources/js/humhub.content.container.js | 15 +++++++++++++-- .../modules/space/controllers/SpaceController.php | 11 +++++++++-- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 70a1ed9189..08eccc5e66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ HumHub Changelog - Fix #4793: Form labels (HForm) are not displayed correctly - Fix #4569: Prevent double module registration - Fix #4389: Require to check a checkbox if the profile field is required +- Fix #4281: Update space chooser after following a space - Fix #2950: Close modal window on click link with url in href - Fix #3687: Disable profile field type for existing record - Fix #4819: Fixed some PHP8 issues. (Updated to Yii 2.0.40 / Imagine 1.0+) diff --git a/protected/humhub/modules/content/resources/js/humhub.content.container.js b/protected/humhub/modules/content/resources/js/humhub.content.container.js index f2e782cb13..5b34b86ff5 100644 --- a/protected/humhub/modules/content/resources/js/humhub.content.container.js +++ b/protected/humhub/modules/content/resources/js/humhub.content.container.js @@ -7,11 +7,17 @@ humhub.module('content.container', function (module, require, $) { var client = require('client'); var additions = require('ui.additions'); + var chooser = require('space.chooser'); var follow = function(evt) { var containerId = evt.$trigger.data('content-container-id'); client.post(evt).then(function(response) { - additions.switchButtons(evt.$trigger, $('[data-content-container-id="'+containerId+'"].unfollowButton')); + if (response.success) { + additions.switchButtons(evt.$trigger, $('[data-content-container-id="' + containerId + '"].unfollowButton')); + if (response.space) { + chooser.SpaceChooser.instance($('#space-menu-dropdown')).appendItem(response.space); + } + } }).catch(function(e) { module.log.error(e, true); }); @@ -20,7 +26,12 @@ humhub.module('content.container', function (module, require, $) { var unfollow = function(evt) { var containerId = evt.$trigger.data('content-container-id'); client.post(evt).then(function(response) { - additions.switchButtons(evt.$trigger, $('[data-content-container-id="'+containerId+'"].followButton')); + if (response.success) { + additions.switchButtons(evt.$trigger, $('[data-content-container-id="' + containerId + '"].followButton')); + if (response.space) { + chooser.SpaceChooser.instance($('#space-menu-dropdown')).removeItem(response.space); + } + } }).catch(function(e) { module.log.error(e, true); }); diff --git a/protected/humhub/modules/space/controllers/SpaceController.php b/protected/humhub/modules/space/controllers/SpaceController.php index 55d2fcaca2..ab2be1f7ae 100644 --- a/protected/humhub/modules/space/controllers/SpaceController.php +++ b/protected/humhub/modules/space/controllers/SpaceController.php @@ -11,6 +11,7 @@ namespace humhub\modules\space\controllers; use humhub\modules\content\components\ContentContainerController; use humhub\components\behaviors\AccessControl; use humhub\modules\space\models\Space; +use humhub\modules\space\widgets\Chooser; use humhub\modules\user\models\User; use humhub\modules\user\widgets\UserListBox; use humhub\modules\stream\actions\ContentContainerStream; @@ -127,7 +128,10 @@ class SpaceController extends ContentContainerController } if (Yii::$app->request->isAjax) { - return $this->asJson(['success' => $success]); + return $this->asJson([ + 'success' => $success, + 'space' => Chooser::getSpaceResult($space, true, ['isFollowing' => true]), + ]); } return $this->redirect($space->getUrl()); @@ -144,7 +148,10 @@ class SpaceController extends ContentContainerController $success = $space->unfollow(); if (Yii::$app->request->isAjax) { - return $this->asJson(['success' => $success]); + return $this->asJson([ + 'success' => $success, + 'space' => $space->guid, + ]); } return $this->redirect($space->getUrl());