feat(item_fixed-price): add search, and defaultSerach

This commit is contained in:
Alex Moreno 2022-03-17 09:13:09 +01:00
parent b4e5631cc7
commit e8b4896e98
4 changed files with 68 additions and 27 deletions

View File

@ -34,7 +34,7 @@
<th field="itemFk">
<span translate>Item ID</span>
</th>
<th field="itemFk">
<th field="itemName">
<span translate>Description</span>
</th>
<th field="warehouseFk">
@ -64,7 +64,7 @@
</thead>
<tbody>
<tr ng-repeat="price in prices">
<td>
<td number>
<vn-autocomplete
vn-focus
class="dense"
@ -100,31 +100,28 @@
tabindex="-1">
</vn-fetched-tags>
</td>
<td mid>
<td>
<vn-autocomplete
vn-one
label="Warehouse"
ng-model="price.warehouseFk"
data="warehouses"
on-change="$ctrl.upsertPrice(price)"
tabindex="2">
</vn-autocomplete>
</td>
<td mid>
<span>
<vn-input-number
ng-model="price.rate2"
on-change="$ctrl.upsertPrice(price)">
</vn-input-number>
</span>
<td number>
<vn-input-number
ng-model="price.rate2"
on-change="$ctrl.upsertPrice(price)">
</vn-input-number>
</td>
<td mid>
<td number>
<vn-input-number
ng-model="price.rate3"
on-change="$ctrl.upsertPrice(price)">
</vn-input-number>
</td>
<td shrink-date>
<td number class="minPrice">
<vn-check
vn-one
ng-model="price.hasMinPrice">
@ -139,7 +136,6 @@
<td shrink-date>
<vn-date-picker
vn-one
label="Started"
ng-model="price.started"
on-change="$ctrl.upsertPrice(price)">
</vn-date-picker>
@ -147,7 +143,6 @@
<td shrink-date>
<vn-date-picker
vn-one
label="Ended"
ng-model="price.ended"
on-change="$ctrl.upsertPrice(price)">
</vn-date-picker>

View File

@ -9,7 +9,34 @@ export default class Controller extends Section {
this.smartTableOptions = {
activeButtons: {
search: true
}
},
defaultSearch: true,
columns: [
{
field: 'itemName',
autocomplete: {
url: 'Items',
showField: 'name',
valueField: 'id'
}
},
{
field: 'warehouseFk',
autocomplete: {
url: 'Warehouses',
showField: 'name',
valueField: 'id',
}
},
{
field: 'started',
searchable: false
},
{
field: 'ended',
searchable: false
}
]
};
}
@ -69,6 +96,22 @@ export default class Controller extends Section {
? {id: $search}
: {name: {like: '%' + $search + '%'}};
}
exprBuilder(param, value) {
switch (param) {
case 'itemName':
return {'i.id': value};
case 'itemFk':
case 'warehouseFk':
case 'rate2':
case 'rate3':
param = `fp.${param}`;
return {[param]: value};
case 'minPrice':
param = `i.${param}`;
return {[param]: value};
}
}
}
ngModule.vnComponent('vnFixedPrice', {

View File

@ -14,17 +14,6 @@ describe('fixed price', () => {
controller = $componentController('vnFixedPrice', {$element, $scope});
}));
describe('$onInit()', () => {
it('should perform a query to GET warehouses', () => {
$httpBackend.expectGET('Warehouses').respond('foo');
controller.$onInit();
$httpBackend.flush();
expect(controller.warehousesData).toBe('foo');
});
});
describe('upsertPrice()', () => {
it('should do nothing if one or more required arguments are missing', () => {
jest.spyOn(controller.vnApp, 'showSuccess');

View File

@ -0,0 +1,14 @@
@import "variables";
vn-autocomplete {
max-width: 150px;
}
vn-input-number {
max-width: 80px;
}
.minPrice {
display: inline-flex;
align-items: center;
justify-content: center;
}