fix: set editState when onchange steps

This commit is contained in:
Takeshi Kimata
2024-07-07 21:38:54 +09:00
parent 82f76bcbb6
commit 908400eb86
4 changed files with 14 additions and 18 deletions

View File

@@ -19,21 +19,10 @@ module.exports = function (sequelize) {
return res.status(404).send('Case not found');
}
// if Case has Steps, update Steps as well
if (updateCase.Steps) {
// Delete existing steps
const steps = updateCase.Steps;
await Promise.all(
steps.map(async (step) => {
const existingStep = await Step.findByPk(step.id);
if (existingStep) {
await existingStep.update(step);
}
})
);
delete updateCase.Steps;
}
delete updateCase.Steps;
await testcase.update(updateCase);
res.json(testcase);
} catch (error) {

View File

@@ -35,7 +35,7 @@ export default function StepsEditor({ isDisabled, steps, onStepUpdate, onStepPlu
label={messages.detailsOfTheStep}
value={step.step}
onValueChange={(changeValue) => {
onStepUpdate(step.id, { ...step, step: changeValue });
onStepUpdate(step.id, { ...step, step: changeValue, editState: 'changed' });
}}
className="mt-3 me-1"
/>
@@ -46,7 +46,7 @@ export default function StepsEditor({ isDisabled, steps, onStepUpdate, onStepPlu
label={messages.expectedResult}
value={step.result}
onValueChange={(changeValue) => {
onStepUpdate(step.id, { ...step, result: changeValue });
onStepUpdate(step.id, { ...step, result: changeValue, editState: 'changed' });
}}
className="mt-3 ms-1"
/>

View File

@@ -3,7 +3,6 @@ import { StepType } from '@/types/case';
const apiServer = Config.apiServer;
async function updateSteps(jwt: string, caseId: number, steps: StepType[]) {
console.log(steps);
const fetchOptions = {
method: 'POST',
headers: {

View File

@@ -62,7 +62,7 @@ type CasePriorityCountType = {
count: number;
};
export type CasesMessages = {
type CasesMessages = {
testCaseList: string;
id: string;
title: string;
@@ -85,7 +85,7 @@ export type CasesMessages = {
pleaseEnter: string;
};
export type CaseMessages = {
type CaseMessages = {
backToCases: string;
updating: string;
update: string;
@@ -134,4 +134,12 @@ export type CaseMessages = {
areYouSureLeave: string;
};
export { CaseType, StepType, AttachmentType, CaseTypeCountType, CasePriorityCountType, CasesMessages, CaseMessages };
export type {
CaseType,
StepType,
AttachmentType,
CaseTypeCountType,
CasePriorityCountType,
CasesMessages,
CaseMessages,
};