| 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.dto.DtoConstants.DtoState; |
| 5 | |
import org.kuali.student.common.ui.client.application.Application; |
| 6 | |
import org.kuali.student.common.ui.client.application.ViewContext; |
| 7 | |
import org.kuali.student.common.ui.client.configurable.mvc.FieldDescriptor; |
| 8 | |
import org.kuali.student.common.ui.client.configurable.mvc.sections.BaseSection; |
| 9 | |
import org.kuali.student.common.ui.client.event.ActionEvent; |
| 10 | |
import org.kuali.student.common.ui.client.event.SaveActionEvent; |
| 11 | |
import org.kuali.student.common.ui.client.mvc.ActionCompleteCallback; |
| 12 | |
import org.kuali.student.common.ui.client.mvc.Callback; |
| 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.shared.IdAttributes.IdType; |
| 18 | |
import org.kuali.student.lum.common.client.widgets.AppLocations; |
| 19 | |
import org.kuali.student.lum.lu.assembly.data.client.constants.orch.CreditCourseConstants; |
| 20 | |
import org.kuali.student.lum.lu.ui.course.client.configuration.CourseAdminWithoutVersionConfigurer; |
| 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 CourseAdminWithoutVersionController extends CourseAdminController{ |
| 33 | |
|
| 34 | |
|
| 35 | |
|
| 36 | |
|
| 37 | |
@Override |
| 38 | |
protected void initializeController() { |
| 39 | |
|
| 40 | 0 | super.cfg = GWT.create(CourseAdminWithoutVersionConfigurer.class); |
| 41 | |
|
| 42 | |
|
| 43 | 0 | cfg.setState(DtoConstants.STATE_APPROVED.toUpperCase()); |
| 44 | 0 | cfg.setNextState(DtoConstants.STATE_ACTIVE.toUpperCase()); |
| 45 | 0 | super.setDefaultModelId(cfg.getModelId()); |
| 46 | 0 | super.registerModelsAndHandlers(); |
| 47 | 0 | super.addStyleName("ks-course-admin"); |
| 48 | 0 | } |
| 49 | |
|
| 50 | |
|
| 51 | |
|
| 52 | |
|
| 53 | |
@Override |
| 54 | |
protected void progressiveEnableFields() { |
| 55 | 0 | super.progressiveEnableFields(); |
| 56 | 0 | final FieldDescriptor retireRationale = Application.getApplicationContext().getPathToFieldMapping(null,CreditCourseConstants.RETIREMENT_RATIONALE); |
| 57 | 0 | final FieldDescriptor lastTermOffered = Application.getApplicationContext().getPathToFieldMapping(null,CreditCourseConstants.LAST_TERM_OFFERED); |
| 58 | 0 | final FieldDescriptor lastPublicationYear = Application.getApplicationContext().getPathToFieldMapping(null,CreditCourseConstants.LAST_PUBLICATION_YEAR); |
| 59 | 0 | final FieldDescriptor specialCircumstances = Application.getApplicationContext().getPathToFieldMapping(null,CreditCourseConstants.SPECIAL_CIRCUMSTANCES); |
| 60 | |
|
| 61 | 0 | String courseState = cluProposalModel.get(CreditCourseConstants.STATE); |
| 62 | 0 | Boolean pilotValue = cluProposalModel.get(CreditCourseConstants.PILOT_COURSE); |
| 63 | |
|
| 64 | 0 | Boolean enableRetireFields = !DtoState.ACTIVE.equalsString(courseState) && (pilotValue == null || !pilotValue); |
| 65 | |
|
| 66 | 0 | BaseSection.progressiveEnableFields(enableRetireFields, retireRationale, lastTermOffered, lastPublicationYear, specialCircumstances); |
| 67 | 0 | } |
| 68 | |
|
| 69 | |
|
| 70 | |
|
| 71 | |
|
| 72 | |
@Override |
| 73 | |
public KSButton getSaveButton(){ |
| 74 | 0 | KSButton saveButton = new KSButton("Save", new ClickHandler(){ |
| 75 | |
public void onClick(ClickEvent event) { |
| 76 | 0 | handleButtonClick(DtoConstants.STATE_APPROVED); |
| 77 | 0 | } |
| 78 | |
}); |
| 79 | |
|
| 80 | 0 | return saveButton; |
| 81 | |
} |
| 82 | |
|
| 83 | |
|
| 84 | |
public KSButton getCancelButton(){ |
| 85 | 0 | KSButton button = new KSButton("Cancel", new ClickHandler(){ |
| 86 | |
public void onClick(ClickEvent event) { |
| 87 | 0 | Application.navigate(AppLocations.Locations.CURRICULUM_MANAGEMENT.getLocation()); |
| 88 | 0 | } |
| 89 | |
}); |
| 90 | |
|
| 91 | 0 | button.addStyleName("ks-button-spacing"); |
| 92 | 0 | return button; |
| 93 | |
} |
| 94 | |
|
| 95 | |
|
| 96 | |
|
| 97 | |
|
| 98 | |
|
| 99 | |
|
| 100 | |
protected void handleButtonClick(final String state){ |
| 101 | 0 | final SaveActionEvent saveActionEvent = new SaveActionEvent(false); |
| 102 | |
|
| 103 | 0 | saveActionEvent.setActionCompleteCallback(new ActionCompleteCallback(){ |
| 104 | |
@Override |
| 105 | |
public void onActionComplete(ActionEvent actionEvent) { |
| 106 | 0 | if (saveActionEvent.isSaveSuccessful()){ |
| 107 | 0 | final ViewContext viewContext = new ViewContext(); |
| 108 | 0 | viewContext.setId((String)cluProposalModel.get(CreditCourseConstants.ID)); |
| 109 | 0 | viewContext.setIdType(IdType.OBJECT_ID); |
| 110 | 0 | if (DtoConstants.STATE_ACTIVE.equalsIgnoreCase(state) || 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 | |
|
| 118 | |
|
| 119 | 0 | if((String)cluProposalModel.get(CreditCourseConstants.ID)!=null && cfg instanceof CourseAdminWithoutVersionConfigurer){ |
| 120 | 0 | ((CourseAdminWithoutVersionConfigurer)cfg).getRequisitesSection().storeRules(new Callback<Boolean>(){ |
| 121 | |
public void exec(Boolean result) { |
| 122 | 0 | if(result){ |
| 123 | 0 | CourseAdminWithoutVersionController.this.fireApplicationEvent(saveActionEvent); |
| 124 | |
}else{ |
| 125 | 0 | KSNotifier.show("Error saving rules."); |
| 126 | |
} |
| 127 | 0 | } |
| 128 | |
}); |
| 129 | |
}else{ |
| 130 | 0 | CourseAdminWithoutVersionController.this.fireApplicationEvent(saveActionEvent); |
| 131 | |
} |
| 132 | 0 | } |
| 133 | |
|
| 134 | |
|
| 135 | |
|
| 136 | |
|
| 137 | |
|
| 138 | |
@Override |
| 139 | |
protected void setHeaderTitle(){ |
| 140 | 0 | StringBuffer sb = new StringBuffer(); |
| 141 | 0 | sb.append("Modify: "); |
| 142 | 0 | sb.append(cluProposalModel.get(cfg.getCourseTitlePath())); |
| 143 | 0 | sb.append(" (Admin)"); |
| 144 | |
|
| 145 | 0 | currentTitle = sb.toString(); |
| 146 | |
|
| 147 | 0 | this.setContentTitle(currentTitle); |
| 148 | 0 | this.setName(currentTitle); |
| 149 | 0 | WindowTitleUtils.setContextTitle(currentTitle); |
| 150 | 0 | } |
| 151 | |
|
| 152 | |
@Override |
| 153 | |
protected Callback<Boolean> previousEndTermConfigurationCallback(Callback<Boolean> onReadyCallback) { |
| 154 | |
|
| 155 | 0 | return onReadyCallback; |
| 156 | |
} |
| 157 | |
|
| 158 | |
protected BaseDataOrchestrationRpcServiceAsync getCourseProposalRpcService(){ |
| 159 | 0 | return courseServiceAsync; |
| 160 | |
} |
| 161 | |
|
| 162 | |
public boolean startSectionRequired(){ |
| 163 | 0 | return false; |
| 164 | |
} |
| 165 | |
@Override |
| 166 | |
public boolean isAuthorizationRequired() { |
| 167 | |
|
| 168 | 0 | return false; |
| 169 | |
} |
| 170 | |
|
| 171 | |
} |