Add execution_priority to task
This commit is contained in:
parent
5b3f6518dc
commit
c20d7fbe77
@ -62,6 +62,7 @@ class ProjectTaskSearch extends ProjectTask
|
||||
'id' => $this->id,
|
||||
'project_task.project_id' => $this->project_id,
|
||||
'project_task.status' => $this->status,
|
||||
'project_task.execution_priority' => $this->execution_priority,
|
||||
'project_task.created_at' => $this->created_at,
|
||||
'project_task.updated_at' => $this->updated_at,
|
||||
]);
|
||||
|
@ -60,12 +60,12 @@ use yii\widgets\ActiveForm;
|
||||
|
||||
<?= $form->field($model, 'priority')->input('number') ?>
|
||||
|
||||
<!-- --><?//= $form->field($model, 'priority')->dropDownList(
|
||||
// ProjectTask::priorityList(),
|
||||
// [
|
||||
// 'prompt' => 'Выберите'
|
||||
// ]
|
||||
// ) ?>
|
||||
<?= $form->field($model, 'execution_priority')->dropDownList(
|
||||
ProjectTask::priorityList(),
|
||||
[
|
||||
'prompt' => 'Выберите'
|
||||
]
|
||||
) ?>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton('Создать', ['class' => 'btn btn-success']) ?>
|
||||
|
@ -58,14 +58,14 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
return StatusHelper::statusLabel($model->status);
|
||||
}
|
||||
],
|
||||
// [
|
||||
// 'attribute' => 'priority',
|
||||
// 'format' => 'raw',
|
||||
// 'filter' => ProjectTask::priorityList(),
|
||||
// 'value' => function($model){
|
||||
// return ProjectTask::getPriority($model->status);
|
||||
// }
|
||||
// ],
|
||||
[
|
||||
'attribute' => 'execution_priority',
|
||||
'format' => 'raw',
|
||||
'filter' => ProjectTask::priorityList(),
|
||||
'value' => function($model){
|
||||
return ProjectTask::getPriority($model->status);
|
||||
}
|
||||
],
|
||||
[
|
||||
'attribute' => 'created_at',
|
||||
'format' => ['datetime', 'php:d.m.Y H:i']
|
||||
|
@ -61,12 +61,12 @@ YiiAsset::register($this);
|
||||
],
|
||||
'description',
|
||||
'priority',
|
||||
// [
|
||||
// 'attribute' => 'priority',
|
||||
// 'value' => function($model){
|
||||
// return ProjectTask::getPriority($model->status);
|
||||
// }
|
||||
// ],
|
||||
[
|
||||
'attribute' => 'execution_priority',
|
||||
'value' => function($model){
|
||||
return ProjectTask::getPriority($model->status);
|
||||
}
|
||||
],
|
||||
],
|
||||
]) ?>
|
||||
|
||||
|
@ -21,6 +21,7 @@ use yii\helpers\ArrayHelper;
|
||||
* @property int $user_id
|
||||
* @property int $executor_id
|
||||
* @property int $priority
|
||||
* @property int $execution_priority
|
||||
* @property string $description
|
||||
* @property string $dead_line
|
||||
*
|
||||
@ -37,31 +38,31 @@ class ProjectTask extends ActiveRecord
|
||||
const STATUS_ACTIVE = 1;
|
||||
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 => 'Высокий',
|
||||
// ];
|
||||
// }
|
||||
const PRIORITY_LOW = 0;
|
||||
const PRIORITY_MEDIUM = 1;
|
||||
const PRIORITY_HIGH = 2;
|
||||
|
||||
// /**
|
||||
// * @param $priority
|
||||
// * @return string
|
||||
// * @throws \Exception
|
||||
// */
|
||||
// public static function getPriority($priority): string
|
||||
// {
|
||||
// return ArrayHelper::getValue(self::priorityList(), $priority);
|
||||
// }
|
||||
/**
|
||||
* @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}
|
||||
@ -90,9 +91,9 @@ class ProjectTask extends ActiveRecord
|
||||
{
|
||||
return [
|
||||
[['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'],
|
||||
// ['status', 'in', 'range' => [self::PRIORITY_LOW, self::PRIORITY_MEDIUM, self::PRIORITY_HIGH]],
|
||||
['execution_priority', 'in', 'range' => [self::PRIORITY_LOW, self::PRIORITY_MEDIUM, self::PRIORITY_HIGH]],
|
||||
['title', 'unique', 'targetAttribute' => ['title', 'project_id'], 'message' => 'Такая задача уже создана'],
|
||||
[['title'], 'string', 'max' => 255],
|
||||
[['description'], 'string', 'max' => 1500],
|
||||
@ -121,6 +122,7 @@ class ProjectTask extends ActiveRecord
|
||||
'executor_id' => 'Исполнитель',
|
||||
'priority' => 'Приоритет',
|
||||
'dead_line' => 'Срок выполнения задачи',
|
||||
'execution_priority' => 'Приоритет выполнения',
|
||||
];
|
||||
}
|
||||
|
||||
@ -165,7 +167,8 @@ class ProjectTask extends ActiveRecord
|
||||
return Comment::find()->where(['entity_id' => $this->id, 'entity_type' => 2, 'status' => Comment::STATUS_ACTIVE])->count();
|
||||
},
|
||||
'taskUsers',
|
||||
'mark'
|
||||
'mark',
|
||||
'execution_priority'
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -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');
|
||||
}
|
||||
}
|
@ -75,6 +75,11 @@ class TaskController extends ApiController
|
||||
* description="Приоритет задачи.",
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="execution_priority",
|
||||
* type="integer",
|
||||
* description="Приоритет выполнения задачи (0 - low, 1 - medium, 2 - high)",
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="column_id",
|
||||
* type="integer",
|
||||
* description="Колонка к которой относится задача",
|
||||
|
Loading…
Reference in New Issue
Block a user