Merge branch 'master' into config-smtp
This commit is contained in:
commit
5469a209a5
@ -2,14 +2,10 @@
|
|||||||
|
|
||||||
namespace backend\modules\task\controllers;
|
namespace backend\modules\task\controllers;
|
||||||
|
|
||||||
use backend\modules\project\models\ProjectUser;
|
|
||||||
use backend\modules\task\models\ProjectTaskUser;
|
|
||||||
use common\classes\Debug;
|
|
||||||
use yii\data\ActiveDataProvider;
|
use yii\data\ActiveDataProvider;
|
||||||
use yii\web\Response;
|
|
||||||
use Yii;
|
use Yii;
|
||||||
use backend\modules\task\models\ProjectTask;
|
use backend\modules\task\models\ProjectTask;
|
||||||
use backend\modules\task\models\TaskSearch;
|
use backend\modules\task\models\ProjectTaskSearch;
|
||||||
use yii\web\Controller;
|
use yii\web\Controller;
|
||||||
use yii\web\NotFoundHttpException;
|
use yii\web\NotFoundHttpException;
|
||||||
use yii\filters\VerbFilter;
|
use yii\filters\VerbFilter;
|
||||||
@ -43,7 +39,7 @@ class TaskController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function actionIndex()
|
public function actionIndex()
|
||||||
{
|
{
|
||||||
$searchModel = new TaskSearch();
|
$searchModel = new ProjectTaskSearch();
|
||||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||||
|
|
||||||
return $this->render('index', [
|
return $this->render('index', [
|
||||||
|
@ -10,7 +10,7 @@ use backend\modules\task\models\ProjectTask;
|
|||||||
/**
|
/**
|
||||||
* TaskSearch represents the model behind the search form of `backend\modules\task\models\Task`.
|
* TaskSearch represents the model behind the search form of `backend\modules\task\models\Task`.
|
||||||
*/
|
*/
|
||||||
class TaskSearch extends ProjectTask
|
class ProjectTaskSearch extends ProjectTask
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
@ -60,14 +60,15 @@ class TaskSearch extends ProjectTask
|
|||||||
// grid filtering conditions
|
// grid filtering conditions
|
||||||
$query->andFilterWhere([
|
$query->andFilterWhere([
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'task.project_id' => $this->project_id,
|
'project_task.project_id' => $this->project_id,
|
||||||
'task.status' => $this->status,
|
'project_task.status' => $this->status,
|
||||||
'task.created_at' => $this->created_at,
|
'project_task.execution_priority' => $this->execution_priority,
|
||||||
'task.updated_at' => $this->updated_at,
|
'project_task.created_at' => $this->created_at,
|
||||||
|
'project_task.updated_at' => $this->updated_at,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$query->andFilterWhere(['like', 'title', $this->title])
|
$query->andFilterWhere(['like', 'title', $this->title])
|
||||||
->andFilterWhere(['like', 'task.description', $this->description]);
|
->andFilterWhere(['like', 'project_task.description', $this->description]);
|
||||||
|
|
||||||
return $dataProvider;
|
return $dataProvider;
|
||||||
}
|
}
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
use backend\modules\card\models\UserCard;
|
use backend\modules\card\models\UserCard;
|
||||||
use backend\modules\project\models\Project;
|
use backend\modules\project\models\Project;
|
||||||
|
use backend\modules\task\models\ProjectTask;
|
||||||
use common\helpers\StatusHelper;
|
use common\helpers\StatusHelper;
|
||||||
use kartik\select2\Select2;
|
use kartik\select2\Select2;
|
||||||
use yii\helpers\Html;
|
use yii\helpers\Html;
|
||||||
@ -59,6 +60,13 @@ use yii\widgets\ActiveForm;
|
|||||||
|
|
||||||
<?= $form->field($model, 'priority')->input('number') ?>
|
<?= $form->field($model, 'priority')->input('number') ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'execution_priority')->dropDownList(
|
||||||
|
ProjectTask::priorityList(),
|
||||||
|
[
|
||||||
|
'prompt' => 'Выберите'
|
||||||
|
]
|
||||||
|
) ?>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<?= Html::submitButton('Создать', ['class' => 'btn btn-success']) ?>
|
<?= Html::submitButton('Создать', ['class' => 'btn btn-success']) ?>
|
||||||
</div>
|
</div>
|
||||||
|
@ -4,7 +4,7 @@ use yii\helpers\Html;
|
|||||||
use yii\widgets\ActiveForm;
|
use yii\widgets\ActiveForm;
|
||||||
|
|
||||||
/* @var $this yii\web\View */
|
/* @var $this yii\web\View */
|
||||||
/* @var $model backend\modules\task\models\TaskSearch */
|
/* @var $model backend\modules\task\models\ProjectTaskSearch */
|
||||||
/* @var $form yii\widgets\ActiveForm */
|
/* @var $form yii\widgets\ActiveForm */
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ use yii\helpers\Html;
|
|||||||
use yii\grid\GridView;
|
use yii\grid\GridView;
|
||||||
|
|
||||||
/* @var $this yii\web\View */
|
/* @var $this yii\web\View */
|
||||||
/* @var $searchModel backend\modules\task\models\TaskSearch */
|
/* @var $searchModel backend\modules\task\models\ProjectTaskSearch */
|
||||||
/* @var $dataProvider yii\data\ActiveDataProvider */
|
/* @var $dataProvider yii\data\ActiveDataProvider */
|
||||||
|
|
||||||
$this->title = 'Задачи';
|
$this->title = 'Задачи';
|
||||||
@ -58,6 +58,14 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
return StatusHelper::statusLabel($model->status);
|
return StatusHelper::statusLabel($model->status);
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'attribute' => 'execution_priority',
|
||||||
|
'format' => 'raw',
|
||||||
|
'filter' => ProjectTask::priorityList(),
|
||||||
|
'value' => function($model){
|
||||||
|
return ProjectTask::getPriority($model->status);
|
||||||
|
}
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'attribute' => 'created_at',
|
'attribute' => 'created_at',
|
||||||
'format' => ['datetime', 'php:d.m.Y H:i']
|
'format' => ['datetime', 'php:d.m.Y H:i']
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use backend\modules\task\models\ProjectTask;
|
||||||
use common\helpers\StatusHelper;
|
use common\helpers\StatusHelper;
|
||||||
use kartik\grid\GridView;
|
use kartik\grid\GridView;
|
||||||
use yii\helpers\ArrayHelper;
|
use yii\helpers\ArrayHelper;
|
||||||
@ -60,6 +61,12 @@ YiiAsset::register($this);
|
|||||||
],
|
],
|
||||||
'description',
|
'description',
|
||||||
'priority',
|
'priority',
|
||||||
|
[
|
||||||
|
'attribute' => 'execution_priority',
|
||||||
|
'value' => function($model){
|
||||||
|
return ProjectTask::getPriority($model->status);
|
||||||
|
}
|
||||||
|
],
|
||||||
],
|
],
|
||||||
]) ?>
|
]) ?>
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ use yii\helpers\ArrayHelper;
|
|||||||
*
|
*
|
||||||
* @property FieldsValue[] $fieldsValues
|
* @property FieldsValue[] $fieldsValues
|
||||||
* @property Company $company
|
* @property Company $company
|
||||||
|
* @property User $owner
|
||||||
* @property ProjectUser[] $projectUsers
|
* @property ProjectUser[] $projectUsers
|
||||||
* @property Mark[] $mark
|
* @property Mark[] $mark
|
||||||
* @property MarkEntity[] $markEntity
|
* @property MarkEntity[] $markEntity
|
||||||
@ -55,8 +56,8 @@ class Project extends \yii\db\ActiveRecord
|
|||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
['name', 'unique'],
|
[['name', 'owner_id', 'status'], 'required'],
|
||||||
[['name', 'status'], 'required'],
|
[['owner_id', 'name'], 'unique', 'targetAttribute' => ['owner_id', 'name']],
|
||||||
[['description'], 'string'],
|
[['description'], 'string'],
|
||||||
[['created_at', 'updated_at'], 'safe'],
|
[['created_at', 'updated_at'], 'safe'],
|
||||||
[['status'], 'exist', 'skipOnError' => true, 'targetClass' => Status::class, 'targetAttribute' => ['status' => 'id']],
|
[['status'], 'exist', 'skipOnError' => true, 'targetClass' => Status::class, 'targetAttribute' => ['status' => 'id']],
|
||||||
|
@ -65,6 +65,7 @@ class ProjectColumn extends \yii\db\ActiveRecord
|
|||||||
return [
|
return [
|
||||||
[['title', 'project_id'], 'required'],
|
[['title', 'project_id'], 'required'],
|
||||||
[['project_id', 'status', 'priority'], 'integer'],
|
[['project_id', 'status', 'priority'], 'integer'],
|
||||||
|
[['project_id', 'title'], 'unique', 'targetAttribute' => ['project_id', 'title']],
|
||||||
[['created_at', 'updated_at'], 'safe'],
|
[['created_at', 'updated_at'], 'safe'],
|
||||||
[['title'], 'string', 'max' => 255],
|
[['title'], 'string', 'max' => 255],
|
||||||
[['project_id'], 'exist', 'skipOnError' => true, 'targetClass' => Project::className(), 'targetAttribute' => ['project_id' => 'id']],
|
[['project_id'], 'exist', 'skipOnError' => true, 'targetClass' => Project::className(), 'targetAttribute' => ['project_id' => 'id']],
|
||||||
|
@ -21,6 +21,7 @@ use yii\helpers\ArrayHelper;
|
|||||||
* @property int $user_id
|
* @property int $user_id
|
||||||
* @property int $executor_id
|
* @property int $executor_id
|
||||||
* @property int $priority
|
* @property int $priority
|
||||||
|
* @property int $execution_priority
|
||||||
* @property string $description
|
* @property string $description
|
||||||
* @property string $dead_line
|
* @property string $dead_line
|
||||||
*
|
*
|
||||||
@ -37,6 +38,32 @@ class ProjectTask extends ActiveRecord
|
|||||||
const STATUS_ACTIVE = 1;
|
const STATUS_ACTIVE = 1;
|
||||||
const STATUS_DISABLE = 0;
|
const STATUS_DISABLE = 0;
|
||||||
|
|
||||||
|
const PRIORITY_LOW = 0;
|
||||||
|
const PRIORITY_MEDIUM = 1;
|
||||||
|
const PRIORITY_HIGH = 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
|
public static function priorityList() :array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
self::PRIORITY_LOW => 'Низкий',
|
||||||
|
self::PRIORITY_MEDIUM => 'Средний',
|
||||||
|
self::PRIORITY_HIGH => 'Высокий',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $priority
|
||||||
|
* @return string
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
public static function getPriority($priority): string
|
||||||
|
{
|
||||||
|
return ArrayHelper::getValue(self::priorityList(), $priority);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
@ -64,8 +91,9 @@ class ProjectTask extends ActiveRecord
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[['project_id', 'status', 'title', 'description',], 'required'],
|
[['project_id', 'status', 'title', 'description',], 'required'],
|
||||||
[['project_id', 'status', 'column_id', 'user_id', 'executor_id', 'priority'], 'integer'],
|
[['project_id', 'status', 'column_id', 'user_id', 'executor_id', 'priority', 'execution_priority'], 'integer'],
|
||||||
[['created_at', 'updated_at', 'dead_line'], 'safe'],
|
[['created_at', 'updated_at', 'dead_line'], 'safe'],
|
||||||
|
['execution_priority', 'in', 'range' => [self::PRIORITY_LOW, self::PRIORITY_MEDIUM, self::PRIORITY_HIGH]],
|
||||||
['title', 'unique', 'targetAttribute' => ['title', 'project_id'], 'message' => 'Такая задача уже создана'],
|
['title', 'unique', 'targetAttribute' => ['title', 'project_id'], 'message' => 'Такая задача уже создана'],
|
||||||
[['title'], 'string', 'max' => 255],
|
[['title'], 'string', 'max' => 255],
|
||||||
[['description'], 'string', 'max' => 1500],
|
[['description'], 'string', 'max' => 1500],
|
||||||
@ -94,6 +122,69 @@ class ProjectTask extends ActiveRecord
|
|||||||
'executor_id' => 'Исполнитель',
|
'executor_id' => 'Исполнитель',
|
||||||
'priority' => 'Приоритет',
|
'priority' => 'Приоритет',
|
||||||
'dead_line' => 'Срок выполнения задачи',
|
'dead_line' => 'Срок выполнения задачи',
|
||||||
|
'execution_priority' => 'Приоритет выполнения',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
|
public function fields(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id',
|
||||||
|
'project_id',
|
||||||
|
'project_name' => function () {
|
||||||
|
return $this->project->name ?? null;
|
||||||
|
},
|
||||||
|
'title',
|
||||||
|
'created_at',
|
||||||
|
'updated_at',
|
||||||
|
'dead_line',
|
||||||
|
'description',
|
||||||
|
'status',
|
||||||
|
'column_id',
|
||||||
|
'user_id',
|
||||||
|
'user' => function () {
|
||||||
|
return [
|
||||||
|
"fio" => $this->user->userCard->fio ?? $this->user->id,
|
||||||
|
"avatar" => $this->user->userCard->photo ?? '',
|
||||||
|
];
|
||||||
|
},
|
||||||
|
'executor_id',
|
||||||
|
'priority',
|
||||||
|
'executor' => function () {
|
||||||
|
if ($this->executor) {
|
||||||
|
return [
|
||||||
|
"fio" => $this->executor->userCard->fio ?? $this->executor->username,
|
||||||
|
"avatar" => $this->executor->userCard->photo ?? '',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
'comment_count' => function () {
|
||||||
|
return Comment::find()->where(['entity_id' => $this->id, 'entity_type' => 2, 'status' => Comment::STATUS_ACTIVE])->count();
|
||||||
|
},
|
||||||
|
'taskUsers',
|
||||||
|
'mark',
|
||||||
|
'execution_priority'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
|
public function extraFields(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'timers',
|
||||||
|
'column' => function () {
|
||||||
|
return [
|
||||||
|
'column_title' => $this->column->title ?? null
|
||||||
|
];
|
||||||
|
},
|
||||||
|
'mark'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
namespace common\services;
|
namespace common\services;
|
||||||
|
|
||||||
|
use common\models\ProjectTask;
|
||||||
use common\models\ProjectTaskUser;
|
use common\models\ProjectTaskUser;
|
||||||
use frontend\modules\api\models\ProjectTask;
|
|
||||||
|
|
||||||
class TaskService
|
class TaskService
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\db\Migration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class m231013_122324_add_foreign_key_in_project_from_owner_id_to_user_id
|
||||||
|
*/
|
||||||
|
class m231013_122324_add_foreign_key_in_project_from_owner_id_to_user_id extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function safeUp()
|
||||||
|
{
|
||||||
|
$this->addForeignKey(
|
||||||
|
'project_user',
|
||||||
|
'project',
|
||||||
|
'owner_id',
|
||||||
|
'user',
|
||||||
|
'id'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function safeDown()
|
||||||
|
{
|
||||||
|
$this->dropForeignKey('project_user', 'project');
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\db\Migration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles adding columns to table `{{%project_task}}`.
|
||||||
|
*/
|
||||||
|
class m231013_144526_add_execution_priority_column_to_project_task_table extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function safeUp()
|
||||||
|
{
|
||||||
|
$this->addColumn('project_task', 'execution_priority', $this->integer(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function safeDown()
|
||||||
|
{
|
||||||
|
$this->dropColumn('project_task', 'execution_priority');
|
||||||
|
}
|
||||||
|
}
|
@ -72,7 +72,12 @@ class TaskController extends ApiController
|
|||||||
* @OA\Property(
|
* @OA\Property(
|
||||||
* property="priority",
|
* property="priority",
|
||||||
* type="integer",
|
* type="integer",
|
||||||
* description="Приоритет задачи",
|
* description="Приоритет задачи.",
|
||||||
|
* ),
|
||||||
|
* @OA\Property(
|
||||||
|
* property="execution_priority",
|
||||||
|
* type="integer",
|
||||||
|
* description="Приоритет выполнения задачи (0 - low, 1 - medium, 2 - high)",
|
||||||
* ),
|
* ),
|
||||||
* @OA\Property(
|
* @OA\Property(
|
||||||
* property="column_id",
|
* property="column_id",
|
||||||
|
@ -71,6 +71,12 @@ namespace frontend\modules\api\models;
|
|||||||
* description="Приоритет задачи"
|
* description="Приоритет задачи"
|
||||||
* ),
|
* ),
|
||||||
* @OA\Property(
|
* @OA\Property(
|
||||||
|
* property="execution_priority",
|
||||||
|
* type="integer",
|
||||||
|
* example="2",
|
||||||
|
* description="Приоритет выполнения задачи (0 - low, 1 - medium, 2 - high)",
|
||||||
|
* ),
|
||||||
|
* @OA\Property(
|
||||||
* property="status",
|
* property="status",
|
||||||
* type="int",
|
* type="int",
|
||||||
* example="1",
|
* example="1",
|
||||||
@ -152,63 +158,5 @@ namespace frontend\modules\api\models;
|
|||||||
*/
|
*/
|
||||||
class ProjectTask extends \common\models\ProjectTask
|
class ProjectTask extends \common\models\ProjectTask
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @return string[]
|
|
||||||
*/
|
|
||||||
public function fields(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'id',
|
|
||||||
'project_id',
|
|
||||||
'project_name' => function () {
|
|
||||||
return $this->project->name ?? null;
|
|
||||||
},
|
|
||||||
'title',
|
|
||||||
'created_at',
|
|
||||||
'updated_at',
|
|
||||||
'dead_line',
|
|
||||||
'description',
|
|
||||||
'status',
|
|
||||||
'column_id',
|
|
||||||
'user_id',
|
|
||||||
'user' => function () {
|
|
||||||
return [
|
|
||||||
"fio" => $this->user->userCard->fio ?? $this->user->id,
|
|
||||||
"avatar" => $this->user->userCard->photo ?? '',
|
|
||||||
];
|
|
||||||
},
|
|
||||||
'executor_id',
|
|
||||||
'priority',
|
|
||||||
'executor' => function () {
|
|
||||||
if ($this->executor) {
|
|
||||||
return [
|
|
||||||
"fio" => $this->executor->userCard->fio ?? $this->executor->username,
|
|
||||||
"avatar" => $this->executor->userCard->photo ?? '',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
'comment_count' => function () {
|
|
||||||
return Comment::find()->where(['entity_id' => $this->id, 'entity_type' => 2, 'status' => Comment::STATUS_ACTIVE])->count();
|
|
||||||
},
|
|
||||||
'taskUsers',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string[]
|
|
||||||
*/
|
|
||||||
public function extraFields(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'timers',
|
|
||||||
'column' => function () {
|
|
||||||
return [
|
|
||||||
'column_title' => $this->column->title ?? null
|
|
||||||
];
|
|
||||||
},
|
|
||||||
'mark'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user