fix isssue add data chức năng sprintReview
This commit is contained in:
parent
ba71078a72
commit
a1032bf5d9
|
|
@ -229,7 +229,8 @@ class CriteriasController extends Controller
|
||||||
'criterias' => 'required|array',
|
'criterias' => 'required|array',
|
||||||
'users' => 'required|array',
|
'users' => 'required|array',
|
||||||
]);
|
]);
|
||||||
// $sprintId = (int)$sprintId;
|
$sprintId = (int)$sprintId;
|
||||||
|
|
||||||
// Sử dụng transaction để đảm bảo tính toàn vẹn dữ liệu
|
// Sử dụng transaction để đảm bảo tính toàn vẹn dữ liệu
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
try {
|
try {
|
||||||
|
|
@ -245,8 +246,12 @@ class CriteriasController extends Controller
|
||||||
$sprint->update([
|
$sprint->update([
|
||||||
'name' => $validated['name'],
|
'name' => $validated['name'],
|
||||||
'project_id' => $validated['project_id'],
|
'project_id' => $validated['project_id'],
|
||||||
'point' => $validated['finalPoint'] ?? "",
|
'point' => $request->finalPoint ?? "",
|
||||||
// Cập nhật các trường khác nếu có
|
|
||||||
|
'start_date' => $request->start_date,
|
||||||
|
'end_date' => $request->end_date,
|
||||||
|
'complete_date' => $request->complete_date,
|
||||||
|
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
// Nếu không tồn tại, tạo mới Sprint
|
// Nếu không tồn tại, tạo mới Sprint
|
||||||
|
|
@ -254,15 +259,18 @@ class CriteriasController extends Controller
|
||||||
'id' => $sprintId,
|
'id' => $sprintId,
|
||||||
'name' => $validated['name'],
|
'name' => $validated['name'],
|
||||||
'project_id' => $validated['project_id'],
|
'project_id' => $validated['project_id'],
|
||||||
'point' => $validated['finalPoint'] ?? "",
|
'point' => $request->finalPoint ?? "",
|
||||||
// Thêm các trường khác nếu có
|
|
||||||
|
'start_date' => $request->start_date,
|
||||||
|
'end_date' => $request->end_date,
|
||||||
|
'complete_date' => $request->complete_date,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Thêm lại các liên kết sprints_criterias
|
// Thêm lại các liên kết sprints_criterias
|
||||||
foreach ($validated['criterias'] as $criteria) {
|
foreach ($validated['criterias'] as $criteria) {
|
||||||
SprintCriteria::create([
|
SprintCriteria::create([
|
||||||
'sprint_id' => $sprint->id,
|
'sprint_id' => $sprintId,
|
||||||
'criteria_id' => $criteria['id'],
|
'criteria_id' => $criteria['id'],
|
||||||
'point' => $criteria['point'] ?? "",
|
'point' => $criteria['point'] ?? "",
|
||||||
'expect_result' => $criteria['expect'] ?? "",
|
'expect_result' => $criteria['expect'] ?? "",
|
||||||
|
|
@ -276,7 +284,7 @@ class CriteriasController extends Controller
|
||||||
UserCriteria::create([
|
UserCriteria::create([
|
||||||
'user_email' => $userCriteria['user_email'],
|
'user_email' => $userCriteria['user_email'],
|
||||||
'criteria_id' => $userCriteria['criteria_id'],
|
'criteria_id' => $userCriteria['criteria_id'],
|
||||||
'sprint_id' => $sprint->id,
|
'sprint_id' => $sprintId,
|
||||||
'point' => $userCriteria['point'] ?? "",
|
'point' => $userCriteria['point'] ?? "",
|
||||||
'note' => $userCriteria['note'] ?? "",
|
'note' => $userCriteria['note'] ?? "",
|
||||||
]);
|
]);
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ return new class extends Migration
|
||||||
$table->string('created_by');
|
$table->string('created_by');
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
|
|
||||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
// $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||||
$table->foreign('criteria_id')->references('id')->on('criterias')->onDelete('cascade');
|
$table->foreign('criteria_id')->references('id')->on('criterias')->onDelete('cascade');
|
||||||
$table->foreign('sprint_id')->references('id')->on('sprint')->onDelete('cascade');
|
$table->foreign('sprint_id')->references('id')->on('sprint')->onDelete('cascade');
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,10 @@ type DataProject = {
|
||||||
type DataSprint = {
|
type DataSprint = {
|
||||||
id: number
|
id: number
|
||||||
name: string
|
name: string
|
||||||
|
|
||||||
|
startDate?: string
|
||||||
|
endDate?: string
|
||||||
|
completeDate?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
type DataCriteriaSprint = {
|
type DataCriteriaSprint = {
|
||||||
|
|
@ -221,8 +225,17 @@ const SprintReview = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleUpdate = async () => {
|
const handleUpdate = async () => {
|
||||||
|
const dataSprintSearch = dataSprint.find(
|
||||||
|
(item: DataSprint) => item.id == Number(filter.sprint),
|
||||||
|
)
|
||||||
|
|
||||||
const values = {
|
const values = {
|
||||||
name: dataSprint.find((item: any) => item.id == filter.sprint)?.name,
|
name: dataSprint.find((item: any) => item.id == filter.sprint)?.name,
|
||||||
|
|
||||||
|
start_date: dataSprintSearch?.startDate,
|
||||||
|
end_date: dataSprintSearch?.endDate,
|
||||||
|
complete_date: dataSprintSearch?.completeDate,
|
||||||
|
|
||||||
project_id: filter.project,
|
project_id: filter.project,
|
||||||
criterias: criteriaSprint,
|
criterias: criteriaSprint,
|
||||||
users: criteriaUsers,
|
users: criteriaUsers,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue