Add in task item log entry to task exports

This commit is contained in:
David Bomba 2024-08-12 08:37:23 +10:00
parent 344603123a
commit 92f1ef98d0
6 changed files with 35 additions and 5 deletions

View File

@ -451,6 +451,7 @@ class BaseExport
'project' => 'task.project_id', 'project' => 'task.project_id',
'billable' => 'task.billable', 'billable' => 'task.billable',
'item_notes' => 'task.item_notes', 'item_notes' => 'task.item_notes',
'time_log' => 'task.time_log',
]; ];
protected array $forced_client_fields = [ protected array $forced_client_fields = [

View File

@ -156,7 +156,7 @@ class TaskExport extends BaseExport
$entity[$key] = $transformed_entity[$parts[1]]; $entity[$key] = $transformed_entity[$parts[1]];
} elseif (array_key_exists($key, $transformed_entity)) { } elseif (array_key_exists($key, $transformed_entity)) {
$entity[$key] = $transformed_entity[$key]; $entity[$key] = $transformed_entity[$key];
} elseif (in_array($key, ['task.start_date', 'task.end_date', 'task.duration', 'task.billable', 'task.item_notes'])) { } elseif (in_array($key, ['task.start_date', 'task.end_date', 'task.duration', 'task.billable', 'task.item_notes', 'task.time_log'])) {
$entity[$key] = ''; $entity[$key] = '';
} else { } else {
$entity[$key] = $this->decorator->transform($key, $task); $entity[$key] = $this->decorator->transform($key, $task);
@ -207,6 +207,9 @@ class TaskExport extends BaseExport
$seconds = $task->calcDuration(); $seconds = $task->calcDuration();
$entity['task.duration'] = $seconds; $entity['task.duration'] = $seconds;
$entity['task.duration_words'] = $seconds > 86400 ? CarbonInterval::seconds($seconds)->locale($this->company->locale())->cascade()->forHumans() : now()->startOfDay()->addSeconds($seconds)->format('H:i:s'); $entity['task.duration_words'] = $seconds > 86400 ? CarbonInterval::seconds($seconds)->locale($this->company->locale())->cascade()->forHumans() : now()->startOfDay()->addSeconds($seconds)->format('H:i:s');
$entity['task.time_log'] = (isset($item[1]) && $item[1] != 0) ? $item[1] - $item[0] : ctrans('texts.is_running');
} }
if (in_array('task.billable', $this->input['report_keys']) || in_array('billable', $this->input['report_keys'])) { if (in_array('task.billable', $this->input['report_keys']) || in_array('billable', $this->input['report_keys'])) {

View File

@ -133,7 +133,7 @@ class UpdateTaskRequest extends Request
} }
if(!isset($input['time_log']) || empty($input['time_log']) || $input['time_log'] == '{}') { if(!isset($input['time_log']) || empty($input['time_log']) || $input['time_log'] == '{}' || $input['time_log'] == '[""]') {
$input['time_log'] = json_encode([]); $input['time_log'] = json_encode([]);
} }

View File

@ -79,7 +79,7 @@ class AdjustEmailQuota implements ShouldQueue
/** Use redis pipelines to execute bulk deletes efficiently */ /** Use redis pipelines to execute bulk deletes efficiently */
$redis = Redis::connection('sentinel-cache'); $redis = Redis::connection('sentinel-cache');
$prefix = config('cache.prefix'). ":email_quota*"; $prefix = config('cache.prefix'). "email_quota*";
$keys = $redis->keys($prefix); $keys = $redis->keys($prefix);
@ -92,7 +92,7 @@ class AdjustEmailQuota implements ShouldQueue
} }
$keys = null; $keys = null;
$prefix = config('cache.prefix'). ":throttle_notified*"; $prefix = config('cache.prefix'). "throttle_notified*";
$keys = $redis->keys($prefix); $keys = $redis->keys($prefix);

View File

@ -2,6 +2,13 @@
@section('meta_title', ctrans('texts.dashboard')) @section('meta_title', ctrans('texts.dashboard'))
@section('body') @section('body')
@if($client->getSetting('custom_message_dashboard'))
@component('portal.ninja2020.components.message')
<pre>{{ $client->getSetting('custom_message_dashboard') }}</pre>
@endcomponent
@endif
<div class="flex flex-col xl:flex-row gap-4"> <div class="flex flex-col xl:flex-row gap-4">
<div class="w-full rounded-md border border-[#E5E7EB] bg-white p-5 text-sm text-[#6C727F]"> <div class="w-full rounded-md border border-[#E5E7EB] bg-white p-5 text-sm text-[#6C727F]">
<h3 class="mb-4 text-xl font-semibold text-[#212529]">{{ $contact->first_name }} {{ $contact->last_name }}</h3> <h3 class="mb-4 text-xl font-semibold text-[#212529]">{{ $contact->first_name }} {{ $contact->last_name }}</h3>

View File

@ -224,6 +224,25 @@ class TaskApiTest extends TestCase
])->postJson("/api/v1/tasks", $data); ])->postJson("/api/v1/tasks", $data);
$response->assertStatus(200); $response->assertStatus(200);
$arr = $response->json();
$data = [
'client_id' => $this->client->hashed_id,
'description' => 'Test Task',
'time_log' => '[""]',
'assigned_user' => [],
'project' => [],
'user' => [],
];
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->putJson("/api/v1/tasks/".$arr['data']['id'], $data);
$response->assertStatus(200);
} }
public function testUserFilters() public function testUserFilters()