From 05fec10cf290c14aa05c971c8ee30825bb9cf112 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Thu, 19 Sep 2019 17:30:16 +0200 Subject: [PATCH] Zone.getLeaves refactor & fixes --- modules/agency/back/methods/{zone-geo => zone}/getLeaves.js | 4 ++-- modules/agency/back/models/zone-geo.js | 3 --- modules/agency/back/models/zone.js | 1 + modules/agency/front/location/index.html | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) rename modules/agency/back/methods/{zone-geo => zone}/getLeaves.js (95%) delete mode 100644 modules/agency/back/models/zone-geo.js diff --git a/modules/agency/back/methods/zone-geo/getLeaves.js b/modules/agency/back/methods/zone/getLeaves.js similarity index 95% rename from modules/agency/back/methods/zone-geo/getLeaves.js rename to modules/agency/back/methods/zone/getLeaves.js index 11487304e..d919f97ac 100644 --- a/modules/agency/back/methods/zone-geo/getLeaves.js +++ b/modules/agency/back/methods/zone/getLeaves.js @@ -29,7 +29,7 @@ module.exports = Self => { Self.getLeaves = async(zoneFk, parentFk = null, search) => { let [res] = await Self.rawSql( - `CALL zoneGeo_getLeaves(?, ?, ?)`, + `CALL zone_getLeaves(?, ?, ?)`, [zoneFk, parentFk, search] ); @@ -51,6 +51,6 @@ module.exports = Self => { let leaves = map.get(parentFk); setLeaves(leaves); - return leaves; + return leaves || []; }; }; diff --git a/modules/agency/back/models/zone-geo.js b/modules/agency/back/models/zone-geo.js deleted file mode 100644 index 987e2de71..000000000 --- a/modules/agency/back/models/zone-geo.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = Self => { - require('../methods/zone-geo/getLeaves')(Self); -}; diff --git a/modules/agency/back/models/zone.js b/modules/agency/back/models/zone.js index c7ba642f3..2c540603d 100644 --- a/modules/agency/back/models/zone.js +++ b/modules/agency/back/models/zone.js @@ -1,6 +1,7 @@ module.exports = Self => { require('../methods/zone/clone')(Self); require('../methods/zone/editPrices')(Self); + require('../methods/zone/getLeaves')(Self); Self.validatesPresenceOf('warehouseFk', { message: `Warehouse cannot be blank` diff --git a/modules/agency/front/location/index.html b/modules/agency/front/location/index.html index 8773530ea..53957faf7 100644 --- a/modules/agency/front/location/index.html +++ b/modules/agency/front/location/index.html @@ -1,6 +1,6 @@