From 0c335b970532549fe55aa8d0665080d681b9554b Mon Sep 17 00:00:00 2001 From: Jorge Padawan Date: Thu, 11 Feb 2021 18:35:23 +0100 Subject: [PATCH] Put bankEntity on global components, and fixed conflict updates --- .../salix/components/bank-entity}/index.html | 8 ++++---- .../salix/components/bank-entity}/index.js | 16 ++++++---------- .../components/bank-entity}/index.spec.js | 18 +++++++++--------- .../components/bank-entity}/locale/es.yml | 3 ++- .../salix/components/bank-entity}/style.scss | 0 front/salix/components/index.js | 1 + loopback/locale/en.json | 3 ++- loopback/locale/es.json | 4 +++- modules/supplier/front/account/index.html | 4 +--- modules/supplier/front/account/index.js | 19 ++++++++++++------- modules/supplier/front/account/index.spec.js | 4 +++- modules/supplier/front/account/locale/es.yml | 3 ++- modules/supplier/front/index.js | 1 - modules/supplier/front/routes.json | 2 +- 14 files changed, 46 insertions(+), 40 deletions(-) rename {modules/supplier/front/bankentity => front/salix/components/bank-entity}/index.html (86%) rename {modules/supplier/front/bankentity => front/salix/components/bank-entity}/index.js (66%) rename {modules/supplier/front/bankentity => front/salix/components/bank-entity}/index.spec.js (70%) rename {modules/supplier/front/bankentity => front/salix/components/bank-entity}/locale/es.yml (77%) rename {modules/supplier/front/bankentity => front/salix/components/bank-entity}/style.scss (100%) diff --git a/modules/supplier/front/bankentity/index.html b/front/salix/components/bank-entity/index.html similarity index 86% rename from modules/supplier/front/bankentity/index.html rename to front/salix/components/bank-entity/index.html index 74a302d06..3a7786607 100644 --- a/modules/supplier/front/bankentity/index.html +++ b/front/salix/components/bank-entity/index.html @@ -1,6 +1,6 @@ @@ -11,7 +11,7 @@ vn-focus vn-id="entityName" label="Name" - ng-model="$ctrl.location.name" + ng-model="$ctrl.data.name" required="true"> @@ -21,11 +21,11 @@ vn-focus vn-id="bic" label="Swift" - ng-model="$ctrl.location.bic" + ng-model="$ctrl.data.bic" required="true"> { + this.$http.post(`bankEntities`, this.data).then(() => { this.vnApp.showMessage(this.$t('The bank entity has been created. You can save the data now')); - this.emit('response', {$response: this.location}); + this.emit('response', {$response: this.data}); }); } catch (e) { this.vnApp.showError(this.$t(e.message)); diff --git a/modules/supplier/front/bankentity/index.spec.js b/front/salix/components/bank-entity/index.spec.js similarity index 70% rename from modules/supplier/front/bankentity/index.spec.js rename to front/salix/components/bank-entity/index.spec.js index 84273ded8..c288c3052 100644 --- a/modules/supplier/front/bankentity/index.spec.js +++ b/front/salix/components/bank-entity/index.spec.js @@ -1,13 +1,13 @@ import './index'; -describe('Supplier Component vnNewBankEntity', () => { +describe('Salix Component vnNewBankEntity', () => { let controller; let $httpBackend; let $scope; let $element; let vnApp; - beforeEach(ngModule('supplier')); + beforeEach(ngModule('salix')); beforeEach(inject(($componentController, $rootScope, _$httpBackend_, _vnApp_) => { $httpBackend = _$httpBackend_; @@ -18,13 +18,13 @@ describe('Supplier Component vnNewBankEntity', () => { controller = $componentController('vnNewBankEntity', {$element, $scope}); })); - describe('resetLocation()', () => { + describe('resetData()', () => { it('should reset the location in the controller', () => { - expect(controller.location).toBeUndefined(); + expect(controller.data).toBeUndefined(); - controller.resetLocation(); + controller.resetData(); - expect(controller.location).toEqual({}); + expect(controller.data).toEqual({}); }); }); @@ -32,7 +32,7 @@ describe('Supplier Component vnNewBankEntity', () => { it('should throw an error if there is no country id in the location', () => { jest.spyOn(controller.vnApp, 'showMessage'); - controller.location = {}; + controller.data = {}; controller.onAccept(); @@ -40,11 +40,11 @@ describe('Supplier Component vnNewBankEntity', () => { }); it('should do add the new bank entity', () => { - controller.location = { + controller.data = { countryFk: 1 }; - $httpBackend.expectPOST('Bankentities', controller.location).respond(200, controller.location); + $httpBackend.expectPOST('bankEntities', controller.data).respond(200, controller.data); controller.onAccept(); $httpBackend.flush(); diff --git a/modules/supplier/front/bankentity/locale/es.yml b/front/salix/components/bank-entity/locale/es.yml similarity index 77% rename from modules/supplier/front/bankentity/locale/es.yml rename to front/salix/components/bank-entity/locale/es.yml index 782690e88..fe5160572 100644 --- a/modules/supplier/front/bankentity/locale/es.yml +++ b/front/salix/components/bank-entity/locale/es.yml @@ -8,4 +8,5 @@ The province can't be empty: La provincia no puede quedar vacía The country can't be empty: El país no puede quedar vacío The postcode has been created. You can save the data now: Se ha creado el código postal. Ahora puedes guardar los datos The city has been created: Se ha creado la ciudad -The province has been created: Se ha creado la provincia \ No newline at end of file +The province has been created: Se ha creado la provincia +The bank entity has been created. You can save the data now: Se ha creado la entidad bancaria. Puedes guardar los datos ahora \ No newline at end of file diff --git a/modules/supplier/front/bankentity/style.scss b/front/salix/components/bank-entity/style.scss similarity index 100% rename from modules/supplier/front/bankentity/style.scss rename to front/salix/components/bank-entity/style.scss diff --git a/front/salix/components/index.js b/front/salix/components/index.js index 13f8366cd..5167b21d6 100644 --- a/front/salix/components/index.js +++ b/front/salix/components/index.js @@ -14,3 +14,4 @@ import './summary'; import './topbar/topbar'; import './user-popover'; import './upload-photo'; +import './bank-entity'; diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 44f882638..c5062c3e9 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -91,5 +91,6 @@ "The observation type can't be repeated": "The observation type can't be repeated", "New ticket request has been created with price": "New ticket request has been created *'{{description}}'* for day *{{shipped}}*, with a quantity of *{{quantity}}* and a price of *{{price}} €*", "New ticket request has been created": "New ticket request has been created *'{{description}}'* for day *{{shipped}}*, with a quantity of *{{quantity}}*", - "There's a new urgent ticket": "There's a new urgent ticket: [{{title}}](https://cau.verdnatura.es/WorkOrder.do?woMode=viewWO&woID={{issueId}})" + "There's a new urgent ticket": "There's a new urgent ticket: [{{title}}](https://cau.verdnatura.es/WorkOrder.do?woMode=viewWO&woID={{issueId}})", + "Swift / BIC cannot be empty": "Swift / BIC cannot be empty" } \ No newline at end of file diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 1b5fbd917..36b59fcf6 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -172,5 +172,7 @@ "New ticket request has been created": "Se ha creado una nueva petición de compra *'{{description}}'* para el día *{{shipped}}*, con una cantidad de *{{quantity}}*", "That item doesn't exists": "Ese artículo no existe", "There's a new urgent ticket": "Hay un nuevo ticket urgente: [{{title}}](https://cau.verdnatura.es/WorkOrder.do?woMode=viewWO&woID={{issueId}})", - "Compensation account is empty": "La cuenta para compensar está vacia" + "Compensation account is empty": "La cuenta para compensar está vacia", + "Swift / BIC cannot be empty": "Swift / BIC cannot be empty", + "This BIC already exist.": "This BIC already exist." } \ No newline at end of file diff --git a/modules/supplier/front/account/index.html b/modules/supplier/front/account/index.html index 5a9addeea..6248da2e2 100644 --- a/modules/supplier/front/account/index.html +++ b/modules/supplier/front/account/index.html @@ -21,12 +21,10 @@ ng-model="supplierAccount.iban" rule> - diff --git a/modules/supplier/front/account/index.js b/modules/supplier/front/account/index.js index 069601a20..85b00d25c 100644 --- a/modules/supplier/front/account/index.js +++ b/modules/supplier/front/account/index.js @@ -18,13 +18,9 @@ class Controller extends Section { }); } - onSubmit() { - this.$.watcher.check(); - this.$.model.save().then(() => { - this.$.watcher.notifySaved(); - this.$.watcher.updateOriginalData(); - this.card.reload(); - }); + onResponse(response) { + this.name = response.name; + console.log(this.name); } showBankEntity(event) { @@ -38,6 +34,15 @@ class Controller extends Section { return this.$http.patch(query, this.newBankEntity) .then(res => this.supplierAccount.bankEntityFk = res.data.id); } + + onSubmit() { + this.$.watcher.check(); + this.$.model.save().then(() => { + this.$.watcher.notifySaved(); + this.$.watcher.updateOriginalData(); + this.card.reload(); + }); + } } ngModule.vnComponent('vnSupplierAccount', { diff --git a/modules/supplier/front/account/index.spec.js b/modules/supplier/front/account/index.spec.js index 448db0777..d64baa016 100644 --- a/modules/supplier/front/account/index.spec.js +++ b/modules/supplier/front/account/index.spec.js @@ -57,7 +57,9 @@ describe('Supplier Component vnSupplierAccount', () => { countryFk: 1, id: 2200 }; - $httpBackend.expectPATCH(`SupplierAccounts/${controller.$.bankEntity.id}/createBankEntity`).respond({id: 2200}); + + const query = `SupplierAccounts/${controller.$.bankEntity.id}/createBankEntity`; + $httpBackend.expectPATCH(query).respond({id: 2200}); controller.onBankEntityAccept(); $httpBackend.flush(); diff --git a/modules/supplier/front/account/locale/es.yml b/modules/supplier/front/account/locale/es.yml index 7443ad4e3..b5cac0207 100644 --- a/modules/supplier/front/account/locale/es.yml +++ b/modules/supplier/front/account/locale/es.yml @@ -1,2 +1,3 @@ Bank entity: Entidad bancaria -swift: Swift BIC \ No newline at end of file +swift: Swift BIC +Add account: Añadir cuenta \ No newline at end of file diff --git a/modules/supplier/front/index.js b/modules/supplier/front/index.js index f24fb997e..80c49a8b4 100644 --- a/modules/supplier/front/index.js +++ b/modules/supplier/front/index.js @@ -8,7 +8,6 @@ import './search-panel'; import './summary'; import './basic-data'; import './fiscal-data'; -import './bankentity'; import './account'; import './contact'; import './log'; diff --git a/modules/supplier/front/routes.json b/modules/supplier/front/routes.json index cf2ec3264..1be4df0fc 100644 --- a/modules/supplier/front/routes.json +++ b/modules/supplier/front/routes.json @@ -9,7 +9,7 @@ {"state": "supplier.index", "icon": "icon-supplier"} ], "card": [ - {"state": "supplier.card.account", "icon": "face"}, + {"state": "supplier.card.account", "icon": "contact_support"}, {"state": "supplier.card.basicData", "icon": "settings"}, {"state": "supplier.card.fiscalData", "icon": "account_balance"}, {"state": "supplier.card.billingData", "icon": "icon-payment"},