2181 - Ticket sale fix item search
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Joan Sanchez 2020-03-11 15:56:02 +01:00
parent ac2b04d117
commit b9a482fc37
3 changed files with 25 additions and 8 deletions

View File

@ -175,5 +175,12 @@
"model": "ItemNiche",
"foreignKey": "itemFk"
}
},
"scope": {
"where": {
"name": {
"neq": ""
}
}
}
}

View File

@ -105,20 +105,22 @@
on-error-src/>
</vn-td>
<vn-td vn-focus number>
<span class="link" ng-if="sale.itemFk"
<span class="link" ng-if="sale.id"
ng-click="$ctrl.showDescriptor($event, sale.itemFk)">
{{sale.itemFk | zeroFill:6}}
{{sale.itemFk}}
</span>
<vn-autocomplete
ng-if="!sale.itemFk"
ng-if="!sale.id"
vn-focus
vn-one
url="Items"
ng-model="sale.itemFk"
show-field="name"
value-field="id"
search-function="{or: [{id: $search}, {name: {like: '%' + $search + '%'}}]}"
order="id DESC">
search-function="$ctrl.itemSearchFunc($search)"
on-change="sale.quantity && $ctrl.onChangeQuantity(sale)"
order="id DESC"
tabindex="1">
<tpl-item>
{{id}} - {{name}}
</tpl-item>
@ -137,7 +139,8 @@
<vn-td ng-if="!sale.id" number>
<vn-input-number
ng-model="sale.quantity"
on-change="$ctrl.onChangeQuantity(sale)">
on-change="$ctrl.onChangeQuantity(sale)"
tabindex="2">
</vn-input-number>
</vn-td>
<vn-td-editable disabled="!sale.id || !$ctrl.isEditable" expand>
@ -150,7 +153,7 @@
</vn-fetched-tags>
</text>
<field>
<vn-textfield
<vn-textfield class="dense"
vn-id="concept"
ng-model="sale.concept"
on-change="$ctrl.updateConcept(sale)">
@ -167,7 +170,8 @@
<vn-td number>
<span ng-class="{'link': !$ctrl.isLocked}"
title="{{!$ctrl.isLocked ? 'Edit discount' : ''}}"
ng-click="$ctrl.showEditDiscountPopover($event, sale)">
ng-click="$ctrl.showEditDiscountPopover($event, sale)"
ng-if="sale.id">
{{(sale.discount / 100) | percentage}}
</span>
</vn-td>

View File

@ -560,6 +560,12 @@ class Controller {
this.$scope.model.refresh();
});
}
itemSearchFunc($search) {
return /^\d+$/.test($search)
? {id: $search}
: {name: {like: '%' + $search + '%'}};
}
}
Controller.$inject = ['$scope', '$state', '$http', 'vnApp', '$translate'];