add filters, refactoring
This commit is contained in:
@ -1,10 +1,17 @@
|
||||
<?php
|
||||
|
||||
use common\helpers\AnswerHelper;
|
||||
use common\helpers\StatusHelper;
|
||||
use common\helpers\TimeHelper;
|
||||
use yii\grid\GridView;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\DetailView;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\questionnaire\models\Question */
|
||||
/* @var $answerSearchModel backend\modules\questionnaire\models\Question */
|
||||
/* @var $answerDataProvider backend\modules\questionnaire\models\Question */
|
||||
|
||||
$this->title = $model->question_body;
|
||||
$this->params['breadcrumbs'][] = ['label' => 'Questions', 'url' => ['index']];
|
||||
@ -31,15 +38,11 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
'id',
|
||||
[
|
||||
'attribute' => 'question_type_id',
|
||||
'value' => function($model){
|
||||
return $model->getQuestionTitle();
|
||||
}
|
||||
'value' => ArrayHelper::getValue($model, 'questionType.question_type'),
|
||||
],
|
||||
[
|
||||
'attribute' => 'questionnaire_id',
|
||||
'value' => function($model){
|
||||
return $model->getQuestionnaireTitle();
|
||||
}
|
||||
'value' => ArrayHelper::getValue($model,'questionnaire.title'),
|
||||
],
|
||||
'question_body',
|
||||
'question_priority',
|
||||
@ -47,22 +50,81 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
[
|
||||
'attribute' => 'status',
|
||||
'format' => 'raw',
|
||||
'filter' => \common\helpers\StatusHelper::statusList(),
|
||||
'value' => function ($model) {
|
||||
return \common\helpers\StatusHelper::statusLabel($model->status);
|
||||
},
|
||||
'filter' => StatusHelper::statusList(),
|
||||
'value' => StatusHelper::statusLabel($model->status),
|
||||
],
|
||||
'created_at',
|
||||
'updated_at',
|
||||
[
|
||||
'attribute' => 'time_limit',
|
||||
'format' => 'raw',
|
||||
'value' => function($model){
|
||||
return \common\helpers\TimeHelper::limitTime($model->time_limit);
|
||||
}
|
||||
'value' => TimeHelper::limitTime($model->time_limit),
|
||||
],
|
||||
'score'
|
||||
],
|
||||
]) ?>
|
||||
|
||||
<div>
|
||||
<h2>
|
||||
<?= 'Ответы: '?>
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
<?= GridView::widget([
|
||||
'dataProvider' => $answerDataProvider,
|
||||
'filterModel' => $answerSearchModel,
|
||||
'columns' => [
|
||||
['class' => 'yii\grid\SerialColumn'],
|
||||
'answer_body',
|
||||
[
|
||||
'attribute' => 'answer_flag',
|
||||
'format' => 'raw',
|
||||
'filter' => AnswerHelper::answerFlagsList(),
|
||||
'value' => function ($model) {
|
||||
return AnswerHelper::answerStatusLabel($model->answer_flag);
|
||||
},
|
||||
],
|
||||
[
|
||||
'attribute' => 'status',
|
||||
'format' => 'raw',
|
||||
'filter' => StatusHelper::statusList(),
|
||||
'value' => function($model){
|
||||
return StatusHelper::statusLabel($model->status);
|
||||
}
|
||||
],
|
||||
[
|
||||
'class' => 'yii\grid\ActionColumn',
|
||||
'template' => '{view} {update} {delete}',
|
||||
'controller' => 'answer',
|
||||
'buttons' => [
|
||||
|
||||
'update' => function ($url,$model) {
|
||||
return Html::a(
|
||||
'<span class="glyphicon glyphicon-pencil"></span>',
|
||||
['answer/update', 'id' => $model['id'], 'question_id' => $model['question_id']]);
|
||||
},
|
||||
'delete' => function ($url,$model) {
|
||||
return Html::a(
|
||||
'<span class="glyphicon glyphicon-trash"></span>',
|
||||
[
|
||||
'answer/delete', 'id' => $model['id'], 'question_id' => $model['question_id']
|
||||
],
|
||||
[
|
||||
'data' => ['confirm' => 'Вы уверены, что хотите удалить этот вопрос?', 'method' => 'post']
|
||||
]
|
||||
);
|
||||
},
|
||||
],
|
||||
],
|
||||
],
|
||||
]); ?>
|
||||
|
||||
<p>
|
||||
<?= Html::a(
|
||||
'Добавить новый ответ',
|
||||
['answer/create', 'question_id' => $model->id],
|
||||
['class' => 'btn btn-primary']
|
||||
) ?>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user