IO-1693 Allow 0 line supplements.

This commit is contained in:
Patrick Fic
2022-03-16 11:47:32 -07:00
parent 279e93f0c3
commit 3439f09d9a
2 changed files with 14 additions and 7 deletions

View File

@@ -37,7 +37,6 @@ export const GetSupplementDelta = async (client, jobId, newLines) => {
}); });
//Wahtever is left in the existing lines, are lines that should be removed. //Wahtever is left in the existing lines, are lines that should be removed.
const insertQueries = linesToInsert.reduce((acc, value, idx) => { const insertQueries = linesToInsert.reduce((acc, value, idx) => {
return acc + generateInsertQuery(value, idx, jobId); return acc + generateInsertQuery(value, idx, jobId);
}, ""); }, "");
@@ -49,6 +48,13 @@ export const GetSupplementDelta = async (client, jobId, newLines) => {
const removeQueries = existingLines.reduce((acc, value, idx) => { const removeQueries = existingLines.reduce((acc, value, idx) => {
return acc + generateRemoveQuery(value, idx); return acc + generateRemoveQuery(value, idx);
}, ""); }, "");
console.log(insertQueries, updateQueries, removeQueries);
if ((insertQueries + updateQueries + removeQueries).trim() === "") {
return new Promise((resolve, reject) => {
resolve(null);
});
}
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
resolve(gql` resolve(gql`

View File

@@ -220,12 +220,13 @@ export function JobsAvailableContainer({
); );
delete supp.joblines; delete supp.joblines;
await client.mutate({ if (suppDelta !== null) {
mutation: gql` await client.mutate({
${suppDelta} mutation: gql`
`, ${suppDelta}
}); `,
});
}
const updateResult = await updateJob({ const updateResult = await updateJob({
variables: { variables: {
jobId: selectedJob, jobId: selectedJob,