u
This commit is contained in:
@@ -42,12 +42,19 @@ export default function toggleFather(provider) {
|
||||
}
|
||||
|
||||
const currentRes = await runner.query(
|
||||
'SELECT fatherarticle_id FROM article WHERE id = @articleId',
|
||||
'SELECT fatherarticle_id, articlelist_id, optionslist_id FROM article WHERE id = @articleId',
|
||||
{ articleId },
|
||||
);
|
||||
const currentArt = currentRes.rows[0];
|
||||
if (currentArt?.articlelist_id != null) {
|
||||
throw new Error('A Stückliste article cannot become a father');
|
||||
}
|
||||
if (currentArt?.optionslist_id != null) {
|
||||
throw new Error('An article with options cannot become a father');
|
||||
}
|
||||
|
||||
// If article is a child, verify attribute is not used by father or any father up the chain
|
||||
let currentFatherId = currentRes.rows[0]?.fatherarticle_id;
|
||||
let currentFatherId = currentArt?.fatherarticle_id;
|
||||
const visited = new Set();
|
||||
while (currentFatherId != null && !visited.has(currentFatherId)) {
|
||||
visited.add(currentFatherId);
|
||||
|
||||
Reference in New Issue
Block a user