refactor(newbankentity): both client.billingdata and supplier.account now use newbankentity component
This commit is contained in:
parent
0f1b33802e
commit
d8a2302b18
|
@ -108,53 +108,8 @@
|
|||
</vn-button-bar>
|
||||
</form>
|
||||
|
||||
<!-- Create bank entity dialog -->
|
||||
<vn-dialog class="edit"
|
||||
vn-id="bankEntityDialog"
|
||||
on-accept="$ctrl.onBankEntityAccept()"
|
||||
message="New bank entity">
|
||||
<tpl-body>
|
||||
<vn-horizontal>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="Name"
|
||||
ng-model="$ctrl.newBankEntity.name"
|
||||
required="true"
|
||||
vn-focus>
|
||||
</vn-textfield>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-autocomplete
|
||||
vn-one
|
||||
vn-id="country"
|
||||
label="Country"
|
||||
ng-model="$ctrl.newBankEntity.countryFk"
|
||||
fields="['id', 'country', 'code']"
|
||||
url="Countries"
|
||||
value-field="id"
|
||||
show-field="country"
|
||||
required="true">
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="Entity Code"
|
||||
ng-model="$ctrl.newBankEntity.id"
|
||||
ng-show="country.selection.code === 'ES'">
|
||||
</vn-textfield>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="Swift / BIC"
|
||||
ng-model="$ctrl.newBankEntity.bic"
|
||||
required="true">
|
||||
</vn-textfield>
|
||||
</vn-horizontal>
|
||||
</tpl-body>
|
||||
<tpl-buttons>
|
||||
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
|
||||
<button response="accept" translate>Create</button>
|
||||
</tpl-buttons>
|
||||
</vn-dialog>
|
||||
<!-- New bankentity dialog -->
|
||||
<vn-new-bank-entity
|
||||
vn-id="bankEntity"
|
||||
on-response="$ctrl.onResponse($response)">
|
||||
</vn-new-bank-entity>
|
|
@ -42,12 +42,11 @@ export default class Controller extends Section {
|
|||
this.newBankEntity = {
|
||||
countryFk: Number.parseInt(this.client.countryFk)
|
||||
};
|
||||
this.$.bankEntityDialog.show();
|
||||
this.$.bankEntity.open();
|
||||
}
|
||||
|
||||
onBankEntityAccept() {
|
||||
return this.$http.post(`BankEntities`, this.newBankEntity)
|
||||
.then(res => this.client.bankEntityFk = res.data.id);
|
||||
onResponse(response) {
|
||||
this.client.bankEntityFk = response.id;
|
||||
}
|
||||
|
||||
get ibanCountry() {
|
||||
|
|
|
@ -35,20 +35,12 @@ describe('Client', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('onBankEntityAccept()', () => {
|
||||
it('should request to create a new bank entity', () => {
|
||||
let newBankEntity = {
|
||||
name: 'My new bank entity',
|
||||
bic: 'ES123',
|
||||
countryFk: 1,
|
||||
id: 999
|
||||
};
|
||||
controller.newBankEntity = newBankEntity;
|
||||
$httpBackend.expectPOST('BankEntities', newBankEntity).respond({id: 999});
|
||||
controller.onBankEntityAccept();
|
||||
$httpBackend.flush();
|
||||
describe('onResponse()', () => {
|
||||
it('should assign the response id to the client bankEntityFk', () => {
|
||||
const expectedResponse = {id: 999};
|
||||
controller.onResponse(expectedResponse);
|
||||
|
||||
expect(controller.client.bankEntityFk).toEqual(newBankEntity.id);
|
||||
expect(controller.client.bankEntityFk).toEqual(expectedResponse.id);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -14,5 +14,4 @@ Received core VNL: Recibido core VNL
|
|||
Received B2B VNL: Recibido B2B VNL
|
||||
Save: Guardar
|
||||
New bank entity: Nueva entidad bancaria
|
||||
Name can't be empty: El nombre no puede quedar vacío
|
||||
Entity Code: Código
|
||||
Name can't be empty: El nombre no puede quedar vacío
|
|
@ -65,6 +65,7 @@
|
|||
</vn-submit>
|
||||
</vn-button-bar>
|
||||
</form>
|
||||
|
||||
<!-- New bankentity dialog -->
|
||||
<vn-new-bank-entity
|
||||
vn-id="bankEntity"
|
||||
|
|
|
@ -51,7 +51,7 @@ describe('Supplier Component vnSupplierAccount', () => {
|
|||
expect(controller.$.bankEntity.open).toHaveBeenCalledWith();
|
||||
});
|
||||
|
||||
it('should request to create a new bank entity', () => {
|
||||
it('should now request to create a new bank entity', () => {
|
||||
controller.bankEntity = {
|
||||
name: 'My new bank entity',
|
||||
bic: 'ES1234',
|
||||
|
|
Loading…
Reference in New Issue