dfaruque / Serenity.Extra

Name of the repo says that this is an EXTRA of http://serenity.is platform
60 stars 34 forks source link

How do I create an autocomplete filter by name using the product completion code to direct invoice؟ #86

Closed ahmedabdelh closed 10 months ago

ahmedabdelh commented 1 year ago

let $barcodeInput = $('');

        $barcodeInput.appendTo(this.toolbar.element)
            .keypress(event => {
                if (event.keyCode == 13) {
                    let productId = $barcodeInput.val();

                    if (productId) {
                        let eqFilter = {};
                        eqFilter[ProductRow.Fields.ProductID] = productId

                        ProductService.List({ EqualityFilter: eqFilter, Take: 1 }, response => {
                            if (response.Entities.length > 0) {
                                let pickedProduct = response.Entities[0];

                                let orderDetails = this.value;
                                orderDetails.push({
                                    ProductID: pickedProduct.ProductID,
                                    ProductName: pickedProduct.ProductName,
                                    UnitPrice: pickedProduct.UnitPrice,
                                    Quantity: 1,
                                    LineTotal: 1 * (pickedProduct.UnitPrice || 0)
                                });

                                this.value = orderDetails;
                            } else {
                                Q.alert('Product not found!')
                            }
                        });
                    }
                }
            });
muhammedyaman commented 1 year ago

Can you explain a little more?