changed the creator for tasks from project_user to user, fixed api, documentation, filters, some other fixes
This commit is contained in:
@ -3,6 +3,7 @@
|
||||
use backend\modules\project\models\Project;
|
||||
use backend\modules\project\models\ProjectUser;
|
||||
use common\helpers\StatusHelper;
|
||||
use common\models\User;
|
||||
use kartik\depdrop\DepDrop;
|
||||
use kartik\select2\Select2;
|
||||
use yii\helpers\Html;
|
||||
@ -21,20 +22,19 @@ use yii\widgets\ActiveForm;
|
||||
<?= $form->field($model, 'project_id')->dropDownList(Project::find()
|
||||
->select(['name', 'id'])->indexBy('id')->column(),
|
||||
[
|
||||
'id' => 'project-id',
|
||||
'prompt' => 'Выберите'
|
||||
]
|
||||
);
|
||||
?>
|
||||
|
||||
<?= $form->field($model, 'project_user_id')->widget(DepDrop::className(),
|
||||
<?= $form->field($model, 'user_id_creator')->widget(Select2::class,
|
||||
[
|
||||
'options' => ['id' => 'project-user-id'],
|
||||
'data' => User::find()->select(['username', 'id'])->indexBy('id')->column(),
|
||||
'options' => ['placeholder' => '...','class' => 'form-control'],
|
||||
'pluginOptions' => [
|
||||
'depends' => ['project-id'],
|
||||
'placeholder' => 'Выберите',
|
||||
'url' => Url::to(['/task/task/creator'])
|
||||
]
|
||||
'allowClear' => true,
|
||||
'prompt' => 'Выберите'
|
||||
],
|
||||
]
|
||||
); ?>
|
||||
|
||||
@ -47,12 +47,21 @@ use yii\widgets\ActiveForm;
|
||||
]
|
||||
) ?>
|
||||
|
||||
<?= $form->field($model, 'user_id')->textInput() ?>
|
||||
<?= $form->field($model, 'user_id')->widget(Select2::class,
|
||||
[
|
||||
'data' => User::find()->select(['username', 'id'])->indexBy('id')->column(),
|
||||
'options' => ['placeholder' => '...','class' => 'form-control'],
|
||||
'pluginOptions' => [
|
||||
'allowClear' => true,
|
||||
'prompt' => 'Выберите'
|
||||
],
|
||||
]
|
||||
); ?>
|
||||
|
||||
<?= $form->field($model, 'description')->textInput(['maxlength' => true]) ?>
|
||||
<?= $form->field($model, 'description')->textarea(['rows' => '6']) ?>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>
|
||||
<?= Html::submitButton('Создать', ['class' => 'btn btn-success']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
@ -29,14 +29,14 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
|
||||
[
|
||||
'attribute' => 'project_id',
|
||||
'filter' => ArrayHelper::map(Project::find()->all(), 'id', 'name'),
|
||||
'filter' => Project::find()->select(['name', 'id'])->indexBy('id')->column(),
|
||||
'value' => 'project.name'
|
||||
],
|
||||
'title',
|
||||
[
|
||||
'attribute' => 'project_user_id',
|
||||
'filter' => ProjectUser::find()->select(['username', 'project_user.id'])->joinWith('user')->indexBy('id')->column(),
|
||||
'value' => 'projectUser.user.username'
|
||||
'attribute' => 'user_id_creator',
|
||||
'filter' => User::find()->select(['username', 'id'])->indexBy('id')->column(),
|
||||
'value' => 'userIdCreator.username'
|
||||
],
|
||||
[
|
||||
'attribute' => 'user_id',
|
||||
@ -48,12 +48,19 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
'attribute' => 'status',
|
||||
'format' => 'raw',
|
||||
'filter' => StatusHelper::statusList(),
|
||||
'value' => function ($model) {
|
||||
'value' => function($model){
|
||||
return StatusHelper::statusLabel($model->status);
|
||||
},
|
||||
}
|
||||
],
|
||||
[
|
||||
'attribute' => 'created_at',
|
||||
'format' => ['datetime', 'php:d.m.Y H:i']
|
||||
],
|
||||
[
|
||||
'attribute' => 'updated_at',
|
||||
'filter' => User::find()->select(['updated_at', 'updated_at'])->indexBy('updated_at')->column(),
|
||||
'format' => ['datetime', 'php:d.m.Y H:i']
|
||||
],
|
||||
'created_at',
|
||||
'updated_at',
|
||||
|
||||
['class' => 'yii\grid\ActionColumn'],
|
||||
],
|
||||
|
@ -69,17 +69,43 @@ YiiAsset::register($this);
|
||||
'columns' => [
|
||||
['class' => 'yii\grid\SerialColumn'],
|
||||
|
||||
[
|
||||
'attribute' => 'task_id', // ArrayHelper::map(Task::find()->all(), 'id', 'title'),
|
||||
'value' => 'task.title'
|
||||
],
|
||||
[
|
||||
'attribute' => 'project_user_id',
|
||||
'value' => 'projectUser.user.username'
|
||||
],
|
||||
|
||||
['class' => 'yii\grid\ActionColumn'],
|
||||
[
|
||||
'class' => 'yii\grid\ActionColumn',
|
||||
'template' => '{view} {update} {delete}',
|
||||
'controller' => 'task-user',
|
||||
'buttons' => [
|
||||
'update' => function ($url,$model) {
|
||||
return Html::a(
|
||||
'<span class="glyphicon glyphicon-pencil"></span>',
|
||||
['task-user/update', 'id' => $model['id'], 'task_id' => $model['task_id']]);
|
||||
},
|
||||
'delete' => function ($url,$model) {
|
||||
return Html::a(
|
||||
'<span class="glyphicon glyphicon-trash"></span>',
|
||||
[
|
||||
'task-user/delete', 'id' => $model['id'], 'task_id' => $model['task_id']
|
||||
],
|
||||
[
|
||||
'data' => ['confirm' => 'Вы уверены, что хотите удалить этого сотрудника?', 'method' => 'post']
|
||||
]
|
||||
);
|
||||
},
|
||||
],
|
||||
],
|
||||
],
|
||||
]); ?>
|
||||
|
||||
<p>
|
||||
<?= Html::a(
|
||||
'Назначить исполнителя',
|
||||
['task-user/create', 'task_id' => $model->id],
|
||||
['class' => 'btn btn-primary']
|
||||
) ?>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user