From 28f9f3a87ed7d1e476075ab1b2d3e04db50e1d32 Mon Sep 17 00:00:00 2001 From: Kavalar Date: Mon, 19 Feb 2024 22:54:01 +0300 Subject: [PATCH] task uodate fix --- common/models/ProjectTask.php | 14 ++++++++++++-- .../modules/api/controllers/TaskController.php | 1 + frontend/modules/api/services/TaskService.php | 1 - 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/common/models/ProjectTask.php b/common/models/ProjectTask.php index fb4a13e..d16a6ec 100644 --- a/common/models/ProjectTask.php +++ b/common/models/ProjectTask.php @@ -108,11 +108,11 @@ class ProjectTask extends ActiveRecord public function rules() { return [ - [['project_id', 'status', 'title', 'description',], 'required', 'on' => self::SCENARIO_DEFAULT], + [['project_id', 'status', 'title', 'description'], 'required'], [['project_id', 'status', 'column_id', 'user_id', 'executor_id', 'priority', 'execution_priority'], 'integer'], [['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], ['status', 'in', 'range' => [self::STATUS_DISABLE, self::STATUS_ACTIVE, self::STATUS_ARCHIVE, self::STATUS_AT_WORK]], [['description'], 'string', 'max' => 1500], @@ -194,6 +194,16 @@ class ProjectTask extends ActiveRecord ]; } + /** + * @return array + */ + public function scenarios(): array + { + $scenarios = parent::scenarios(); + $scenarios[self::SCENARIO_UPDATE_TASK] = ['id']; + return $scenarios; + } + /** * @return bool|int|string|null */ diff --git a/frontend/modules/api/controllers/TaskController.php b/frontend/modules/api/controllers/TaskController.php index fe3df56..6266d06 100644 --- a/frontend/modules/api/controllers/TaskController.php +++ b/frontend/modules/api/controllers/TaskController.php @@ -2,6 +2,7 @@ namespace frontend\modules\api\controllers; +use common\classes\Debug; use common\models\ProjectTask; use common\models\ProjectTaskUser; use common\models\User; diff --git a/frontend/modules/api/services/TaskService.php b/frontend/modules/api/services/TaskService.php index 3d0b3e6..28af3e5 100644 --- a/frontend/modules/api/services/TaskService.php +++ b/frontend/modules/api/services/TaskService.php @@ -115,7 +115,6 @@ class TaskService public function updateTask($task_params): ?ProjectTask { $modelTask = ProjectTask::findOne($task_params['task_id']); - $modelTask->scenario = ProjectTask::SCENARIO_UPDATE_TASK; if (isset($task_params['executor_id']) && $task_params['executor_id'] == 0){ $task_params['executor_id'] = null;