Merge branch 'master' into develop

This commit is contained in:
Lucas Bartholemy 2021-02-08 18:49:21 +01:00
commit 17b1618603
4 changed files with 34 additions and 4 deletions

View File

@ -8,6 +8,8 @@ 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+)
- Fix #4825: Ensure unique setting values (Added unique table index)

View File

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

View File

@ -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());

View File

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