1
|
package eu.dnetlib.client.monitor;
|
2
|
|
3
|
import com.github.gwtbootstrap.client.ui.*;
|
4
|
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
5
|
import com.github.gwtbootstrap.client.ui.constants.BackdropType;
|
6
|
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
|
7
|
import com.github.gwtbootstrap.client.ui.constants.FormType;
|
8
|
import com.google.gwt.core.client.GWT;
|
9
|
import com.google.gwt.event.dom.client.ClickEvent;
|
10
|
import com.google.gwt.event.dom.client.ClickHandler;
|
11
|
import com.google.gwt.user.client.History;
|
12
|
import com.google.gwt.user.client.Window;
|
13
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
14
|
import com.google.gwt.user.client.ui.FlowPanel;
|
15
|
import com.google.gwt.user.client.ui.HTML;
|
16
|
import com.google.gwt.user.client.ui.IsWidget;
|
17
|
import com.google.gwt.user.client.ui.Widget;
|
18
|
import eu.dnetlib.client.*;
|
19
|
import eu.dnetlib.client.fundingrequest.newrequest.EligibilityDisplayWidget;
|
20
|
import eu.dnetlib.client.fundingrequest.stepinfo.*;
|
21
|
import eu.dnetlib.client.widgets.ConfirmActionModal;
|
22
|
import eu.dnetlib.client.widgets.FormFieldSet;
|
23
|
import eu.dnetlib.goldoa.domain.*;
|
24
|
|
25
|
import java.sql.Timestamp;
|
26
|
import java.util.ArrayList;
|
27
|
import java.util.Date;
|
28
|
import java.util.List;
|
29
|
|
30
|
/**
|
31
|
* Created by stefania on 3/26/15.
|
32
|
*/
|
33
|
public class RequestInfoElement implements IsWidget {
|
34
|
|
35
|
private FlowPanel requestInfoPanel = new FlowPanel();
|
36
|
|
37
|
private Alert errorLabel = new Alert();
|
38
|
private Alert successLabel = new Alert();
|
39
|
|
40
|
private FlowPanel requestSummaryPanel = new FlowPanel();
|
41
|
private FlowPanel firstDivider = new FlowPanel();
|
42
|
|
43
|
private FlowPanel actionButtons = new FlowPanel();
|
44
|
private Button approve = new Button("Approve");
|
45
|
private Button conditionalApprove = new Button("Conditional Approve");
|
46
|
private Button reject = new Button("Reject");
|
47
|
|
48
|
private Button libraryFundPaid = new Button("Library Fund - Paid");
|
49
|
private Button publisherFundPaid = new Button("Publisher Fund - Paid");
|
50
|
|
51
|
private Button editRequest = new Button("Edit request");
|
52
|
private Button addDOI = new Button("Add DOI / repository");
|
53
|
|
54
|
private FlowPanel secondDivider = new FlowPanel();
|
55
|
|
56
|
private ActionListener actionListener;
|
57
|
private PublicationUpdatedListener publicationUpdatedListener;
|
58
|
|
59
|
private DataServiceAsync dataService = GWT.create(DataService.class);
|
60
|
private GoldOAConstants goldOAConstants = GWT.create(GoldOAConstants.class);
|
61
|
|
62
|
public RequestInfoElement(final Request request) {
|
63
|
|
64
|
requestInfoPanel.addStyleName("requestInfoPanel");
|
65
|
|
66
|
successLabel.addStyleName("alertLabel");
|
67
|
successLabel.setType(AlertType.SUCCESS);
|
68
|
successLabel.setVisible(false);
|
69
|
successLabel.setClose(false);
|
70
|
|
71
|
errorLabel.addStyleName("alertLabel");
|
72
|
errorLabel.setType(AlertType.ERROR);
|
73
|
errorLabel.setVisible(false);
|
74
|
errorLabel.setClose(false);
|
75
|
|
76
|
requestSummaryPanel.addStyleName("requestDetailedInfoPanel");
|
77
|
|
78
|
if(request.getResearcher()!=null) {
|
79
|
ResearcherInlineInfo researcherInlineInfo = new ResearcherInlineInfo(request.getResearcher());
|
80
|
requestSummaryPanel.add(researcherInlineInfo.asWidget());
|
81
|
}
|
82
|
|
83
|
if(request.getProject()!=null) {
|
84
|
ProjectInlineInfo projectInlineInfo = new ProjectInlineInfo(request.getProject());
|
85
|
requestSummaryPanel.add(projectInlineInfo.asWidget());
|
86
|
}
|
87
|
|
88
|
if(request.getPublication()!=null) {
|
89
|
PublicationInlineInfo publicationInlineInfo = new PublicationInlineInfo(request.getPublication());
|
90
|
requestSummaryPanel.add(publicationInlineInfo.asWidget());
|
91
|
}
|
92
|
|
93
|
double apc = 0;
|
94
|
double discount = 0;
|
95
|
|
96
|
if(request.getPublication()!=null && request.getPublication().getJournal()!=null) {
|
97
|
JournalInlineInfo journalInlineInfo = new JournalInlineInfo(request.getPublication().getJournal());
|
98
|
requestSummaryPanel.add(journalInlineInfo.asWidget());
|
99
|
apc = request.getPublication().getJournal().getApc();
|
100
|
discount = request.getPublication().getJournal().getDiscount();
|
101
|
}
|
102
|
|
103
|
if(request.getPublication()!=null && request.getPublication().getPublisher()!=null) {
|
104
|
PublisherInlineInfo publisherInlineInfo = new PublisherInlineInfo(request.getPublication().getPublisher());
|
105
|
requestSummaryPanel.add(publisherInlineInfo.asWidget());
|
106
|
apc = request.getPublication().getPublisher().getApc();
|
107
|
discount = request.getPublication().getPublisher().getDiscount();
|
108
|
}
|
109
|
|
110
|
if(request.getPublication()!=null) {
|
111
|
LicenseFullInfo licenseFullInfo = new LicenseFullInfo(request.getPublication().getLicense());
|
112
|
requestSummaryPanel.add(licenseFullInfo.asWidget());
|
113
|
}
|
114
|
|
115
|
if(request.getProjectparticipation()!=null && request.getFundingrequested()!=null) {
|
116
|
|
117
|
if(!request.getCurrency().equals(Currency.EUR)) {
|
118
|
|
119
|
final double finalApc = apc;
|
120
|
final double finalDiscount = discount;
|
121
|
dataService.convert(request.getCurrency(), Currency.EUR, request.getFundingrequested(), new AsyncCallback<Float>() {
|
122
|
|
123
|
@Override
|
124
|
public void onFailure(Throwable throwable) {
|
125
|
AccountingInlineInfo accountingInlineInfo = new AccountingInlineInfo(request, finalApc, finalDiscount, request.getCurrency(), 0);
|
126
|
requestSummaryPanel.add(accountingInlineInfo.asWidget());
|
127
|
}
|
128
|
|
129
|
@Override
|
130
|
public void onSuccess(Float aFloat) {
|
131
|
AccountingInlineInfo accountingInlineInfo = new AccountingInlineInfo(request, finalApc, finalDiscount, request.getCurrency(), aFloat);
|
132
|
requestSummaryPanel.add(accountingInlineInfo.asWidget());
|
133
|
}
|
134
|
});
|
135
|
} else {
|
136
|
AccountingInlineInfo accountingInlineInfo = new AccountingInlineInfo(request, apc, discount, request.getCurrency(), 0);
|
137
|
requestSummaryPanel.add(accountingInlineInfo.asWidget());
|
138
|
}
|
139
|
}
|
140
|
|
141
|
if(request.getInvoice()!=null) {
|
142
|
InvoiceInlineInfo invoiceInlineInfo = new InvoiceInlineInfo(request.getInvoice());
|
143
|
requestSummaryPanel.add(invoiceInlineInfo.asWidget());
|
144
|
}
|
145
|
|
146
|
if(request.getBankAccount()!=null &&
|
147
|
((request.getBankAccount().getBankName()!=null && !request.getBankAccount().getBankName().equals(""))
|
148
|
|| (request.getBankAccount().getBankAddress()!=null && !request.getBankAccount().getBankAddress().equals(""))
|
149
|
|| (request.getBankAccount().getAccountHolder()!=null && !request.getBankAccount().getAccountHolder().equals(""))
|
150
|
|| (request.getBankAccount().getIban()!=null && !request.getBankAccount().getIban().equals(""))
|
151
|
|| (request.getBankAccount().getBankCode()!=null && !request.getBankAccount().getBankCode().equals("")))) {
|
152
|
BankAccountInlineInfo bankAccountInlineInfo = new BankAccountInlineInfo(request.getBankAccount());
|
153
|
requestSummaryPanel.add(bankAccountInlineInfo.asWidget());
|
154
|
}
|
155
|
|
156
|
if(request.getPublisherEmail()!=null) {
|
157
|
PublisherContactInfo publisherContactInfo = new PublisherContactInfo(request.getPublisherEmail());
|
158
|
requestSummaryPanel.add(publisherContactInfo.asWidget());
|
159
|
}
|
160
|
|
161
|
if (request.getStatus().equals(Request.RequestStatus.ACCOUNTING_PAID) && request.getApcPaid()!=null
|
162
|
&& request.getTransferCost()!=null && request.getDatePaid()!=null) {
|
163
|
BankTransferInlineInfo bankTransferInlineInfo = new BankTransferInlineInfo(request);
|
164
|
requestSummaryPanel.add(bankTransferInlineInfo.asWidget());
|
165
|
}
|
166
|
|
167
|
actionButtons.addStyleName("requestInfoActionButtons");
|
168
|
|
169
|
approve.addStyleName("requestInfoActionButton");
|
170
|
approve.setType(ButtonType.DEFAULT);
|
171
|
approve.addClickHandler(new ClickHandler() {
|
172
|
@Override
|
173
|
public void onClick(ClickEvent event) {
|
174
|
|
175
|
errorLabel.setVisible(false);
|
176
|
successLabel.setVisible(false);
|
177
|
|
178
|
ConfirmActionModal confirmActionModal = new ConfirmActionModal("Approve", null);
|
179
|
ConfirmActionModal.ActionConfirmedListener actionConfirmedListener = new ConfirmActionModal.ActionConfirmedListener() {
|
180
|
@Override
|
181
|
public void actionConfirmed(final String comment, final String templateId) {
|
182
|
|
183
|
final HTML loadingWheel = new HTML("<div class=\"loader-big\"></div><div class=\"whiteFilm\"></div>");
|
184
|
requestInfoPanel.addStyleName("loading");
|
185
|
requestInfoPanel.add(loadingWheel);
|
186
|
|
187
|
dataService.approveRequest(request.getId(), GoldOAPortal.currentUser.getEmail(), comment,
|
188
|
templateId, new AsyncCallback<Void>() {
|
189
|
|
190
|
@Override
|
191
|
public void onFailure(Throwable throwable) {
|
192
|
|
193
|
requestInfoPanel.removeStyleName("loading");
|
194
|
requestInfoPanel.remove(loadingWheel);
|
195
|
|
196
|
errorLabel.setText(goldOAConstants.monitorErrorApprovingRequest());
|
197
|
errorLabel.setVisible(true);
|
198
|
if(actionListener!=null) {
|
199
|
//TODO fix comment template
|
200
|
CommentTemplate ct = new CommentTemplate();
|
201
|
/*ct.setId(templateId);
|
202
|
ct.setComment(comment);*/
|
203
|
Comment newComment = new Comment(GoldOAPortal.currentUser, new Timestamp(new Date().getTime()), comment, ct);
|
204
|
actionListener.actionHappened(false, Request.RequestStatus.APPROVED, newComment);
|
205
|
}
|
206
|
}
|
207
|
|
208
|
@Override
|
209
|
public void onSuccess(Void aVoid) {
|
210
|
|
211
|
requestInfoPanel.removeStyleName("loading");
|
212
|
requestInfoPanel.remove(loadingWheel);
|
213
|
|
214
|
successLabel.setText(goldOAConstants.monitorSuccessApprovingRequest());
|
215
|
successLabel.setVisible(true);
|
216
|
requestInfoPanel.remove(actionButtons);
|
217
|
if(actionListener!=null) {
|
218
|
//TODO fix comment template
|
219
|
CommentTemplate ct = new CommentTemplate();
|
220
|
/*ct.setId(templateId);
|
221
|
ct.setComment(comment);*/
|
222
|
Comment newComment = new Comment(GoldOAPortal.currentUser, new Timestamp(new Date().getTime()), comment, ct);
|
223
|
actionListener.actionHappened(true, Request.RequestStatus.APPROVED, newComment);
|
224
|
}
|
225
|
}
|
226
|
});
|
227
|
}
|
228
|
};
|
229
|
confirmActionModal.setActionConfirmedListener(actionConfirmedListener);
|
230
|
confirmActionModal.show();
|
231
|
}
|
232
|
});
|
233
|
|
234
|
conditionalApprove.addStyleName("requestInfoActionButton");
|
235
|
conditionalApprove.setType(ButtonType.DEFAULT);
|
236
|
conditionalApprove.addClickHandler(new ClickHandler() {
|
237
|
@Override
|
238
|
public void onClick(ClickEvent event) {
|
239
|
|
240
|
errorLabel.setVisible(false);
|
241
|
successLabel.setVisible(false);
|
242
|
|
243
|
ConfirmActionModal confirmActionModal = new ConfirmActionModal("Conditional Approve", null);
|
244
|
ConfirmActionModal.ActionConfirmedListener actionConfirmedListener = new ConfirmActionModal.ActionConfirmedListener() {
|
245
|
@Override
|
246
|
public void actionConfirmed(final String comment, final String templateId) {
|
247
|
|
248
|
final HTML loadingWheel = new HTML("<div class=\"loader-big\"></div><div class=\"whiteFilm\"></div>");
|
249
|
requestInfoPanel.addStyleName("loading");
|
250
|
requestInfoPanel.add(loadingWheel);
|
251
|
|
252
|
dataService.conditionalApproveRequest(request.getId(), GoldOAPortal.currentUser.getEmail(), comment,
|
253
|
templateId, new AsyncCallback<Void>() {
|
254
|
|
255
|
@Override
|
256
|
public void onFailure(Throwable throwable) {
|
257
|
|
258
|
requestInfoPanel.removeStyleName("loading");
|
259
|
requestInfoPanel.remove(loadingWheel);
|
260
|
|
261
|
errorLabel.setText("Error while conditionally approving request.");
|
262
|
errorLabel.setVisible(true);
|
263
|
if (actionListener != null) {
|
264
|
//TODO fix comment template
|
265
|
CommentTemplate ct = new CommentTemplate();
|
266
|
/*ct.setId(templateId);
|
267
|
ct.setComment(comment);*/
|
268
|
Comment newComment = new Comment(GoldOAPortal.currentUser, new Timestamp(new Date().getTime()), comment, ct);
|
269
|
actionListener.actionHappened(false, Request.RequestStatus.CONDITIONALLY_APPROVED, newComment);
|
270
|
}
|
271
|
}
|
272
|
|
273
|
@Override
|
274
|
public void onSuccess(Void aVoid) {
|
275
|
|
276
|
requestInfoPanel.removeStyleName("loading");
|
277
|
requestInfoPanel.remove(loadingWheel);
|
278
|
|
279
|
successLabel.setText("Request conditionally approved.");
|
280
|
successLabel.setVisible(true);
|
281
|
requestInfoPanel.remove(actionButtons);
|
282
|
if (actionListener != null) {
|
283
|
//TODO fix comment template
|
284
|
CommentTemplate ct = new CommentTemplate();
|
285
|
/*ct.setId(templateId);
|
286
|
ct.setComment(comment);*/
|
287
|
Comment newComment = new Comment(GoldOAPortal.currentUser, new Timestamp(new Date().getTime()), comment, ct);
|
288
|
actionListener.actionHappened(true, Request.RequestStatus.CONDITIONALLY_APPROVED, newComment);
|
289
|
}
|
290
|
}
|
291
|
});
|
292
|
}
|
293
|
};
|
294
|
confirmActionModal.setActionConfirmedListener(actionConfirmedListener);
|
295
|
confirmActionModal.show();
|
296
|
}
|
297
|
});
|
298
|
|
299
|
reject.addStyleName("requestInfoActionButton");
|
300
|
reject.setType(ButtonType.DEFAULT);
|
301
|
reject.addClickHandler(new ClickHandler() {
|
302
|
@Override
|
303
|
public void onClick(ClickEvent event) {
|
304
|
|
305
|
errorLabel.setVisible(false);
|
306
|
successLabel.setVisible(false);
|
307
|
|
308
|
dataService.getCommentTemplates(Request.RequestStatus.REJECTED, new AsyncCallback<List<CommentTemplate>>() {
|
309
|
|
310
|
@Override
|
311
|
public void onFailure(Throwable caught) {
|
312
|
|
313
|
ConfirmActionModal confirmActionModal = new ConfirmActionModal("Reject", null);
|
314
|
ConfirmActionModal.ActionConfirmedListener actionConfirmedListener = new ConfirmActionModal.ActionConfirmedListener() {
|
315
|
@Override
|
316
|
public void actionConfirmed(final String comment, final String templateId) {
|
317
|
|
318
|
final HTML loadingWheel = new HTML("<div class=\"loader-big\"></div><div class=\"whiteFilm\"></div>");
|
319
|
requestInfoPanel.addStyleName("loading");
|
320
|
requestInfoPanel.add(loadingWheel);
|
321
|
|
322
|
dataService.rejectRequest(request.getId(), GoldOAPortal.currentUser.getEmail(), comment,
|
323
|
templateId, new AsyncCallback<Void>() {
|
324
|
|
325
|
@Override
|
326
|
public void onFailure(Throwable throwable) {
|
327
|
|
328
|
requestInfoPanel.removeStyleName("loading");
|
329
|
requestInfoPanel.remove(loadingWheel);
|
330
|
|
331
|
errorLabel.setText(goldOAConstants.monitorErrorRejectingRequest());
|
332
|
errorLabel.setVisible(true);
|
333
|
if (actionListener != null) {
|
334
|
//TODO fix comment template
|
335
|
CommentTemplate ct = new CommentTemplate();
|
336
|
/*ct.setId(templateId);
|
337
|
ct.setComment(comment);*/
|
338
|
Comment newComment = new Comment(GoldOAPortal.currentUser, new Timestamp(new Date().getTime()), comment, ct);
|
339
|
actionListener.actionHappened(false, Request.RequestStatus.REJECTED, newComment);
|
340
|
}
|
341
|
}
|
342
|
|
343
|
@Override
|
344
|
public void onSuccess(Void aVoid) {
|
345
|
|
346
|
requestInfoPanel.removeStyleName("loading");
|
347
|
requestInfoPanel.remove(loadingWheel);
|
348
|
|
349
|
successLabel.setText(goldOAConstants.monitorSuccessRejectingRequest());
|
350
|
successLabel.setVisible(true);
|
351
|
requestInfoPanel.remove(actionButtons);
|
352
|
if (actionListener != null) {
|
353
|
//TODO fix comment template
|
354
|
CommentTemplate ct = new CommentTemplate();
|
355
|
/*ct.setId(templateId);
|
356
|
ct.setComment(comment);*/
|
357
|
Comment newComment = new Comment(GoldOAPortal.currentUser, new Timestamp(new Date().getTime()), comment, ct);
|
358
|
actionListener.actionHappened(true, Request.RequestStatus.REJECTED, newComment);
|
359
|
}
|
360
|
}
|
361
|
});
|
362
|
}
|
363
|
};
|
364
|
confirmActionModal.setActionConfirmedListener(actionConfirmedListener);
|
365
|
confirmActionModal.show();
|
366
|
}
|
367
|
|
368
|
@Override
|
369
|
public void onSuccess(List<CommentTemplate> commentTemplates) {
|
370
|
|
371
|
ConfirmActionModal confirmActionModal = new ConfirmActionModal("Reject", commentTemplates);
|
372
|
ConfirmActionModal.ActionConfirmedListener actionConfirmedListener = new ConfirmActionModal.ActionConfirmedListener() {
|
373
|
@Override
|
374
|
public void actionConfirmed(final String comment, final String templateId) {
|
375
|
|
376
|
final HTML loadingWheel = new HTML("<div class=\"loader-big\"></div><div class=\"whiteFilm\"></div>");
|
377
|
requestInfoPanel.addStyleName("loading");
|
378
|
requestInfoPanel.add(loadingWheel);
|
379
|
|
380
|
dataService.rejectRequest(request.getId(), GoldOAPortal.currentUser.getEmail(), comment,
|
381
|
templateId, new AsyncCallback<Void>() {
|
382
|
|
383
|
@Override
|
384
|
public void onFailure(Throwable throwable) {
|
385
|
|
386
|
requestInfoPanel.removeStyleName("loading");
|
387
|
requestInfoPanel.remove(loadingWheel);
|
388
|
|
389
|
errorLabel.setText(goldOAConstants.monitorErrorRejectingRequest());
|
390
|
errorLabel.setVisible(true);
|
391
|
if (actionListener != null) {
|
392
|
//TODO fix comment template
|
393
|
CommentTemplate ct = new CommentTemplate();
|
394
|
/*ct.setId(templateId);
|
395
|
ct.setComment(comment);*/
|
396
|
Comment newComment = new Comment(GoldOAPortal.currentUser, new Timestamp(new Date().getTime()), comment, ct);
|
397
|
actionListener.actionHappened(false, Request.RequestStatus.REJECTED, newComment);
|
398
|
}
|
399
|
}
|
400
|
|
401
|
@Override
|
402
|
public void onSuccess(Void aVoid) {
|
403
|
|
404
|
requestInfoPanel.removeStyleName("loading");
|
405
|
requestInfoPanel.remove(loadingWheel);
|
406
|
|
407
|
successLabel.setText(goldOAConstants.monitorSuccessRejectingRequest());
|
408
|
successLabel.setVisible(true);
|
409
|
requestInfoPanel.remove(actionButtons);
|
410
|
if (actionListener != null) {
|
411
|
//TODO fix comment template
|
412
|
CommentTemplate ct = new CommentTemplate();
|
413
|
/*ct.setId(templateId);
|
414
|
ct.setComment(comment);*/
|
415
|
Comment newComment = new Comment(GoldOAPortal.currentUser, new Timestamp(new Date().getTime()), comment, ct);
|
416
|
actionListener.actionHappened(true, Request.RequestStatus.REJECTED, newComment);
|
417
|
}
|
418
|
}
|
419
|
});
|
420
|
}
|
421
|
};
|
422
|
confirmActionModal.setActionConfirmedListener(actionConfirmedListener);
|
423
|
confirmActionModal.show();
|
424
|
}
|
425
|
});
|
426
|
}
|
427
|
});
|
428
|
|
429
|
libraryFundPaid.addStyleName("requestInfoActionButton");
|
430
|
libraryFundPaid.setType(ButtonType.DEFAULT);
|
431
|
libraryFundPaid.addClickHandler(new ClickHandler() {
|
432
|
@Override
|
433
|
public void onClick(ClickEvent event) {
|
434
|
|
435
|
errorLabel.setVisible(false);
|
436
|
successLabel.setVisible(false);
|
437
|
|
438
|
ConfirmActionModal confirmActionModal = new ConfirmActionModal("Library Fund - Paid", null);
|
439
|
ConfirmActionModal.ActionConfirmedListener actionConfirmedListener = new ConfirmActionModal.ActionConfirmedListener() {
|
440
|
@Override
|
441
|
public void actionConfirmed(final String comment, final String templateId) {
|
442
|
|
443
|
final HTML loadingWheel = new HTML("<div class=\"loader-big\"></div><div class=\"whiteFilm\"></div>");
|
444
|
requestInfoPanel.addStyleName("loading");
|
445
|
requestInfoPanel.add(loadingWheel);
|
446
|
|
447
|
dataService.paidLibraryRequest(request.getId(), GoldOAPortal.currentUser.getEmail(), comment, templateId,
|
448
|
request.getFundingrequested(), 0, 0, new Date(), new AsyncCallback<Void>() {
|
449
|
|
450
|
@Override
|
451
|
public void onFailure(Throwable caught) {
|
452
|
|
453
|
requestInfoPanel.removeStyleName("loading");
|
454
|
requestInfoPanel.remove(loadingWheel);
|
455
|
|
456
|
errorLabel.setText("Error while marking the request as liberary fund - paid.");
|
457
|
errorLabel.setVisible(true);
|
458
|
if (actionListener != null) {
|
459
|
//TODO fix comment template
|
460
|
CommentTemplate ct = new CommentTemplate();
|
461
|
/*ct.setId(templateId);
|
462
|
ct.setComment(comment);*/
|
463
|
Comment newComment = new Comment(GoldOAPortal.currentUser, new Timestamp(new Date().getTime()), comment, ct);
|
464
|
actionListener.actionHappened(false, Request.RequestStatus.LIBRARY_FUND_PAID, newComment);
|
465
|
}
|
466
|
}
|
467
|
|
468
|
@Override
|
469
|
public void onSuccess(Void result) {
|
470
|
|
471
|
requestInfoPanel.removeStyleName("loading");
|
472
|
requestInfoPanel.remove(loadingWheel);
|
473
|
|
474
|
successLabel.setText("Request marked successfully as library fund - paid.");
|
475
|
successLabel.setVisible(true);
|
476
|
requestInfoPanel.remove(actionButtons);
|
477
|
if (actionListener != null) {
|
478
|
//TODO fix comment template
|
479
|
CommentTemplate ct = new CommentTemplate();
|
480
|
/*ct.setId(templateId);
|
481
|
ct.setComment(comment);*/
|
482
|
Comment newComment = new Comment(GoldOAPortal.currentUser, new Timestamp(new Date().getTime()), comment, ct);
|
483
|
actionListener.actionHappened(true, Request.RequestStatus.LIBRARY_FUND_PAID, newComment);
|
484
|
}
|
485
|
}
|
486
|
});
|
487
|
}
|
488
|
};
|
489
|
confirmActionModal.setActionConfirmedListener(actionConfirmedListener);
|
490
|
confirmActionModal.show();
|
491
|
}
|
492
|
});
|
493
|
|
494
|
publisherFundPaid.addStyleName("requestInfoActionButton");
|
495
|
publisherFundPaid.setType(ButtonType.DEFAULT);
|
496
|
publisherFundPaid.addClickHandler(new ClickHandler() {
|
497
|
@Override
|
498
|
public void onClick(ClickEvent event) {
|
499
|
|
500
|
errorLabel.setVisible(false);
|
501
|
successLabel.setVisible(false);
|
502
|
|
503
|
ConfirmActionModal confirmActionModal = new ConfirmActionModal("Publisher Fund - Paid", null);
|
504
|
ConfirmActionModal.ActionConfirmedListener actionConfirmedListener = new ConfirmActionModal.ActionConfirmedListener() {
|
505
|
@Override
|
506
|
public void actionConfirmed(final String comment, final String templateId) {
|
507
|
|
508
|
final HTML loadingWheel = new HTML("<div class=\"loader-big\"></div><div class=\"whiteFilm\"></div>");
|
509
|
requestInfoPanel.addStyleName("loading");
|
510
|
requestInfoPanel.add(loadingWheel);
|
511
|
|
512
|
dataService.paidPublisherRequest(request.getId(), GoldOAPortal.currentUser.getEmail(), comment, templateId,
|
513
|
request.getFundingrequested(), 0, 0, new Date(), new AsyncCallback<Void>() {
|
514
|
|
515
|
@Override
|
516
|
public void onFailure(Throwable caught) {
|
517
|
|
518
|
requestInfoPanel.removeStyleName("loading");
|
519
|
requestInfoPanel.remove(loadingWheel);
|
520
|
|
521
|
errorLabel.setText("Error while marking the request as publisher fund - paid.");
|
522
|
errorLabel.setVisible(true);
|
523
|
if (actionListener != null) {
|
524
|
//TODO fix comment template
|
525
|
CommentTemplate ct = new CommentTemplate();
|
526
|
/*ct.setId(templateId);
|
527
|
ct.setComment(comment);*/
|
528
|
Comment newComment = new Comment(GoldOAPortal.currentUser, new Timestamp(new Date().getTime()), comment, ct);
|
529
|
actionListener.actionHappened(false, Request.RequestStatus.PUBLISHER_FUND_PAID, newComment);
|
530
|
}
|
531
|
}
|
532
|
|
533
|
@Override
|
534
|
public void onSuccess(Void result) {
|
535
|
|
536
|
requestInfoPanel.removeStyleName("loading");
|
537
|
requestInfoPanel.remove(loadingWheel);
|
538
|
|
539
|
successLabel.setText("Request marked successfully as publisher fund - paid.");
|
540
|
successLabel.setVisible(true);
|
541
|
requestInfoPanel.remove(actionButtons);
|
542
|
if (actionListener != null) {
|
543
|
//TODO fix comment template
|
544
|
CommentTemplate ct = new CommentTemplate();
|
545
|
/*ct.setId(templateId);
|
546
|
ct.setComment(comment);*/
|
547
|
Comment newComment = new Comment(GoldOAPortal.currentUser, new Timestamp(new Date().getTime()), comment, ct);
|
548
|
actionListener.actionHappened(true, Request.RequestStatus.PUBLISHER_FUND_PAID, newComment);
|
549
|
}
|
550
|
}
|
551
|
});
|
552
|
}
|
553
|
};
|
554
|
confirmActionModal.setActionConfirmedListener(actionConfirmedListener);
|
555
|
confirmActionModal.show();
|
556
|
}
|
557
|
});
|
558
|
|
559
|
editRequest.addStyleName("float-right");
|
560
|
editRequest.setType(ButtonType.PRIMARY);
|
561
|
editRequest.addClickHandler(new ClickHandler() {
|
562
|
@Override
|
563
|
public void onClick(ClickEvent clickEvent) {
|
564
|
History.newItem("newFundingRequest." + request.getId());
|
565
|
}
|
566
|
});
|
567
|
|
568
|
addDOI.addStyleName("float-right");
|
569
|
addDOI.addStyleName("marginLeft10");
|
570
|
addDOI.setType(ButtonType.PRIMARY);
|
571
|
addDOI.addClickHandler(new ClickHandler() {
|
572
|
@Override
|
573
|
public void onClick(ClickEvent event) {
|
574
|
|
575
|
final Modal addDOIAndRepositoryModal = new Modal();
|
576
|
|
577
|
addDOIAndRepositoryModal.addStyleName("contactModal");
|
578
|
addDOIAndRepositoryModal.setTitle("Add DOI and Repository");
|
579
|
addDOIAndRepositoryModal.setAnimation(true);
|
580
|
addDOIAndRepositoryModal.setBackdrop(BackdropType.STATIC);
|
581
|
addDOIAndRepositoryModal.setDynamicSafe(true);
|
582
|
|
583
|
DOIAndRepositoryForm doiAndRepositoryForm = new DOIAndRepositoryForm(request.getPublication());
|
584
|
DOIAndRepositoryForm.DOIAndRepositorySubmittedListener doiAndRepositorySubmittedListener =
|
585
|
new DOIAndRepositoryForm.DOIAndRepositorySubmittedListener() {
|
586
|
@Override
|
587
|
public void doiAndRepositorySubmitted() {
|
588
|
addDOIAndRepositoryModal.hide();
|
589
|
if(publicationUpdatedListener!=null)
|
590
|
publicationUpdatedListener.publicationUpdated();
|
591
|
}
|
592
|
};
|
593
|
doiAndRepositoryForm.setDoiAndRepositorySubmittedListener(doiAndRepositorySubmittedListener);
|
594
|
|
595
|
addDOIAndRepositoryModal.add(doiAndRepositoryForm.asWidget());
|
596
|
|
597
|
addDOIAndRepositoryModal.show();
|
598
|
}
|
599
|
});
|
600
|
|
601
|
firstDivider.addStyleName("uk-grid-divider");
|
602
|
secondDivider.addStyleName("uk-grid-divider");
|
603
|
|
604
|
EligibilityDisplayWidget eligibilityDisplayWidget = new EligibilityDisplayWidget(request.getEligibility());
|
605
|
|
606
|
requestInfoPanel.add(successLabel);
|
607
|
requestInfoPanel.add(errorLabel);
|
608
|
requestInfoPanel.add(eligibilityDisplayWidget.asWidget());
|
609
|
requestInfoPanel.add(firstDivider);
|
610
|
requestInfoPanel.add(requestSummaryPanel);
|
611
|
|
612
|
requestInfoPanel.add(secondDivider);
|
613
|
if(request.getRequestComments()!=null && !request.getRequestComments().isEmpty()) {
|
614
|
List<Comment> comments = request.getRequestComments();
|
615
|
CommentsInfo commentsInfo = new CommentsInfo(comments);
|
616
|
commentsInfo.addStyleName("requestComments");
|
617
|
requestInfoPanel.add(commentsInfo.asWidget());
|
618
|
}
|
619
|
|
620
|
if(!request.getStatus().equals(Request.RequestStatus.APPROVED) && !request.getStatus().equals(Request.RequestStatus.REJECTED)
|
621
|
&& !request.getStatus().equals(Request.RequestStatus.INCOMPLETE) && !request.getStatus().equals(Request.RequestStatus.ACCOUNTING_PAID)
|
622
|
&& !request.getStatus().equals(Request.RequestStatus.LIBRARY_FUND_SUBMITTED) && !request.getStatus().equals(Request.RequestStatus.LIBRARY_FUND_PAID)
|
623
|
&& !request.getStatus().equals(Request.RequestStatus.PUBLISHER_FUND_SUBMITTED) && !request.getStatus().equals(Request.RequestStatus.PUBLISHER_FUND_PAID)) {
|
624
|
actionButtons.add(approve);
|
625
|
actionButtons.add(conditionalApprove);
|
626
|
actionButtons.add(reject);
|
627
|
}
|
628
|
|
629
|
// if(requestInfo.getStatus().equals(Request.RequestStatus.LIBRARY_FUND_SUBMITTED)) {
|
630
|
if(request.getStatus().equals(Request.RequestStatus.SUBMITTED) || request.getStatus().equals(Request.RequestStatus.CONDITIONALLY_APPROVED)) {
|
631
|
actionButtons.add(libraryFundPaid);
|
632
|
}
|
633
|
|
634
|
// if(requestInfo.getStatus().equals(Request.RequestStatus.PUBLISHER_FUND_SUBMITTED)) {
|
635
|
if(request.getStatus().equals(Request.RequestStatus.SUBMITTED) || request.getStatus().equals(Request.RequestStatus.CONDITIONALLY_APPROVED)) {
|
636
|
actionButtons.add(publisherFundPaid);
|
637
|
}
|
638
|
|
639
|
actionButtons.add(addDOI);
|
640
|
|
641
|
if (!request.getStatus().equals(Request.RequestStatus.ACCOUNTING_PAID) &&
|
642
|
!request.getStatus().equals(Request.RequestStatus.APPROVED) &&
|
643
|
!request.getStatus().equals(Request.RequestStatus.ACCOUNTING_PROCESSING))
|
644
|
actionButtons.add(editRequest);
|
645
|
|
646
|
|
647
|
requestInfoPanel.add(actionButtons);
|
648
|
}
|
649
|
|
650
|
@Override
|
651
|
public Widget asWidget() {
|
652
|
return requestInfoPanel;
|
653
|
}
|
654
|
|
655
|
public interface ActionListener {
|
656
|
public void actionHappened(boolean succeeded, Request.RequestStatus status, Comment comment);
|
657
|
}
|
658
|
|
659
|
public void setActionListener(ActionListener actionListener) {
|
660
|
this.actionListener = actionListener;
|
661
|
}
|
662
|
|
663
|
public interface PublicationUpdatedListener {
|
664
|
void publicationUpdated();
|
665
|
}
|
666
|
|
667
|
public void setPublicationUpdatedListener(PublicationUpdatedListener publicationUpdatedListener) {
|
668
|
this.publicationUpdatedListener = publicationUpdatedListener;
|
669
|
}
|
670
|
}
|