Merge branch 'dev' into 3061-send_thermograph
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Carlos Jimenez Ruiz 2021-09-07 10:10:09 +00:00
commit 2ce79a8d49
7 changed files with 63 additions and 3 deletions

View File

@ -63,7 +63,7 @@
show-field="bank" show-field="bank"
order="id" order="id"
value-field="id" value-field="id"
search-function="{or: [{id: $search}, {bank: {like: '%'+ $search +'%'}}]}"> search-function="$ctrl.bankSearchFunc($search)">
<tpl-item>{{id}}: {{bank}}</tpl-item> <tpl-item>{{id}}: {{bank}}</tpl-item>
</vn-autocomplete> </vn-autocomplete>
<vn-autocomplete <vn-autocomplete

View File

@ -78,6 +78,12 @@ class Controller {
this.$.companies.refresh(); this.$.companies.refresh();
this.$.popover.show(event.target); this.$.popover.show(event.target);
} }
bankSearchFunc($search) {
return /^\d+$/.test($search)
? {id: $search}
: {bank: {like: '%' + $search + '%'}};
}
} }
Controller.$inject = ['$scope', '$translate', 'vnConfig', 'vnAuth', 'vnToken']; Controller.$inject = ['$scope', '$translate', 'vnConfig', 'vnAuth', 'vnToken'];

View File

@ -61,12 +61,28 @@ describe('Salix', () => {
}); });
describe('getImageUrl()', () => { describe('getImageUrl()', () => {
it('should return de url image', () => { it('should return the url image', () => {
const url = $root.imagePath('user', '160x160', userId); const url = $root.imagePath('user', '160x160', userId);
expect(url).toBeDefined(); expect(url).toBeDefined();
expect(url).toEqual(`/api/Images/user/160x160/${userId}/download?access_token=null`); expect(url).toEqual(`/api/Images/user/160x160/${userId}/download?access_token=null`);
}); });
}); });
describe('bankSearchFunc()', () => {
it('should return the filter by id property for an input of a number', () => {
const bankId = 1;
const result = controller.bankSearchFunc(bankId);
expect(result).toEqual({id: bankId});
});
it('should return the filter by bank property for an input of an string', () => {
const bankName = 'Bank of America';
const result = controller.bankSearchFunc(bankName);
expect(result).toEqual({bank: {like: '%' + bankName + '%'}});
});
});
}); });
}); });

View File

@ -33,7 +33,7 @@
fields="['accountingTypeFk']" fields="['accountingTypeFk']"
include="{relation: 'accountingType'}" include="{relation: 'accountingType'}"
ng-model="$ctrl.bankFk" ng-model="$ctrl.bankFk"
search-function="{or: [{id: $search}, {bank: {like: '%'+ $search +'%'}}]}" search-function="$ctrl.bankSearchFunc($search)"
selection="$ctrl.bankSelection" selection="$ctrl.bankSelection"
order="id" order="id"
required="true"> required="true">

View File

@ -137,6 +137,12 @@ class Controller extends Dialog {
} }
}); });
} }
bankSearchFunc($search) {
return /^\d+$/.test($search)
? {id: $search}
: {bank: {like: '%' + $search + '%'}};
}
} }
Controller.$inject = ['$element', '$scope', '$transclude', 'vnReport']; Controller.$inject = ['$element', '$scope', '$transclude', 'vnReport'];

View File

@ -118,5 +118,21 @@ describe('Client', () => {
expect(controller.receipt.compensationAccount).toEqual('4000000003'); expect(controller.receipt.compensationAccount).toEqual('4000000003');
}); });
}); });
describe('bankSearchFunc()', () => {
it('should return the filter by id property for an input of a number', () => {
const bankId = 1;
const result = controller.bankSearchFunc(bankId);
expect(result).toEqual({id: bankId});
});
it('should return the filter by bank property for an input of an string', () => {
const bankName = 'Bank of America';
const result = controller.bankSearchFunc(bankName);
expect(result).toEqual({bank: {like: '%' + bankName + '%'}});
});
});
}); });
}); });

View File

@ -679,5 +679,21 @@ describe('Ticket', () => {
expect(controller.$.model.refresh).toHaveBeenCalledWith(); expect(controller.$.model.refresh).toHaveBeenCalledWith();
}); });
}); });
describe('itemSearchFunc()', () => {
it('should return the filter by id property for an input of a number', () => {
const itemId = 1;
const result = controller.itemSearchFunc(itemId);
expect(result).toEqual({id: itemId});
});
it('should return the filter by bank property for an input of an string', () => {
const itemName = 'Bow';
const result = controller.itemSearchFunc(itemName);
expect(result).toEqual({name: {like: '%' + itemName + '%'}});
});
});
}); });
}); });