12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?php
- use manager\models\Comments;
- use yii\helpers\Html;
- use yii\helpers\Url;
- use yii\grid\ActionColumn;
- use yii\grid\GridView;
- /** @var yii\web\View $this */
- /** @var yii\data\ActiveDataProvider $dataProvider */
- $this->title = 'Список комментариев';
- $this->params['breadcrumbs'][] = $this->title;
- ?>
- <div class="comments-index">
- <?php \yii\widgets\Pjax::begin([
- 'timeout'=>5000,
- 'enablePushState'=>false
- ])?>
- <?= GridView::widget([
- 'dataProvider' => $dataProvider,
- 'layout' => "{errors}\n{summary}\n{pager}\n{items}\n{pager}",
- 'pager' => [
- 'prevPageCssClass' => 'page-item',
- 'firstPageLabel' => 'Начало',
- 'lastPageLabel' => 'Конец',
- 'linkOptions' => [ 'class'=>'page-link'],
- 'pageCssClass' => 'page-item',
- 'disabledListItemSubTagOptions' => ['tag' => 'a', 'class' => 'page-link'],
- ],
- 'columns' => [
- 'created_at',
- ['label'=>"Новость","format"=>"raw","value"=>fn($model)=>isset( $model->post->title )?Html::a($model->post->title,$model->post->getUrl(),["target"=>"_blank"]).Html::a(" <i class='fas fa-edit'></i>",['/manager/news/update','id'=>$model->post->id],['target'=>"_blank"]):''],
- 'message:ntext',
- 'fakename',
- ['label'=>"Модерация","format"=>"raw","value"=>function($model){
- /**
- * @var $model Comments
- */
- $moderate_button_class = $model->visible=="Y"?"btn-danger":"btn-success";
- return Html::a($model->visible=="Y"?"Скрыть":"Пропустить",['/manager/comments/toggle',"id"=>$model->id,"value"=>$model->visible=="Y"?"N":"Y"],['class'=>"btn {$moderate_button_class}"]);
- }],
- [
- 'class' => ActionColumn::className(),
- 'template' => '{view}{update}{filter}{delete}',
- 'urlCreator' => function ($action, Comments $model, $key, $index, $column) {
- return Url::toRoute([$action, 'id' => $model->id]);
- },
- 'buttons' =>
- [
- 'filter' => function ($url, $model, $key) {
- return Html::a("<i class='fas fa-filter'></i>", $url, ['class' => 'btn btn-default btn-sm', 'title' => 'Фильтр на основе коментария']);
- },
- ],
- 'buttonOptions' => ['class' => 'btn btn-default btn-sm'],
- 'contentOptions'=>['style'=>'min-width: 180px;'],
- 'options' =>
- [
- 'class' => 'nowrap',
- ],
- ],
- ],
- ]); ?>
- <?php \yii\widgets\Pjax::end()?>
- </div>
|