From dd9a38d1bfc8746be0bd5d843b6b874bc5c619cc Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 6 Apr 2022 12:29:00 +0200 Subject: [PATCH] feat(client_search-panel): filter by province --- db/dump/fixtures.sql | 8 ++-- .../methods/client/getPostCodeFromZone.js | 38 ------------------- modules/client/back/models/client.js | 1 - modules/client/front/main/index.js | 16 +------- modules/client/front/search-panel/index.html | 7 ---- modules/zone/back/models/zone-geo.json | 12 ------ modules/zone/back/models/zone.json | 5 --- 7 files changed, 5 insertions(+), 82 deletions(-) delete mode 100644 modules/client/back/methods/client/getPostCodeFromZone.js diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index e8302b1a2..5bd89ebd2 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -292,10 +292,10 @@ INSERT INTO `vn`.`contactChannel`(`id`, `name`) INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city`,`postcode`,`phone`,`mobile`,`isRelevant`,`email`,`iban`,`dueDay`,`accountingAccount`,`isEqualizated`,`provinceFk`,`hasToInvoice`,`credit`,`countryFk`,`isActive`,`gestdocFk`,`quality`,`payMethodFk`,`created`,`isToBeMailed`,`contactChannelFk`,`hasSepaVnl`,`hasCoreVnl`,`hasCoreVnh`,`riskCalculated`,`clientTypeFk`,`mailAddress`,`hasToInvoiceByAddress`,`isTaxDataChecked`,`isFreezed`,`creditInsurance`,`isCreatedAsServed`,`hasInvoiceSimplified`,`salesPersonFk`,`isVies`,`eypbc`, `businessTypeFk`) VALUES (1101, 'Bruce Wayne', '84612325V', 'Batman', 'Alfred', '1007 Mountain Drive, Gotham', 'Silla', 46460, 1111111111, 222222222, 1, 'BruceWayne@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'), - (1102, 'Petter Parker', '87945234L', 'Spider man', 'Aunt May', '20 Ingram Street, Queens, USA', 'Silla', 46460, 1111111111, 222222222, 1, 'PetterParker@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'), - (1103, 'Clark Kent', '06815934E', 'Super man', 'lois lane', '344 Clinton Street, Apartament 3-D', 'Silla', 46460, 1111111111, 222222222, 1, 'ClarkKent@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 0, 19, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'), - (1104, 'Tony Stark', '06089160W', 'Iron man', 'Pepper Potts', '10880 Malibu Point, 90265', 'Silla', 46460, 1111111111, 222222222, 1, 'TonyStark@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'), - (1105, 'Max Eisenhardt', '251628698', 'Magneto', 'Rogue', 'Unknown Whereabouts', 'Silla', 46460, 1111111111, 222222222, 1, 'MaxEisenhardt@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 8, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 1, NULL, 0, 0, 18, 0, 1, 'florist'), + (1102, 'Petter Parker', '87945234L', 'Spider man', 'Aunt May', '20 Ingram Street, Queens, USA', 'Silla', 46460, 1111111111, 222222222, 1, 'PetterParker@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'), + (1103, 'Clark Kent', '06815934E', 'Super man', 'lois lane', '344 Clinton Street, Apartament 3-D', 'Silla', 46460, 1111111111, 222222222, 1, 'ClarkKent@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 0, 19, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'), + (1104, 'Tony Stark', '06089160W', 'Iron man', 'Pepper Potts', '10880 Malibu Point, 90265', 'Silla', 46460, 1111111111, 222222222, 1, 'TonyStark@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'), + (1105, 'Max Eisenhardt', '251628698', 'Magneto', 'Rogue', 'Unknown Whereabouts', 'Silla', 46460, 1111111111, 222222222, 1, 'MaxEisenhardt@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 300, 8, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 1, NULL, 0, 0, 18, 0, 1, 'florist'), (1106, 'DavidCharlesHaller', '53136686Q', 'Legion', 'Charles Xavier', 'City of New York, New York, USA', 'Silla', 46460, 1111111111, 222222222, 1, 'DavidCharlesHaller@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 0, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 19, 0, 1, 'florist'), (1107, 'Hank Pym', '09854837G', 'Ant man', 'Hawk', 'Anthill, San Francisco, California', 'Silla', 46460, 1111111111, 222222222, 1, 'HankPym@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, 0, NULL, 0, 0, 19, 0, 1, 'florist'), (1108, 'Charles Xavier', '22641921P', 'Professor X', 'Beast', '3800 Victory Pkwy, Cincinnati, OH 45207, USA', 'Silla', 46460, 1111111111, 222222222, 1, 'CharlesXavier@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 1, NULL, 0, 0, 19, 0, 1, 'florist'), diff --git a/modules/client/back/methods/client/getPostCodeFromZone.js b/modules/client/back/methods/client/getPostCodeFromZone.js deleted file mode 100644 index 79d8de357..000000000 --- a/modules/client/back/methods/client/getPostCodeFromZone.js +++ /dev/null @@ -1,38 +0,0 @@ -module.exports = Self => { - Self.remoteMethod('getPostCodeFromZone', { - description: 'CHANGEEEEEEEEEEEEEEE', - accessType: 'READ', - accepts: [{ - arg: 'zoneId', - type: 'number', - required: true, - description: 'zone id' - }], - returns: { - type: 'number', - root: true - }, - http: { - path: `/getPostCodeFromZone`, - verb: 'GET' - } - }); - - Self.getPostCodeFromZone = async(zoneId, options) => { - const myOptions = {}; - - if (typeof options == 'object') - Object.assign(myOptions, options); - - const query = ` - SELECT p.code - FROM postCode p - JOIN zoneIncluded z ON z.geoFk = p.geoFk - WHERE z.zoneFk = ?`; - const postCodes = await Self.rawSql(query, [zoneId], myOptions); - const postCodeIds = []; - postCodes.map(postCode => postCodeIds.push(postCode.code)); - console.log(postCodeIds); - return postCodeIds; - }; -}; diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js index 9785703d3..9ec45f58d 100644 --- a/modules/client/back/models/client.js +++ b/modules/client/back/models/client.js @@ -30,7 +30,6 @@ module.exports = Self => { require('../methods/client/consumption')(Self); require('../methods/client/createReceipt')(Self); require('../methods/client/updatePortfolio')(Self); - require('../methods/client/getPostCodeFromZone')(Self); // Validations diff --git a/modules/client/front/main/index.js b/modules/client/front/main/index.js index 04f357261..1069d3487 100644 --- a/modules/client/front/main/index.js +++ b/modules/client/front/main/index.js @@ -2,7 +2,7 @@ import ngModule from '../module'; import ModuleMain from 'salix/components/module-main'; export default class Client extends ModuleMain { - async exprBuilder(param, value) { + exprBuilder(param, value) { switch (param) { case 'search': return /^\d+$/.test(value) @@ -15,10 +15,6 @@ export default class Client extends ModuleMain { {mobile: value} ] }; - case 'zoneFk': - await this.getPostCodesFromZone(value); - console.log(this.postCodeIds); - return {postcode: {inq: this.postCodeIds}}; case 'name': case 'socialName': case 'city': @@ -32,16 +28,6 @@ export default class Client extends ModuleMain { return {[param]: value}; } } - - async getPostCodesFromZone(zoneId) { - const params = { - zoneId: zoneId - }; - this.$http.get('Clients/getPostCodeFromZone', {params}) - .then(res => { - this.postCodeIds = res.data; - }); - } } ngModule.vnComponent('vnClient', { diff --git a/modules/client/front/search-panel/index.html b/modules/client/front/search-panel/index.html index a02f93882..234cb6f53 100644 --- a/modules/client/front/search-panel/index.html +++ b/modules/client/front/search-panel/index.html @@ -58,13 +58,6 @@ value-field="id" label="Province"> - -