1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
package org.kuali.student.core.workflow.ui.client.widgets; |
16 | |
|
17 | |
import java.util.ArrayList; |
18 | |
import java.util.List; |
19 | |
|
20 | |
import org.kuali.student.common.assembly.data.QueryPath; |
21 | |
import org.kuali.student.common.dto.RichTextInfo; |
22 | |
import org.kuali.student.common.dto.DtoConstants.DtoState; |
23 | |
import org.kuali.student.common.ui.client.application.Application; |
24 | |
import org.kuali.student.common.ui.client.application.KSAsyncCallback; |
25 | |
import org.kuali.student.common.ui.client.configurable.mvc.LayoutController; |
26 | |
import org.kuali.student.common.ui.client.configurable.mvc.SectionTitle; |
27 | |
import org.kuali.student.common.ui.client.event.SaveActionEvent; |
28 | |
import org.kuali.student.common.ui.client.mvc.Callback; |
29 | |
import org.kuali.student.common.ui.client.mvc.DataModel; |
30 | |
import org.kuali.student.common.ui.client.mvc.ModelRequestCallback; |
31 | |
import org.kuali.student.common.ui.client.widgets.KSDropDown; |
32 | |
import org.kuali.student.common.ui.client.widgets.KSLabel; |
33 | |
import org.kuali.student.common.ui.client.widgets.KSLightBox; |
34 | |
import org.kuali.student.common.ui.client.widgets.KSRichEditor; |
35 | |
import org.kuali.student.common.ui.client.widgets.StylishDropDown; |
36 | |
import org.kuali.student.common.ui.client.widgets.KSButtonAbstract.ButtonStyle; |
37 | |
import org.kuali.student.common.ui.client.widgets.buttongroups.AcknowledgeCancelGroup; |
38 | |
import org.kuali.student.common.ui.client.widgets.buttongroups.ConfirmApprovalCancelGroup; |
39 | |
import org.kuali.student.common.ui.client.widgets.buttongroups.ConfirmCancelGroup; |
40 | |
import org.kuali.student.common.ui.client.widgets.buttongroups.RejectCancelGroup; |
41 | |
import org.kuali.student.common.ui.client.widgets.buttongroups.ButtonEnumerations.AcknowledgeCancelEnum; |
42 | |
import org.kuali.student.common.ui.client.widgets.buttongroups.ButtonEnumerations.ConfirmApprovalCancelEnum; |
43 | |
import org.kuali.student.common.ui.client.widgets.buttongroups.ButtonEnumerations.ConfirmCancelEnum; |
44 | |
import org.kuali.student.common.ui.client.widgets.buttongroups.ButtonEnumerations.RejectCancelEnum; |
45 | |
import org.kuali.student.common.ui.client.widgets.dialog.ConfirmationDialog; |
46 | |
import org.kuali.student.common.ui.client.widgets.field.layout.element.AbbrPanel; |
47 | |
import org.kuali.student.common.ui.client.widgets.list.impl.SimpleListItems; |
48 | |
import org.kuali.student.common.ui.client.widgets.menus.KSMenuItemData; |
49 | |
import org.kuali.student.common.ui.client.widgets.notification.KSNotification; |
50 | |
import org.kuali.student.common.ui.client.widgets.notification.KSNotifier; |
51 | |
import org.kuali.student.common.validation.dto.ValidationResultInfo; |
52 | |
import org.kuali.student.core.comment.dto.CommentInfo; |
53 | |
import org.kuali.student.core.comments.ui.client.service.CommentRpcService; |
54 | |
import org.kuali.student.core.comments.ui.client.service.CommentRpcServiceAsync; |
55 | |
import org.kuali.student.core.workflow.ui.client.WorkflowConstants; |
56 | |
import org.kuali.student.core.workflow.ui.client.service.WorkflowRpcService; |
57 | |
import org.kuali.student.core.workflow.ui.client.service.WorkflowRpcServiceAsync; |
58 | |
|
59 | |
import com.google.gwt.core.client.GWT; |
60 | |
import com.google.gwt.event.dom.client.ClickEvent; |
61 | |
import com.google.gwt.event.dom.client.ClickHandler; |
62 | |
import com.google.gwt.user.client.Window; |
63 | |
import com.google.gwt.user.client.rpc.AsyncCallback; |
64 | |
import com.google.gwt.user.client.ui.VerticalPanel; |
65 | |
import com.google.gwt.user.client.ui.Widget; |
66 | |
|
67 | 0 | public class WorkflowUtilities{ |
68 | |
|
69 | |
|
70 | |
public static final String PROPOSAL_REF_TYPE_KEY = "referenceType.clu.proposal"; |
71 | |
|
72 | 0 | public static enum DecisionRationaleDetail { |
73 | 0 | APPROVE("kuali.comment.type.workflowDecisionRationale.approve", "Approved"), |
74 | 0 | REJECT("kuali.comment.type.workflowDecisionRationale.reject", "Rejected"), |
75 | 0 | RETURN_TO_PREVIOUS("kuali.comment.type.workflowDecisionRationale.return", "Sent for Revisions"), |
76 | 0 | WITHDRAW("kuali.comment.type.workflowDecisionRationale.withdraw", "Withdrawn"), |
77 | 0 | ACKNOWLEDGE("kuali.comment.type.workflowDecisionRationale.acknowledge", "Acknowledged"), |
78 | 0 | FYI("kuali.comment.type.workflowDecisionRationale.fyi", "FYI"), |
79 | 0 | CANCEL_WORKFLOW("kuali.comment.type.workflowDecisionRationale.cancelWorkflow", "Cancelled"), |
80 | 0 | BLANKET_APPROVE("kuali.comment.type.workflowDecisionRationale.blanketApprove", "Blanket Approved") |
81 | |
; |
82 | |
|
83 | 0 | private String type = ""; |
84 | 0 | private String label = ""; |
85 | |
|
86 | 0 | private DecisionRationaleDetail(String type, String label) { |
87 | 0 | this.type = type; |
88 | 0 | this.label = label; |
89 | 0 | } |
90 | |
|
91 | |
public String getType() { |
92 | 0 | return type; |
93 | |
} |
94 | |
|
95 | |
public String getLabel() { |
96 | 0 | return label; |
97 | |
} |
98 | |
|
99 | |
public static DecisionRationaleDetail getByType(String type) { |
100 | 0 | for (DecisionRationaleDetail detail : DecisionRationaleDetail.values()) { |
101 | 0 | if (detail.getType().equals(type)) { |
102 | 0 | return detail; |
103 | |
} |
104 | |
} |
105 | 0 | return null; |
106 | |
} |
107 | |
|
108 | |
} |
109 | |
|
110 | 0 | DataModel dataModel=null; |
111 | |
|
112 | 0 | boolean loaded=false; |
113 | |
|
114 | 0 | private boolean workflowWidgetsEnabled = true; |
115 | |
|
116 | |
private KSMenuItemData wfApproveItem; |
117 | |
private KSMenuItemData wfDisApproveItem; |
118 | |
private KSMenuItemData wfAcknowledgeItem; |
119 | |
private KSMenuItemData wfStartWorkflowItem; |
120 | |
private KSMenuItemData wfCancelWorkflowItem; |
121 | |
private KSMenuItemData wfFYIWorkflowItem; |
122 | |
private KSMenuItemData wfWithdrawItem; |
123 | |
private KSMenuItemData wfReturnToPreviousItem; |
124 | |
private KSMenuItemData wfBlanketApproveItem; |
125 | |
|
126 | 0 | private final List<KSMenuItemData> items = new ArrayList<KSMenuItemData>(); |
127 | 0 | private final List<KSMenuItemData> additionalItems = new ArrayList<KSMenuItemData>(); |
128 | |
|
129 | |
|
130 | |
SaveActionEvent approveSaveActionEvent; |
131 | |
SaveActionEvent startWorkflowSaveActionEvent; |
132 | |
|
133 | 0 | WorkflowRpcServiceAsync workflowRpcServiceAsync = GWT.create(WorkflowRpcService.class); |
134 | 0 | private final CommentRpcServiceAsync commentServiceAsync = GWT.create(CommentRpcService.class); |
135 | |
|
136 | |
private String modelName; |
137 | |
private String proposalPath; |
138 | 0 | private String proposalId = ""; |
139 | |
private String workflowId; |
140 | 0 | private String proposalName=""; |
141 | 0 | private String workflowActions=""; |
142 | |
|
143 | 0 | private final List<StylishDropDown> workflowWidgets = new ArrayList<StylishDropDown>(); |
144 | |
private Callback<Boolean> submitCallback; |
145 | 0 | private final ConfirmationDialog dialog = new ConfirmationDialog("Submit Proposal", "Are you sure you want to submit the proposal to workflow?", "Submit"); |
146 | |
private AbbrPanel required; |
147 | |
private KSLightBox submitSuccessDialog; |
148 | |
private VerticalPanel dialogPanel; |
149 | |
|
150 | 0 | private final KSLabel workflowStatusLabel = new KSLabel(""); |
151 | |
|
152 | |
private final LayoutController parentController; |
153 | |
|
154 | 0 | private String dropDownLabel = "Workflow Actions"; |
155 | |
|
156 | 0 | public WorkflowUtilities(LayoutController parentController, String proposalPath) { |
157 | 0 | this.parentController = parentController; |
158 | 0 | this.proposalPath = proposalPath; |
159 | 0 | setupWFButtons(); |
160 | 0 | setupDialog(); |
161 | 0 | } |
162 | |
|
163 | 0 | public WorkflowUtilities(LayoutController parentController, String proposalPath, String dropDownLabel) { |
164 | 0 | this.dropDownLabel = dropDownLabel; |
165 | 0 | this.parentController = parentController; |
166 | 0 | this.proposalPath = proposalPath; |
167 | 0 | setupWFButtons(); |
168 | 0 | setupDialog(); |
169 | 0 | } |
170 | |
|
171 | |
public void requestAndSetupModel() { |
172 | |
|
173 | 0 | if(null==dataModel){ |
174 | |
|
175 | 0 | parentController.requestModel(modelName, new ModelRequestCallback<DataModel>() { |
176 | |
|
177 | |
@Override |
178 | |
public void onRequestFail(Throwable cause) { |
179 | 0 | Window.alert("Model Request Failed. "+cause.getMessage()); |
180 | 0 | } |
181 | |
|
182 | |
@Override |
183 | |
public void onModelReady(DataModel model) { |
184 | |
|
185 | 0 | dataModel = model; |
186 | 0 | updateWorkflow(dataModel); |
187 | 0 | } |
188 | |
}); |
189 | |
}else{ |
190 | |
|
191 | |
|
192 | 0 | updateWorkflow(dataModel); |
193 | |
} |
194 | 0 | } |
195 | |
|
196 | |
private void setupWFButtons() { |
197 | 0 | wfApproveItem = getApproveItem(); |
198 | 0 | wfDisApproveItem = getDisApproveItem(); |
199 | 0 | wfAcknowledgeItem = getAcknowledgeItem(); |
200 | 0 | wfStartWorkflowItem = getStartItem(); |
201 | 0 | wfCancelWorkflowItem = getCancelWorkflowItem(); |
202 | 0 | wfFYIWorkflowItem = getFYIWorkflowItem(); |
203 | 0 | wfWithdrawItem = getWithdrawItem(); |
204 | 0 | wfReturnToPreviousItem = getReturnToPreviousItem(); |
205 | 0 | wfBlanketApproveItem = getBlanketApproveItem(); |
206 | 0 | } |
207 | |
|
208 | |
private void setupSubmitSuccessDialog(){ |
209 | 0 | if(submitSuccessDialog==null){ |
210 | 0 | submitSuccessDialog= new KSLightBox(); |
211 | 0 | submitSuccessDialog.setSize(580, 400); |
212 | 0 | dialogPanel = new VerticalPanel(); |
213 | 0 | submitSuccessDialog.setWidget(dialogPanel); |
214 | |
|
215 | |
} |
216 | |
|
217 | 0 | } |
218 | |
|
219 | |
private void setupDialog(){ |
220 | |
|
221 | 0 | dialog.getConfirmButton().addClickHandler(new ClickHandler(){ |
222 | |
|
223 | |
@Override |
224 | |
public void onClick(ClickEvent event) { |
225 | 0 | dialog.getConfirmButton().setEnabled(false); |
226 | 0 | workflowRpcServiceAsync.submitDocumentWithId(workflowId, new KSAsyncCallback<Boolean>(){ |
227 | |
@Override |
228 | |
public void handleFailure(Throwable caught) { |
229 | 0 | Window.alert("Error starting Proposal workflow"); |
230 | 0 | dialog.getConfirmButton().setEnabled(true); |
231 | 0 | } |
232 | |
public void onSuccess(Boolean result) { |
233 | 0 | if (result){ |
234 | 0 | updateWorkflow(dataModel); |
235 | 0 | dialog.hide(); |
236 | 0 | dialog.getConfirmButton().setEnabled(true); |
237 | 0 | if(submitCallback != null){ |
238 | 0 | submitCallback.exec(true); |
239 | |
} |
240 | |
|
241 | 0 | KSNotifier.add(new KSNotification("Proposal has been routed to workflow", false)); |
242 | |
} else { |
243 | 0 | Window.alert("Error starting Proposal workflow"); |
244 | |
} |
245 | 0 | } |
246 | |
}); |
247 | |
|
248 | 0 | } |
249 | |
}); |
250 | 0 | } |
251 | |
|
252 | |
public Widget getWorkflowActionsWidget(){ |
253 | |
|
254 | 0 | StylishDropDown workflowActionsDropDown = new StylishDropDown(dropDownLabel ); |
255 | 0 | workflowActionsDropDown.makeAButtonWhenOneItem(true); |
256 | 0 | workflowActionsDropDown.addStyleName("KS-Workflow-DropDown"); |
257 | 0 | workflowWidgets.add(workflowActionsDropDown); |
258 | 0 | workflowActionsDropDown.setVisible(false); |
259 | 0 | updateWorkflow(dataModel); |
260 | |
|
261 | |
|
262 | |
|
263 | |
|
264 | 0 | return workflowActionsDropDown; |
265 | |
} |
266 | |
|
267 | |
public void enableWorkflowActionsWidgets(boolean enable) { |
268 | 0 | workflowWidgetsEnabled = enable; |
269 | 0 | updateWorkflowActionsWidget(); |
270 | 0 | } |
271 | |
|
272 | |
public void doValidationCheck(Callback<List<ValidationResultInfo>> callback){ |
273 | 0 | dataModel.validateNextState(callback); |
274 | 0 | } |
275 | |
|
276 | |
public KSLabel getWorkflowStatusLabel(){ |
277 | 0 | return workflowStatusLabel; |
278 | |
} |
279 | |
|
280 | |
private void updateWorkflowIdFromModel(final DataModel model){ |
281 | 0 | if(model!=null){ |
282 | 0 | String modelProposalId = model.get(QueryPath.parse(proposalPath + "/id")); |
283 | |
|
284 | |
|
285 | 0 | if (modelProposalId != null && !modelProposalId.isEmpty() && !modelProposalId.equals(proposalId)){ |
286 | 0 | proposalId = modelProposalId; |
287 | 0 | workflowId = model.get(QueryPath.parse(proposalPath + "/workflowId")); |
288 | 0 | proposalName = model.get(QueryPath.parse(proposalPath + "/name")); |
289 | |
} |
290 | |
} |
291 | 0 | } |
292 | |
|
293 | |
private void updateWorkflow(DataModel model){ |
294 | 0 | updateWorkflowIdFromModel(model); |
295 | |
|
296 | 0 | if (workflowId != null && !workflowId.isEmpty()){ |
297 | |
|
298 | 0 | workflowRpcServiceAsync.getActionsRequested(workflowId, new KSAsyncCallback<String>(){ |
299 | |
|
300 | |
public void onSuccess(String result) { |
301 | 0 | workflowActions = result; |
302 | 0 | updateWorkflowActionsWidget(); |
303 | 0 | } |
304 | |
}); |
305 | |
|
306 | 0 | workflowRpcServiceAsync.getDocumentStatus(workflowId, new KSAsyncCallback<String>(){ |
307 | |
@Override |
308 | |
public void handleFailure(Throwable caught) { |
309 | 0 | workflowStatusLabel.setText("Status: Unknown"); |
310 | 0 | } |
311 | |
|
312 | |
@Override |
313 | |
public void onSuccess(String result) { |
314 | 0 | setWorkflowStatus(result); |
315 | 0 | } |
316 | |
}); |
317 | |
} else { |
318 | 0 | workflowStatusLabel.setText("Status: Draft"); |
319 | |
} |
320 | 0 | } |
321 | |
|
322 | |
private void updateWorkflowActionsWidget(){ |
323 | 0 | items.clear(); |
324 | |
|
325 | |
|
326 | |
|
327 | 0 | if (workflowWidgetsEnabled){ |
328 | 0 | if(workflowActions.contains("S")){ |
329 | 0 | items.add(wfStartWorkflowItem); |
330 | |
} |
331 | 0 | if(workflowActions.contains("C")){ |
332 | 0 | items.add(wfCancelWorkflowItem); |
333 | |
} |
334 | 0 | if(workflowActions.contains("A")){ |
335 | 0 | items.add(wfApproveItem); |
336 | 0 | items.add(wfDisApproveItem); |
337 | |
} |
338 | 0 | if(workflowActions.contains("K")){ |
339 | 0 | items.add(wfAcknowledgeItem); |
340 | |
} |
341 | 0 | if(workflowActions.contains("F")){ |
342 | 0 | items.add(wfFYIWorkflowItem); |
343 | |
} |
344 | 0 | if(workflowActions.contains("R")){ |
345 | 0 | items.add(wfReturnToPreviousItem); |
346 | |
} |
347 | 0 | if(workflowActions.contains("B")){ |
348 | 0 | items.add(wfBlanketApproveItem); |
349 | |
} |
350 | 0 | if(workflowActions.contains("W")){ |
351 | 0 | items.add(wfWithdrawItem); |
352 | |
} |
353 | |
} else { |
354 | 0 | if(workflowActions.contains("C")){ |
355 | 0 | items.add(wfCancelWorkflowItem); |
356 | |
} |
357 | 0 | if(workflowActions.contains("W")){ |
358 | 0 | items.add(wfWithdrawItem); |
359 | |
} |
360 | |
} |
361 | |
|
362 | |
|
363 | 0 | items.addAll(additionalItems); |
364 | |
|
365 | 0 | for(StylishDropDown widget: workflowWidgets){ |
366 | |
|
367 | 0 | widget.setItems(items); |
368 | 0 | widget.setEnabled(true); |
369 | 0 | if(items.isEmpty()){ |
370 | 0 | widget.setVisible(false); |
371 | |
} |
372 | |
else{ |
373 | 0 | widget.setVisible(true); |
374 | |
} |
375 | |
} |
376 | 0 | } |
377 | |
|
378 | |
private KSMenuItemData getFYIWorkflowItem() { |
379 | |
KSMenuItemData wfFYIWorkflowItem; |
380 | 0 | final KSRichEditor rationaleEditor = new KSRichEditor(); |
381 | 0 | wfFYIWorkflowItem = new KSMenuItemData("FYI Proposal", new ClickHandler(){ |
382 | |
public void onClick(ClickEvent event) { |
383 | 0 | addRationale(rationaleEditor,DecisionRationaleDetail.FYI.getType()); |
384 | 0 | workflowRpcServiceAsync.fyiDocumentWithId(workflowId, new KSAsyncCallback<Boolean>(){ |
385 | |
@Override |
386 | |
public void handleFailure(Throwable caught) { |
387 | 0 | Window.alert("Error FYIing Proposal"); |
388 | 0 | } |
389 | |
public void onSuccess( |
390 | |
Boolean result) { |
391 | 0 | if(result){ |
392 | 0 | updateWorkflow(dataModel); |
393 | 0 | if(submitCallback != null){ |
394 | 0 | submitCallback.exec(true); |
395 | |
} |
396 | |
|
397 | 0 | KSNotifier.add(new KSNotification("Proposal was FYIed", false)); |
398 | |
}else{ |
399 | 0 | Window.alert("Error FYIing Proposal"); |
400 | |
} |
401 | 0 | } |
402 | |
|
403 | |
}); |
404 | 0 | } |
405 | |
}); |
406 | 0 | return wfFYIWorkflowItem; |
407 | |
} |
408 | |
|
409 | |
private KSMenuItemData getAcknowledgeItem() { |
410 | |
KSMenuItemData wfAcknowledgeItem; |
411 | 0 | wfAcknowledgeItem = new KSMenuItemData("Acknowledge Proposal", new ClickHandler(){ |
412 | |
public void onClick(ClickEvent event) { |
413 | 0 | setupSubmitSuccessDialog(); |
414 | 0 | final KSRichEditor rationaleEditor = new KSRichEditor(); |
415 | 0 | AcknowledgeCancelGroup approvalButton = new AcknowledgeCancelGroup(new Callback<AcknowledgeCancelEnum>(){ |
416 | |
|
417 | |
@Override |
418 | |
public void exec(AcknowledgeCancelEnum result) { |
419 | 0 | if(!result.name().equals("CANCEL")){ |
420 | 0 | addRationale(rationaleEditor,DecisionRationaleDetail.ACKNOWLEDGE.getType()); |
421 | 0 | workflowRpcServiceAsync.acknowledgeDocumentWithId(workflowId, new KSAsyncCallback<Boolean>(){ |
422 | |
@Override |
423 | |
public void handleFailure(Throwable caught) { |
424 | 0 | submitSuccessDialog.hide(); |
425 | 0 | Window.alert("Error acknowledging Proposal"); |
426 | 0 | } |
427 | |
public void onSuccess(Boolean result) { |
428 | 0 | submitSuccessDialog.hide(); |
429 | 0 | if(result){ |
430 | 0 | updateWorkflow(dataModel); |
431 | 0 | if(submitCallback != null){ |
432 | 0 | submitCallback.exec(true); |
433 | |
} |
434 | |
|
435 | 0 | KSNotifier.add(new KSNotification("Proposal was acknowledged", false)); |
436 | |
}else{ |
437 | 0 | Window.alert("Error acknowledging Proposal"); |
438 | |
} |
439 | 0 | } |
440 | |
}); |
441 | |
} |
442 | |
else{ |
443 | 0 | submitSuccessDialog.hide(); |
444 | |
} |
445 | 0 | } |
446 | |
}); |
447 | |
|
448 | 0 | SectionTitle headerTitle = SectionTitle.generateH3Title("Acknowledge Proposal"); |
449 | 0 | SectionTitle dialogLabel = SectionTitle.generateH4Title("You are acknowledging the " + proposalName +" proposal"); |
450 | 0 | SectionTitle fieldLabel = SectionTitle.generateH4Title("Decision Rationale"); |
451 | 0 | rationaleEditor.addStyleName("KS-Comment-Create-Editor"); |
452 | 0 | dialogPanel.clear(); |
453 | 0 | dialogPanel.add(headerTitle); |
454 | 0 | dialogPanel.add(dialogLabel); |
455 | 0 | dialogPanel.add(fieldLabel); |
456 | 0 | dialogPanel.add(rationaleEditor); |
457 | 0 | dialogPanel.add(approvalButton); |
458 | 0 | submitSuccessDialog.show(); |
459 | 0 | } |
460 | |
}); |
461 | 0 | return wfAcknowledgeItem; |
462 | |
} |
463 | |
|
464 | |
private KSMenuItemData getDisApproveItem() { |
465 | |
KSMenuItemData wfDisApproveItem; |
466 | 0 | wfDisApproveItem = new KSMenuItemData("Reject Proposal", new ClickHandler(){ |
467 | |
public void onClick(ClickEvent event) { |
468 | 0 | setupSubmitSuccessDialog(); |
469 | 0 | final KSRichEditor rationaleEditor = new KSRichEditor(); |
470 | 0 | RejectCancelGroup disapprovalButton = new RejectCancelGroup(new Callback<RejectCancelEnum>(){ |
471 | |
|
472 | |
@Override |
473 | |
public void exec(RejectCancelEnum result) { |
474 | 0 | if(!result.name().equals("CANCEL")){ |
475 | 0 | if(rationaleEditor.getText().trim().equals("")){ |
476 | 0 | required.setText("Please enter the decision rationale"); |
477 | |
} |
478 | |
else{ |
479 | 0 | addRationale(rationaleEditor,DecisionRationaleDetail.REJECT.getType()); |
480 | 0 | workflowRpcServiceAsync.disapproveDocumentWithId(workflowId, new KSAsyncCallback<Boolean>(){ |
481 | |
@Override |
482 | |
public void handleFailure(Throwable caught) { |
483 | 0 | submitSuccessDialog.hide(); |
484 | 0 | Window.alert("Error rejecting Proposal"); |
485 | 0 | } |
486 | |
public void onSuccess(Boolean result) { |
487 | 0 | submitSuccessDialog.hide(); |
488 | 0 | if(submitCallback != null){ |
489 | 0 | submitCallback.exec(result); |
490 | |
} |
491 | 0 | if(result){ |
492 | 0 | KSNotifier.add(new KSNotification("Proposal was rejected", false)); |
493 | 0 | updateWorkflow(dataModel); |
494 | |
}else{ |
495 | 0 | Window.alert("Error rejecting Proposal"); |
496 | |
} |
497 | 0 | } |
498 | |
|
499 | |
}); |
500 | |
} |
501 | |
|
502 | |
} |
503 | |
else{ |
504 | 0 | submitSuccessDialog.hide(); |
505 | |
} |
506 | 0 | } |
507 | |
}); |
508 | 0 | SectionTitle headerTitle = SectionTitle.generateH3Title("Reject Proposal"); |
509 | 0 | SectionTitle dialogLabel = SectionTitle.generateH4Title("You are rejecting the " + proposalName +" proposal"); |
510 | 0 | SectionTitle fieldLabel = SectionTitle.generateH4Title("Decision Rationale"); |
511 | 0 | required = new AbbrPanel("Required", "ks-form-module-elements-required", " * "); |
512 | 0 | required.setVisible(true); |
513 | |
|
514 | |
|
515 | |
|
516 | 0 | rationaleEditor.addStyleName("KS-Comment-Create-Editor"); |
517 | 0 | dialogPanel.clear(); |
518 | 0 | dialogPanel.add(headerTitle); |
519 | 0 | dialogPanel.add(dialogLabel); |
520 | 0 | dialogPanel.add(fieldLabel); |
521 | 0 | dialogPanel.add(required); |
522 | 0 | dialogPanel.add(rationaleEditor); |
523 | 0 | dialogPanel.add(disapprovalButton); |
524 | 0 | submitSuccessDialog.setWidget(dialogPanel); |
525 | 0 | submitSuccessDialog.show(); |
526 | 0 | } |
527 | |
}); |
528 | 0 | return wfDisApproveItem; |
529 | |
} |
530 | |
|
531 | |
private KSMenuItemData getApproveItem() { |
532 | |
KSMenuItemData wfApproveItem; |
533 | |
|
534 | 0 | wfApproveItem= new KSMenuItemData("Approve Proposal", new ClickHandler(){ |
535 | |
public void onClick(ClickEvent event) { |
536 | 0 | setupSubmitSuccessDialog(); |
537 | 0 | final KSRichEditor rationaleEditor = new KSRichEditor(); |
538 | 0 | ConfirmApprovalCancelGroup approvalButton = new ConfirmApprovalCancelGroup(new Callback<ConfirmApprovalCancelEnum>(){ |
539 | |
|
540 | |
@Override |
541 | |
public void exec(ConfirmApprovalCancelEnum result) { |
542 | 0 | if(!result.name().equals("CANCEL")){ |
543 | 0 | if(rationaleEditor.getText().trim().equals("")){ |
544 | 0 | required.setText("Please enter the decision rationale"); |
545 | |
} |
546 | |
else{ |
547 | 0 | addRationale(rationaleEditor,DecisionRationaleDetail.APPROVE.getType()); |
548 | |
|
549 | 0 | workflowRpcServiceAsync.approveDocumentWithId(workflowId, new KSAsyncCallback<Boolean>(){ |
550 | |
@Override |
551 | |
public void handleFailure(Throwable caught) { |
552 | 0 | submitSuccessDialog.hide(); |
553 | 0 | Window.alert("Error approving Proposal"); |
554 | 0 | } |
555 | |
public void onSuccess(Boolean result) { |
556 | 0 | submitSuccessDialog.hide(); |
557 | 0 | if (result){ |
558 | 0 | updateWorkflow(dataModel); |
559 | 0 | if(submitCallback != null){ |
560 | 0 | submitCallback.exec(result); |
561 | |
} |
562 | |
|
563 | 0 | KSNotifier.add(new KSNotification("Proposal was approved", false)); |
564 | |
} else { |
565 | 0 | Window.alert("Error approving Proposal"); |
566 | |
} |
567 | 0 | } |
568 | |
}); |
569 | |
} |
570 | |
|
571 | |
} |
572 | |
else{ |
573 | 0 | submitSuccessDialog.hide(); |
574 | |
} |
575 | 0 | } |
576 | |
}); |
577 | |
|
578 | 0 | SectionTitle headerTitle = SectionTitle.generateH3Title("Approve Proposal"); |
579 | 0 | SectionTitle dialogLabel = SectionTitle.generateH4Title("You are approving the " + proposalName +" proposal"); |
580 | 0 | SectionTitle fieldLabel = SectionTitle.generateH4Title("Decision Rationale"); |
581 | 0 | required = new AbbrPanel("Required", "ks-form-module-elements-required", " * "); |
582 | 0 | required.setVisible(true); |
583 | 0 | rationaleEditor.addStyleName("KS-Comment-Create-Editor"); |
584 | 0 | dialogPanel.clear(); |
585 | 0 | dialogPanel.add(headerTitle); |
586 | 0 | dialogPanel.add(dialogLabel); |
587 | 0 | dialogPanel.add(fieldLabel); |
588 | 0 | dialogPanel.add(required); |
589 | 0 | dialogPanel.add(rationaleEditor); |
590 | 0 | dialogPanel.add(approvalButton); |
591 | 0 | dialogPanel.setSize("580px", "400px"); |
592 | |
|
593 | 0 | submitSuccessDialog.show(); |
594 | 0 | } |
595 | |
}); |
596 | 0 | return wfApproveItem; |
597 | |
} |
598 | |
|
599 | |
private KSMenuItemData getWithdrawItem() { |
600 | |
KSMenuItemData wfWithdrawItem; |
601 | |
|
602 | 0 | wfWithdrawItem = new KSMenuItemData("Withdraw Proposal", new ClickHandler() { |
603 | |
public void onClick(ClickEvent event) { |
604 | 0 | setupSubmitSuccessDialog(); |
605 | 0 | final KSRichEditor rationaleEditor = new KSRichEditor(); |
606 | 0 | ConfirmCancelGroup withdrawButton = new ConfirmCancelGroup(new Callback<ConfirmCancelEnum>() { |
607 | |
|
608 | |
@Override |
609 | |
public void exec(ConfirmCancelEnum result) { |
610 | 0 | if (!result.name().equals("CANCEL")) { |
611 | 0 | if (rationaleEditor.getText().trim().equals("")) { |
612 | 0 | required.setText("Please enter the decision rationale"); |
613 | |
} else { |
614 | 0 | addRationale(rationaleEditor, DecisionRationaleDetail.WITHDRAW.getType()); |
615 | |
|
616 | 0 | workflowRpcServiceAsync.withdrawDocumentWithId(workflowId, new KSAsyncCallback<Boolean>() { |
617 | |
@Override |
618 | |
public void handleFailure(Throwable caught) { |
619 | 0 | submitSuccessDialog.hide(); |
620 | 0 | Window.alert("Error withdrawing Proposal"); |
621 | 0 | } |
622 | |
|
623 | |
public void onSuccess(Boolean result) { |
624 | 0 | submitSuccessDialog.hide(); |
625 | 0 | if (result) { |
626 | 0 | updateWorkflow(dataModel); |
627 | 0 | if (submitCallback != null) { |
628 | 0 | submitCallback.exec(result); |
629 | |
} |
630 | |
|
631 | 0 | KSNotifier.add(new KSNotification("Proposal will be withdrawn", false)); |
632 | |
} else { |
633 | 0 | Window.alert("Error withdrawing Proposal"); |
634 | |
} |
635 | 0 | } |
636 | |
}); |
637 | |
} |
638 | |
|
639 | |
} else { |
640 | 0 | submitSuccessDialog.hide(); |
641 | |
} |
642 | 0 | } |
643 | |
}); |
644 | |
|
645 | 0 | SectionTitle headerTitle = SectionTitle.generateH3Title("Withdraw Proposal"); |
646 | 0 | SectionTitle dialogLabel = SectionTitle.generateH4Title("You are withdrawing the " + proposalName + " proposal"); |
647 | 0 | SectionTitle fieldLabel = SectionTitle.generateH4Title("Decision Rationale"); |
648 | 0 | required = new AbbrPanel("Required", "ks-form-module-elements-required", " * "); |
649 | 0 | required.setVisible(true); |
650 | 0 | rationaleEditor.addStyleName("KS-Comment-Create-Editor"); |
651 | 0 | dialogPanel.clear(); |
652 | 0 | dialogPanel.add(headerTitle); |
653 | 0 | dialogPanel.add(dialogLabel); |
654 | 0 | dialogPanel.add(fieldLabel); |
655 | 0 | dialogPanel.add(required); |
656 | 0 | dialogPanel.add(rationaleEditor); |
657 | 0 | dialogPanel.add(withdrawButton); |
658 | 0 | dialogPanel.setSize("580px", "400px"); |
659 | |
|
660 | 0 | submitSuccessDialog.show(); |
661 | 0 | } |
662 | |
}); |
663 | 0 | return wfWithdrawItem; |
664 | |
} |
665 | |
|
666 | |
private KSMenuItemData getBlanketApproveItem() { |
667 | |
KSMenuItemData wfBlanketApproveItem; |
668 | |
|
669 | 0 | wfBlanketApproveItem = new KSMenuItemData("Blanket Approve Proposal", new ClickHandler() { |
670 | |
public void onClick(ClickEvent event) { |
671 | 0 | setupSubmitSuccessDialog(); |
672 | 0 | final KSRichEditor rationaleEditor = new KSRichEditor(); |
673 | 0 | ConfirmCancelGroup blanketApprovalButton = new ConfirmCancelGroup(new Callback<ConfirmCancelEnum>() { |
674 | |
|
675 | |
@Override |
676 | |
public void exec(ConfirmCancelEnum result) { |
677 | 0 | if (!result.name().equals("CANCEL")) { |
678 | 0 | if (rationaleEditor.getText().trim().equals("")) { |
679 | 0 | required.setText("Please enter the decision rationale"); |
680 | |
} else { |
681 | 0 | addRationale(rationaleEditor, DecisionRationaleDetail.BLANKET_APPROVE.getType()); |
682 | 0 | workflowRpcServiceAsync.blanketApproveDocumentWithId(workflowId, new KSAsyncCallback<Boolean>() { |
683 | |
@Override |
684 | |
public void handleFailure(Throwable caught) { |
685 | 0 | submitSuccessDialog.hide(); |
686 | 0 | Window.alert("Error blanket approving Proposal"); |
687 | 0 | } |
688 | |
|
689 | |
public void onSuccess(Boolean result) { |
690 | 0 | submitSuccessDialog.hide(); |
691 | 0 | if (result) { |
692 | |
|
693 | |
|
694 | |
|
695 | 0 | enableWorkflowActionsWidgets(false); |
696 | |
|
697 | 0 | updateWorkflow(dataModel); |
698 | 0 | if (submitCallback != null) { |
699 | 0 | submitCallback.exec(result); |
700 | |
} |
701 | |
|
702 | 0 | KSNotifier.add(new KSNotification("Proposal will be blanket approved", false)); |
703 | |
} else { |
704 | 0 | Window.alert("Error blanket approving Proposal"); |
705 | |
} |
706 | 0 | } |
707 | |
}); |
708 | |
} |
709 | |
} else { |
710 | 0 | submitSuccessDialog.hide(); |
711 | |
} |
712 | 0 | } |
713 | |
}); |
714 | |
|
715 | 0 | SectionTitle headerTitle = SectionTitle.generateH3Title("Blanket Approve Proposal"); |
716 | 0 | SectionTitle dialogLabel = SectionTitle.generateH4Title("You are blanket approving the " + proposalName + " proposal"); |
717 | 0 | SectionTitle fieldLabel = SectionTitle.generateH4Title("Decision Rationale"); |
718 | 0 | required = new AbbrPanel("Required", "ks-form-module-elements-required", " * "); |
719 | 0 | required.setVisible(true); |
720 | 0 | rationaleEditor.addStyleName("KS-Comment-Create-Editor"); |
721 | 0 | dialogPanel.clear(); |
722 | 0 | dialogPanel.add(headerTitle); |
723 | 0 | dialogPanel.add(dialogLabel); |
724 | 0 | dialogPanel.add(fieldLabel); |
725 | 0 | dialogPanel.add(required); |
726 | 0 | dialogPanel.add(rationaleEditor); |
727 | 0 | dialogPanel.add(blanketApprovalButton); |
728 | 0 | dialogPanel.setSize("580px", "400px"); |
729 | |
|
730 | 0 | submitSuccessDialog.show(); |
731 | 0 | } |
732 | |
}); |
733 | 0 | return wfBlanketApproveItem; |
734 | |
} |
735 | |
|
736 | |
|
737 | |
|
738 | |
|
739 | |
|
740 | |
|
741 | |
|
742 | |
public void blanketApprove(final Callback<Boolean> onSuccessCallback){ |
743 | 0 | updateWorkflowIdFromModel(dataModel); |
744 | 0 | workflowRpcServiceAsync.blanketApproveDocumentWithId(workflowId, new KSAsyncCallback<Boolean>() { |
745 | |
@Override |
746 | |
public void handleFailure(Throwable caught) { |
747 | 0 | Window.alert("Error blanket approving Proposal"); |
748 | 0 | } |
749 | |
|
750 | |
public void onSuccess(Boolean result) { |
751 | 0 | if (result) { |
752 | 0 | onSuccessCallback.exec(true); |
753 | |
} else { |
754 | 0 | Window.alert("Error blanket approving Proposal"); |
755 | |
} |
756 | 0 | } |
757 | |
}); |
758 | 0 | } |
759 | |
|
760 | |
|
761 | |
|
762 | |
|
763 | |
|
764 | |
|
765 | |
|
766 | |
public void cancel(final Callback<Boolean> onSuccessCallback){ |
767 | 0 | ConfirmationDialog confirmCancelDialog = getConfirmationCancelProposalDialog(onSuccessCallback); |
768 | 0 | confirmCancelDialog.show(); |
769 | 0 | } |
770 | |
|
771 | |
|
772 | |
protected KSDropDown setUpReturnToPreviousDropDown(String workflowId) { |
773 | |
|
774 | 0 | final KSDropDown nodeNameDropDown = new KSDropDown(); |
775 | 0 | nodeNameDropDown.setBlankFirstItem(true); |
776 | 0 | workflowRpcServiceAsync.getPreviousRouteNodeNames(workflowId, new KSAsyncCallback<List<String>>() { |
777 | |
@Override |
778 | |
public void handleFailure(Throwable caught) { |
779 | 0 | Window.alert("Error getting previous node names for Proposal"); |
780 | 0 | } |
781 | |
|
782 | |
public void onSuccess(List<String> result) { |
783 | 0 | SimpleListItems nodeNameList = new SimpleListItems(); |
784 | 0 | for (String nodeName : result) { |
785 | 0 | nodeNameList.addItem(nodeName, nodeName); |
786 | |
} |
787 | 0 | nodeNameDropDown.setListItems(nodeNameList); |
788 | 0 | } |
789 | |
}); |
790 | 0 | nodeNameDropDown.setInitialized(true); |
791 | 0 | return nodeNameDropDown; |
792 | |
} |
793 | |
|
794 | |
private KSMenuItemData getReturnToPreviousItem() { |
795 | |
KSMenuItemData wfReturnToPreviousItem; |
796 | |
|
797 | 0 | wfReturnToPreviousItem = new KSMenuItemData("Return Proposal to Previous Node", new ClickHandler() { |
798 | |
public void onClick(ClickEvent event) { |
799 | 0 | setupSubmitSuccessDialog(); |
800 | 0 | final KSRichEditor rationaleEditor = new KSRichEditor(); |
801 | 0 | final KSDropDown nodeNameDropDown = setUpReturnToPreviousDropDown(workflowId); |
802 | 0 | ConfirmCancelGroup returnButton = new ConfirmCancelGroup(new Callback<ConfirmCancelEnum>() { |
803 | |
|
804 | |
@Override |
805 | |
public void exec(ConfirmCancelEnum result) { |
806 | 0 | if (!result.name().equals("CANCEL")) { |
807 | 0 | if ((rationaleEditor.getText().trim().equals("")) && (nodeNameDropDown.getSelectedItem().trim().equals(""))) { |
808 | 0 | required.setText("Please enter the decision rationale and select a node name to return to"); |
809 | 0 | } else if (rationaleEditor.getText().trim().equals("")) { |
810 | 0 | required.setText("Please enter the decision rationale"); |
811 | 0 | } else if (nodeNameDropDown.getSelectedItem().trim().equals("")) { |
812 | 0 | required.setText("Please select a node name to return to"); |
813 | |
} else { |
814 | 0 | addRationale(rationaleEditor, DecisionRationaleDetail.RETURN_TO_PREVIOUS.getType()); |
815 | 0 | String nodeName = nodeNameDropDown.getSelectedItem().trim(); |
816 | 0 | workflowRpcServiceAsync.returnDocumentWithId(workflowId, nodeName, new KSAsyncCallback<Boolean>() { |
817 | |
@Override |
818 | |
public void handleFailure(Throwable caught) { |
819 | 0 | submitSuccessDialog.hide(); |
820 | 0 | Window.alert("Error returning the Proposal to a previous node"); |
821 | 0 | } |
822 | |
|
823 | |
public void onSuccess(Boolean result) { |
824 | 0 | submitSuccessDialog.hide(); |
825 | 0 | if (result) { |
826 | 0 | updateWorkflow(dataModel); |
827 | 0 | if (submitCallback != null) { |
828 | 0 | submitCallback.exec(result); |
829 | |
} |
830 | |
|
831 | 0 | KSNotifier.add(new KSNotification("Proposal was returned", false)); |
832 | |
} else { |
833 | 0 | Window.alert("Error returning the Proposal to a previous node"); |
834 | |
} |
835 | 0 | } |
836 | |
}); |
837 | 0 | } |
838 | |
|
839 | |
} else { |
840 | 0 | submitSuccessDialog.hide(); |
841 | |
} |
842 | 0 | } |
843 | |
}); |
844 | |
|
845 | 0 | SectionTitle headerTitle = SectionTitle.generateH3Title("Return Proposal to Previous Node"); |
846 | 0 | SectionTitle dialogLabel = SectionTitle.generateH4Title("You are returning the " + proposalName + " proposal to a previous node"); |
847 | 0 | SectionTitle nnFieldLabel = SectionTitle.generateH4Title("Workflow Node Name"); |
848 | 0 | SectionTitle drFieldLabel = SectionTitle.generateH4Title("Decision Rationale"); |
849 | 0 | required = new AbbrPanel("Required", "ks-form-module-elements-required", " * "); |
850 | 0 | required.setVisible(true); |
851 | 0 | rationaleEditor.addStyleName("KS-Comment-Create-Editor"); |
852 | 0 | dialogPanel.clear(); |
853 | 0 | dialogPanel.add(headerTitle); |
854 | 0 | dialogPanel.add(dialogLabel); |
855 | 0 | dialogPanel.add(nnFieldLabel); |
856 | 0 | dialogPanel.add(nodeNameDropDown); |
857 | 0 | dialogPanel.add(drFieldLabel); |
858 | 0 | dialogPanel.add(required); |
859 | 0 | dialogPanel.add(rationaleEditor); |
860 | 0 | dialogPanel.add(returnButton); |
861 | 0 | dialogPanel.setSize("580px", "400px"); |
862 | |
|
863 | 0 | submitSuccessDialog.show(); |
864 | 0 | } |
865 | |
}); |
866 | 0 | return wfReturnToPreviousItem; |
867 | |
} |
868 | |
|
869 | |
private void addRationale(KSRichEditor rationaleEditor, String rationaleType) { |
870 | 0 | CommentInfo newDecisionRationale = new CommentInfo(); |
871 | 0 | RichTextInfo text = new RichTextInfo(); |
872 | 0 | text.setFormatted(rationaleEditor.getHTML()); |
873 | 0 | text.setPlain(rationaleEditor.getText()); |
874 | 0 | newDecisionRationale.setReferenceTypeKey(PROPOSAL_REF_TYPE_KEY); |
875 | 0 | newDecisionRationale.setReferenceId(proposalId); |
876 | 0 | newDecisionRationale.setState(DtoState.ACTIVE.toString()); |
877 | 0 | newDecisionRationale.setCommentText(text); |
878 | 0 | newDecisionRationale.setType(rationaleType); |
879 | |
|
880 | |
try { |
881 | 0 | commentServiceAsync.addComment(proposalId, PROPOSAL_REF_TYPE_KEY, newDecisionRationale, new KSAsyncCallback<CommentInfo>() { |
882 | |
|
883 | |
@Override |
884 | |
public void handleFailure(Throwable caught) { |
885 | 0 | GWT.log("Add Comment Failed", caught); |
886 | 0 | } |
887 | |
|
888 | |
@Override |
889 | |
public void onSuccess(CommentInfo result) { |
890 | 0 | System.out.println("Rationale Added successfully"); |
891 | 0 | } |
892 | |
}); |
893 | 0 | } catch (Exception e) { |
894 | 0 | GWT.log("Add Comment Failed", e); |
895 | 0 | } |
896 | 0 | } |
897 | |
|
898 | |
private KSMenuItemData getStartItem() { |
899 | |
KSMenuItemData wfStartWorkflowItem; |
900 | 0 | wfStartWorkflowItem = new KSMenuItemData("Submit Proposal", new ClickHandler(){ |
901 | |
public void onClick(ClickEvent event) { |
902 | |
|
903 | 0 | dataModel.validateNextState(new Callback<List<ValidationResultInfo>>() { |
904 | |
@Override |
905 | |
public void exec(List<ValidationResultInfo> result) { |
906 | |
|
907 | 0 | boolean isValid = parentController.isValid(result, false); |
908 | 0 | if(isValid){ |
909 | 0 | dialog.show(); |
910 | |
} |
911 | |
else{ |
912 | 0 | Window.alert("Unable to submit to workflow. Please check sections for missing fields."); |
913 | |
} |
914 | 0 | } |
915 | |
}); |
916 | 0 | } |
917 | |
|
918 | |
}); |
919 | 0 | return wfStartWorkflowItem; |
920 | |
} |
921 | |
|
922 | |
private KSMenuItemData getCancelWorkflowItem() { |
923 | |
KSMenuItemData wfCancelWorkflowItem; |
924 | 0 | wfCancelWorkflowItem = new KSMenuItemData("Cancel Proposal", new ClickHandler() { |
925 | |
public void onClick(ClickEvent event) { |
926 | 0 | ConfirmationDialog confirmationCancelProposal = getConfirmationCancelProposalDialog(null); |
927 | 0 | confirmationCancelProposal.show(); |
928 | 0 | } |
929 | |
}); |
930 | 0 | return wfCancelWorkflowItem; |
931 | |
} |
932 | |
|
933 | |
protected ConfirmationDialog getConfirmationCancelProposalDialog (final Callback<Boolean> onSuccessCallback){ |
934 | 0 | final ConfirmationDialog confirmationCancelProposal = new ConfirmationDialog("Cancel Proposal","This action is not reversible and all data will be lost. Do you wish to cancel this proposal?"); |
935 | |
|
936 | 0 | confirmationCancelProposal.getConfirmButton().setText("Yes, cancel proposal"); |
937 | 0 | confirmationCancelProposal.getCancelButton().setStyleName(ButtonStyle.PRIMARY_SMALL.getStyle()); |
938 | 0 | confirmationCancelProposal.getCancelButton().setText("No, return to proposal"); |
939 | |
|
940 | 0 | confirmationCancelProposal.getConfirmButton().addClickHandler(new ClickHandler(){ |
941 | |
@Override |
942 | |
public void onClick(ClickEvent event) { |
943 | 0 | workflowRpcServiceAsync.cancelDocumentWithId(workflowId, new KSAsyncCallback<Boolean>() { |
944 | |
@Override |
945 | |
public void handleFailure(Throwable caught) { |
946 | 0 | confirmationCancelProposal.hide(); |
947 | 0 | Window.alert("Error Cancelling Proposal"); |
948 | 0 | } |
949 | |
public void onSuccess(Boolean result) { |
950 | 0 | confirmationCancelProposal.hide(); |
951 | 0 | if (result) { |
952 | 0 | updateWorkflow(dataModel); |
953 | 0 | if (submitCallback != null) { |
954 | 0 | submitCallback.exec(true); |
955 | |
} |
956 | 0 | if (onSuccessCallback != null){ |
957 | 0 | onSuccessCallback.exec(true); |
958 | |
} |
959 | |
|
960 | 0 | KSNotifier.add(new KSNotification("Proposal will be Cancelled", false)); |
961 | |
} else { |
962 | 0 | Window.alert("Error Cancelling Proposal"); |
963 | |
} |
964 | 0 | } |
965 | |
}); |
966 | |
|
967 | 0 | } |
968 | |
|
969 | |
}); |
970 | |
|
971 | 0 | return confirmationCancelProposal; |
972 | |
} |
973 | |
|
974 | |
private void setWorkflowStatus(String statusCd){ |
975 | 0 | String statusTranslation = ""; |
976 | 0 | if (WorkflowConstants.ROUTE_HEADER_SAVED_CD.equals(statusCd)){ |
977 | 0 | statusTranslation = getLabel(WorkflowConstants.ROUTE_HEADER_SAVED_LABEL_KEY); |
978 | 0 | } else if (WorkflowConstants.ROUTE_HEADER_INITIATED_CD.equals(statusCd)){ |
979 | 0 | statusTranslation = getLabel(WorkflowConstants.ROUTE_HEADER_INITIATED_LABEL_KEY); |
980 | 0 | } else if (WorkflowConstants.ROUTE_HEADER_ENROUTE_CD.equals(statusCd)){ |
981 | 0 | statusTranslation = getLabel(WorkflowConstants.ROUTE_HEADER_ENROUTE_LABEL_KEY); |
982 | 0 | } else if (WorkflowConstants.ROUTE_HEADER_APPROVED_CD.equals(statusCd)){ |
983 | 0 | statusTranslation = getLabel(WorkflowConstants.ROUTE_HEADER_APPROVED_LABEL_KEY); |
984 | 0 | } else if (WorkflowConstants.ROUTE_HEADER_CANCEL_CD.equals(statusCd)){ |
985 | 0 | statusTranslation = getLabel(WorkflowConstants.ROUTE_HEADER_CANCEL_LABEL_KEY); |
986 | 0 | } else if (WorkflowConstants.ROUTE_HEADER_EXCEPTION_CD.equals(statusCd)){ |
987 | 0 | statusTranslation = getLabel(WorkflowConstants.ROUTE_HEADER_EXCEPTION_LABEL_KEY); |
988 | 0 | } else if (WorkflowConstants.ROUTE_HEADER_DISAPPROVED_CD.equals(statusCd)){ |
989 | 0 | statusTranslation = getLabel(WorkflowConstants.ROUTE_HEADER_DISAPPROVED_LABEL_KEY); |
990 | 0 | } else if (WorkflowConstants.ROUTE_HEADER_FINAL_CD.equals(statusCd)){ |
991 | 0 | statusTranslation = getLabel(WorkflowConstants.ROUTE_HEADER_FINAL_LABEL_KEY); |
992 | 0 | } else if (WorkflowConstants.ROUTE_HEADER_DISAPPROVE_CANCEL_CD.equals(statusCd)){ |
993 | 0 | statusTranslation = getLabel(WorkflowConstants.ROUTE_HEADER_DISAPPROVE_CANCEL_LABEL_KEY); |
994 | 0 | } else if (WorkflowConstants.ROUTE_HEADER_PROCESSED_CD.equals(statusCd)){ |
995 | 0 | statusTranslation = getLabel(WorkflowConstants.ROUTE_HEADER_PROCESSED_LABEL_KEY); |
996 | |
} else { |
997 | 0 | statusTranslation = statusCd; |
998 | |
} |
999 | |
|
1000 | 0 | workflowStatusLabel.setText("Status: " + statusTranslation); |
1001 | 0 | } |
1002 | |
|
1003 | |
|
1004 | |
|
1005 | |
|
1006 | |
|
1007 | |
|
1008 | |
public void setModelName(String modelName) { |
1009 | 0 | this.modelName = modelName; |
1010 | 0 | } |
1011 | |
|
1012 | |
|
1013 | |
|
1014 | |
|
1015 | |
|
1016 | |
public void setProposalPath(String proposalPath) { |
1017 | 0 | this.proposalPath = proposalPath; |
1018 | 0 | } |
1019 | |
|
1020 | |
public void setWorkflowRpcService(WorkflowRpcServiceAsync workflowRpcServiceAsync){ |
1021 | 0 | this.workflowRpcServiceAsync = workflowRpcServiceAsync; |
1022 | 0 | } |
1023 | |
|
1024 | |
|
1025 | |
public void refresh(){ |
1026 | 0 | updateWorkflow(dataModel); |
1027 | 0 | } |
1028 | |
|
1029 | |
private String getLabel(String labelKey) { |
1030 | 0 | return Application.getApplicationContext().getUILabel("common", null, null, labelKey); |
1031 | |
} |
1032 | |
|
1033 | |
public void getDataIdFromWorkflowId(String workflowId, AsyncCallback<String> callback){ |
1034 | 0 | workflowRpcServiceAsync.getDataIdFromWorkflowId(workflowId, callback); |
1035 | 0 | } |
1036 | |
|
1037 | |
public void addSubmitCallback(Callback<Boolean> callback) { |
1038 | 0 | this.submitCallback = callback; |
1039 | |
|
1040 | 0 | } |
1041 | |
|
1042 | |
public List<KSMenuItemData> getAdditionalItems() { |
1043 | 0 | return additionalItems; |
1044 | |
} |
1045 | |
} |