pick2
gitea/salix/master This commit looks good Details

This commit is contained in:
Joan Sanchez 2019-09-13 13:00:33 +02:00
parent dd0c34d31b
commit c7423f5580
1 changed files with 9 additions and 12 deletions

View File

@ -31,7 +31,7 @@ module.exports = Self => {
}
});
Self.getLeaves = async(zoneFk, parentFk, filter) => {
Self.getLeaves = async(zoneFk, parentFk = null, filter) => {
let conn = Self.dataSource.connector;
let stmts = [];
@ -79,18 +79,15 @@ module.exports = Self => {
AND zg.depth > 0
UNION ALL
SELECT
child.id,
child.name,
child.lft,
child.rgt,
child.depth,
child.sons,
zg.id,
zg.name,
zg.lft,
zg.rgt,
zg.depth,
zg.sons,
zi.isIncluded AS selected
FROM zoneGeo parent
JOIN zoneGeo child ON child.lft > parent.lft
AND child.rgt < parent.rgt
AND child.depth = parent.depth + 1
LEFT JOIN zoneIncluded zi ON zi.geoFk = child.id
FROM zoneGeo zg
LEFT JOIN zoneIncluded zi ON zi.geoFk = zg.id
AND zi.zoneFk = ?
WHERE (? IS NULL AND zg.parentFk IS NULL)
OR (? IS NOT NULL AND zg.parentFk = ?)) AS nst`,