diff --git a/app/Http/Controllers/TaskKanbanController.php b/app/Http/Controllers/TaskKanbanController.php
index e4f6fa6c13a5..a4b5c59adb1e 100644
--- a/app/Http/Controllers/TaskKanbanController.php
+++ b/app/Http/Controllers/TaskKanbanController.php
@@ -12,7 +12,7 @@ class TaskKanbanController extends BaseController
/**
* @return \Illuminate\Contracts\View\View
*/
- public function index()
+ public function index($clientPublicId = false)
{
$tasks = Task::scope()
->with(['project', 'client', 'task_status'])
@@ -84,6 +84,7 @@ class TaskKanbanController extends BaseController
'tasks' => $tasks,
'clients' => $clients,
'projects' => $projects,
+ 'clientPublicId' => $clientPublicId,
];
return view('tasks.kanban', $data);
diff --git a/resources/views/list.blade.php b/resources/views/list.blade.php
index b26ae8e546c3..f91234c96ce1 100644
--- a/resources/views/list.blade.php
+++ b/resources/views/list.blade.php
@@ -84,7 +84,7 @@
});
@elseif ($entityType == ENTITY_TASK)
- {!! Button::normal(trans('texts.kanban'))->asLinkTo(url('/tasks/kanban'))->appendIcon(Icon::create('th')) !!}
+ {!! Button::normal(trans('texts.kanban'))->asLinkTo(url('/tasks/kanban' . (! empty($clientId) ? '/' . $clientId : '')))->appendIcon(Icon::create('th')) !!}
{!! Button::normal(trans('texts.time_tracker'))->asLinkTo('javascript:openTimeTracker()')->appendIcon(Icon::create('time')) !!}
@endif
diff --git a/resources/views/tasks/kanban.blade.php b/resources/views/tasks/kanban.blade.php
index 8daf068b86dc..9f72e4861506 100644
--- a/resources/views/tasks/kanban.blade.php
+++ b/resources/views/tasks/kanban.blade.php
@@ -121,7 +121,7 @@
@section('top-right')
-
@stop
@@ -560,14 +560,50 @@
function ClientModel(data) {
var self = this;
self.name = ko.observable();
+ self.contacts = ko.observableArray();
self.displayName = ko.computed(function() {
- return self.name();
+ if (self.name()) {
+ return self.name();
+ }
+
+ if (self.contacts().length) {
+ return self.contacts()[0].displayName();
+ }
})
+ self.mapping = {
+ 'contacts': {
+ create: function(options) {
+ return new ContactModel(options.data);
+ }
+ }
+ }
+
+ if (data) {
+ ko.mapping.fromJS(data, self.mapping, this);
+ }
+ }
+
+ function ContactModel(data) {
+ var self = this;
+ self.public_id = ko.observable('');
+ self.first_name = ko.observable('');
+ self.last_name = ko.observable('');
+ self.email = ko.observable('');
+ self.phone = ko.observable('');
+
if (data) {
ko.mapping.fromJS(data, {}, this);
}
+
+ self.displayName = ko.computed(function() {
+ if (self.first_name() || self.last_name()) {
+ return self.first_name() + ' ' + self.last_name();
+ } else {
+ return self.email();
+ }
+ });
}
$(function() {
@@ -610,6 +646,14 @@
window.model = new ViewModel();
ko.applyBindings(model);
+ if ({{ $clientPublicId ? 'true' : 'false' }}) {
+ var client = clientMap[{{ $clientPublicId ?: 0 }}];
+ if (client) {
+ model.filter_client_id({{ $clientPublicId }});
+ model.filter(client.displayName());
+ }
+ }
+
$('.kanban').show();
});
diff --git a/routes/web.php b/routes/web.php
index ef1db445b0fd..af8d667ffbfc 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -143,7 +143,7 @@ Route::group(['middleware' => ['lookup:user', 'auth:user']], function () {
Route::get('clients/statement/{client_id}/{status_id?}/{start_date?}/{end_date?}', 'ClientController@statement');
Route::get('time_tracker', 'TimeTrackerController@index');
- Route::get('tasks/kanban', 'TaskKanbanController@index');
+ Route::get('tasks/kanban/{client_id?}', 'TaskKanbanController@index');
Route::post('task_statuses', 'TaskKanbanController@storeStatus');
Route::put('task_statuses/{task_status_id}', 'TaskKanbanController@updateStatus');
Route::delete('task_statuses/{task_status_id}', 'TaskKanbanController@deleteStatus');