Skip to content

Commit

Permalink
fixed task update of recurring task
Browse files Browse the repository at this point in the history
fixed copy task of recurring task
fixed creation of a monitoring
  • Loading branch information
simialbi committed Dec 20, 2021
1 parent 7bd26af commit 6c06bcc
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ $ php composer.phar require --prefer-dist simialbi/yii2-kanban
or add

```
"simialbi/yii2-kanban": "^1.0.0"
"simialbi/yii2-kanban": "^2.0.0"
```

to the `require` section of your `composer.json`.
Expand Down
4 changes: 4 additions & 0 deletions src/behaviors/RepeatableBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ public function events()
];
}

/**
* @param \yii\base\ModelEvent $event
* @throws \yii\base\InvalidConfigException
*/
public function deleteRecurrentInstance(\yii\base\ModelEvent $event)
{
if (!$this->isRecurrentInstance()) {
Expand Down
15 changes: 9 additions & 6 deletions src/controllers/TaskController.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,8 @@ public function actionHistory($id)
*/
protected function findModel($id)
{
// if (preg_match('#^r-\d+$#', $id)) {
// $id = preg_replace('#[^\d]#', '', $id);
// }
if (($model = Task::findOne($id)) !== null) {
/** @var $model Task */
if (($model = Task::find()->with('assignments')->where(['id' => $id])->one()) !== null) {
return $model;
} else {
throw new NotFoundHttpException(Yii::t('yii', 'Page not found.'));
Expand Down Expand Up @@ -437,7 +435,7 @@ public function actionUpdate($id, $updateSeries = false, $return = 'card')
]);
}

$model = Task::findOne(['id' => $model->id]);
$model = $this->findModel($model->id);

return $this->renderAjax('item', [
'boardId' => $model->board->id,
Expand Down Expand Up @@ -484,11 +482,16 @@ public function actionUpdate($id, $updateSeries = false, $return = 'card')
public function actionCopyPerUser($id, $group = 'bucket')
{
$model = $this->findModel($id);

if ($model->isRecurrentInstance()) {
$model = $model->getOriginalRecord();
}

$assignees = Yii::$app->request->getBodyParam('assignees', []);

if (Yii::$app->request->isPost && !empty($assignees)) {
foreach ($assignees as $assignee) {
$newTask = new Task($model->toArray());
$newTask = new Task($model);
$newTask->id = null;
if (!$newTask->save()) {
continue;
Expand Down
3 changes: 2 additions & 1 deletion src/views/monitoring/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
'data' => [
'toggle' => 'modal',
'pjax' => '0',
'target' => '#taskModal'
'turbo-frame' => 'task-modal-frame',
'target' => '#task-modal'
]
])
]
Expand Down

0 comments on commit 6c06bcc

Please sign in to comment.