Fixes for tasks, and migrations

This commit is contained in:
David Bomba 2021-01-06 10:36:20 +11:00
parent 2e3c80500c
commit c132e9ace8
8 changed files with 25 additions and 12 deletions

View File

@ -18,7 +18,7 @@
* @OA\Property(property="task_status_id", type="string", example="", description="________"), * @OA\Property(property="task_status_id", type="string", example="", description="________"),
* @OA\Property(property="description", type="string", example="", description="________"), * @OA\Property(property="description", type="string", example="", description="________"),
* @OA\Property(property="duration", type="integer", example="", description="________"), * @OA\Property(property="duration", type="integer", example="", description="________"),
* @OA\Property(property="task_status_sort_order", type="integer", example="", description="________"), * @OA\Property(property="task_status_order", type="integer", example="", description="________"),
* @OA\Property(property="custom_value1", type="string", example="", description="________"), * @OA\Property(property="custom_value1", type="string", example="", description="________"),
* @OA\Property(property="custom_value2", type="string", example="", description="________"), * @OA\Property(property="custom_value2", type="string", example="", description="________"),
* @OA\Property(property="custom_value3", type="string", example="", description="________"), * @OA\Property(property="custom_value3", type="string", example="", description="________"),

View File

@ -390,6 +390,7 @@ class Import implements ShouldQueue
foreach ($data as $resource) { foreach ($data as $resource) {
$modified = $resource; $modified = $resource;
unset($modified['id']); unset($modified['id']);
unset($modified['password']); //cant import passwords.
$user = $user_repository->save($modified, $this->fetchUser($resource['email']), true, true); $user = $user_repository->save($modified, $this->fetchUser($resource['email']), true, true);

View File

@ -34,11 +34,12 @@ class Task extends BaseModel
'is_running', 'is_running',
'time_log', 'time_log',
'status_id', 'status_id',
'status_sort_order', 'status_sort_order', //deprecated
'invoice_documents', 'invoice_documents',
'rate', 'rate',
'number', 'number',
'is_date_based', 'is_date_based',
'status_order',
]; ];
protected $touches = []; protected $touches = [];

View File

@ -29,5 +29,5 @@ class TaskStatus extends BaseModel
*/ */
protected $dates = ['deleted_at']; protected $dates = ['deleted_at'];
protected $fillable = ['name','color']; protected $fillable = ['name','color','status_order'];
} }

View File

@ -42,8 +42,9 @@ class TaskRepository extends BaseRepository
$task->description = trim($data['description']); $task->description = trim($data['description']);
} }
if (isset($data['status_sort_order'])) { //todo i can't set it - i need to calculate it.
$task->status_sort_order = $data['status_sort_order']; if (isset($data['status_order'])) {
$task->status_order = $data['status_order'];
} }
if (isset($data['time_log'])) { if (isset($data['time_log'])) {

View File

@ -24,11 +24,12 @@ class TaskStatusTransformer extends EntityTransformer
'id' => (string) $this->encodePrimaryKey($task_status->id), 'id' => (string) $this->encodePrimaryKey($task_status->id),
'name' => (string) $task_status->name, 'name' => (string) $task_status->name,
'color' => (string) $task_status->color, 'color' => (string) $task_status->color,
'sort_order' => (int) $task_status->sort_order, 'sort_order' => (int) $task_status->sort_order, //deprecated
'is_deleted' => (bool) $task_status->is_deleted, 'is_deleted' => (bool) $task_status->is_deleted,
'created_at' => (int) $task_status->created_at, 'created_at' => (int) $task_status->created_at,
'updated_at' => (int) $task_status->updated_at, 'updated_at' => (int) $task_status->updated_at,
'archived_at' => (int) $task_status->deleted_at, 'archived_at' => (int) $task_status->deleted_at,
'status_order' => $task_status->status_order,
]; ];
} }
} }

View File

@ -65,8 +65,9 @@ class TaskTransformer extends EntityTransformer
'custom_value3' => $task->custom_value3 ?: '', 'custom_value3' => $task->custom_value3 ?: '',
'custom_value4' => $task->custom_value4 ?: '', 'custom_value4' => $task->custom_value4 ?: '',
'status_id' => $this->encodePrimaryKey($task->status_id) ?: '', 'status_id' => $this->encodePrimaryKey($task->status_id) ?: '',
'status_sort_order' => (int) $task->status_sort_order, 'status_sort_order' => (int) $task->status_sort_order, //deprecated 5.0.34
'is_date_based' => (bool) $task->is_date_based, 'is_date_based' => (bool) $task->is_date_based,
'status_order' => $task->status_order
]; ];
} }
} }

View File

@ -110,6 +110,11 @@ class ImproveDecimalResolution extends Migration
$table->integer('status_sort_order')->nullable()->default(null)->change(); $table->integer('status_sort_order')->nullable()->default(null)->change();
}); });
Schema::table('task_statuses', function (Blueprint $table){
$table->string('color')->default('#fff');
$table->integer('status_sort_order')->nullable()->default(null)->change();
});
Schema::table('tax_rates', function (Blueprint $table) { Schema::table('tax_rates', function (Blueprint $table) {
$table->decimal('rate', 20, 6)->change(); $table->decimal('rate', 20, 6)->change();
}); });
@ -119,11 +124,6 @@ class ImproveDecimalResolution extends Migration
$table->boolean('hide_empty_columns_on_pdf')->false(); $table->boolean('hide_empty_columns_on_pdf')->false();
}); });
Schema::table('task_statuses', function (Blueprint $table){
$table->string('color')->default('#fff');
$table->integer('status_sort_order')->nullable()->default(null)->change();
});
Schema::table('expense_categories', function (Blueprint $table){ Schema::table('expense_categories', function (Blueprint $table){
$table->string('color')->default('#fff'); $table->string('color')->default('#fff');
}); });
@ -136,6 +136,14 @@ class ImproveDecimalResolution extends Migration
Task::query()->update(['status_sort_order' => NULL]); Task::query()->update(['status_sort_order' => NULL]);
TaskStatus::query()->update(['status_sort_order' => NULL]); TaskStatus::query()->update(['status_sort_order' => NULL]);
Schema::table('tasks', function (Blueprint $table) {
$table->integer('status_order')->nullable();
});
Schema::table('task_statuses', function (Blueprint $table){
$table->integer('status_order')->nullable();
});
} }
/** /**