mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
clone tasks
This commit is contained in:
parent
0fccf69e62
commit
dc62abd766
33
app/Http/Controllers/TaskController.php
Normal file → Executable file
33
app/Http/Controllers/TaskController.php
Normal file → Executable file
@ -140,6 +140,12 @@ class TaskController extends BaseController
|
|||||||
return View::make('tasks.edit', $data);
|
return View::make('tasks.edit', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function cloneTask(TaskRequest $request, $publicId)
|
||||||
|
{
|
||||||
|
return self::edit($request, $publicId, true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show the form for editing the specified resource.
|
* Show the form for editing the specified resource.
|
||||||
*
|
*
|
||||||
@ -147,7 +153,7 @@ class TaskController extends BaseController
|
|||||||
*
|
*
|
||||||
* @return \Illuminate\Contracts\View\View
|
* @return \Illuminate\Contracts\View\View
|
||||||
*/
|
*/
|
||||||
public function edit(TaskRequest $request)
|
public function edit(TaskRequest $request, $publicId, $clone = false)
|
||||||
{
|
{
|
||||||
$this->checkTimezone();
|
$this->checkTimezone();
|
||||||
$task = $request->entity();
|
$task = $request->entity();
|
||||||
@ -172,19 +178,35 @@ class TaskController extends BaseController
|
|||||||
|
|
||||||
$actions[] = DropdownButton::DIVIDER;
|
$actions[] = DropdownButton::DIVIDER;
|
||||||
if (! $task->trashed()) {
|
if (! $task->trashed()) {
|
||||||
|
if (! $clone) {
|
||||||
|
$actions[] = ['url' => 'javascript:submitAction("clone")', 'label' => trans("texts.clone_task")];
|
||||||
|
}
|
||||||
$actions[] = ['url' => 'javascript:submitAction("archive")', 'label' => trans('texts.archive_task')];
|
$actions[] = ['url' => 'javascript:submitAction("archive")', 'label' => trans('texts.archive_task')];
|
||||||
$actions[] = ['url' => 'javascript:onDeleteClick()', 'label' => trans('texts.delete_task')];
|
$actions[] = ['url' => 'javascript:onDeleteClick()', 'label' => trans('texts.delete_task')];
|
||||||
} else {
|
} else {
|
||||||
$actions[] = ['url' => 'javascript:submitAction("restore")', 'label' => trans('texts.restore_task')];
|
$actions[] = ['url' => 'javascript:submitAction("restore")', 'label' => trans('texts.restore_task')];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($clone) {
|
||||||
|
$task->id = null;
|
||||||
|
$task->public_id = null;
|
||||||
|
$task->deleted_at = null;
|
||||||
|
|
||||||
|
$method = 'POST';
|
||||||
|
$url = 'tasks';
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$method = 'PUT';
|
||||||
|
$url = 'tasks/'.$task->public_id;
|
||||||
|
}
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'task' => $task,
|
'task' => $task,
|
||||||
'entity' => $task,
|
'entity' => $task,
|
||||||
'clientPublicId' => $task->client ? $task->client->public_id : 0,
|
'clientPublicId' => $task->client ? $task->client->public_id : 0,
|
||||||
'projectPublicId' => $task->project ? $task->project->public_id : 0,
|
'projectPublicId' => $task->project ? $task->project->public_id : 0,
|
||||||
'method' => 'PUT',
|
'method' => $method,
|
||||||
'url' => 'tasks/'.$task->public_id,
|
'url' => $url,
|
||||||
'title' => trans('texts.edit_task'),
|
'title' => trans('texts.edit_task'),
|
||||||
'actions' => $actions,
|
'actions' => $actions,
|
||||||
'timezone' => Auth::user()->account->timezone ? Auth::user()->account->timezone->name : DEFAULT_TIMEZONE,
|
'timezone' => Auth::user()->account->timezone ? Auth::user()->account->timezone->name : DEFAULT_TIMEZONE,
|
||||||
@ -229,8 +251,13 @@ class TaskController extends BaseController
|
|||||||
*/
|
*/
|
||||||
private function save($request, $publicId = null)
|
private function save($request, $publicId = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
$action = Input::get('action');
|
$action = Input::get('action');
|
||||||
|
|
||||||
|
if ( in_array($action, ['clone'])) {
|
||||||
|
return redirect()->to(sprintf('tasks/%s/clone', $publicId));
|
||||||
|
}
|
||||||
|
|
||||||
if (in_array($action, ['archive', 'delete', 'restore'])) {
|
if (in_array($action, ['archive', 'delete', 'restore'])) {
|
||||||
return self::bulk();
|
return self::bulk();
|
||||||
}
|
}
|
||||||
|
@ -85,6 +85,15 @@ class TaskDatatable extends EntityDatatable
|
|||||||
return (! $model->deleted_at || $model->deleted_at == '0000-00-00') && Auth::user()->can('view', [ENTITY_TASK, $model]);
|
return (! $model->deleted_at || $model->deleted_at == '0000-00-00') && Auth::user()->can('view', [ENTITY_TASK, $model]);
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
trans('texts.clone_task'),
|
||||||
|
function ($model) {
|
||||||
|
return URL::to("tasks/{$model->public_id}/clone");
|
||||||
|
},
|
||||||
|
function ($model) {
|
||||||
|
return Auth::user()->can('create', ENTITY_TASK);
|
||||||
|
},
|
||||||
|
],
|
||||||
[
|
[
|
||||||
trans('texts.view_invoice'),
|
trans('texts.view_invoice'),
|
||||||
function ($model) {
|
function ($model) {
|
||||||
|
@ -549,6 +549,7 @@ $LANG = array(
|
|||||||
'created_task' => 'Successfully created task',
|
'created_task' => 'Successfully created task',
|
||||||
'updated_task' => 'Successfully updated task',
|
'updated_task' => 'Successfully updated task',
|
||||||
'edit_task' => 'Edit Task',
|
'edit_task' => 'Edit Task',
|
||||||
|
'clone_task' => 'Clone Task',
|
||||||
'archive_task' => 'Archive Task',
|
'archive_task' => 'Archive Task',
|
||||||
'restore_task' => 'Restore Task',
|
'restore_task' => 'Restore Task',
|
||||||
'delete_task' => 'Delete Task',
|
'delete_task' => 'Delete Task',
|
||||||
|
@ -549,6 +549,7 @@ $LANG = array(
|
|||||||
'created_task' => 'Successfully created task',
|
'created_task' => 'Successfully created task',
|
||||||
'updated_task' => 'Successfully updated task',
|
'updated_task' => 'Successfully updated task',
|
||||||
'edit_task' => 'Edit Task',
|
'edit_task' => 'Edit Task',
|
||||||
|
'clone_task' => 'Clone Task',
|
||||||
'archive_task' => 'Archive Task',
|
'archive_task' => 'Archive Task',
|
||||||
'restore_task' => 'Restore Task',
|
'restore_task' => 'Restore Task',
|
||||||
'delete_task' => 'Delete Task',
|
'delete_task' => 'Delete Task',
|
||||||
|
@ -549,6 +549,7 @@ $LANG = array(
|
|||||||
'created_task' => 'Successfully created task',
|
'created_task' => 'Successfully created task',
|
||||||
'updated_task' => 'Successfully updated task',
|
'updated_task' => 'Successfully updated task',
|
||||||
'edit_task' => 'Edit Task',
|
'edit_task' => 'Edit Task',
|
||||||
|
'clone_task' => 'Clone Task',
|
||||||
'archive_task' => 'Archive Task',
|
'archive_task' => 'Archive Task',
|
||||||
'restore_task' => 'Restore Task',
|
'restore_task' => 'Restore Task',
|
||||||
'delete_task' => 'Delete Task',
|
'delete_task' => 'Delete Task',
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
@endif
|
@endif
|
||||||
{!! Former::text('action') !!}
|
{!! Former::text('action') !!}
|
||||||
{!! Former::text('time_log') !!}
|
{!! Former::text('time_log') !!}
|
||||||
|
{!! Former::text('is_running') !!}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row" onkeypress="formEnterClick(event)">
|
<div class="row" onkeypress="formEnterClick(event)">
|
||||||
|
@ -183,6 +183,7 @@ Route::group(['middleware' => ['lookup:user', 'auth:user']], function () {
|
|||||||
Route::delete('task_statuses/{task_status_id}', 'TaskKanbanController@deleteStatus');
|
Route::delete('task_statuses/{task_status_id}', 'TaskKanbanController@deleteStatus');
|
||||||
Route::put('task_status_order/{task_id}', 'TaskKanbanController@updateTask');
|
Route::put('task_status_order/{task_id}', 'TaskKanbanController@updateTask');
|
||||||
Route::resource('tasks', 'TaskController');
|
Route::resource('tasks', 'TaskController');
|
||||||
|
Route::get('tasks/{tasks}/clone', 'TaskController@cloneTask');
|
||||||
Route::get('api/tasks/{client_id?}/{project_id?}', 'TaskController@getDatatable');
|
Route::get('api/tasks/{client_id?}/{project_id?}', 'TaskController@getDatatable');
|
||||||
Route::get('tasks/create/{client_id?}/{project_id?}', 'TaskController@create');
|
Route::get('tasks/create/{client_id?}/{project_id?}', 'TaskController@create');
|
||||||
Route::post('tasks/bulk', 'TaskController@bulk');
|
Route::post('tasks/bulk', 'TaskController@bulk');
|
||||||
@ -442,4 +443,4 @@ if (Utils::isNinjaDev())
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Include static app constants
|
// Include static app constants
|
||||||
require_once app_path() . '/Constants.php';
|
require_once app_path() . '/Constants.php';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user