fix: set editState when onchange steps
This commit is contained in:
@@ -19,21 +19,10 @@ module.exports = function (sequelize) {
|
|||||||
return res.status(404).send('Case not found');
|
return res.status(404).send('Case not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
// if Case has Steps, update Steps as well
|
|
||||||
if (updateCase.Steps) {
|
if (updateCase.Steps) {
|
||||||
// Delete existing steps
|
delete updateCase.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;
|
|
||||||
await testcase.update(updateCase);
|
await testcase.update(updateCase);
|
||||||
res.json(testcase);
|
res.json(testcase);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ export default function StepsEditor({ isDisabled, steps, onStepUpdate, onStepPlu
|
|||||||
label={messages.detailsOfTheStep}
|
label={messages.detailsOfTheStep}
|
||||||
value={step.step}
|
value={step.step}
|
||||||
onValueChange={(changeValue) => {
|
onValueChange={(changeValue) => {
|
||||||
onStepUpdate(step.id, { ...step, step: changeValue });
|
onStepUpdate(step.id, { ...step, step: changeValue, editState: 'changed' });
|
||||||
}}
|
}}
|
||||||
className="mt-3 me-1"
|
className="mt-3 me-1"
|
||||||
/>
|
/>
|
||||||
@@ -46,7 +46,7 @@ export default function StepsEditor({ isDisabled, steps, onStepUpdate, onStepPlu
|
|||||||
label={messages.expectedResult}
|
label={messages.expectedResult}
|
||||||
value={step.result}
|
value={step.result}
|
||||||
onValueChange={(changeValue) => {
|
onValueChange={(changeValue) => {
|
||||||
onStepUpdate(step.id, { ...step, result: changeValue });
|
onStepUpdate(step.id, { ...step, result: changeValue, editState: 'changed' });
|
||||||
}}
|
}}
|
||||||
className="mt-3 ms-1"
|
className="mt-3 ms-1"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import { StepType } from '@/types/case';
|
|||||||
const apiServer = Config.apiServer;
|
const apiServer = Config.apiServer;
|
||||||
|
|
||||||
async function updateSteps(jwt: string, caseId: number, steps: StepType[]) {
|
async function updateSteps(jwt: string, caseId: number, steps: StepType[]) {
|
||||||
console.log(steps);
|
|
||||||
const fetchOptions = {
|
const fetchOptions = {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ type CasePriorityCountType = {
|
|||||||
count: number;
|
count: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type CasesMessages = {
|
type CasesMessages = {
|
||||||
testCaseList: string;
|
testCaseList: string;
|
||||||
id: string;
|
id: string;
|
||||||
title: string;
|
title: string;
|
||||||
@@ -85,7 +85,7 @@ export type CasesMessages = {
|
|||||||
pleaseEnter: string;
|
pleaseEnter: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type CaseMessages = {
|
type CaseMessages = {
|
||||||
backToCases: string;
|
backToCases: string;
|
||||||
updating: string;
|
updating: string;
|
||||||
update: string;
|
update: string;
|
||||||
@@ -134,4 +134,12 @@ export type CaseMessages = {
|
|||||||
areYouSureLeave: string;
|
areYouSureLeave: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export { CaseType, StepType, AttachmentType, CaseTypeCountType, CasePriorityCountType, CasesMessages, CaseMessages };
|
export type {
|
||||||
|
CaseType,
|
||||||
|
StepType,
|
||||||
|
AttachmentType,
|
||||||
|
CaseTypeCountType,
|
||||||
|
CasePriorityCountType,
|
||||||
|
CasesMessages,
|
||||||
|
CaseMessages,
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user