Skip to content

Commit

Permalink
Merge pull request #472 from Chia-Network/fix-removing-a-label-from-t…
Browse files Browse the repository at this point in the history
…he-unit-deletes-it-from-the-data-layer-even-if-it-is-assigned-to-a-project-or-other-units

fix: removing a label from the unit deletes it from the data layer
  • Loading branch information
MichaelTaylor3D authored Apr 15, 2022
2 parents a6b8379 + 4a0fbb8 commit cb0a774
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 cb0a774

Please sign in to comment.