kj6682 / gundulf

gundful : a humble application entry point
0 stars 0 forks source link

shop: the list of orders is not sorted #2

Closed kj6682 closed 6 years ago

kj6682 commented 6 years ago

As a shop holder I want my list of orders sorted by deadline and product.

kj6682 commented 6 years ago

version 1.0.0.7 comes with a sorted list <deadline, product> indexed of order lines

kj6682 commented 6 years ago

the order is lexicographic : tiramisu-12 < tiramisu-2

kj6682 commented 6 years ago

order 1.0.0.10 - @Query(value = "select new org.kj6682.gundulf.orders.OrderSynthesis(v.deadline, v.product, SUM(v.quantity)) from OrderLine v where v.producer = ?1 group by (v.deadline, v.product) order by (v.deadline, v.product) asc")

kj6682 commented 6 years ago

even though the deadline is sorted, the lexicographic order on products was still there:

baba-1, baba-12, baba-2 is what we have.

it was fixed by adding the following js function in the main list components: let filteredOrders = this.props.orders.filter( (order) => order.product.indexOf(this.props.filterText) !== -1 ).sort( (a, b) => { if( a.deadline > b.deadline) return 1 if( a.deadline < b.deadline) return -1 var aa = a.product.split("-") var bb = b.product.split("-") if( aa[0] > bb[0] ) return 1 if( aa[0] < bb[0] ) return -1

            return parseInt(aa[1])-parseInt(bb[1])
        });

en passant, I fix the search bar for both products and ordes in chef as well