| Line 57... |
Line 57... |
| 57 |
|
57 |
|
| 58 |
private final int TABLE_INDEX_WAREHOUSE_ID = 0,
|
58 |
private final int TABLE_INDEX_WAREHOUSE_ID = 0,
|
| 59 |
TABLE_INDEX_WAREHOUSE_DESC = 1,
|
59 |
TABLE_INDEX_WAREHOUSE_DESC = 1,
|
| 60 |
TABLE_INDEX_WAREHOUSE_INV = 2;
|
60 |
TABLE_INDEX_WAREHOUSE_INV = 2;
|
| 61 |
|
61 |
|
| - |
|
62 |
private final int TABLE_INDEX_SIMILAR_ITEMS_CATALOG_ITEM_ID = 0,
|
| - |
|
63 |
TABLE_INDEX_SIMILAR_ITEMS_PRODUCT_GROUP = 1,
|
| - |
|
64 |
TABLE_INDEX_SIMILAR_ITEMS_BRAND = 2,
|
| - |
|
65 |
TABLE_INDEX_SIMILAR_ITEMS_MODEL_NUMBER = 3,
|
| - |
|
66 |
TABLE_INDEX_SIMILAR_ITEMS_MODEL_NAME = 4,
|
| - |
|
67 |
TABLE_INDEX_SIMILAR_ITEMS_CATEGORY = 5,
|
| - |
|
68 |
TABLE_INDEX_SIMILAR_ITEMS_BUTTON = 6;
|
| - |
|
69 |
|
| 62 |
private final String PRICE_WIDTH = "100px", VENDOR_DESC_WIDTH = "130px",
|
70 |
private final String PRICE_WIDTH = "100px", VENDOR_DESC_WIDTH = "130px",
|
| 63 |
VENDOR_ID_WIDTH = "100px", ITEM_KEY_WIDTH = "200px",
|
71 |
VENDOR_ID_WIDTH = "100px", ITEM_KEY_WIDTH = "200px",
|
| 64 |
BUTTON_WIDTH = "50px";
|
72 |
BUTTON_WIDTH = "50px";
|
| 65 |
|
73 |
|
| 66 |
interface ItemDetailsUiBinder extends UiBinder<Widget, ItemDetails> {}
|
74 |
interface ItemDetailsUiBinder extends UiBinder<Widget, ItemDetails> {}
|
| Line 92... |
Line 100... |
| 92 |
@UiField TextBox bestSellingRank;
|
100 |
@UiField TextBox bestSellingRank;
|
| 93 |
@UiField TextBox expectedDelay;
|
101 |
@UiField TextBox expectedDelay;
|
| 94 |
@UiField TextBox preferredWarehouse, defaultWarehouse;
|
102 |
@UiField TextBox preferredWarehouse, defaultWarehouse;
|
| 95 |
@UiField CheckBox defaultForEntity, risky, warehouseStickiness;
|
103 |
@UiField CheckBox defaultForEntity, risky, warehouseStickiness;
|
| 96 |
@UiField DateBox startDate;
|
104 |
@UiField DateBox startDate;
|
| - |
|
105 |
@UiField FlexTable headerSimilarItems, tableSimilarItems;
|
| 97 |
|
106 |
|
| 98 |
public ItemDetails(Item item){
|
107 |
public ItemDetails(Item item){
|
| 99 |
this();
|
108 |
this();
|
| 100 |
setItemDetails(item);
|
109 |
setItemDetails(item);
|
| 101 |
}
|
110 |
}
|
| Line 104... |
Line 113... |
| 104 |
initWidget(uiBinder.createAndBindUi(this));
|
113 |
initWidget(uiBinder.createAndBindUi(this));
|
| 105 |
initAvailabilityHeader();
|
114 |
initAvailabilityHeader();
|
| 106 |
initVendorKeysHeader();
|
115 |
initVendorKeysHeader();
|
| 107 |
initVendorPricingHeader();
|
116 |
initVendorPricingHeader();
|
| 108 |
initSourcePricingHeader();
|
117 |
initSourcePricingHeader();
|
| 109 |
|
118 |
initSimilarItemList();
|
| 110 |
headerAvailability.setVisible(false);
|
119 |
headerAvailability.setVisible(false);
|
| 111 |
availabilityTable.setVisible(false);
|
120 |
availabilityTable.setVisible(false);
|
| 112 |
}
|
121 |
}
|
| 113 |
|
122 |
|
| 114 |
/**
|
123 |
/**
|
| Line 153... |
Line 162... |
| 153 |
|
162 |
|
| 154 |
updateAvailabilityTable(item.getAvailability());
|
163 |
updateAvailabilityTable(item.getAvailability());
|
| 155 |
updateVendorKeysTable(item.getVendorKeysMap());
|
164 |
updateVendorKeysTable(item.getVendorKeysMap());
|
| 156 |
updateVendorPricingTable(item.getVendorPricesMap());
|
165 |
updateVendorPricingTable(item.getVendorPricesMap());
|
| 157 |
updateSourcePricingTable(item.getSourcePricesMap());
|
166 |
updateSourcePricingTable(item.getSourcePricesMap());
|
| - |
|
167 |
updateSimilarItemsTable(item.getSimilarItems());
|
| 158 |
}
|
168 |
}
|
| 159 |
|
169 |
|
| 160 |
/**
|
170 |
/**
|
| 161 |
* initialise item availability table header.
|
171 |
* initialise item availability table header.
|
| 162 |
*/
|
172 |
*/
|
| Line 337... |
Line 347... |
| 337 |
}
|
347 |
}
|
| 338 |
});
|
348 |
});
|
| 339 |
}
|
349 |
}
|
| 340 |
|
350 |
|
| 341 |
/**
|
351 |
/**
|
| - |
|
352 |
* initialises similar items table header. Creates an Add button and
|
| - |
|
353 |
* adds click event listener to it to create and pop up a dialog for adding
|
| - |
|
354 |
* a new similar item.
|
| - |
|
355 |
*/
|
| - |
|
356 |
private void initSimilarItemList() {
|
| - |
|
357 |
headerSimilarItems.getColumnFormatter().setWidth(TABLE_INDEX_SIMILAR_ITEMS_CATALOG_ITEM_ID, PRICE_WIDTH);
|
| - |
|
358 |
headerSimilarItems.getColumnFormatter().setWidth(TABLE_INDEX_SIMILAR_ITEMS_PRODUCT_GROUP, PRICE_WIDTH);
|
| - |
|
359 |
headerSimilarItems.getColumnFormatter().setWidth(TABLE_INDEX_SIMILAR_ITEMS_BRAND, PRICE_WIDTH);
|
| - |
|
360 |
headerSimilarItems.getColumnFormatter().setWidth(TABLE_INDEX_SIMILAR_ITEMS_MODEL_NUMBER, PRICE_WIDTH);
|
| - |
|
361 |
headerSimilarItems.getColumnFormatter().setWidth(TABLE_INDEX_SIMILAR_ITEMS_MODEL_NAME, PRICE_WIDTH);
|
| - |
|
362 |
headerSimilarItems.getColumnFormatter().setWidth(TABLE_INDEX_SIMILAR_ITEMS_CATEGORY, "150px");
|
| - |
|
363 |
headerSimilarItems.getColumnFormatter().setWidth(TABLE_INDEX_SIMILAR_ITEMS_BUTTON, BUTTON_WIDTH);
|
| - |
|
364 |
|
| - |
|
365 |
headerSimilarItems.setText(0, TABLE_INDEX_SIMILAR_ITEMS_CATALOG_ITEM_ID, "Catalog ItemId");
|
| - |
|
366 |
headerSimilarItems.setText(0, TABLE_INDEX_SIMILAR_ITEMS_PRODUCT_GROUP, "Product Group");
|
| - |
|
367 |
headerSimilarItems.setText(0, TABLE_INDEX_SIMILAR_ITEMS_BRAND, "Brand");
|
| - |
|
368 |
headerSimilarItems.setText(0, TABLE_INDEX_SIMILAR_ITEMS_MODEL_NUMBER, "Model Number");
|
| - |
|
369 |
headerSimilarItems.setText(0, TABLE_INDEX_SIMILAR_ITEMS_MODEL_NAME, "Model Name");
|
| - |
|
370 |
headerSimilarItems.setText(0, TABLE_INDEX_SIMILAR_ITEMS_CATEGORY, "Category");
|
| - |
|
371 |
|
| - |
|
372 |
Button addButton = new Button("Add");
|
| - |
|
373 |
headerSimilarItems.setWidget(0, TABLE_INDEX_SIMILAR_ITEMS_BUTTON, addButton);
|
| - |
|
374 |
addButton.addClickHandler(new ClickHandler() {
|
| - |
|
375 |
@Override
|
| - |
|
376 |
public void onClick(ClickEvent event) {
|
| - |
|
377 |
AddSimilarItemDialog addSimilarItemDialog = new AddSimilarItemDialog();
|
| - |
|
378 |
addSimilarItemDialog.setAddSimilarItemUpdateListener(new AddSimilarItemDialog.AddSimilarItemUpdateListener() {
|
| - |
|
379 |
@Override
|
| - |
|
380 |
public boolean onUpdate(long catalogItemId) {
|
| - |
|
381 |
if (item.getSimilarItems().containsKey(catalogItemId)) {
|
| - |
|
382 |
Window.alert("Similar Item exists.");
|
| - |
|
383 |
return false;
|
| - |
|
384 |
}
|
| - |
|
385 |
else {
|
| - |
|
386 |
catalogService.addSimilarItem(item.getId(), catalogItemId, new AsyncCallback<Item>() {
|
| - |
|
387 |
@Override
|
| - |
|
388 |
public void onSuccess(Item similarItem) {
|
| - |
|
389 |
if(similarItem != null) {
|
| - |
|
390 |
GWT.log("Similar Item Added");
|
| - |
|
391 |
Map<Long, Item> newsimilarItems = item.getSimilarItems();
|
| - |
|
392 |
newsimilarItems.put(similarItem.getCatalogItemId(), similarItem);
|
| - |
|
393 |
item.setSimilarItems(newsimilarItems);
|
| - |
|
394 |
updateSimilarItemsTable(item.getSimilarItems());
|
| - |
|
395 |
Window.alert("Similar Item Added successfully.");
|
| - |
|
396 |
}
|
| - |
|
397 |
else {
|
| - |
|
398 |
GWT.log("Error Adding Similar Item");
|
| - |
|
399 |
Window.alert("Error Adding Similar Item");
|
| - |
|
400 |
}
|
| - |
|
401 |
}
|
| - |
|
402 |
@Override
|
| - |
|
403 |
public void onFailure(Throwable caught) {
|
| - |
|
404 |
caught.printStackTrace();
|
| - |
|
405 |
Window.alert("Error deleting Similar Item");
|
| - |
|
406 |
}
|
| - |
|
407 |
});
|
| - |
|
408 |
return true;
|
| - |
|
409 |
}
|
| - |
|
410 |
}
|
| - |
|
411 |
});
|
| - |
|
412 |
addSimilarItemDialog.show();
|
| - |
|
413 |
}
|
| - |
|
414 |
});
|
| - |
|
415 |
}
|
| - |
|
416 |
|
| - |
|
417 |
/**
|
| 342 |
* Clear and populate item availability table.
|
418 |
* Clear and populate item availability table.
|
| 343 |
* @param availabilityMap
|
419 |
* @param availabilityMap
|
| 344 |
*/
|
420 |
*/
|
| 345 |
private void updateAvailabilityTable(Map<Long, Long> availabilityMap){
|
421 |
private void updateAvailabilityTable(Map<Long, Long> availabilityMap){
|
| 346 |
availabilityTable.removeAllRows();
|
422 |
availabilityTable.removeAllRows();
|
| Line 357... |
Line 433... |
| 357 |
availabilityTable.setText(i, TABLE_INDEX_WAREHOUSE_DESC, Utils.getWarehouseDesc(availability.getKey()));
|
433 |
availabilityTable.setText(i, TABLE_INDEX_WAREHOUSE_DESC, Utils.getWarehouseDesc(availability.getKey()));
|
| 358 |
availabilityTable.setText(i, TABLE_INDEX_WAREHOUSE_INV, availability.getValue() + "");
|
434 |
availabilityTable.setText(i, TABLE_INDEX_WAREHOUSE_INV, availability.getValue() + "");
|
| 359 |
i++;
|
435 |
i++;
|
| 360 |
}
|
436 |
}
|
| 361 |
}
|
437 |
}
|
| 362 |
|
438 |
|
| 363 |
/**
|
439 |
/**
|
| 364 |
* Clear and populate vendor item key table with keys in the passed argument.
|
440 |
* Clear and populate vendor item key table with keys in the passed argument.
|
| 365 |
* With each row in the table, an edit button is created and click event listener
|
441 |
* With each row in the table, an edit button is created and click event listener
|
| 366 |
* is added to it to edit that vendor item key row.
|
442 |
* is added to it to edit that vendor item key row.
|
| 367 |
* @param vendorKeysMap
|
443 |
* @param vendorKeysMap
|
| Line 443... |
Line 519... |
| 443 |
tableVendorPrices.getCellFormatter().setVisible(i, TABLE_INDEX_PRICING_VENDORID, false);
|
519 |
tableVendorPrices.getCellFormatter().setVisible(i, TABLE_INDEX_PRICING_VENDORID, false);
|
| 444 |
i++;
|
520 |
i++;
|
| 445 |
}
|
521 |
}
|
| 446 |
}
|
522 |
}
|
| 447 |
|
523 |
|
| 448 |
|
- |
|
| 449 |
/**
|
524 |
/**
|
| 450 |
* Clear and populate vendor prices table with prices in the passed argument.
|
525 |
* Clear and populate vendor prices table with prices in the passed argument.
|
| 451 |
* With each row in the table, an edit button is created and click event listener
|
526 |
* With each row in the table, an edit button is created and click event listener
|
| 452 |
* is added to it to edit that vendor prices row.
|
527 |
* is added to it to edit that vendor prices row.
|
| 453 |
* @param sourcePricingMap
|
528 |
* @param sourcePricingMap
|
| Line 484... |
Line 559... |
| 484 |
});
|
559 |
});
|
| 485 |
tableSourcePrices.getCellFormatter().setVisible(i, TABLE_INDEX_SOURCE_PRICING_SOURCE_ID, false);
|
560 |
tableSourcePrices.getCellFormatter().setVisible(i, TABLE_INDEX_SOURCE_PRICING_SOURCE_ID, false);
|
| 486 |
i++;
|
561 |
i++;
|
| 487 |
}
|
562 |
}
|
| 488 |
}
|
563 |
}
|
| - |
|
564 |
|
| - |
|
565 |
/**
|
| - |
|
566 |
* Clear and populate similar items table with items in the passed argument.
|
| - |
|
567 |
* With each row in the table, an delete button is created and click event listener
|
| - |
|
568 |
* is added to it to delete that similar item row.
|
| - |
|
569 |
* @param similarItems
|
| - |
|
570 |
*/
|
| - |
|
571 |
private void updateSimilarItemsTable(Map<Long, Item> similarItems){
|
| - |
|
572 |
tableSimilarItems.removeAllRows();
|
| - |
|
573 |
|
| - |
|
574 |
if(similarItems == null || similarItems.isEmpty()) {
|
| - |
|
575 |
return;
|
| - |
|
576 |
}
|
| - |
|
577 |
tableSimilarItems.getColumnFormatter().setWidth(TABLE_INDEX_SIMILAR_ITEMS_CATALOG_ITEM_ID, PRICE_WIDTH);
|
| - |
|
578 |
tableSimilarItems.getColumnFormatter().setWidth(TABLE_INDEX_SIMILAR_ITEMS_PRODUCT_GROUP, PRICE_WIDTH);
|
| - |
|
579 |
tableSimilarItems.getColumnFormatter().setWidth(TABLE_INDEX_SIMILAR_ITEMS_BRAND, PRICE_WIDTH);
|
| - |
|
580 |
tableSimilarItems.getColumnFormatter().setWidth(TABLE_INDEX_SIMILAR_ITEMS_MODEL_NUMBER, PRICE_WIDTH);
|
| - |
|
581 |
tableSimilarItems.getColumnFormatter().setWidth(TABLE_INDEX_SIMILAR_ITEMS_MODEL_NAME, PRICE_WIDTH);
|
| - |
|
582 |
tableSimilarItems.getColumnFormatter().setWidth(TABLE_INDEX_SIMILAR_ITEMS_CATEGORY, "150px");
|
| - |
|
583 |
tableSimilarItems.getColumnFormatter().setWidth(TABLE_INDEX_SIMILAR_ITEMS_BUTTON, BUTTON_WIDTH);
|
| - |
|
584 |
|
| - |
|
585 |
|
| - |
|
586 |
int i=0;
|
| - |
|
587 |
for(Item similarItemDetail : similarItems.values()){
|
| - |
|
588 |
tableSimilarItems.setText(i, TABLE_INDEX_SIMILAR_ITEMS_CATALOG_ITEM_ID, similarItemDetail.getCatalogItemId() + "");
|
| - |
|
589 |
tableSimilarItems.setText(i, TABLE_INDEX_SIMILAR_ITEMS_PRODUCT_GROUP, similarItemDetail.getProductGroup() + "");
|
| - |
|
590 |
tableSimilarItems.setText(i, TABLE_INDEX_SIMILAR_ITEMS_BRAND, similarItemDetail.getBrand() + "");
|
| - |
|
591 |
tableSimilarItems.setText(i, TABLE_INDEX_SIMILAR_ITEMS_MODEL_NUMBER, similarItemDetail.getModelNumber() + "");
|
| - |
|
592 |
tableSimilarItems.setText(i, TABLE_INDEX_SIMILAR_ITEMS_MODEL_NAME, similarItemDetail.getModelName() + "");
|
| - |
|
593 |
tableSimilarItems.setText(i, TABLE_INDEX_SIMILAR_ITEMS_CATEGORY, similarItemDetail.getContentCategory() + "");
|
| - |
|
594 |
|
| - |
|
595 |
Button deleteButton = new Button("Delete");
|
| - |
|
596 |
tableSimilarItems.setWidget(i, TABLE_INDEX_SIMILAR_ITEMS_BUTTON, deleteButton);
|
| - |
|
597 |
deleteButton.addClickHandler(new ClickHandler() {
|
| - |
|
598 |
@Override
|
| - |
|
599 |
public void onClick(ClickEvent event) {
|
| - |
|
600 |
Cell cell = tableSimilarItems.getCellForEvent(event);
|
| - |
|
601 |
final int row = cell.getRowIndex();
|
| - |
|
602 |
long catalogItemId = Long.parseLong(tableSimilarItems.getText(row, TABLE_INDEX_SIMILAR_ITEMS_CATALOG_ITEM_ID));
|
| - |
|
603 |
|
| - |
|
604 |
catalogService.deleteSimilarItem(item.getId(), catalogItemId, new AsyncCallback<Boolean>() {
|
| - |
|
605 |
@Override
|
| - |
|
606 |
public void onSuccess(Boolean result) {
|
| - |
|
607 |
if(result) {
|
| - |
|
608 |
GWT.log("Similar Item deleted");
|
| - |
|
609 |
long catalogItemId = Long.parseLong(tableSimilarItems.getText(row, TABLE_INDEX_SIMILAR_ITEMS_CATALOG_ITEM_ID));
|
| - |
|
610 |
tableSimilarItems.removeRow(row);
|
| - |
|
611 |
Map<Long, Item> newsimilarItems = item.getSimilarItems();
|
| - |
|
612 |
newsimilarItems.remove(catalogItemId);
|
| - |
|
613 |
item.setSimilarItems(newsimilarItems);
|
| - |
|
614 |
}
|
| - |
|
615 |
else {
|
| - |
|
616 |
GWT.log("Error deleting Similar Item");
|
| - |
|
617 |
Window.alert("Error deleting Similar Item");
|
| - |
|
618 |
}
|
| - |
|
619 |
}
|
| - |
|
620 |
@Override
|
| - |
|
621 |
public void onFailure(Throwable caught) {
|
| - |
|
622 |
caught.printStackTrace();
|
| - |
|
623 |
Window.alert("Error deleting Similar Item");
|
| - |
|
624 |
}
|
| - |
|
625 |
});
|
| - |
|
626 |
}
|
| - |
|
627 |
});
|
| - |
|
628 |
i++;
|
| - |
|
629 |
}
|
| 489 |
|
630 |
}
|
| 490 |
|
631 |
|
| 491 |
/**
|
632 |
/**
|
| 492 |
* called on the click event of update item button in ItemActions
|
633 |
* called on the click event of update item button in ItemActions
|
| 493 |
*/
|
634 |
*/
|
| 494 |
void updateItem() {
|
635 |
void updateItem() {
|
| Line 729... |
Line 870... |
| 729 |
newItem.setRetireDate(item.getRetireDate());
|
870 |
newItem.setRetireDate(item.getRetireDate());
|
| 730 |
newItem.setUpdatedOn(item.getUpdatedOn());
|
871 |
newItem.setUpdatedOn(item.getUpdatedOn());
|
| 731 |
newItem.setItemStatus(item.getItemStatus());
|
872 |
newItem.setItemStatus(item.getItemStatus());
|
| 732 |
newItem.setOtherInfo(item.getOtherInfo());
|
873 |
newItem.setOtherInfo(item.getOtherInfo());
|
| 733 |
newItem.setAvailability(item.getAvailability());
|
874 |
newItem.setAvailability(item.getAvailability());
|
| - |
|
875 |
newItem.setSimilarItems(item.getSimilarItems());
|
| 734 |
|
876 |
|
| 735 |
return true;
|
877 |
return true;
|
| 736 |
}
|
878 |
}
|
| 737 |
|
879 |
|
| 738 |
/**
|
880 |
/**
|