| 5217 |
amit.gupta |
1 |
package in.shop2020.catalog.dashboard.client;
|
|
|
2 |
|
|
|
3 |
import java.util.Date;
|
|
|
4 |
|
|
|
5 |
import com.google.gwt.core.client.GWT;
|
|
|
6 |
import com.google.gwt.event.dom.client.ClickEvent;
|
|
|
7 |
import com.google.gwt.uibinder.client.UiBinder;
|
|
|
8 |
import com.google.gwt.uibinder.client.UiField;
|
|
|
9 |
import com.google.gwt.uibinder.client.UiHandler;
|
|
|
10 |
import com.google.gwt.user.client.Window;
|
|
|
11 |
import com.google.gwt.user.client.ui.Button;
|
|
|
12 |
import com.google.gwt.user.client.ui.DialogBox;
|
|
|
13 |
import com.google.gwt.user.client.ui.TextBox;
|
|
|
14 |
import com.google.gwt.user.client.ui.Widget;
|
|
|
15 |
import com.google.gwt.user.datepicker.client.DateBox;
|
|
|
16 |
|
|
|
17 |
public class ComingSoonDialog extends DialogBox {
|
|
|
18 |
interface Binder extends UiBinder<Widget, ComingSoonDialog> { }
|
|
|
19 |
private static final Binder binder = GWT.create(Binder.class);
|
|
|
20 |
private ComingSoon comingSoon;
|
|
|
21 |
|
|
|
22 |
@UiField Button okButton, cancelButton, cancelComingSoonButton;
|
|
|
23 |
@UiField TextBox lightBoxText;
|
|
|
24 |
@UiField DateBox comingSoonStartDate, expectedArrivalDate;
|
|
|
25 |
|
|
|
26 |
|
|
|
27 |
public ComingSoonDialog(ComingSoon comingSoon){
|
|
|
28 |
setText("Coming Soon");
|
|
|
29 |
setWidget(binder.createAndBindUi(this));
|
|
|
30 |
setAnimationEnabled(true);
|
|
|
31 |
center();
|
|
|
32 |
//Do the coding for moving both the info to appropriate fields.
|
|
|
33 |
this.comingSoon = comingSoon;
|
|
|
34 |
if(this.comingSoon.getExpectedArrivalDate() != null){
|
|
|
35 |
this.lightBoxText.setValue(this.comingSoon.getBestDealsText());
|
|
|
36 |
this.comingSoonStartDate.setValue(this.comingSoon.getComingSoonStartDate());
|
|
|
37 |
this.expectedArrivalDate.setValue(this.comingSoon.getExpectedArrivalDate());
|
|
|
38 |
}else {
|
|
|
39 |
this.cancelComingSoonButton.setEnabled(false);
|
|
|
40 |
}
|
|
|
41 |
}
|
|
|
42 |
|
|
|
43 |
|
|
|
44 |
|
|
|
45 |
|
|
|
46 |
@UiHandler("cancelComingSoonButton")
|
|
|
47 |
void onCancelComingSoon(ClickEvent event){
|
|
|
48 |
if(Window.confirm("The item will be removed from Coming Soon Page.\nAre you sure?")){
|
|
|
49 |
this.comingSoon.setComingSoonStartDate(null);
|
|
|
50 |
this.comingSoon.setExpectedArrivalDate(null);
|
|
|
51 |
this.comingSoon.setBestDealsText("");
|
|
|
52 |
this.hide();
|
|
|
53 |
}
|
|
|
54 |
}
|
|
|
55 |
|
|
|
56 |
@UiHandler("cancelButton")
|
|
|
57 |
void onCancelClicked(ClickEvent event) {
|
|
|
58 |
hide();
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
@UiHandler("okButton")
|
|
|
62 |
void onOkClicked(ClickEvent event) {
|
|
|
63 |
String lightBoxTxt;
|
|
|
64 |
Date comingSoonStartDt = null;
|
|
|
65 |
Date expectedArrivalDt = null;
|
|
|
66 |
lightBoxTxt = this.lightBoxText.getText().trim();
|
|
|
67 |
boolean sure = true;
|
|
|
68 |
|
|
|
69 |
|
|
|
70 |
try {
|
|
|
71 |
if(!expectedArrivalDate.getTextBox().getText().trim().equals("")) {
|
|
|
72 |
expectedArrivalDt = expectedArrivalDate.getValue();
|
|
|
73 |
if(expectedArrivalDt.compareTo(new Date()) <=0 ){
|
|
|
74 |
Window.alert("Expected arrival date should be higher than Current Time.");
|
|
|
75 |
return;
|
|
|
76 |
}
|
|
|
77 |
if(!comingSoonStartDate.getTextBox().getText().trim().equals("")) {
|
|
|
78 |
comingSoonStartDt = comingSoonStartDate.getValue();
|
|
|
79 |
if(comingSoonStartDt.compareTo(expectedArrivalDt) >= 0 ){
|
|
|
80 |
Window.alert("Expected arrival date should be higher than Coming Soon Start Date.");
|
|
|
81 |
return;
|
|
|
82 |
}
|
|
|
83 |
}
|
|
|
84 |
} else {
|
|
|
85 |
Window.alert("Expected arrival date can't be blank.");
|
|
|
86 |
}
|
|
|
87 |
} catch(Exception ex) {
|
|
|
88 |
Window.alert("Invalid Date format");
|
|
|
89 |
return;
|
|
|
90 |
}
|
|
|
91 |
|
|
|
92 |
if(lightBoxTxt.equals("")){
|
|
|
93 |
sure = Window.confirm("No offer message will be displayed in the light Box. Are you sure?");
|
|
|
94 |
if(!sure) {
|
|
|
95 |
return;
|
|
|
96 |
}
|
|
|
97 |
}
|
|
|
98 |
//Do the coding for moving both the info to appropriate fields.
|
|
|
99 |
|
|
|
100 |
this.comingSoon.setComingSoonStartDate(comingSoonStartDt);
|
|
|
101 |
this.comingSoon.setExpectedArrivalDate(expectedArrivalDt);
|
|
|
102 |
this.comingSoon.setBestDealsText(lightBoxTxt);
|
|
|
103 |
hide();
|
|
|
104 |
}
|
|
|
105 |
}
|