1 | |
package org.kuali.student.lum.program.client.major.proposal; |
2 | |
|
3 | |
import java.util.List; |
4 | |
|
5 | |
import org.kuali.student.common.ui.client.application.Application; |
6 | |
import org.kuali.student.common.ui.client.configurable.mvc.sections.Section; |
7 | |
import org.kuali.student.common.ui.client.configurable.mvc.sections.WarnContainer; |
8 | |
import org.kuali.student.common.ui.client.configurable.mvc.views.VerticalSectionView; |
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.mvc.ModelRequestCallback; |
12 | |
import org.kuali.student.common.ui.client.widgets.KSButton; |
13 | |
import org.kuali.student.common.ui.client.widgets.KSButtonAbstract.ButtonStyle; |
14 | |
import org.kuali.student.common.ui.client.widgets.field.layout.element.MessageKeyInfo; |
15 | |
import org.kuali.student.common.validation.dto.ValidationResultInfo; |
16 | |
import org.kuali.student.common.validation.dto.ValidationResultInfo.ErrorLevel; |
17 | |
import org.kuali.student.core.workflow.ui.client.widgets.WorkflowEnhancedNavController; |
18 | |
import org.kuali.student.core.workflow.ui.client.widgets.WorkflowUtilities; |
19 | |
import org.kuali.student.lum.common.client.configuration.AbstractControllerConfiguration; |
20 | |
import org.kuali.student.lum.common.client.configuration.Configuration; |
21 | |
import org.kuali.student.lum.common.client.configuration.ConfigurationManager; |
22 | |
import org.kuali.student.lum.common.client.widgets.AppLocations; |
23 | |
import org.kuali.student.lum.program.client.ProgramConstants; |
24 | |
import org.kuali.student.lum.program.client.ProgramSections; |
25 | |
import org.kuali.student.lum.program.client.major.view.CatalogInformationViewConfiguration; |
26 | |
import org.kuali.student.lum.program.client.major.view.LearningObjectivesViewConfiguration; |
27 | |
import org.kuali.student.lum.program.client.major.view.MajorKeyProgramInfoViewConfiguration; |
28 | |
import org.kuali.student.lum.program.client.major.view.ManagingBodiesViewConfiguration; |
29 | |
import org.kuali.student.lum.program.client.major.view.ProgramRequirementsViewConfiguration; |
30 | |
import org.kuali.student.lum.program.client.major.view.ProposalChangeImpactViewConfiguration; |
31 | |
import org.kuali.student.lum.program.client.major.view.ProposalInformationViewConfiguration; |
32 | |
import org.kuali.student.lum.program.client.major.view.SpecializationsViewConfiguration; |
33 | |
import org.kuali.student.lum.program.client.major.view.SupportingDocsViewConfiguration; |
34 | |
import org.kuali.student.lum.program.client.properties.ProgramProperties; |
35 | |
|
36 | |
import com.google.gwt.event.dom.client.ClickEvent; |
37 | |
import com.google.gwt.event.dom.client.ClickHandler; |
38 | |
import com.google.gwt.user.client.ui.Widget; |
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | 0 | public class MajorProposalSummaryConfiguration extends AbstractControllerConfiguration { |
50 | |
|
51 | 0 | boolean showEditLinks = false; |
52 | |
|
53 | |
public MajorProposalSummaryConfiguration(boolean showEditLinks) { |
54 | 0 | super(); |
55 | 0 | this.showEditLinks = showEditLinks; |
56 | 0 | } |
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
@Override |
62 | |
protected void buildLayout() { |
63 | |
|
64 | 0 | if (controller instanceof WorkflowEnhancedNavController |
65 | |
&& ((WorkflowEnhancedNavController) controller).getWfUtilities() != null) { |
66 | |
final WarnContainer infoContainerHeader; |
67 | |
|
68 | 0 | infoContainerHeader = generateWorkflowWidgetContainer(((WorkflowEnhancedNavController) controller) |
69 | |
.getWfUtilities().getWorkflowActionsWidget()); |
70 | 0 | rootSection = new VerticalSectionView(ProgramSections.SUMMARY, ProgramProperties.get().proposal_menu_sections_summary(), ProgramConstants.PROGRAM_MODEL_ID, true){ |
71 | |
|
72 | |
@Override |
73 | |
public void beforeShow(final Callback<Boolean> onReadyCallback) { |
74 | 0 | super.beforeShow(new Callback<Boolean>() { |
75 | |
|
76 | |
@Override |
77 | |
public void exec(final Boolean result) { |
78 | 0 | if (result) { |
79 | |
|
80 | 0 | ((WorkflowEnhancedNavController) controller).getWfUtilities().refresh(); |
81 | 0 | ((WorkflowEnhancedNavController) controller).getWfUtilities().requestAndSetupModel(new Callback<Boolean>(){ |
82 | |
public void exec(Boolean modelReadyResult) { |
83 | |
|
84 | 0 | ((WorkflowEnhancedNavController) controller).getWfUtilities().doValidationCheck(new Callback<List<ValidationResultInfo>>() { |
85 | |
@Override |
86 | |
public void exec(List<ValidationResultInfo> validationResult) { |
87 | 0 | ErrorLevel isValid = rootSection.processValidationResults( |
88 | |
validationResult, true); |
89 | |
|
90 | 0 | if (isValid == ErrorLevel.OK) { |
91 | 0 | infoContainerHeader.showWarningLayout(false); |
92 | 0 | ((WorkflowEnhancedNavController) controller) |
93 | |
.getWfUtilities() |
94 | |
.enableWorkflowActionsWidgets(true); |
95 | |
} else { |
96 | 0 | ((WorkflowEnhancedNavController) controller).getWfUtilities() |
97 | |
.enableWorkflowActionsWidgets(false); |
98 | |
} |
99 | 0 | onReadyCallback.exec(result); |
100 | 0 | } |
101 | |
}); |
102 | 0 | } |
103 | |
}); |
104 | |
}else{ |
105 | 0 | onReadyCallback.exec(result); |
106 | |
} |
107 | 0 | } |
108 | |
}); |
109 | 0 | } |
110 | |
|
111 | |
}; |
112 | |
|
113 | 0 | rootSection.addWidget(infoContainerHeader); |
114 | |
} |
115 | |
|
116 | |
|
117 | |
|
118 | |
|
119 | 0 | ConfigurationManager configurationManager = new ConfigurationManager(configurer); |
120 | |
|
121 | |
|
122 | 0 | if (showEditLinks){ |
123 | 0 | configureSectionsWithEditLinks(configurationManager); |
124 | |
} else { |
125 | 0 | configureSectionsWithoutEditLinks(configurationManager); |
126 | |
} |
127 | |
|
128 | |
|
129 | |
|
130 | 0 | if (controller instanceof MajorProposalController){ |
131 | |
|
132 | |
|
133 | 0 | final WorkflowUtilities workflowUtilities = ((MajorProposalController) controller).getWfUtilities(); |
134 | 0 | workflowUtilities.addSubmitCallback(new Callback<Boolean>() { |
135 | |
|
136 | |
@Override |
137 | |
public void exec(Boolean result) { |
138 | 0 | if (result) { |
139 | 0 | ((MajorProposalController) controller).setStatus(); |
140 | |
} |
141 | |
|
142 | 0 | } |
143 | |
}); |
144 | |
|
145 | 0 | if(workflowUtilities!=null){ |
146 | 0 | controller.requestModel(new ModelRequestCallback<DataModel>(){ |
147 | |
public void onModelReady(DataModel model) { |
148 | |
|
149 | 0 | String versionedFromId = model.get("versionInfo/versionedFromId"); |
150 | 0 | if(versionedFromId!=null && !versionedFromId.isEmpty()){ |
151 | |
|
152 | 0 | workflowUtilities.addApproveDialogField("", "startTerm", new MessageKeyInfo(ProgramProperties.get().programInformation_startTerm()), MajorProposalSummaryConfiguration.this.configurer.getModelDefinition(), true, true); |
153 | 0 | workflowUtilities.addApproveDialogField("proposal", "prevEndTerm", new MessageKeyInfo(ProgramProperties.get().majorDiscipline_prevEndTerm()), MajorProposalSummaryConfiguration.this.configurer.getModelDefinition(),false); |
154 | 0 | workflowUtilities.addApproveDialogField("proposal", "prevEndProgramEntryTerm", new MessageKeyInfo(ProgramProperties.get().majorDiscipline_prevEndProgramEntryTerm()), MajorProposalSummaryConfiguration.this.configurer.getModelDefinition(),false); |
155 | 0 | workflowUtilities.addApproveDialogField("proposal", "prevEndInstAdmitTerm", new MessageKeyInfo(ProgramProperties.get().majorDiscipline_prevEndInstAdmitTerm()), MajorProposalSummaryConfiguration.this.configurer.getModelDefinition(),false); |
156 | 0 | workflowUtilities.updateApproveFields(); |
157 | 0 | workflowUtilities.progressiveEnableFields(); |
158 | |
}else{ |
159 | |
|
160 | 0 | workflowUtilities.addIgnoreDialogField("proposal/prevEndTerm"); |
161 | 0 | workflowUtilities.addIgnoreDialogField("proposal/prevEndProgramEntryTerm"); |
162 | 0 | workflowUtilities.addIgnoreDialogField("proposal/prevEndInstAdmitTerm"); |
163 | |
} |
164 | 0 | } |
165 | |
public void onRequestFail(Throwable cause) { |
166 | 0 | } |
167 | |
}); |
168 | |
} |
169 | |
|
170 | |
} |
171 | |
|
172 | |
|
173 | |
|
174 | 0 | for (Configuration configuration : configurationManager.getConfigurations()) { |
175 | 0 | if (configuration instanceof AbstractControllerConfiguration) { |
176 | 0 | ((AbstractControllerConfiguration) configuration).setController(controller); |
177 | |
} |
178 | 0 | rootSection.addSection((Section) configuration.getView()); |
179 | |
} |
180 | 0 | } |
181 | |
|
182 | |
protected void configureSectionsWithEditLinks(ConfigurationManager configurationManager){ |
183 | 0 | configurationManager.registerConfiguration(ProposalInformationViewConfiguration.createSpecial(controller)); |
184 | 0 | configurationManager.registerConfiguration(ProposalChangeImpactViewConfiguration.createSpecial(controller)); |
185 | 0 | configurationManager.registerConfiguration(MajorKeyProgramInfoViewConfiguration.createSpecial(controller)); |
186 | 0 | configurationManager.registerConfiguration(ManagingBodiesViewConfiguration.createSpecial(controller)); |
187 | 0 | configurationManager.registerConfiguration(SpecializationsViewConfiguration.createSpecial(controller)); |
188 | 0 | configurationManager.registerConfiguration(CatalogInformationViewConfiguration.createSpecial(controller)); |
189 | 0 | configurationManager.registerConfiguration(new ProgramRequirementsViewConfiguration(controller, true)); |
190 | 0 | configurationManager.registerConfiguration(LearningObjectivesViewConfiguration.createSpecial(controller)); |
191 | 0 | configurationManager.registerConfiguration(SupportingDocsViewConfiguration.createSpecial(controller)); |
192 | 0 | } |
193 | |
|
194 | |
protected void configureSectionsWithoutEditLinks(ConfigurationManager configurationManager){ |
195 | 0 | configurationManager.registerConfiguration(ProposalInformationViewConfiguration.create()); |
196 | 0 | configurationManager.registerConfiguration(ProposalChangeImpactViewConfiguration.create()); |
197 | 0 | configurationManager.registerConfiguration(MajorKeyProgramInfoViewConfiguration.create()); |
198 | 0 | configurationManager.registerConfiguration(ManagingBodiesViewConfiguration.create()); |
199 | 0 | configurationManager.registerConfiguration(SpecializationsViewConfiguration.create()); |
200 | 0 | configurationManager.registerConfiguration(CatalogInformationViewConfiguration.create()); |
201 | 0 | configurationManager.registerConfiguration(new ProgramRequirementsViewConfiguration(controller, false)); |
202 | 0 | configurationManager.registerConfiguration(LearningObjectivesViewConfiguration.create()); |
203 | 0 | configurationManager.registerConfiguration(SupportingDocsViewConfiguration.create()); |
204 | 0 | } |
205 | |
|
206 | |
|
207 | |
private WarnContainer generateWorkflowWidgetContainer(Widget w) { |
208 | |
|
209 | 0 | WarnContainer warnContainer = new WarnContainer(); |
210 | |
|
211 | 0 | warnContainer.add(w); |
212 | 0 | w.addStyleName("ks-button-spacing"); |
213 | 0 | warnContainer.add(new KSButton("Return to Curriculum Management", |
214 | 0 | ButtonStyle.DEFAULT_ANCHOR, new ClickHandler() { |
215 | |
|
216 | |
@Override |
217 | |
public void onClick(ClickEvent event) { |
218 | 0 | Application |
219 | |
.navigate(AppLocations.Locations.CURRICULUM_MANAGEMENT |
220 | |
.getLocation()); |
221 | 0 | } |
222 | |
})); |
223 | |
|
224 | |
|
225 | |
|
226 | 0 | return warnContainer; |
227 | |
} |
228 | |
} |