| Line 5... |
Line 5... |
| 5 |
import in.shop2020.catalog.dashboard.shared.VendorItemMapping;
|
5 |
import in.shop2020.catalog.dashboard.shared.VendorItemMapping;
|
| 6 |
import in.shop2020.catalog.dashboard.shared.VendorPricings;
|
6 |
import in.shop2020.catalog.dashboard.shared.VendorPricings;
|
| 7 |
|
7 |
|
| 8 |
import java.util.HashMap;
|
8 |
import java.util.HashMap;
|
| 9 |
import java.util.Map;
|
9 |
import java.util.Map;
|
| - |
|
10 |
import java.util.Map.Entry;
|
| 10 |
|
11 |
|
| 11 |
import com.google.gwt.core.client.GWT;
|
12 |
import com.google.gwt.core.client.GWT;
|
| 12 |
import com.google.gwt.event.dom.client.ChangeEvent;
|
13 |
import com.google.gwt.event.dom.client.ChangeEvent;
|
| 13 |
import com.google.gwt.event.dom.client.ClickEvent;
|
14 |
import com.google.gwt.event.dom.client.ClickEvent;
|
| 14 |
import com.google.gwt.event.dom.client.ClickHandler;
|
15 |
import com.google.gwt.event.dom.client.ClickHandler;
|
| Line 55... |
Line 56... |
| 55 |
@UiField DateBox startDate, retireDate;
|
56 |
@UiField DateBox startDate, retireDate;
|
| 56 |
@UiField Button addButton, cancelButton;
|
57 |
@UiField Button addButton, cancelButton;
|
| 57 |
@UiField CheckBox defaultForEntity, risky;
|
58 |
@UiField CheckBox defaultForEntity, risky;
|
| 58 |
@UiField FlexTable headerVendor, vendorTable;
|
59 |
@UiField FlexTable headerVendor, vendorTable;
|
| 59 |
@UiField FlexTable headerVendorM, vendorTableM;
|
60 |
@UiField FlexTable headerVendorM, vendorTableM;
|
| - |
|
61 |
@UiField ListBox preferredVendor, defaultWarehouse;
|
| 60 |
|
62 |
|
| 61 |
public ItemForm(){
|
63 |
public ItemForm(){
|
| 62 |
setText("Add New Item");
|
64 |
setText("Add New Item");
|
| 63 |
setWidget(uiBinder.createAndBindUi(this));
|
65 |
setWidget(uiBinder.createAndBindUi(this));
|
| 64 |
initVendorKeysHeader();
|
66 |
initVendorKeysHeader();
|
| 65 |
initVendorPricesHeader();
|
67 |
initVendorPricesHeader();
|
| 66 |
vendorCategory.addItem(HANDSETS);
|
68 |
vendorCategory.addItem(HANDSETS);
|
| 67 |
vendorCategory.addItem(ACCESSORIES);
|
69 |
vendorCategory.addItem(ACCESSORIES);
|
| 68 |
productGroup.setText(HANDSETS);
|
70 |
productGroup.setText(HANDSETS);
|
| - |
|
71 |
for(Entry<Long, String> e : Utils.getAllVendors().entrySet()){
|
| - |
|
72 |
preferredVendor.addItem(e.getValue());
|
| - |
|
73 |
}
|
| - |
|
74 |
for(Entry<Long, String> e : Utils.getAllWarehouses().entrySet()){
|
| - |
|
75 |
defaultWarehouse.addItem(e.getValue());
|
| - |
|
76 |
}
|
| 69 |
}
|
77 |
}
|
| 70 |
|
78 |
|
| 71 |
/**
|
79 |
/**
|
| 72 |
* initialises vendor item key table header. Creates an Add button and
|
80 |
* initialises vendor item key table header. Creates an Add button and
|
| 73 |
* adds click event listener to it to create and pop up a dialog for adding
|
81 |
* adds click event listener to it to create and pop up a dialog for adding
|
| Line 198... |
Line 206... |
| 198 |
* On add button click a new Item instance is created and all the information from UI fields is dumped in this item instance.
|
206 |
* On add button click a new Item instance is created and all the information from UI fields is dumped in this item instance.
|
| 199 |
* This item instance is then passed to the service to be added to the database.
|
207 |
* This item instance is then passed to the service to be added to the database.
|
| 200 |
*/
|
208 |
*/
|
| 201 |
void addItem(ClickEvent event) {
|
209 |
void addItem(ClickEvent event) {
|
| 202 |
//TODO: validate UI fields
|
210 |
//TODO: validate UI fields
|
| 203 |
catalogService.checkSimilarItem(productGroup.getText().trim(), brand.getText().trim(),
|
211 |
catalogService.checkSimilarItem(brand.getText().trim(), modelNumber.getText().trim(),
|
| 204 |
modelNumber.getText().trim(), color.getText().trim(), new AsyncCallback<Long>() {
|
212 |
modelName.getText().trim(), color.getText().trim(), new AsyncCallback<Long>() {
|
| 205 |
@Override
|
213 |
@Override
|
| 206 |
public void onFailure(Throwable caught) {
|
214 |
public void onFailure(Throwable caught) {
|
| 207 |
GWT.log("Error checking similar item");
|
215 |
GWT.log("Error checking similar item");
|
| 208 |
Window.alert("Error checking similar item");
|
216 |
Window.alert("Error checking similar item");
|
| 209 |
return;
|
217 |
return;
|
| Line 299... |
Line 307... |
| 299 |
Window.alert("Invalid best selling rank format");
|
307 |
Window.alert("Invalid best selling rank format");
|
| 300 |
return;
|
308 |
return;
|
| 301 |
}
|
309 |
}
|
| 302 |
item.setDefaultForEntity(defaultForEntity.getValue());
|
310 |
item.setDefaultForEntity(defaultForEntity.getValue());
|
| 303 |
item.setRisky(risky.getValue());
|
311 |
item.setRisky(risky.getValue());
|
| - |
|
312 |
item.setPreferredVendor(Utils.getVendorId(preferredVendor.getItemText(preferredVendor.getSelectedIndex())));
|
| - |
|
313 |
item.setDefaultWarehouse(Utils.getWarehouseId(defaultWarehouse.getItemText(defaultWarehouse.getSelectedIndex())) + "");
|
| 304 |
|
314 |
|
| 305 |
/*Create an instance of VendorPricings for each row in vendor pricing table. Set the vendor prices to the instance.
|
315 |
/*Create an instance of VendorPricings for each row in vendor pricing table. Set the vendor prices to the instance.
|
| 306 |
Add the instance to map and set the map to the item instance created above.*/
|
316 |
Add the instance to map and set the map to the item instance created above.*/
|
| 307 |
Map<Long, VendorPricings> vendorPrices = new HashMap<Long, VendorPricings>();
|
317 |
Map<Long, VendorPricings> vendorPrices = new HashMap<Long, VendorPricings>();
|
| 308 |
VendorPricings v;
|
318 |
VendorPricings v;
|