1
|
package eu.dnetlib.client;
|
2
|
|
3
|
import com.github.gwtbootstrap.client.ui.Alert;
|
4
|
import com.github.gwtbootstrap.client.ui.Button;
|
5
|
import com.github.gwtbootstrap.client.ui.Form;
|
6
|
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
7
|
import com.github.gwtbootstrap.client.ui.constants.AlternateSize;
|
8
|
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
|
9
|
import com.github.gwtbootstrap.client.ui.constants.FormType;
|
10
|
import com.github.gwtbootstrap.datepicker.client.ui.DateBox;
|
11
|
import com.google.gwt.core.client.GWT;
|
12
|
import com.google.gwt.event.dom.client.ClickEvent;
|
13
|
import com.google.gwt.event.dom.client.ClickHandler;
|
14
|
import com.google.gwt.user.client.ui.*;
|
15
|
import eu.dnetlib.client.widgets.FormFieldSet;
|
16
|
import eu.dnetlib.client.widgets.TextBox;
|
17
|
import eu.dnetlib.shared.FundingWizardState;
|
18
|
|
19
|
/**
|
20
|
* Created by stefania on 3/9/15.
|
21
|
*/
|
22
|
public class AccountingStepWidget extends FundingWizardStepWidget {
|
23
|
|
24
|
private FlowPanel accountingStepPanel = new FlowPanel();
|
25
|
|
26
|
private FlowPanel uploadInvoicePanel = new FlowPanel();
|
27
|
private Label uploadInvoiceLabel = new Label();
|
28
|
private Alert UploadInvoiceErrorLabel = new Alert();
|
29
|
private Alert uploadInvoiceSuccessLabel = new Alert();
|
30
|
private Form uploadInvoiceForm = new Form();
|
31
|
private TextBox invoiceNumber = new TextBox();
|
32
|
private DateBox dateIssued = new DateBox();
|
33
|
private FileUpload fileUpload = new FileUpload();
|
34
|
private Button upload = new Button("Upload");
|
35
|
|
36
|
private FlowPanel accountingInfoPanel = new FlowPanel();
|
37
|
private Label accountingInfoLabel = new Label();
|
38
|
private Alert accountingInfoErrorLabel = new Alert();
|
39
|
private Form accountingInfoForm = new Form();
|
40
|
private TextBox apc = new TextBox();
|
41
|
private TextBox goldDiscount = new TextBox();
|
42
|
private TextBox projectParticipation = new TextBox();
|
43
|
private TextBox fundingRequested = new TextBox();
|
44
|
|
45
|
private FundingWizardStepCompleteListener fundingWizardStepCompleteListener;
|
46
|
|
47
|
public AccountingStepWidget(String title) {
|
48
|
super(title);
|
49
|
|
50
|
accountingStepPanel.addStyleName("accountingForm");
|
51
|
|
52
|
uploadInvoiceLabel.addStyleName("uploadInvoiceLabel");
|
53
|
uploadInvoiceLabel.setText("Upload your invoice");
|
54
|
|
55
|
uploadInvoiceSuccessLabel.addStyleName("alertLabel");
|
56
|
uploadInvoiceSuccessLabel.setType(AlertType.SUCCESS);
|
57
|
uploadInvoiceSuccessLabel.setVisible(false);
|
58
|
uploadInvoiceSuccessLabel.setClose(false);
|
59
|
|
60
|
UploadInvoiceErrorLabel.addStyleName("alertLabel");
|
61
|
UploadInvoiceErrorLabel.setType(AlertType.ERROR);
|
62
|
UploadInvoiceErrorLabel.setVisible(false);
|
63
|
UploadInvoiceErrorLabel.setClose(false);
|
64
|
|
65
|
uploadInvoicePanel.addStyleName("uploadInvoicePanel");
|
66
|
uploadInvoicePanel.add(uploadInvoiceLabel);
|
67
|
uploadInvoicePanel.add(uploadInvoiceSuccessLabel);
|
68
|
uploadInvoicePanel.add(UploadInvoiceErrorLabel);
|
69
|
|
70
|
uploadInvoiceForm.setType(FormType.HORIZONTAL);
|
71
|
uploadInvoiceForm.setAction(GWT.getModuleBaseURL() + "fileupload");
|
72
|
uploadInvoiceForm.setEncoding(FormPanel.ENCODING_MULTIPART);
|
73
|
uploadInvoiceForm.setMethod(FormPanel.METHOD_POST);
|
74
|
uploadInvoicePanel.add(uploadInvoiceForm);
|
75
|
|
76
|
invoiceNumber.setAlternateSize(AlternateSize.LARGE);
|
77
|
invoiceNumber.setName("invoiceNumber");
|
78
|
uploadInvoiceForm.add(new FormFieldSet("Invoice number (*)", invoiceNumber));
|
79
|
|
80
|
dateIssued.setAlternateSize(AlternateSize.LARGE);
|
81
|
dateIssued.setName("dateIssued");
|
82
|
uploadInvoiceForm.add(new FormFieldSet("Date issued (*)", dateIssued));
|
83
|
|
84
|
fileUpload.setName("fileUpload");
|
85
|
uploadInvoiceForm.add(new FormFieldSet("Invoice (*)", fileUpload));
|
86
|
|
87
|
upload.setType(ButtonType.SUCCESS);
|
88
|
upload.addClickHandler(new ClickHandler() {
|
89
|
@Override
|
90
|
public void onClick(ClickEvent clickEvent) {
|
91
|
|
92
|
uploadInvoiceSuccessLabel.setVisible(false);
|
93
|
UploadInvoiceErrorLabel.setVisible(false);
|
94
|
|
95
|
if(!invoiceNumber.getValue().trim().equals("") && fileUpload.getFilename()!=null && !fileUpload.getFilename().equals(""))
|
96
|
uploadInvoiceForm.submit();
|
97
|
else {
|
98
|
UploadInvoiceErrorLabel.setText("All asterisk (*) fields are required.");
|
99
|
UploadInvoiceErrorLabel.setVisible(true);
|
100
|
}
|
101
|
}
|
102
|
});
|
103
|
uploadInvoiceForm.add(new FormFieldSet(null, upload));
|
104
|
|
105
|
uploadInvoiceForm.addSubmitCompleteHandler(new Form.SubmitCompleteHandler() {
|
106
|
@Override
|
107
|
public void onSubmitComplete(Form.SubmitCompleteEvent submitCompleteEvent) {
|
108
|
|
109
|
uploadInvoiceSuccessLabel.setVisible(false);
|
110
|
UploadInvoiceErrorLabel.setVisible(false);
|
111
|
|
112
|
uploadInvoiceSuccessLabel.setText("Upload completed successfully");
|
113
|
uploadInvoiceSuccessLabel.setVisible(true);
|
114
|
}
|
115
|
});
|
116
|
|
117
|
|
118
|
accountingInfoLabel.addStyleName("uploadInvoiceLabel");
|
119
|
accountingInfoLabel.setText("Accounting Information");
|
120
|
|
121
|
accountingInfoErrorLabel.addStyleName("alertLabel");
|
122
|
accountingInfoErrorLabel.setType(AlertType.ERROR);
|
123
|
accountingInfoErrorLabel.setVisible(false);
|
124
|
accountingInfoErrorLabel.setClose(false);
|
125
|
|
126
|
accountingInfoPanel.addStyleName("uploadInvoicePanel");
|
127
|
accountingInfoPanel.add(accountingInfoLabel);
|
128
|
accountingInfoPanel.add(accountingInfoErrorLabel);
|
129
|
|
130
|
accountingInfoForm.setType(FormType.HORIZONTAL);
|
131
|
accountingInfoPanel.add(accountingInfoForm);
|
132
|
|
133
|
apc.setAlternateSize(AlternateSize.LARGE);
|
134
|
apc.setEnabled(false);
|
135
|
accountingInfoForm.add(new FormFieldSet("APC", apc));
|
136
|
|
137
|
goldDiscount.setAlternateSize(AlternateSize.LARGE);
|
138
|
goldDiscount.setEnabled(false);
|
139
|
accountingInfoForm.add(new FormFieldSet("OpenAIRE Gold Discount", goldDiscount));
|
140
|
|
141
|
projectParticipation.setAlternateSize(AlternateSize.LARGE);
|
142
|
projectParticipation.setPlaceholder(" %");
|
143
|
accountingInfoForm.add(new FormFieldSet("Project participation", projectParticipation));
|
144
|
|
145
|
fundingRequested.setAlternateSize(AlternateSize.LARGE);
|
146
|
fundingRequested.setEnabled(false);
|
147
|
accountingInfoForm.add(new FormFieldSet("Funding Requested", fundingRequested));
|
148
|
|
149
|
|
150
|
accountingStepPanel.add(uploadInvoicePanel);
|
151
|
accountingStepPanel.add(accountingInfoPanel);
|
152
|
}
|
153
|
|
154
|
@Override
|
155
|
public Widget asWidget() {
|
156
|
return accountingStepPanel;
|
157
|
}
|
158
|
|
159
|
@Override
|
160
|
public void updateState(FundingWizardState fundingWizardState) {
|
161
|
|
162
|
}
|
163
|
|
164
|
@Override
|
165
|
public void save() {
|
166
|
|
167
|
}
|
168
|
|
169
|
@Override
|
170
|
public void loadContent(FundingWizardState fundingWizardState) {
|
171
|
|
172
|
}
|
173
|
|
174
|
@Override
|
175
|
public void setFundingWizardStepCompleteListener(FundingWizardStepCompleteListener fundingWizardStepCompleteListener) {
|
176
|
this.fundingWizardStepCompleteListener = fundingWizardStepCompleteListener;
|
177
|
}
|
178
|
}
|