Skip to content

Commit 86f418e

Browse files
committed
Task:
- It is not possible to set a responsible person per task - Added responsible to card - Fixed scroll-issue in board overview Board: - Added responsible-overview to the hub - Improved search of overviews delegated and todo - Fixed order of overviews delegated and todo Various: - Added autocomplete off to some search- and input-fields
1 parent ff11cf4 commit 86f418e

26 files changed

+643
-209
lines changed

src/Module.php

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ public function init()
123123
// TODO: Cache somehow
124124
$this->users = ArrayHelper::index(call_user_func([Yii::$app->user->identityClass, 'findIdentities']), 'id');
125125
if (Yii::$app->has('authManager')) {
126-
$this->roles = ArrayHelper::getColumn(ArrayHelper::index(Yii::$app->authManager->getRoles(), 'name'), 'description');
126+
$this->roles = ArrayHelper::getColumn(ArrayHelper::index(Yii::$app->authManager->getRoles(), 'name'),
127+
'description');
127128
}
128129

129130
Yii::$app->view->registerJs(
@@ -152,4 +153,32 @@ public static function getUserBoards($userId = null)
152153
->indexBy('id')
153154
->all();
154155
}
156+
157+
/**
158+
* Sorts an array of tasks like this:
159+
* - End-date ASC,
160+
* - Subject ASC
161+
*
162+
* @param Task[] $tasks
163+
* @return void
164+
*/
165+
public static function sortTasks(&$tasks)
166+
{
167+
usort($tasks, function ($a, $b) {
168+
if ($a->endDate === $b->endDate) {
169+
if ($a->end_date !== null) {
170+
return 0;
171+
} else {
172+
return strcasecmp($a->subject, $b->subject);
173+
}
174+
}
175+
if ($a->endDate === null && $b->endDate !== null) {
176+
return 1;
177+
}
178+
if ($a->endDate !== null && $b->endDate === null) {
179+
return -1;
180+
}
181+
return ($a->endDate < $b->endDate) ? -1 : 1;
182+
});
183+
}
155184
}

src/assets/css/kanban.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/assets/css/kanban.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/assets/js/kanban.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,26 @@ window.sa.kanban = (function ($, Swiper, baseUrl) {
197197
$this.closest('.dropdown-menu').find('.add-assignee[data-id="' + id + '"]')
198198
.removeClass('is-assigned').css('display', '');
199199
},
200+
/**
201+
* Set responsible person
202+
* @param {int} id
203+
*/
204+
chooseResponsible: function (id) {
205+
var $this = $(this);
206+
var $name = $this.data('name');
207+
$('#task-responsible_id-dummy').val($name);
208+
$('#task-responsible_id').val(id);
209+
},
210+
/**
211+
* remove responsible person
212+
*/
213+
removeResponsible: function() {
214+
var id = $('#task-responsible_id').val();
215+
if (id) {
216+
$('#task-responsible_id-dummy').val('');
217+
}
218+
$('#task-responsible_id').val(null);
219+
},
200220
/**
201221
* Copy passed text to browser clipboard
202222
*

src/assets/scss/kanban.scss

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,18 @@ turbo-frame {
302302
}
303303
}
304304

305-
.kanban-task-assignees, .card-footer.kanban-task-assignees, .kanban-plan-assignees {
305+
.kanban-task-assignees, .card-footer.kanban-task-assignees, .kanban-plan-assignees, .kanban-task-responsible {
306306
background: none transparent;
307307
padding: 0;
308308

309+
.kanban-user.responsible {
310+
padding: .5rem .75rem;
311+
312+
& + .dropdown .dropdown-menu {
313+
margin-left: calc((#{$user-image-size} + 1.5rem) * -1);
314+
}
315+
}
316+
309317
.dropdown {
310318
.dropdown-toggle {
311319
padding: .5rem .75rem;
@@ -498,3 +506,21 @@ turbo-frame {
498506
border-color: $nav-link-active-border-color;
499507
}
500508
}
509+
510+
.kanban-plan-index {
511+
#delegated-tasks-frame {
512+
#search-widget-delegated {
513+
width: 200px;
514+
}
515+
516+
.list-group-item {
517+
border-top: 0;
518+
}
519+
}
520+
521+
#responsible-tasks-frame {
522+
turbo-frame + turbo-frame a {
523+
border-top: 0;
524+
}
525+
}
526+
}

src/controllers/PlanController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function behaviors()
8585

8686
/**
8787
* Plan overview
88-
* @param string $activeTab One of 'plan', 'tasks', 'delegated'
88+
* @param string $activeTab One of 'plan', 'tasks', 'delegated', 'responsible'
8989
* @return string
9090
*/
9191
public function actionIndex($activeTab = 'plan')
@@ -189,7 +189,7 @@ public function actionSchedule($id)
189189
->andWhere(['not', ['status' => Task::STATUS_DONE]])->all(),
190190
'calendarTasks' => $calendarTasks,
191191
'users' => $this->module->users,
192-
'statuses' => $this->module->statuses,
192+
'statuses' => $this->module->statuses,
193193
'readonly' => $readonly
194194
]);
195195
}

src/controllers/TaskController.php

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use simialbi\yii2\ticket\models\Ticket;
2323
use Yii;
2424
use yii\base\InvalidConfigException;
25+
use yii\db\ActiveQuery;
2526
use yii\db\Exception;
2627
use yii\db\Query;
2728
use yii\filters\AccessControl;
@@ -70,7 +71,7 @@ public function behaviors()
7071
],
7172
[
7273
'allow' => true,
73-
'actions' => ['view', 'view-completed', 'view-delegated', 'history']
74+
'actions' => ['view', 'view-completed', 'view-delegated', 'view-responsible', 'history']
7475
]
7576
]
7677
]
@@ -167,6 +168,14 @@ public function actionViewDelegated($view = 'task')
167168
}
168169
}
169170

171+
if ($view === 'list') {
172+
$module = $this->module;
173+
foreach ($indexed as &$user) {
174+
$module::sortTasks($user);
175+
}
176+
unset($user);
177+
}
178+
170179
return $this->renderAjax('delegated', [
171180
'tasks' => $indexed,
172181
'view' => $view,
@@ -175,6 +184,44 @@ public function actionViewDelegated($view = 'task')
175184
]);
176185
}
177186

187+
/**
188+
* @return string
189+
* @throws \Exception
190+
*/
191+
public function actionViewResponsible()
192+
{
193+
$filters = Yii::$app->request->getQueryParam('Filters', []);
194+
195+
$query = Board::find()
196+
->alias('bo')
197+
->distinct()
198+
->joinWith([
199+
'buckets b' => function (ActiveQuery $query) {
200+
$query->joinWith([
201+
'tasks t' => function (ActiveQuery $query) {
202+
$query
203+
->where(['{{t}}.[[responsible_id]]' => Yii::$app->user->id])
204+
->andWhere(['not', ['{{t}}.[[status]]' => Task::STATUS_DONE]])
205+
->orderBy([]);
206+
}
207+
], true, 'INNER JOIN')
208+
->orderBy([]);
209+
}
210+
], true, 'INNER JOIN')
211+
->filterWhere([
212+
Board::tableName() . '.id' => ArrayHelper::getValue($filters, 'boardId')
213+
])
214+
->orderBy([
215+
'{{bo}}.[[name]]' => SORT_ASC,
216+
'{{b}}.[[name]]' => SORT_ASC
217+
]);
218+
219+
return $this->renderAjax('responsible', [
220+
'boards' => $query->all(),
221+
'module' => $this->module
222+
]);
223+
}
224+
178225
/**
179226
* Create a new task
180227
* @param integer $boardId
@@ -442,6 +489,10 @@ public function actionUpdate($id, $updateSeries = false, $return = 'card')
442489
'closeModal' => true,
443490
'finishedTasks' => $model->bucket->getTasks()->where(['status' => Task::STATUS_DONE])->count('id')
444491
]);
492+
} elseif ($return === 'list-item') {
493+
return $this->renderAjax('/task/list-item', [
494+
'task' => $model
495+
]);
445496
}
446497

447498
$model = $this->findModel($model->id);

src/messages/de/messages.mo

136 Bytes
Binary file not shown.

src/messages/de/messages.po

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,10 @@ msgctxt "simialbi/kanban/model/task"
346346
msgid "Assignee"
347347
msgstr "Mitglieder"
348348

349+
msgctxt "simialbi/kanban/model/task"
350+
msgid "Responsible"
351+
msgstr "Verantwortlicher"
352+
349353
msgctxt "simialbi/kanban/model/task"
350354
msgid "Board"
351355
msgstr "Plan"
@@ -502,6 +506,10 @@ msgctxt "simialbi/kanban/plan"
502506
msgid "Delegated tasks"
503507
msgstr "Delegierte Aufgaben"
504508

509+
msgctxt "simialbi/kanban/plan"
510+
msgid "Responsible"
511+
msgstr "Verantwortlich"
512+
505513
msgctxt "simialbi/kanban/plan"
506514
msgid "Delete plan"
507515
msgstr "Plan löschen"

src/messages/en/messages.mo

128 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)