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