| 1 | |
package org.kuali.student.lum.lu.ui.course.client.controllers; |
| 2 | |
|
| 3 | |
import org.kuali.student.common.assembly.data.Data; |
| 4 | |
import org.kuali.student.common.dto.DtoConstants; |
| 5 | |
import org.kuali.student.common.ui.client.application.Application; |
| 6 | |
import org.kuali.student.common.ui.client.application.KSAsyncCallback; |
| 7 | |
import org.kuali.student.common.ui.client.application.ViewContext; |
| 8 | |
import org.kuali.student.common.ui.client.event.ActionEvent; |
| 9 | |
import org.kuali.student.common.ui.client.event.SaveActionEvent; |
| 10 | |
import org.kuali.student.common.ui.client.mvc.ActionCompleteCallback; |
| 11 | |
import org.kuali.student.common.ui.client.mvc.Callback; |
| 12 | |
import org.kuali.student.common.ui.client.mvc.ModelRequestCallback; |
| 13 | |
import org.kuali.student.common.ui.client.service.BaseDataOrchestrationRpcServiceAsync; |
| 14 | |
import org.kuali.student.common.ui.client.util.WindowTitleUtils; |
| 15 | |
import org.kuali.student.common.ui.client.widgets.KSButton; |
| 16 | |
import org.kuali.student.common.ui.client.widgets.notification.KSNotifier; |
| 17 | |
import org.kuali.student.common.ui.client.widgets.progress.KSBlockingProgressIndicator; |
| 18 | |
import org.kuali.student.common.ui.shared.IdAttributes.IdType; |
| 19 | |
import org.kuali.student.lum.common.client.widgets.AppLocations; |
| 20 | |
import org.kuali.student.lum.lu.assembly.data.client.constants.orch.CreditCourseConstants; |
| 21 | |
import org.kuali.student.lum.lu.ui.course.client.configuration.CourseAdminWithoutVersionConfigurer; |
| 22 | |
import org.kuali.student.lum.lu.ui.course.client.widgets.CourseWorkflowActionList; |
| 23 | |
|
| 24 | |
import com.google.gwt.core.client.GWT; |
| 25 | |
import com.google.gwt.event.dom.client.ClickEvent; |
| 26 | |
import com.google.gwt.event.dom.client.ClickHandler; |
| 27 | |
import com.google.gwt.user.client.Window; |
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | 0 | public class CourseAdminWithoutVersionController extends CourseAdminController{ |
| 36 | |
|
| 37 | |
|
| 38 | |
|
| 39 | |
|
| 40 | |
@Override |
| 41 | |
protected void initializeController() { |
| 42 | |
|
| 43 | 0 | super.cfg = GWT.create(CourseAdminWithoutVersionConfigurer.class); |
| 44 | |
|
| 45 | |
|
| 46 | 0 | cfg.setState(DtoConstants.STATE_APPROVED.toUpperCase()); |
| 47 | 0 | cfg.setNextState(DtoConstants.STATE_ACTIVE.toUpperCase()); |
| 48 | 0 | super.setDefaultModelId(cfg.getModelId()); |
| 49 | 0 | super.registerModelsAndHandlers(); |
| 50 | 0 | super.addStyleName("ks-course-admin"); |
| 51 | 0 | } |
| 52 | |
|
| 53 | |
|
| 54 | |
|
| 55 | |
|
| 56 | |
@Override |
| 57 | |
public KSButton getSaveButton(){ |
| 58 | 0 | return new KSButton("Save", new ClickHandler(){ |
| 59 | |
public void onClick(ClickEvent event) { |
| 60 | 0 | handleButtonClick(DtoConstants.STATE_APPROVED); |
| 61 | 0 | } |
| 62 | |
}); |
| 63 | |
} |
| 64 | |
|
| 65 | |
public KSButton getActivateButton(){ |
| 66 | 0 | return new KSButton("Activate", new ClickHandler(){ |
| 67 | |
public void onClick(ClickEvent event) { |
| 68 | 0 | handleButtonClick(DtoConstants.STATE_ACTIVE); |
| 69 | 0 | } |
| 70 | |
}); |
| 71 | |
} |
| 72 | |
|
| 73 | |
public KSButton getCancelButton(){ |
| 74 | 0 | KSButton button = new KSButton("Cancel", new ClickHandler(){ |
| 75 | |
public void onClick(ClickEvent event) { |
| 76 | 0 | Application.navigate(AppLocations.Locations.CURRICULUM_MANAGEMENT.getLocation()); |
| 77 | 0 | } |
| 78 | |
}); |
| 79 | |
|
| 80 | 0 | return button; |
| 81 | |
} |
| 82 | |
|
| 83 | |
|
| 84 | |
|
| 85 | |
|
| 86 | |
|
| 87 | |
|
| 88 | |
protected void handleButtonClick(final String state){ |
| 89 | 0 | final SaveActionEvent saveActionEvent = new SaveActionEvent(false); |
| 90 | 0 | saveActionEvent.setActionCompleteCallback(new ActionCompleteCallback(){ |
| 91 | |
@Override |
| 92 | |
public void onActionComplete(ActionEvent actionEvent) { |
| 93 | 0 | if (saveActionEvent.isSaveSuccessful()){ |
| 94 | 0 | final ViewContext viewContext = new ViewContext(); |
| 95 | 0 | viewContext.setId((String)cluProposalModel.get(CreditCourseConstants.ID)); |
| 96 | 0 | viewContext.setIdType(IdType.OBJECT_ID); |
| 97 | 0 | if (DtoConstants.STATE_ACTIVE.equalsIgnoreCase(state)){ |
| 98 | |
|
| 99 | 0 | CourseWorkflowActionList.setCourseState(viewContext.getId(), DtoConstants.STATE_ACTIVE, new Callback<String>(){ |
| 100 | |
@Override |
| 101 | |
public void exec(String result) { |
| 102 | 0 | if (result == null){ |
| 103 | 0 | KSNotifier.show("Course saved, but activation failed."); |
| 104 | |
} else { |
| 105 | 0 | KSNotifier.show("Course saved and activated."); |
| 106 | 0 | Application.navigate(AppLocations.Locations.VIEW_COURSE.getLocation(), viewContext); |
| 107 | |
} |
| 108 | 0 | } |
| 109 | |
}); |
| 110 | 0 | } else if (DtoConstants.STATE_APPROVED.equalsIgnoreCase(state)){ |
| 111 | 0 | KSNotifier.show("Course saved."); |
| 112 | 0 | Application.navigate(AppLocations.Locations.VIEW_COURSE.getLocation(), viewContext); |
| 113 | |
} |
| 114 | |
} |
| 115 | 0 | } |
| 116 | |
}); |
| 117 | 0 | CourseAdminWithoutVersionController.this.fireApplicationEvent(saveActionEvent); |
| 118 | 0 | } |
| 119 | |
|
| 120 | |
|
| 121 | |
|
| 122 | |
|
| 123 | |
@Override |
| 124 | |
protected void setHeaderTitle(){ |
| 125 | 0 | StringBuffer sb = new StringBuffer(); |
| 126 | 0 | sb.append("Modify: "); |
| 127 | 0 | sb.append(cluProposalModel.get(cfg.getCourseTitlePath())); |
| 128 | 0 | sb.append(" (Admin)"); |
| 129 | |
|
| 130 | 0 | currentTitle = sb.toString(); |
| 131 | |
|
| 132 | 0 | this.setContentTitle(currentTitle); |
| 133 | 0 | this.setName(currentTitle); |
| 134 | 0 | WindowTitleUtils.setContextTitle(currentTitle); |
| 135 | 0 | } |
| 136 | |
|
| 137 | |
protected BaseDataOrchestrationRpcServiceAsync getCourseProposalRpcService(){ |
| 138 | 0 | return courseServiceAsync; |
| 139 | |
} |
| 140 | |
|
| 141 | |
public boolean startSectionRequired(){ |
| 142 | 0 | return false; |
| 143 | |
} |
| 144 | |
@Override |
| 145 | |
public boolean isAuthorizationRequired() { |
| 146 | |
|
| 147 | 0 | return false; |
| 148 | |
} |
| 149 | |
|
| 150 | |
|
| 151 | |
@Override |
| 152 | |
@SuppressWarnings("unchecked") |
| 153 | |
protected void getCluProposalFromProposalId(String id, final ModelRequestCallback callback, final Callback<Boolean> workCompleteCallback){ |
| 154 | 0 | KSBlockingProgressIndicator.addTask(loadDataTask); |
| 155 | 0 | cluProposalRpcServiceAsync.getData(id, new KSAsyncCallback<Data>(){ |
| 156 | |
|
| 157 | |
@Override |
| 158 | |
public void handleFailure(Throwable caught) { |
| 159 | 0 | Window.alert("Error loading Proposal: "+caught.getMessage()); |
| 160 | 0 | createNewCluProposalModel(callback, workCompleteCallback); |
| 161 | 0 | KSBlockingProgressIndicator.removeTask(loadDataTask); |
| 162 | 0 | } |
| 163 | |
|
| 164 | |
@Override |
| 165 | |
public void onSuccess(Data result) { |
| 166 | 0 | cluProposalModel.setRoot(result); |
| 167 | 0 | setHeaderTitle(); |
| 168 | 0 | setLastUpdated(); |
| 169 | 0 | reqDataModel.retrieveStatementTypes(cluProposalModel.<String>get("id"), new Callback<Boolean>() { |
| 170 | |
@Override |
| 171 | |
public void exec(Boolean result) { |
| 172 | 0 | if(result){ |
| 173 | 0 | getCourseComparisonModelAndReqs(callback, workCompleteCallback); |
| 174 | |
} |
| 175 | 0 | } |
| 176 | |
}); |
| 177 | 0 | } |
| 178 | |
|
| 179 | |
}); |
| 180 | 0 | } |
| 181 | |
} |