changed the creator for tasks from project_user to user, fixed api, documentation, filters, some other fixes

This commit is contained in:
iIronside
2021-12-06 15:13:31 +03:00
parent daae8b16b6
commit e78ff7d779
23 changed files with 6024 additions and 117 deletions

View File

@ -2,6 +2,7 @@
use backend\modules\task\models\Task;
use kartik\depdrop\DepDrop;
use kartik\select2\Select2;
use yii\helpers\Html;
use yii\helpers\Url;
use yii\widgets\ActiveForm;
@ -9,19 +10,20 @@ use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\task\models\TaskUser */
/* @var $form yii\widgets\ActiveForm */
/* @var $task_id */
?>
<div class="task-user-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'task_id')->dropDownList(Task::find()
->select(['title', 'id'])->indexBy('id')->column(),
[
'id' => 'task-id',
'prompt' => 'Выберите'
]
);
<?= $form->field($model, 'task_id')->widget(Select2::className(),[
'data' => Task::find()->select(['title', 'id'])->indexBy('id')->column(),
'options' => ['placeholder' => 'Выберите проект', 'value' => $task_id, 'id' => 'task-id',],
'pluginOptions' => [
'allowClear' => true,
],
]);
?>
<?= $form->field($model, 'project_user_id')->widget(DepDrop::className(),
@ -30,13 +32,14 @@ use yii\widgets\ActiveForm;
'pluginOptions' => [
'depends' => ['task-id'],
'placeholder' => 'Выберите',
'initialize' => true,
'url' => Url::to(['/task/task-user/executor'])
]
]
); ?>
<div class="form-group">
<?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>
<?= Html::submitButton('Назначить', ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>

View File

@ -0,0 +1,35 @@
<?php
use backend\modules\project\models\Project;
use kartik\select2\Select2;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\task\models\TaskUserSearch */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="question-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
<?= $form->field($model, 'projectId')->widget(Select2::className(),[
'data' => Project::find()->select(['name', 'id'])->indexBy('id')->column(),
'options' => ['placeholder' => 'Выберите проект'],
'pluginOptions' => [
'allowClear' => true
],
])->label('Проект') ?>
<div class="form-group">
<?= Html::submitButton('Поиск', ['class' => 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -3,6 +3,7 @@
/* @var $this yii\web\View */
/* @var $model backend\modules\task\models\TaskUser */
/* @var $task_id */
$this->title = 'Назначить сотрудника';
$this->params['breadcrumbs'][] = ['label' => 'Task Users', 'url' => ['index']];
@ -12,6 +13,7 @@ $this->params['breadcrumbs'][] = $this->title;
<?= $this->render('_form', [
'model' => $model,
'task_id' => $task_id,
]) ?>
</div>

View File

@ -2,7 +2,6 @@
use backend\modules\project\models\ProjectUser;
use backend\modules\task\models\Task;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\grid\GridView;
@ -19,6 +18,10 @@ $this->params['breadcrumbs'][] = $this->title;
<?= Html::a('Назначить сотрудника', ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= $this->render('_search_by_project', [
'model' => $searchModel,
]) ?>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,

View File

@ -1,9 +1,9 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\task\models\TaskUser */
/* @var $task_id */
$this->title = 'Изменить назначение';
$this->params['breadcrumbs'][] = ['label' => 'Task Users', 'url' => ['index']];
@ -14,6 +14,7 @@ $this->params['breadcrumbs'][] = 'Update';
<?= $this->render('_form', [
'model' => $model,
'task_id' => $task_id,
]) ?>
</div>

View File

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

View File

@ -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'],
],

View File

@ -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>