| 18150 |
kshitij.so |
1 |
package in.shop2020.catalog.dashboard.client;
|
|
|
2 |
|
|
|
3 |
import in.shop2020.catalog.dashboard.shared.Utils;
|
|
|
4 |
|
|
|
5 |
import java.util.Map.Entry;
|
|
|
6 |
|
|
|
7 |
import com.google.gwt.core.client.GWT;
|
|
|
8 |
import com.google.gwt.event.dom.client.ClickEvent;
|
|
|
9 |
import com.google.gwt.uibinder.client.UiBinder;
|
|
|
10 |
import com.google.gwt.uibinder.client.UiField;
|
|
|
11 |
import com.google.gwt.uibinder.client.UiHandler;
|
|
|
12 |
import com.google.gwt.user.client.Window;
|
|
|
13 |
import com.google.gwt.user.client.ui.Button;
|
|
|
14 |
import com.google.gwt.user.client.ui.DialogBox;
|
|
|
15 |
import com.google.gwt.user.client.ui.ListBox;
|
|
|
16 |
import com.google.gwt.user.client.ui.TextBox;
|
|
|
17 |
import com.google.gwt.user.client.ui.Widget;
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
public class BulkPricingDialog extends DialogBox {
|
|
|
21 |
|
|
|
22 |
interface Binder extends UiBinder<Widget, BulkPricingDialog> { }
|
|
|
23 |
private static final Binder binder = GWT.create(Binder.class);
|
|
|
24 |
|
|
|
25 |
public interface BulkPricingUpdateListener{
|
|
|
26 |
boolean onUpdate(long quantity, double price);
|
|
|
27 |
}
|
|
|
28 |
|
|
|
29 |
private BulkPricingUpdateListener bulkPricingUpdateListener;
|
|
|
30 |
|
|
|
31 |
@UiField Button closeButton, updateButton;
|
|
|
32 |
@UiField TextBox quantity, price;
|
|
|
33 |
|
|
|
34 |
public BulkPricingDialog() {
|
|
|
35 |
setText("Add bulk Pricing");
|
|
|
36 |
setWidget(binder.createAndBindUi(this));
|
|
|
37 |
setAnimationEnabled(true);
|
|
|
38 |
center();
|
|
|
39 |
}
|
|
|
40 |
|
|
|
41 |
public BulkPricingDialog(String quantity, String price) {
|
|
|
42 |
this();
|
|
|
43 |
setFields(quantity, price);
|
|
|
44 |
}
|
|
|
45 |
|
|
|
46 |
public void setFields(String quantity, String price) {
|
|
|
47 |
this.quantity.setText(quantity);
|
|
|
48 |
this.price.setText(price);
|
|
|
49 |
}
|
|
|
50 |
|
|
|
51 |
public void setBulkPricingUpdateListener(BulkPricingUpdateListener bulkPricingUpdateListener) {
|
|
|
52 |
this.bulkPricingUpdateListener = bulkPricingUpdateListener;
|
|
|
53 |
}
|
|
|
54 |
|
|
|
55 |
@UiHandler("closeButton")
|
|
|
56 |
void onCloseClicked(ClickEvent event) {
|
|
|
57 |
hide();
|
|
|
58 |
}
|
|
|
59 |
|
|
|
60 |
@UiHandler("updateButton")
|
|
|
61 |
void onEditClicked(ClickEvent event) {
|
|
|
62 |
double price;
|
|
|
63 |
long quantity;
|
|
|
64 |
try {
|
|
|
65 |
price = Double.parseDouble(this.price.getText());
|
|
|
66 |
quantity = Long.parseLong(this.quantity.getText());
|
|
|
67 |
} catch(NumberFormatException ex) {
|
|
|
68 |
Window.alert("Format is not valid.");
|
|
|
69 |
return;
|
|
|
70 |
}
|
| 18415 |
kshitij.so |
71 |
if (quantity < 1 || price < 1){
|
| 18624 |
kshitij.so |
72 |
Window.alert("Quantity/Price is not valid");
|
|
|
73 |
return;
|
| 18415 |
kshitij.so |
74 |
}
|
| 18150 |
kshitij.so |
75 |
if(bulkPricingUpdateListener.onUpdate(quantity, price)) {
|
|
|
76 |
hide();
|
|
|
77 |
}
|
|
|
78 |
}
|
|
|
79 |
}
|