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