| 1 | |
package org.kuali.student.lum.lu.ui.course.client.controllers; |
| 2 | |
|
| 3 | |
import org.kuali.student.common.dto.DtoConstants; |
| 4 | |
import org.kuali.student.common.ui.client.application.Application; |
| 5 | |
import org.kuali.student.common.ui.client.application.ViewContext; |
| 6 | |
import org.kuali.student.common.ui.client.event.ActionEvent; |
| 7 | |
import org.kuali.student.common.ui.client.event.SaveActionEvent; |
| 8 | |
import org.kuali.student.common.ui.client.mvc.ActionCompleteCallback; |
| 9 | |
import org.kuali.student.common.ui.client.mvc.Callback; |
| 10 | |
import org.kuali.student.common.ui.client.mvc.DataModel; |
| 11 | |
import org.kuali.student.common.ui.client.service.BaseDataOrchestrationRpcServiceAsync; |
| 12 | |
import org.kuali.student.common.ui.client.util.WindowTitleUtils; |
| 13 | |
import org.kuali.student.common.ui.client.widgets.KSButton; |
| 14 | |
import org.kuali.student.common.ui.client.widgets.notification.KSNotification; |
| 15 | |
import org.kuali.student.common.ui.client.widgets.notification.KSNotifier; |
| 16 | |
import org.kuali.student.common.ui.shared.IdAttributes.IdType; |
| 17 | |
import org.kuali.student.lum.common.client.widgets.AppLocations; |
| 18 | |
import org.kuali.student.lum.lu.assembly.data.client.constants.orch.CreditCourseConstants; |
| 19 | |
import org.kuali.student.lum.lu.ui.course.client.configuration.CourseAdminRetireConfigurer; |
| 20 | |
import org.kuali.student.lum.lu.ui.course.client.widgets.CourseWorkflowActionList; |
| 21 | |
|
| 22 | |
import com.google.gwt.core.client.GWT; |
| 23 | |
import com.google.gwt.event.dom.client.ClickEvent; |
| 24 | |
import com.google.gwt.event.dom.client.ClickHandler; |
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | 0 | public class CourseAdminRetireController extends CourseAdminWithoutVersionController{ |
| 33 | |
|
| 34 | |
|
| 35 | |
|
| 36 | |
|
| 37 | |
@Override |
| 38 | |
protected void initializeController() { |
| 39 | |
|
| 40 | 0 | super.cfg = GWT.create(CourseAdminRetireConfigurer.class); |
| 41 | |
|
| 42 | 0 | cfg.setState(DtoConstants.STATE_RETIRED.toUpperCase()); |
| 43 | 0 | super.setDefaultModelId(cfg.getModelId()); |
| 44 | 0 | super.registerModelsAndHandlers(); |
| 45 | 0 | super.addStyleName("ks-course-admin"); |
| 46 | 0 | } |
| 47 | |
|
| 48 | |
|
| 49 | |
|
| 50 | |
|
| 51 | |
@Override |
| 52 | |
public KSButton getSaveButton(){ |
| 53 | 0 | KSButton saveButton = new KSButton("Retire", new ClickHandler(){ |
| 54 | |
public void onClick(ClickEvent event) { |
| 55 | 0 | handleButtonClick(DtoConstants.STATE_RETIRED); |
| 56 | 0 | } |
| 57 | |
}); |
| 58 | |
|
| 59 | 0 | return saveButton; |
| 60 | |
} |
| 61 | |
|
| 62 | |
public KSButton getCancelButton(){ |
| 63 | 0 | KSButton button = new KSButton("Cancel", new ClickHandler(){ |
| 64 | |
public void onClick(ClickEvent event) { |
| 65 | 0 | Application.navigate(AppLocations.Locations.VIEW_COURSE.getLocation()); |
| 66 | 0 | } |
| 67 | |
}); |
| 68 | |
|
| 69 | 0 | button.addStyleName("ks-button-spacing"); |
| 70 | 0 | return button; |
| 71 | |
} |
| 72 | |
|
| 73 | |
|
| 74 | |
|
| 75 | |
|
| 76 | |
|
| 77 | |
|
| 78 | |
protected void handleButtonClick(final String state){ |
| 79 | 0 | final SaveActionEvent saveActionEvent = new SaveActionEvent(false); |
| 80 | |
|
| 81 | 0 | saveActionEvent.setActionCompleteCallback(new ActionCompleteCallback(){ |
| 82 | |
@Override |
| 83 | |
public void onActionComplete(ActionEvent actionEvent) { |
| 84 | 0 | if (saveActionEvent.isSaveSuccessful()){ |
| 85 | 0 | final ViewContext viewContext = new ViewContext(); |
| 86 | 0 | viewContext.setId((String)cluProposalModel.get(CreditCourseConstants.ID)); |
| 87 | 0 | viewContext.setIdType(IdType.OBJECT_ID); |
| 88 | |
|
| 89 | |
|
| 90 | 0 | CourseWorkflowActionList.setCourseState(viewContext.getId(), DtoConstants.STATE_RETIRED, new Callback<String>(){ |
| 91 | |
@Override |
| 92 | |
public void exec(String result) { |
| 93 | 0 | if (result == null){ |
| 94 | 0 | KSNotifier.add(new KSNotification("Course saved, but unable to set retire state.", false, true, 5000)); |
| 95 | |
} else { |
| 96 | 0 | KSNotifier.show("Course saved and retired."); |
| 97 | 0 | Application.navigate(AppLocations.Locations.VIEW_COURSE.getLocation(), viewContext); |
| 98 | |
} |
| 99 | 0 | } |
| 100 | |
}); |
| 101 | |
} |
| 102 | 0 | } |
| 103 | |
}); |
| 104 | |
|
| 105 | 0 | CourseAdminRetireController.this.fireApplicationEvent(saveActionEvent); |
| 106 | 0 | } |
| 107 | |
|
| 108 | |
|
| 109 | |
|
| 110 | |
|
| 111 | |
|
| 112 | |
@Override |
| 113 | |
protected void setHeaderTitle(){ |
| 114 | 0 | StringBuffer sb = new StringBuffer(); |
| 115 | 0 | sb.append(cluProposalModel.get(cfg.getCourseTitlePath())); |
| 116 | 0 | sb.append(" (Retirement)"); |
| 117 | |
|
| 118 | 0 | currentTitle = sb.toString(); |
| 119 | |
|
| 120 | 0 | this.setContentTitle(currentTitle); |
| 121 | 0 | this.setName(currentTitle); |
| 122 | 0 | WindowTitleUtils.setContextTitle(currentTitle); |
| 123 | 0 | } |
| 124 | |
|
| 125 | |
protected BaseDataOrchestrationRpcServiceAsync getCourseProposalRpcService(){ |
| 126 | 0 | return courseServiceAsync; |
| 127 | |
} |
| 128 | |
|
| 129 | |
public boolean startSectionRequired(){ |
| 130 | |
|
| 131 | 0 | return false; |
| 132 | |
} |
| 133 | |
|
| 134 | |
@Override |
| 135 | |
public boolean isAuthorizationRequired() { |
| 136 | |
|
| 137 | 0 | return false; |
| 138 | |
} |
| 139 | |
|
| 140 | |
@Override |
| 141 | |
protected void progressiveEnableFields() { |
| 142 | |
|
| 143 | 0 | } |
| 144 | |
|
| 145 | |
|
| 146 | |
|
| 147 | |
|
| 148 | |
|
| 149 | |
@Override |
| 150 | |
protected String getStateforSaveAction(DataModel model){ |
| 151 | 0 | return cfg.getState(); |
| 152 | |
} |
| 153 | |
|
| 154 | |
} |