mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Working on task kanban
This commit is contained in:
parent
b3a2da2732
commit
2740c529ec
@ -48,4 +48,55 @@ class TaskKanbanController extends BaseController
|
|||||||
return view('tasks.kanban', $data);
|
return view('tasks.kanban', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function storeStatus()
|
||||||
|
{
|
||||||
|
return $this->saveStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $publicId
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function updateStatus($publicId)
|
||||||
|
{
|
||||||
|
return $this->saveStatus($publicId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param bool $publicId
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
private function saveStatus($publicId = false)
|
||||||
|
{
|
||||||
|
if ($publicId) {
|
||||||
|
$status = TaskStatus::scope($publicId)->firstOrFail();
|
||||||
|
} else {
|
||||||
|
$status = TaskStatus::createNew();
|
||||||
|
}
|
||||||
|
|
||||||
|
$status->name = request('name');
|
||||||
|
$status->save();
|
||||||
|
|
||||||
|
return response()->json($status);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function deleteStatus($publicId)
|
||||||
|
{
|
||||||
|
$status = TaskStatus::scope($publicId)->first();
|
||||||
|
|
||||||
|
if ($status) {
|
||||||
|
$status->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json(['message' => RESULT_SUCCESS]);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -170,12 +170,16 @@
|
|||||||
for (var i=0; i<tasks.length; i++) {
|
for (var i=0; i<tasks.length; i++) {
|
||||||
var task = tasks[i];
|
var task = tasks[i];
|
||||||
var taskModel = new TaskModel(task);
|
var taskModel = new TaskModel(task);
|
||||||
|
var statusModel = false;
|
||||||
if (task.task_status) {
|
if (task.task_status) {
|
||||||
var statusModel = statusMap[task.task_status.public_id];
|
var statusModel = statusMap[task.task_status.public_id];
|
||||||
} else {
|
|
||||||
var statusModel = self.statuses()[0];
|
|
||||||
}
|
}
|
||||||
statusModel.tasks.push(taskModel);
|
if (! statusModel) {
|
||||||
|
statusModel = self.statuses()[0];
|
||||||
|
}
|
||||||
|
if (statusModel) {
|
||||||
|
statusModel.tasks.push(taskModel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.startAddStatus = function() {
|
self.startAddStatus = function() {
|
||||||
@ -188,11 +192,41 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.completeAddStatus = function() {
|
self.completeAddStatus = function() {
|
||||||
self.is_adding_status(false);
|
|
||||||
var statusModel = new StatusModel({
|
var statusModel = new StatusModel({
|
||||||
name: self.new_status()
|
name: self.new_status()
|
||||||
})
|
})
|
||||||
self.statuses.push(statusModel);
|
|
||||||
|
var url = '{{ url('/task_statuses') }}';
|
||||||
|
var data = 'name=' + encodeURIComponent(statusModel.name());
|
||||||
|
self.ajax('post', url, data, function(response) {
|
||||||
|
statusModel.public_id(response.public_id);
|
||||||
|
self.statuses.push(statusModel);
|
||||||
|
self.is_adding_status(false);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
self.ajax = function(method, url, data, callback) {
|
||||||
|
model.is_sending_request(true);
|
||||||
|
$.ajax({
|
||||||
|
type: method,
|
||||||
|
url: url,
|
||||||
|
data: data,
|
||||||
|
dataType: 'json',
|
||||||
|
accepts: {
|
||||||
|
json: 'application/json'
|
||||||
|
},
|
||||||
|
success: function(response) {
|
||||||
|
callback(response);
|
||||||
|
},
|
||||||
|
error: function(error) {
|
||||||
|
console.log('error');
|
||||||
|
console.log(error);
|
||||||
|
},
|
||||||
|
}).always(function() {
|
||||||
|
setTimeout(function() {
|
||||||
|
model.is_sending_request(false);
|
||||||
|
}, 1000);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
self.onDragged = function() {
|
self.onDragged = function() {
|
||||||
@ -217,21 +251,6 @@
|
|||||||
self.is_header_hovered(false);
|
self.is_header_hovered(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
self.inputValue = ko.computed({
|
|
||||||
read: function () {
|
|
||||||
return self.is_blank() ? '' : self.name();
|
|
||||||
},
|
|
||||||
write: function(value) {
|
|
||||||
self.name(value);
|
|
||||||
if (self.is_blank()) {
|
|
||||||
self.is_blank(false);
|
|
||||||
model.statuses.push(new StatusModel());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
|
|
||||||
self.startStatusEdit = function() {
|
self.startStatusEdit = function() {
|
||||||
self.is_editing_status(true);
|
self.is_editing_status(true);
|
||||||
}
|
}
|
||||||
@ -246,7 +265,10 @@
|
|||||||
|
|
||||||
self.archiveStatus = function() {
|
self.archiveStatus = function() {
|
||||||
sweetConfirm(function() {
|
sweetConfirm(function() {
|
||||||
window.model.statuses.remove(self);
|
var url = '{{ url('/task_statuses') }}/' + self.public_id();
|
||||||
|
model.ajax('delete', url, null, function(response) {
|
||||||
|
model.statuses.remove(self);
|
||||||
|
})
|
||||||
}, "{{ trans('texts.archive_status')}}");
|
}, "{{ trans('texts.archive_status')}}");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,30 +291,14 @@
|
|||||||
task_status_sort_order: self.tasks.length,
|
task_status_sort_order: self.tasks.length,
|
||||||
})
|
})
|
||||||
|
|
||||||
$.ajax({
|
var url = '{{ url('/tasks') }}';
|
||||||
dataType: 'json',
|
var data = task.toData();
|
||||||
type: 'post',
|
model.ajax('post', url, data, function(response) {
|
||||||
data: task.toData(),
|
task.public_id(response.public_id);
|
||||||
url: '{{ url('/tasks') }}',
|
self.tasks.push(task);
|
||||||
accepts: {
|
self.new_task.reset();
|
||||||
json: 'application/json'
|
self.endStatusEdit();
|
||||||
},
|
})
|
||||||
success: function(response) {
|
|
||||||
task.public_id(response.public_id);
|
|
||||||
},
|
|
||||||
error: function(error) {
|
|
||||||
console.log('error');
|
|
||||||
console.log(error);
|
|
||||||
},
|
|
||||||
}).always(function() {
|
|
||||||
setTimeout(function() {
|
|
||||||
model.is_sending_request(false);
|
|
||||||
}, 1000);
|
|
||||||
});
|
|
||||||
|
|
||||||
self.tasks.push(task);
|
|
||||||
self.new_task.reset();
|
|
||||||
self.endStatusEdit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
@ -393,29 +399,12 @@
|
|||||||
if (! description) {
|
if (! description) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$.ajax({
|
|
||||||
dataType: 'json',
|
|
||||||
type: 'put',
|
|
||||||
data: self.toData(),
|
|
||||||
url: '{{ url('/tasks') }}/' + self.public_id(),
|
|
||||||
accepts: {
|
|
||||||
json: 'application/json'
|
|
||||||
},
|
|
||||||
success: function(response) {
|
|
||||||
console.log('success');
|
|
||||||
console.log(response);
|
|
||||||
},
|
|
||||||
error: function(error) {
|
|
||||||
console.log('error');
|
|
||||||
console.log(error);
|
|
||||||
},
|
|
||||||
}).always(function() {
|
|
||||||
setTimeout(function() {
|
|
||||||
model.is_sending_request(false);
|
|
||||||
}, 1000);
|
|
||||||
});
|
|
||||||
|
|
||||||
self.endTaskEdit();
|
var url = '{{ url('/tasks') }}/' + self.public_id();
|
||||||
|
var data = self.toData();
|
||||||
|
model.ajax('put', url, data, function(response) {
|
||||||
|
self.endTaskEdit();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
self.viewTask = function() {
|
self.viewTask = function() {
|
||||||
@ -532,7 +521,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="kanban-column-row" data-bind="css: { editing: new_task.is_editing_task }, with: new_task">
|
<div class="kanban-column-row" data-bind="css: { editing: new_task.is_editing_task }, with: new_task">
|
||||||
<div data-bind="event: { click: startTaskEdit }" style="padding-bottom:6px">
|
<div data-bind="event: { click: startEditTask }" style="padding-bottom:6px">
|
||||||
<a href="#" class="view text-muted" style="font-size:13px" data-bind="visible: is_blank">
|
<a href="#" class="view text-muted" style="font-size:13px" data-bind="visible: is_blank">
|
||||||
{{ trans('texts.new_task') }}...
|
{{ trans('texts.new_task') }}...
|
||||||
</a>
|
</a>
|
||||||
|
@ -144,6 +144,9 @@ Route::group(['middleware' => ['lookup:user', 'auth:user']], function () {
|
|||||||
|
|
||||||
Route::get('time_tracker', 'TimeTrackerController@index');
|
Route::get('time_tracker', 'TimeTrackerController@index');
|
||||||
Route::get('tasks/kanban', 'TaskKanbanController@index');
|
Route::get('tasks/kanban', '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');
|
||||||
Route::resource('tasks', 'TaskController');
|
Route::resource('tasks', 'TaskController');
|
||||||
Route::get('api/tasks/{client_id?}', 'TaskController@getDatatable');
|
Route::get('api/tasks/{client_id?}', 'TaskController@getDatatable');
|
||||||
Route::get('tasks/create/{client_id?}/{project_id?}', 'TaskController@create');
|
Route::get('tasks/create/{client_id?}/{project_id?}', 'TaskController@create');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user