Merge branch 'master' into config-smtp

This commit is contained in:
iIronside
2023-10-16 15:08:57 +03:00
14 changed files with 199 additions and 77 deletions

View File

@ -23,6 +23,7 @@ use yii\helpers\ArrayHelper;
*
* @property FieldsValue[] $fieldsValues
* @property Company $company
* @property User $owner
* @property ProjectUser[] $projectUsers
* @property Mark[] $mark
* @property MarkEntity[] $markEntity
@ -55,8 +56,8 @@ class Project extends \yii\db\ActiveRecord
public function rules()
{
return [
['name', 'unique'],
[['name', 'status'], 'required'],
[['name', 'owner_id', 'status'], 'required'],
[['owner_id', 'name'], 'unique', 'targetAttribute' => ['owner_id', 'name']],
[['description'], 'string'],
[['created_at', 'updated_at'], 'safe'],
[['status'], 'exist', 'skipOnError' => true, 'targetClass' => Status::class, 'targetAttribute' => ['status' => 'id']],

View File

@ -65,6 +65,7 @@ class ProjectColumn extends \yii\db\ActiveRecord
return [
[['title', 'project_id'], 'required'],
[['project_id', 'status', 'priority'], 'integer'],
[['project_id', 'title'], 'unique', 'targetAttribute' => ['project_id', 'title']],
[['created_at', 'updated_at'], 'safe'],
[['title'], 'string', 'max' => 255],
[['project_id'], 'exist', 'skipOnError' => true, 'targetClass' => Project::className(), 'targetAttribute' => ['project_id' => 'id']],

View File

@ -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,6 +38,32 @@ 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 => 'Высокий',
];
}
/**
* @param $priority
* @return string
* @throws \Exception
*/
public static function getPriority($priority): string
{
return ArrayHelper::getValue(self::priorityList(), $priority);
}
/**
* {@inheritdoc}
*/
@ -64,8 +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'],
['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],
@ -94,6 +122,69 @@ class ProjectTask extends ActiveRecord
'executor_id' => 'Исполнитель',
'priority' => 'Приоритет',
'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'
];
}

View File

@ -2,8 +2,8 @@
namespace common\services;
use common\models\ProjectTask;
use common\models\ProjectTaskUser;
use frontend\modules\api\models\ProjectTask;
class TaskService
{