Skip to content

Commit

Permalink
fix: removing a label from the unit deletes it from the data layer
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandradumitru22 committed Apr 15, 2022
1 parent a6b8379 commit 4a0fbb8
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/models/units/units.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,28 @@ class Unit extends Model {
toStructuredCsv: true,
});

if (deleteXslsSheets.labels?.data.length > 1) {
const warehouseProjectIdIndex =
deleteXslsSheets.labels.data[0].indexOf('warehouseProjectId');
if (warehouseProjectIdIndex >= 0) {
for (
let index = deleteXslsSheets.labels.data.length - 1;
index > 0;
--index
) {
if (
deleteXslsSheets.labels.data[index][warehouseProjectIdIndex] != null
) {
deleteXslsSheets.labels.data.splice(index, 1);
}
}
}

if (deleteXslsSheets.labels.data.length === 1) {
delete deleteXslsSheets.labels;
}
}

const insertChangeList = await transformFullXslsToChangeList(
insertXslsSheets,
'insert',
Expand Down

0 comments on commit 4a0fbb8

Please sign in to comment.