Put bankEntity on global components, and fixed conflict updates
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Jorge Padawan 2021-02-11 18:35:23 +01:00
parent a1ca8d90c3
commit 0c335b9705
14 changed files with 46 additions and 40 deletions

View File

@ -1,6 +1,6 @@
<vn-dialog class="edit"
vn-id="bankEntityDialog"
on-open="$ctrl.resetLocation()"
on-open="$ctrl.resetData()"
on-accept="$ctrl.onAccept()"
message="New bank entity">
<tpl-body>
@ -11,7 +11,7 @@
vn-focus
vn-id="entityName"
label="Name"
ng-model="$ctrl.location.name"
ng-model="$ctrl.data.name"
required="true">
</vn-textfield>
</vn-horizontal>
@ -21,11 +21,11 @@
vn-focus
vn-id="bic"
label="Swift"
ng-model="$ctrl.location.bic"
ng-model="$ctrl.data.bic"
required="true">
</vn-textfield>
<vn-autocomplete vn-one
ng-model="$ctrl.location.countryFk"
ng-model="$ctrl.data.countryFk"
url="Countries"
show-field="country"
value-field="id"

View File

@ -1,4 +1,4 @@
import ngModule from '../module';
import ngModule from '../../module';
import Component from 'core/lib/component';
import './style.scss';
@ -6,22 +6,18 @@ class Controller extends Component {
open() {
this.$.bankEntityDialog.show();
}
resetLocation() {
this.location = {};
}
onCountryResponse(response) {
this.location.countryFk = response.id;
resetData() {
this.data = {};
}
onAccept() {
try {
if (!this.location.countryFk)
if (!this.data.countryFk)
throw new Error(`The country can't be empty`);
this.$http.post(`Bankentities`, this.location).then(() => {
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));

View File

@ -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();

View File

@ -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
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

View File

@ -14,3 +14,4 @@ import './summary';
import './topbar/topbar';
import './user-popover';
import './upload-photo';
import './bank-entity';

View File

@ -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"
}

View File

@ -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."
}

View File

@ -21,12 +21,10 @@
ng-model="supplierAccount.iban"
rule>
</vn-textfield>
<vn-autocomplete vn-two vn-focus
<vn-autocomplete vn-two
label="Bank entity"
initial-data="$ctrl.getName(bankEntity)"
ng-model="supplierAccount.bankEntityFk"
url="BankEntities"
on-change="$ctrl.getName(bankEntity)"
show-field="name"
rule>
</vn-autocomplete>

View File

@ -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', {

View File

@ -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();

View File

@ -1,2 +1,3 @@
Bank entity: Entidad bancaria
swift: Swift BIC
swift: Swift BIC
Add account: Añadir cuenta

View File

@ -8,7 +8,6 @@ import './search-panel';
import './summary';
import './basic-data';
import './fiscal-data';
import './bankentity';
import './account';
import './contact';
import './log';

View File

@ -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"},