mirror of
https://github.com/humhub/humhub.git
synced 2025-01-17 14:18:27 +01:00
Improve comment buttons style (#5562)
* Improve comment buttons style * Improve post buttons style on edit mode * Fix hidden comment form on reply with errors * FileHandler buttons for comment * FileHandler buttons for post edit form * Fix tests
This commit is contained in:
parent
3e9be9b007
commit
877066b9fc
@ -15,7 +15,7 @@ use humhub\modules\comment\models\forms\CommentForm;
|
|||||||
use humhub\modules\comment\Module;
|
use humhub\modules\comment\Module;
|
||||||
use humhub\modules\comment\widgets\Form;
|
use humhub\modules\comment\widgets\Form;
|
||||||
use humhub\modules\content\components\ContentActiveRecord;
|
use humhub\modules\content\components\ContentActiveRecord;
|
||||||
use humhub\modules\content\models\Content;
|
use humhub\modules\file\handler\FileHandlerCollection;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\data\Pagination;
|
use yii\data\Pagination;
|
||||||
use yii\web\HttpException;
|
use yii\web\HttpException;
|
||||||
@ -134,7 +134,8 @@ class CommentController extends Controller
|
|||||||
|
|
||||||
return $this->renderAjaxContent(Form::widget([
|
return $this->renderAjaxContent(Form::widget([
|
||||||
'object' => $this->target,
|
'object' => $this->target,
|
||||||
'model' => $form->comment
|
'model' => $form->comment,
|
||||||
|
'isHidden' => false,
|
||||||
]));
|
]));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -171,7 +172,8 @@ class CommentController extends Controller
|
|||||||
'comment' => $comment,
|
'comment' => $comment,
|
||||||
'objectModel' => $comment->object_model,
|
'objectModel' => $comment->object_model,
|
||||||
'objectId' => $comment->object_id,
|
'objectId' => $comment->object_id,
|
||||||
'submitUrl' => $submitUrl
|
'submitUrl' => $submitUrl,
|
||||||
|
'fileHandlers' => FileHandlerCollection::getByType([FileHandlerCollection::TYPE_IMPORT, FileHandlerCollection::TYPE_CREATE]),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use humhub\modules\file\handler\BaseFileHandler;
|
||||||
|
use humhub\modules\file\widgets\FileHandlerButtonDropdown;
|
||||||
use humhub\modules\file\widgets\FilePreview;
|
use humhub\modules\file\widgets\FilePreview;
|
||||||
use humhub\modules\file\widgets\UploadButton;
|
use humhub\modules\file\widgets\UploadButton;
|
||||||
use humhub\modules\ui\form\widgets\ActiveForm;
|
use humhub\modules\ui\form\widgets\ActiveForm;
|
||||||
@ -12,6 +14,7 @@ use humhub\modules\content\widgets\richtext\RichTextField;
|
|||||||
/* @var $objectId integer */
|
/* @var $objectId integer */
|
||||||
/* @var $comment \humhub\modules\comment\models\Comment */
|
/* @var $comment \humhub\modules\comment\models\Comment */
|
||||||
/* @var $submitUrl string */
|
/* @var $submitUrl string */
|
||||||
|
/* @var $fileHandlers BaseFileHandler[] */
|
||||||
|
|
||||||
/** @var \humhub\modules\content\Module $contentModule */
|
/** @var \humhub\modules\content\Module $contentModule */
|
||||||
$contentModule = Yii::$app->getModule('content');
|
$contentModule = Yii::$app->getModule('content');
|
||||||
@ -35,19 +38,28 @@ $contentModule = Yii::$app->getModule('content');
|
|||||||
]
|
]
|
||||||
])->label(false) ?>
|
])->label(false) ?>
|
||||||
|
|
||||||
<div class="comment-buttons">
|
<div class="comment-buttons"><?php
|
||||||
<?= UploadButton::widget([
|
$uploadButton = UploadButton::widget([
|
||||||
'id' => 'comment_upload_' . $comment->id,
|
'id' => 'comment_upload_' . $comment->id,
|
||||||
'model' => $comment,
|
'model' => $comment,
|
||||||
'tooltip' => Yii::t('ContentModule.base', 'Attach Files'),
|
'tooltip' => Yii::t('ContentModule.base', 'Attach Files'),
|
||||||
'dropZone' => '#comment_' . $comment->id,
|
'dropZone' => '#comment_' . $comment->id,
|
||||||
'preview' => '#comment_upload_preview_' . $comment->id,
|
'preview' => '#comment_upload_preview_' . $comment->id,
|
||||||
'progress' => '#comment_upload_progress_' . $comment->id,
|
'progress' => '#comment_upload_progress_' . $comment->id,
|
||||||
'max' => $contentModule->maxAttachedFiles
|
'max' => $contentModule->maxAttachedFiles,
|
||||||
]); ?>
|
'cssButtonClass' => 'btn-sm btn-info',
|
||||||
|
]);
|
||||||
<?= Button::defaultType(Yii::t('base', 'Save'))->cssClass('btn-comment-submit')->action('editSubmit', $submitUrl)->submit()->sm() ?>
|
echo FileHandlerButtonDropdown::widget([
|
||||||
</div>
|
'primaryButton' => $uploadButton,
|
||||||
|
'handlers' => $fileHandlers,
|
||||||
|
'cssButtonClass' => 'btn-info btn-sm',
|
||||||
|
'pullRight' => true,
|
||||||
|
]);
|
||||||
|
echo Button::info()
|
||||||
|
->icon('send')
|
||||||
|
->cssClass('btn-comment-submit')->sm()
|
||||||
|
->action('editSubmit', $submitUrl)->submit();
|
||||||
|
?></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="comment_upload_progress_<?= $comment->id ?>" style="display:none; margin:10px 0;"></div>
|
<div id="comment_upload_progress_<?= $comment->id ?>" style="display:none; margin:10px 0;"></div>
|
||||||
|
@ -12,6 +12,7 @@ use humhub\components\Widget;
|
|||||||
use humhub\modules\comment\Module;
|
use humhub\modules\comment\Module;
|
||||||
use humhub\modules\comment\models\Comment as CommentModel;
|
use humhub\modules\comment\models\Comment as CommentModel;
|
||||||
use humhub\modules\content\components\ContentActiveRecord;
|
use humhub\modules\content\components\ContentActiveRecord;
|
||||||
|
use humhub\modules\file\handler\FileHandlerCollection;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\helpers\Url;
|
use yii\helpers\Url;
|
||||||
|
|
||||||
@ -40,6 +41,24 @@ class Form extends Widget
|
|||||||
*/
|
*/
|
||||||
public $mentioningUrl = '/search/mentioning/content';
|
public $mentioningUrl = '/search/mentioning/content';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
public $isHidden;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public function init()
|
||||||
|
{
|
||||||
|
parent::init();
|
||||||
|
|
||||||
|
if ($this->isHidden === null) {
|
||||||
|
// Hide the comment form for sub comments until the button is clicked
|
||||||
|
$this->isHidden = ($this->object instanceof Comment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes the widget.
|
* Executes the widget.
|
||||||
*/
|
*/
|
||||||
@ -67,6 +86,8 @@ class Form extends Widget
|
|||||||
'model' => $this->model,
|
'model' => $this->model,
|
||||||
'isNestedComment' => ($this->object instanceof CommentModel),
|
'isNestedComment' => ($this->object instanceof CommentModel),
|
||||||
'mentioningUrl' => Url::to([$this->mentioningUrl, 'id' => $this->object->content->id]),
|
'mentioningUrl' => Url::to([$this->mentioningUrl, 'id' => $this->object->content->id]),
|
||||||
|
'isHidden' => $this->isHidden,
|
||||||
|
'fileHandlers' => FileHandlerCollection::getByType([FileHandlerCollection::TYPE_IMPORT, FileHandlerCollection::TYPE_CREATE]),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use humhub\modules\content\Module;
|
use humhub\modules\content\Module;
|
||||||
|
use humhub\modules\file\handler\BaseFileHandler;
|
||||||
|
use humhub\modules\file\widgets\FileHandlerButtonDropdown;
|
||||||
use humhub\modules\ui\form\widgets\ActiveForm;
|
use humhub\modules\ui\form\widgets\ActiveForm;
|
||||||
use humhub\modules\ui\view\components\View;
|
use humhub\modules\ui\view\components\View;
|
||||||
use humhub\widgets\Button;
|
use humhub\widgets\Button;
|
||||||
@ -19,6 +21,8 @@ use humhub\modules\comment\models\Comment;
|
|||||||
/* @var $isNestedComment boolean */
|
/* @var $isNestedComment boolean */
|
||||||
/* @var $contentModule Module */
|
/* @var $contentModule Module */
|
||||||
/* @var $mentioningUrl string */
|
/* @var $mentioningUrl string */
|
||||||
|
/* @var $isHidden bool */
|
||||||
|
/* @var $fileHandlers BaseFileHandler[] */
|
||||||
|
|
||||||
$contentModule = Yii::$app->getModule('content');
|
$contentModule = Yii::$app->getModule('content');
|
||||||
$submitUrl = Url::to(['/comment/comment/post']);
|
$submitUrl = Url::to(['/comment/comment/post']);
|
||||||
@ -26,9 +30,6 @@ $submitUrl = Url::to(['/comment/comment/post']);
|
|||||||
$placeholder = ($isNestedComment)
|
$placeholder = ($isNestedComment)
|
||||||
? Yii::t('CommentModule.base', 'Write a new reply...')
|
? Yii::t('CommentModule.base', 'Write a new reply...')
|
||||||
: Yii::t('CommentModule.base', 'Write a new comment...');
|
: Yii::t('CommentModule.base', 'Write a new comment...');
|
||||||
|
|
||||||
// Hide the comment form for sub comments until the button is clicked
|
|
||||||
$isHidden = ($objectModel === Comment::class);
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div id="comment_create_form_<?= $id ?>" class="comment_create" data-ui-widget="comment.Form"
|
<div id="comment_create_form_<?= $id ?>" class="comment_create" data-ui-widget="comment.Form"
|
||||||
@ -57,21 +58,28 @@ $isHidden = ($objectModel === Comment::class);
|
|||||||
]
|
]
|
||||||
])->label(false) ?>
|
])->label(false) ?>
|
||||||
|
|
||||||
<div class="comment-buttons">
|
<div class="comment-buttons"><?php
|
||||||
<?= UploadButton::widget([
|
$uploadButton = UploadButton::widget([
|
||||||
'id' => 'comment_create_upload_' . $id,
|
'id' => 'comment_create_upload_' . $id,
|
||||||
'tooltip' => Yii::t('ContentModule.base', 'Attach Files'),
|
'tooltip' => Yii::t('ContentModule.base', 'Attach Files'),
|
||||||
'options' => ['class' => 'main_comment_upload'],
|
'options' => ['class' => 'main_comment_upload'],
|
||||||
'progress' => '#comment_create_upload_progress_' . $id,
|
'progress' => '#comment_create_upload_progress_' . $id,
|
||||||
'preview' => '#comment_create_upload_preview_' . $id,
|
'preview' => '#comment_create_upload_preview_' . $id,
|
||||||
'dropZone' => '#comment_create_form_' . $id,
|
'dropZone' => '#comment_create_form_' . $id,
|
||||||
'max' => $contentModule->maxAttachedFiles
|
'max' => $contentModule->maxAttachedFiles,
|
||||||
]); ?>
|
'cssButtonClass' => 'btn-sm btn-info',
|
||||||
|
]);
|
||||||
<?= Button::defaultType(Yii::t('CommentModule.base', 'Send'))
|
echo FileHandlerButtonDropdown::widget([
|
||||||
->cssClass('btn-comment-submit')
|
'primaryButton' => $uploadButton,
|
||||||
->action('submit', $submitUrl)->submit()->sm() ?>
|
'handlers' => $fileHandlers,
|
||||||
</div>
|
'cssButtonClass' => 'btn-info btn-sm',
|
||||||
|
'pullRight' => true,
|
||||||
|
]);
|
||||||
|
echo Button::info()
|
||||||
|
->icon('send')
|
||||||
|
->cssClass('btn-comment-submit')->sm()
|
||||||
|
->action('submit', $submitUrl)->submit();
|
||||||
|
?></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="comment_create_upload_progress_<?= $id ?>" style="display:none;margin:10px 0px;"></div>
|
<div id="comment_create_upload_progress_<?= $id ?>" style="display:none;margin:10px 0px;"></div>
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
namespace humhub\modules\content\widgets;
|
namespace humhub\modules\content\widgets;
|
||||||
|
|
||||||
use humhub\modules\content\permissions\CreatePublicContent;
|
use humhub\modules\content\permissions\CreatePublicContent;
|
||||||
use humhub\modules\stream\actions\Stream;
|
|
||||||
use humhub\modules\stream\actions\StreamEntryResponse;
|
use humhub\modules\stream\actions\StreamEntryResponse;
|
||||||
use humhub\modules\topic\models\Topic;
|
use humhub\modules\topic\models\Topic;
|
||||||
use Yii;
|
use Yii;
|
||||||
@ -88,9 +87,6 @@ class WallCreateContentForm extends Widget
|
|||||||
$canSwitchVisibility = false;
|
$canSwitchVisibility = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$fileHandlerImport = FileHandlerCollection::getByType(FileHandlerCollection::TYPE_IMPORT);
|
|
||||||
$fileHandlerCreate = FileHandlerCollection::getByType(FileHandlerCollection::TYPE_CREATE);
|
|
||||||
|
|
||||||
return $this->render('@humhub/modules/content/widgets/views/wallCreateContentForm', [
|
return $this->render('@humhub/modules/content/widgets/views/wallCreateContentForm', [
|
||||||
'form' => $this->renderForm(),
|
'form' => $this->renderForm(),
|
||||||
'contentContainer' => $this->contentContainer,
|
'contentContainer' => $this->contentContainer,
|
||||||
@ -98,7 +94,7 @@ class WallCreateContentForm extends Widget
|
|||||||
'submitButtonText' => $this->submitButtonText,
|
'submitButtonText' => $this->submitButtonText,
|
||||||
'defaultVisibility' => $defaultVisibility,
|
'defaultVisibility' => $defaultVisibility,
|
||||||
'canSwitchVisibility' => $canSwitchVisibility,
|
'canSwitchVisibility' => $canSwitchVisibility,
|
||||||
'fileHandlers' => array_merge($fileHandlerCreate, $fileHandlerImport),
|
'fileHandlers' => FileHandlerCollection::getByType([FileHandlerCollection::TYPE_IMPORT, FileHandlerCollection::TYPE_CREATE]),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,10 +13,13 @@ use humhub\modules\content\widgets\stream\StreamEntryWidget;
|
|||||||
use humhub\modules\content\widgets\stream\WallStreamEntryOptions;
|
use humhub\modules\content\widgets\stream\WallStreamEntryOptions;
|
||||||
use humhub\modules\content\widgets\WallCreateContentForm;
|
use humhub\modules\content\widgets\WallCreateContentForm;
|
||||||
use humhub\modules\content\components\ContentContainerController;
|
use humhub\modules\content\components\ContentContainerController;
|
||||||
|
use humhub\modules\file\handler\FileHandlerCollection;
|
||||||
|
use humhub\modules\post\models\forms\PostEditForm;
|
||||||
use humhub\modules\post\models\Post;
|
use humhub\modules\post\models\Post;
|
||||||
use humhub\modules\post\permissions\CreatePost;
|
use humhub\modules\post\permissions\CreatePost;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\web\HttpException;
|
use yii\web\HttpException;
|
||||||
|
use yii\web\NotFoundHttpException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 0.5
|
* @since 0.5
|
||||||
@ -70,24 +73,31 @@ class PostController extends ContentContainerController
|
|||||||
|
|
||||||
public function actionEdit($id)
|
public function actionEdit($id)
|
||||||
{
|
{
|
||||||
$model = Post::findOne(['id' => $id]);
|
$post = Post::findOne(['id' => $id]);
|
||||||
|
if (!$post) {
|
||||||
|
throw new NotFoundHttpException();
|
||||||
|
}
|
||||||
|
|
||||||
if (!$model->content->canEdit()) {
|
$model = new PostEditForm(['post' => $post]);
|
||||||
|
|
||||||
|
if (!$post->content->canEdit()) {
|
||||||
$this->forbidden();
|
$this->forbidden();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($model->load(Yii::$app->request->post())) {
|
if ($model->load(Yii::$app->request->post())) {
|
||||||
// Reload record to get populated updated_at field
|
// Reload record to get populated updated_at field
|
||||||
if ($model->validate() && $model->save()) {
|
if ($model->save()) {
|
||||||
$model = Post::findOne(['id' => $id]);
|
$post = Post::findOne(['id' => $id]);
|
||||||
return $this->renderAjaxContent(StreamEntryWidget::renderStreamEntry($model));
|
return $this->renderAjaxContent(StreamEntryWidget::renderStreamEntry($post));
|
||||||
} else {
|
} else {
|
||||||
Yii::$app->response->statusCode = 400;
|
Yii::$app->response->statusCode = 400;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->renderAjax('edit', [
|
return $this->renderAjax('edit', [
|
||||||
'post' => $model,
|
'model' => $model,
|
||||||
|
'fileHandlers' => FileHandlerCollection::getByType([FileHandlerCollection::TYPE_IMPORT, FileHandlerCollection::TYPE_CREATE]),
|
||||||
|
'submitUrl' => $post->content->container->createUrl('/post/post/edit', ['id' => $post->id]),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
100
protected/humhub/modules/post/models/forms/PostEditForm.php
Normal file
100
protected/humhub/modules/post/models/forms/PostEditForm.php
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @link https://www.humhub.org/
|
||||||
|
* @copyright Copyright (c) 2022 HumHub GmbH & Co. KG
|
||||||
|
* @license https://www.humhub.com/licences
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace humhub\modules\post\models\forms;
|
||||||
|
|
||||||
|
use humhub\modules\post\models\Post;
|
||||||
|
use Yii;
|
||||||
|
use yii\web\ServerErrorHttpException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PostEditForm
|
||||||
|
* @package humhub\modules\post\models\forms
|
||||||
|
*
|
||||||
|
* @since 1.11
|
||||||
|
*/
|
||||||
|
class PostEditForm extends yii\base\Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The list of files attached to a Post
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public $fileList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Post The edited Post
|
||||||
|
*/
|
||||||
|
public $post;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[['fileList'], 'safe'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public function load($data, $formName = null)
|
||||||
|
{
|
||||||
|
return parent::load($data, $formName) | $this->post->load($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public function validate($attributeNames = null, $clearErrors = true)
|
||||||
|
{
|
||||||
|
if (!$this->post->validate() || !parent::validate($attributeNames, $clearErrors)) {
|
||||||
|
$this->post->addError('message', Yii::t('PostModule.base', 'Post could not be saved!'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($this->post->message)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allow empty message only With attachments
|
||||||
|
if (!empty($this->fileList) || (!$this->post->isNewRecord && $this->post->fileManager->find()->count())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->post->addError('message', Yii::t('PostModule.base', 'The post must not be empty!'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saves the form
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
* @throws ServerErrorHttpException
|
||||||
|
*/
|
||||||
|
public function save()
|
||||||
|
{
|
||||||
|
if (!$this->validate()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->post->save()) {
|
||||||
|
$this->post->fileManager->attach($this->fileList);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->post->addError('message', Yii::t('PostModule.base', 'Post could not be saved!'));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public function formName()
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}
|
@ -1,54 +1,62 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use humhub\modules\file\handler\BaseFileHandler;
|
||||||
|
use humhub\modules\file\widgets\FileHandlerButtonDropdown;
|
||||||
use humhub\modules\file\widgets\FilePreview;
|
use humhub\modules\file\widgets\FilePreview;
|
||||||
use humhub\modules\file\widgets\UploadButton;
|
use humhub\modules\file\widgets\UploadButton;
|
||||||
use humhub\modules\file\widgets\UploadProgress;
|
use humhub\modules\file\widgets\UploadProgress;
|
||||||
|
use humhub\modules\post\models\forms\PostEditForm;
|
||||||
use humhub\widgets\Button;
|
use humhub\widgets\Button;
|
||||||
use humhub\modules\content\widgets\richtext\RichTextField;
|
use humhub\modules\content\widgets\richtext\RichTextField;
|
||||||
use yii\bootstrap\ActiveForm;
|
use yii\bootstrap\ActiveForm;
|
||||||
|
|
||||||
/* @var $post \humhub\modules\post\models\Post */
|
/* @var $model PostEditForm */
|
||||||
/* @var $from string */
|
/* @var $submitUrl string */
|
||||||
/* @var $submitUrl string */
|
/* @var $fileHandlers BaseFileHandler[] */
|
||||||
|
|
||||||
$submitUrl = $post->content->container->createUrl('/post/post/edit', ['id' => $post->id]);
|
|
||||||
?>
|
?>
|
||||||
|
<div class="content content_edit" id="post_edit_<?= $model->post->id; ?>">
|
||||||
<div class="content content_edit" id="post_edit_<?= $post->id; ?>">
|
<?php $form = ActiveForm::begin(['id' => 'post-edit-form_' . $model->post->id]); ?>
|
||||||
<?php $form = ActiveForm::begin(['id' => 'post-edit-form_' . $post->id]); ?>
|
|
||||||
|
|
||||||
<div class="post-richtext-input-group">
|
<div class="post-richtext-input-group">
|
||||||
<?= $form->field($post, 'message')->widget(RichTextField::class, [
|
<?= $form->field($model->post, 'message')->widget(RichTextField::class, [
|
||||||
'id' => 'post_input_'. $post->id,
|
'id' => 'post_input_'. $model->post->id,
|
||||||
'layout' => RichTextField::LAYOUT_INLINE,
|
'layout' => RichTextField::LAYOUT_INLINE,
|
||||||
'focus' => true,
|
'focus' => true,
|
||||||
'pluginOptions' => ['maxHeight' => '300px'],
|
'pluginOptions' => ['maxHeight' => '300px'],
|
||||||
'placeholder' => Yii::t('PostModule.base', 'Edit your post...')
|
'placeholder' => Yii::t('PostModule.base', 'Edit your post...')
|
||||||
])->label(false) ?>
|
])->label(false) ?>
|
||||||
|
|
||||||
<div class="comment-buttons">
|
<div class="comment-buttons"><?php
|
||||||
|
$uploadButton = UploadButton::widget([
|
||||||
<?= UploadButton::widget([
|
'id' => 'post_upload_' . $model->post->id,
|
||||||
'id' => 'post_upload_' . $post->id,
|
|
||||||
'tooltip' => Yii::t('ContentModule.base', 'Attach Files'),
|
'tooltip' => Yii::t('ContentModule.base', 'Attach Files'),
|
||||||
'model' => $post,
|
'model' => $model,
|
||||||
'dropZone' => '#post_edit_' . $post->id . ':parent',
|
'dropZone' => '#post_edit_' . $model->post->id . ':parent',
|
||||||
'preview' => '#post_upload_preview_' . $post->id,
|
'preview' => '#post_upload_preview_' . $model->post->id,
|
||||||
'progress' => '#post_upload_progress_' . $post->id,
|
'progress' => '#post_upload_progress_' . $model->post->id,
|
||||||
'max' => Yii::$app->getModule('content')->maxAttachedFiles
|
'max' => Yii::$app->getModule('content')->maxAttachedFiles,
|
||||||
]) ?>
|
'cssButtonClass' => 'btn-sm btn-info',
|
||||||
|
]);
|
||||||
<?= Button::defaultType(Yii::t('base', 'Save'))->action('editSubmit', $submitUrl)->submit()->cssClass(' btn-comment-submit')->sm() ?>
|
echo FileHandlerButtonDropdown::widget([
|
||||||
|
'primaryButton' => $uploadButton,
|
||||||
</div>
|
'handlers' => $fileHandlers,
|
||||||
|
'cssButtonClass' => 'btn-info btn-sm',
|
||||||
|
'pullRight' => true,
|
||||||
|
]);
|
||||||
|
echo Button::info()
|
||||||
|
->icon('send')
|
||||||
|
->action('editSubmit', $submitUrl)
|
||||||
|
->cssClass(' btn-comment-submit')->sm()
|
||||||
|
->submit();
|
||||||
|
?></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?= UploadProgress::widget(['id' => 'post_upload_progress_'.$post->id])?>
|
<?= UploadProgress::widget(['id' => 'post_upload_progress_'.$model->post->id]) ?>
|
||||||
|
|
||||||
<?= FilePreview::widget([
|
<?= FilePreview::widget([
|
||||||
'id' => 'post_upload_preview_' . $post->id,
|
'id' => 'post_upload_preview_' . $model->post->id,
|
||||||
'options' => ['style' => 'margin-top:10px'],
|
'options' => ['style' => 'margin-top:10px'],
|
||||||
'model' => $post,
|
'model' => $model->post,
|
||||||
'edit' => true
|
'edit' => true
|
||||||
]) ?>
|
]) ?>
|
||||||
|
|
||||||
|
@ -187,7 +187,7 @@ class StreamCest
|
|||||||
|
|
||||||
$I->waitForElementVisible($newEntrySelector . ' .content_edit', 20);
|
$I->waitForElementVisible($newEntrySelector . ' .content_edit', 20);
|
||||||
$I->fillField($newEntrySelector . ' [contenteditable]', 'This is my edited post!');
|
$I->fillField($newEntrySelector . ' [contenteditable]', 'This is my edited post!');
|
||||||
$I->click('Save', $newEntrySelector);
|
$I->click('button[data-action-click=editSubmit]', $newEntrySelector);
|
||||||
|
|
||||||
$I->wait(1);
|
$I->wait(1);
|
||||||
$I->seeElement($newEntrySelector);
|
$I->seeElement($newEntrySelector);
|
||||||
@ -267,7 +267,7 @@ class StreamCest
|
|||||||
$I->wait(1);
|
$I->wait(1);
|
||||||
$I->waitForElementVisible($postSelector . ' .comment-container', null);
|
$I->waitForElementVisible($postSelector . ' .comment-container', null);
|
||||||
$I->fillField($postSelector . ' .comment_create .humhub-ui-richtext', 'My Comment');
|
$I->fillField($postSelector . ' .comment_create .humhub-ui-richtext', 'My Comment');
|
||||||
$I->click('Send', $postSelector . ' .comment_create');
|
$I->click('[data-action-click=submit]', $postSelector . ' .comment_create');
|
||||||
$I->waitForText('My Comment', null, $postSelector . ' .comment');
|
$I->waitForText('My Comment', null, $postSelector . ' .comment');
|
||||||
|
|
||||||
|
|
||||||
@ -315,7 +315,7 @@ class StreamCest
|
|||||||
$I->click('Comment', $post4Selector);
|
$I->click('Comment', $post4Selector);
|
||||||
$I->wait(1);
|
$I->wait(1);
|
||||||
$I->fillField($post4Selector . ' [contenteditable]', 'My Comment!');
|
$I->fillField($post4Selector . ' [contenteditable]', 'My Comment!');
|
||||||
$I->click('Send', $post4Selector . ' .comment-buttons');
|
$I->click('[data-action-click=submit]', $post4Selector . ' .comment-buttons');
|
||||||
|
|
||||||
$I->scrollTop();
|
$I->scrollTop();
|
||||||
|
|
||||||
|
@ -95,56 +95,47 @@
|
|||||||
// fileupload button
|
// fileupload button
|
||||||
.comment_create,
|
.comment_create,
|
||||||
.content_edit {
|
.content_edit {
|
||||||
position: relative;
|
.comment-create-input-group, .post-richtext-input-group {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-end;
|
||||||
|
.field-comment-message, .field-post-message {
|
||||||
|
flex-grow: 1;
|
||||||
|
flex-basis: min-content;
|
||||||
|
}
|
||||||
|
.form-group, .help-block {
|
||||||
|
margin:0;
|
||||||
|
}
|
||||||
|
}
|
||||||
.comment-buttons {
|
.comment-buttons {
|
||||||
position: absolute;
|
white-space: nowrap;
|
||||||
bottom: 2px;
|
padding-bottom: 6px;
|
||||||
right: 5px;
|
.btn:not(.dropdown-toggle) {
|
||||||
z-index: 300;
|
margin-left: 6px;
|
||||||
|
}
|
||||||
button {
|
.btn.fileinput-button, .fileinput-button + .dropdown-toggle {
|
||||||
background-color: @link !important;
|
background-color: fade(@link, 60%);
|
||||||
color: @text-color-contrast !important;
|
}
|
||||||
|
.btn.dropdown-toggle {
|
||||||
|
margin-left: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.has-error + .comment-buttons {
|
.has-error + .comment-buttons {
|
||||||
bottom: 19px !important;
|
padding-bottom: 22px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-comment-submit {
|
|
||||||
margin-top: 3px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.fileinput-button {
|
|
||||||
float: left;
|
|
||||||
padding: 6px 10px;
|
|
||||||
background: transparent !important;
|
|
||||||
|
|
||||||
i {
|
|
||||||
color: @text-color-soft2;
|
|
||||||
}
|
|
||||||
|
|
||||||
i:hover {
|
|
||||||
color: @link;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.fileinput-button:hover i {
|
|
||||||
color: @link;
|
|
||||||
}
|
|
||||||
|
|
||||||
.fileinput-button:active {
|
.fileinput-button:active {
|
||||||
box-shadow: none !important;
|
box-shadow: none !important;
|
||||||
}
|
}
|
||||||
}
|
@media (max-width: 414px) {
|
||||||
|
.comment-create-input-group, .post-richtext-input-group {
|
||||||
.post-richtext-input-group {
|
flex-direction: column;
|
||||||
position: relative;
|
.field-comment-message, .field-post-message {
|
||||||
|
width: 100%;
|
||||||
.comment-buttons {
|
}
|
||||||
bottom: 7px !important;
|
}
|
||||||
|
.comment-buttons {
|
||||||
|
padding-bottom: 0 !important;
|
||||||
|
padding-top: 6px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,20 +163,6 @@
|
|||||||
.text-break();
|
.text-break();
|
||||||
}
|
}
|
||||||
|
|
||||||
.comment-create-input-group, .post-richtext-input-group {
|
|
||||||
position: relative;
|
|
||||||
|
|
||||||
.ProsemirrorEditor {
|
|
||||||
.ProseMirror {
|
|
||||||
padding-right: 72px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-group, .help-block {
|
|
||||||
margin:0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.comment-create-input-group.scrollActive {
|
.comment-create-input-group.scrollActive {
|
||||||
.comment-buttons {
|
.comment-buttons {
|
||||||
right: 22px;
|
right: 22px;
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user