Frank-Shanghai / PencilCase

0 stars 0 forks source link

Bug - Retail, Wholesale and Import page quantity issue #50

Closed Frank-Shanghai closed 6 years ago

Frank-Shanghai commented 6 years ago

Issue 1: Cause: For specific condition, in the code, it takes the quantity value as string to handle.

Repro step:

  1. Import page, select one product, it's Ok the click the minus or plus button to change quantity. But if you try to type numbers into the text box, it will treat it as string, after you changed the number, and then click plus button again, you will found it just append one '1' to the number as a string. For example, you changed the number to 20, and then click plus button, expected it will be 21, but actually it's 201.

  2. Click "Add" button to add a new order, and then try to change the quantity as described in step 1, the same issue appears. And the same issue for the total quantity and total price on the page bottom.

Issue 2: Change order quantity value by typing won't update the total quantity and price, caused wrong total quantity and price value. It works by clicking minus and plus button because there is code in the click event handler to updated corresponding value. Solution: maybe need to add subscription to every order quantity field, once changed, re-calculate corresponding value.

Frank-Shanghai commented 6 years ago

自己实现一个KO observable subscription扩展,可以同时获得new value and old value, 同时允许传递一个dataContext参数以供handler使用。 这个dataContext不同于target, target是指定handler中的this的指向。 //https://stackoverflow.com/questions/12822954/get-previous-value-of-an-observable-in-subscribe-of-same-observable /*

Frank-Shanghai commented 6 years ago

input text box value binding handler, 在修改数据后,并未触发subscription hanldler,只有当失去焦点后才触发。 所以要想立即触发,应使用textInput binding handler, refer to: http://knockoutjs.com/documentation/textinput-binding.html

                                                <!-- Use textInput binding instead of value binding to make the data changed immediatly, but not on losing focus. -->
                                                <!-- http://knockoutjs.com/documentation/textinput-binding.html -->
                                                <!--<input type="number" style="width: 30px; text-align: center" data-bind="value: quantity" />-->
                                                <input type="number" style="width: 30px; text-align: center" data-bind="textInput: quantity" />
Frank-Shanghai commented 6 years ago

New Issue: Set quantity text box cannot be null, add validation to avoid empty data which caused sql exception.

Issue: And with sql exception, while closed dialog, said added successfully, which is wrong.

Optional solution: https://stackoverflow.com/questions/18466766/knockout-js-validation-textbox-highlight