1 | |
package org.kuali.student.lum.lu.ui.main.client.configuration; |
2 | |
|
3 | |
import java.util.ArrayList; |
4 | |
import java.util.List; |
5 | |
|
6 | |
import org.kuali.student.common.assembly.data.Metadata; |
7 | |
import org.kuali.student.common.rice.StudentIdentityConstants; |
8 | |
import org.kuali.student.common.rice.authorization.PermissionType; |
9 | |
import org.kuali.student.common.ui.client.application.Application; |
10 | |
import org.kuali.student.common.ui.client.application.ViewContext; |
11 | |
import org.kuali.student.common.ui.client.configurable.mvc.SectionTitle; |
12 | |
import org.kuali.student.common.ui.client.mvc.Callback; |
13 | |
import org.kuali.student.common.ui.client.widgets.KSButton; |
14 | |
import org.kuali.student.common.ui.client.widgets.KSCheckBox; |
15 | |
import org.kuali.student.common.ui.client.widgets.KSLabel; |
16 | |
import org.kuali.student.common.ui.client.widgets.KSLightBox; |
17 | |
import org.kuali.student.common.ui.client.widgets.KSRadioButton; |
18 | |
import org.kuali.student.common.ui.client.widgets.KSButtonAbstract.ButtonStyle; |
19 | |
import org.kuali.student.common.ui.client.widgets.field.layout.element.AbbrButton; |
20 | |
import org.kuali.student.common.ui.client.widgets.field.layout.element.AbbrButton.AbbrButtonType; |
21 | |
import org.kuali.student.common.ui.client.widgets.layout.ContentBlockLayout; |
22 | |
import org.kuali.student.common.ui.client.widgets.layout.LinkContentBlock; |
23 | |
import org.kuali.student.common.ui.client.widgets.search.KSPicker; |
24 | |
import org.kuali.student.common.ui.client.widgets.search.SearchPanel; |
25 | |
import org.kuali.student.common.ui.client.widgets.search.SelectedResults; |
26 | |
import org.kuali.student.common.ui.shared.IdAttributes.IdType; |
27 | |
import org.kuali.student.lum.common.client.lu.LUUIPermissions; |
28 | |
import org.kuali.student.lum.common.client.widgets.AppLocations; |
29 | |
import org.kuali.student.lum.lu.ui.course.client.widgets.RecentlyViewedBlock; |
30 | |
import org.kuali.student.lum.program.client.ProgramConstants; |
31 | |
import org.kuali.student.lum.program.client.ProgramRegistry; |
32 | |
|
33 | |
import com.google.gwt.core.client.GWT; |
34 | |
import com.google.gwt.event.dom.client.ClickEvent; |
35 | |
import com.google.gwt.event.dom.client.ClickHandler; |
36 | |
import com.google.gwt.event.logical.shared.ValueChangeEvent; |
37 | |
import com.google.gwt.event.logical.shared.ValueChangeHandler; |
38 | |
import com.google.gwt.user.client.ui.Anchor; |
39 | |
import com.google.gwt.user.client.ui.HorizontalPanel; |
40 | |
import com.google.gwt.user.client.ui.Hyperlink; |
41 | |
import com.google.gwt.user.client.ui.Label; |
42 | |
import com.google.gwt.user.client.ui.VerticalPanel; |
43 | |
import com.google.gwt.user.client.ui.Widget; |
44 | |
|
45 | 0 | public class CurriculumHomeConfigurer implements CurriculumHomeConstants { |
46 | |
|
47 | |
protected Metadata searchMetadata; |
48 | 0 | protected final KSCheckBox useCurricReviewCheckbox = new KSCheckBox(getMessage("useCurriculumReview")); |
49 | |
|
50 | |
public Widget configure(Metadata searchMeta) { |
51 | 0 | this.searchMetadata = searchMeta; |
52 | 0 | final ContentBlockLayout layout = new ContentBlockLayout(getMessage(CURRICULUM_MANAGEMENT)); |
53 | 0 | ArrayList<String> permissionList=new ArrayList<String>(); |
54 | |
|
55 | 0 | layout.addContentTitleWidget(getHowToWidget()); |
56 | 0 | layout.addContentTitleWidget(getActionListLink()); |
57 | |
|
58 | |
|
59 | 0 | Application.getApplicationContext().getSecurityContext().loadPermissionsByPermissionType(PermissionType.INITIATE); |
60 | 0 | permissionList.add(LUUIPermissions.USE_CREATE_COURSE_BY_PROPOSAL); |
61 | 0 | permissionList.add(LUUIPermissions.USE_CREATE_COURSE_BY_ADMIN_PROPOSAL); |
62 | 0 | permissionList.add(LUUIPermissions.USE_CREATE_PROGRAM_BY_PROPOSAL); |
63 | 0 | permissionList.add(LUUIPermissions.USE_BROWSE_CATALOG_SCREEN); |
64 | 0 | permissionList.add(LUUIPermissions.USE_FIND_COURSE_SCREEN); |
65 | 0 | permissionList.add(LUUIPermissions.USE_FIND_COURSE_PROPOSAL_SCREEN); |
66 | 0 | permissionList.add(LUUIPermissions.USE_BROWSE_PROGRAM_SCREEN); |
67 | 0 | permissionList.add(LUUIPermissions.USE_FIND_PROGRAM_SCREEN); |
68 | 0 | permissionList.add(LUUIPermissions.USE_FIND_PROGRAM_PROPOSAL_SCREEN); |
69 | 0 | permissionList.add(LUUIPermissions.USE_VIEW_CORE_PROGRAMS_SCREEN); |
70 | 0 | permissionList.add(LUUIPermissions.USE_VIEW_CREDENTIAL_PROGRAMS_SCREEN); |
71 | 0 | permissionList.add(LUUIPermissions.USE_VIEW_COURSE_SET_MANAGEMENT_SCREENS); |
72 | 0 | permissionList.add(LUUIPermissions.USE_LO_CATEGORY_SCREEN); |
73 | 0 | permissionList.add(LUUIPermissions.USE_DEPENDENCY_ANALYSIS_SCREEN); |
74 | |
|
75 | 0 | Application.getApplicationContext().getSecurityContext().loadScreenPermissions(permissionList, new Callback<Boolean>(){ |
76 | |
|
77 | |
@Override |
78 | |
public void exec(Boolean result) { |
79 | |
|
80 | 0 | final LinkContentBlock create = new LinkContentBlock(getMessage(CREATE), getMessage(CREATE_DESC)); |
81 | |
|
82 | 0 | if(Application.getApplicationContext().getSecurityContext().checkCachedScreenPermission(LUUIPermissions.USE_CREATE_COURSE_BY_PROPOSAL)|| |
83 | |
Application.getApplicationContext().getSecurityContext().checkCachedScreenPermission(LUUIPermissions.USE_CREATE_COURSE_BY_ADMIN_PROPOSAL)){ |
84 | |
|
85 | 0 | create.addNavLinkWidget(getMessage(CREATE_COURSE), getCreateCourseClickHandler()); |
86 | |
} |
87 | |
|
88 | 0 | if(Application.getApplicationContext().getSecurityContext().checkCachedScreenPermission(LUUIPermissions.USE_CREATE_PROGRAM_BY_PROPOSAL)){ |
89 | |
|
90 | 0 | create.addNavLinkWidget(getMessage(CREATE_PROGRAM), AppLocations.Locations.EDIT_PROGRAM.getLocation()); |
91 | |
} |
92 | |
|
93 | |
|
94 | 0 | final LinkContentBlock viewModify = new LinkContentBlock(getMessage(VIEW_MODIFY), getMessage(VIEW_MODIFY_DESC)); |
95 | 0 | SectionTitle courses = SectionTitle.generateH4Title(getMessage("courses")); |
96 | 0 | courses.addStyleName("bold"); |
97 | 0 | viewModify.add(courses); |
98 | |
|
99 | |
|
100 | 0 | if(Application.getApplicationContext().getSecurityContext().checkCachedScreenPermission(LUUIPermissions.USE_BROWSE_CATALOG_SCREEN)){ |
101 | |
|
102 | 0 | viewModify.addNavLinkWidget(getMessage(BROWSE_CATALOG), AppLocations.Locations.BROWSE_CATALOG.getLocation()); |
103 | |
} |
104 | |
|
105 | 0 | if(Application.getApplicationContext().getSecurityContext().checkCachedScreenPermission(LUUIPermissions.USE_FIND_COURSE_SCREEN)){ |
106 | |
|
107 | 0 | viewModify.add(getFindCoursesWidget()); |
108 | |
} |
109 | |
|
110 | 0 | if(Application.getApplicationContext().getSecurityContext().checkCachedScreenPermission(LUUIPermissions.USE_FIND_COURSE_PROPOSAL_SCREEN)){ |
111 | |
|
112 | 0 | viewModify.add(getFindCourseProposalsWidget()); |
113 | |
} |
114 | |
|
115 | 0 | SectionTitle programs = SectionTitle.generateH4Title(getMessage("programs")); |
116 | 0 | programs.addStyleName("bold"); |
117 | 0 | viewModify.add(programs); |
118 | |
|
119 | 0 | if(Application.getApplicationContext().getSecurityContext().checkCachedScreenPermission(LUUIPermissions.USE_BROWSE_PROGRAM_SCREEN)){ |
120 | |
|
121 | 0 | viewModify.addNavLinkWidget(getMessage(BROWSE_PROGRAM), AppLocations.Locations.BROWSE_PROGRAM.getLocation()); |
122 | |
} |
123 | |
|
124 | 0 | if(Application.getApplicationContext().getSecurityContext().checkCachedScreenPermission(LUUIPermissions.USE_FIND_PROGRAM_SCREEN)){ |
125 | |
|
126 | 0 | viewModify.add(getFindMajorsWidget()); |
127 | |
} |
128 | |
|
129 | 0 | if(Application.getApplicationContext().getSecurityContext().checkCachedScreenPermission(LUUIPermissions.USE_FIND_PROGRAM_PROPOSAL_SCREEN)){ |
130 | |
|
131 | 0 | viewModify.add(getFindProgramProposalsWidget()); |
132 | |
} |
133 | |
|
134 | 0 | if(Application.getApplicationContext().getSecurityContext().checkCachedScreenPermission(LUUIPermissions.USE_VIEW_CORE_PROGRAMS_SCREEN)){ |
135 | |
|
136 | 0 | viewModify.add(getViewCoreProgramWidget()); |
137 | |
} |
138 | |
|
139 | 0 | if(Application.getApplicationContext().getSecurityContext().checkCachedScreenPermission(LUUIPermissions.USE_VIEW_CREDENTIAL_PROGRAMS_SCREEN)){ |
140 | |
|
141 | 0 | viewModify.add(getViewCredentialProgramWidget()); |
142 | |
} |
143 | |
|
144 | |
|
145 | 0 | RecentlyViewedBlock recent = new RecentlyViewedBlock(getMessage(RECENTLY_VIEWED), getMessage(RV_DESC)); |
146 | 0 | recent.addStyleName("recentlyViewed-block"); |
147 | |
|
148 | |
|
149 | 0 | final LinkContentBlock tools = new LinkContentBlock(getMessage(TOOLS), getMessage(TOOLS_DESC)); |
150 | |
|
151 | 0 | if(Application.getApplicationContext().getSecurityContext().checkCachedScreenPermission(LUUIPermissions.USE_VIEW_COURSE_SET_MANAGEMENT_SCREENS)){ |
152 | |
|
153 | 0 | tools.addNavLinkWidget(getMessage(COURSE_SETS), AppLocations.Locations.MANAGE_CLU_SETS.getLocation()); |
154 | |
} |
155 | |
|
156 | 0 | if(Application.getApplicationContext().getSecurityContext().checkCachedScreenPermission(LUUIPermissions.USE_LO_CATEGORY_SCREEN)){ |
157 | |
|
158 | 0 | tools.addNavLinkWidget(getMessage(LO_CATEGORIES), AppLocations.Locations.MANAGE_LO_CATEGORIES.getLocation()); |
159 | |
} |
160 | |
|
161 | 0 | if(Application.getApplicationContext().getSecurityContext().checkCachedScreenPermission(LUUIPermissions.USE_DEPENDENCY_ANALYSIS_SCREEN)){ |
162 | |
|
163 | 0 | tools.addNavLinkWidget(getMessage(DEP_ANALYSIS), AppLocations.Locations.DEPENDENCY_ANALYSIS.getLocation()); |
164 | |
} |
165 | |
|
166 | |
|
167 | 0 | layout.addContentBlock(create); |
168 | 0 | layout.addContentBlock(viewModify); |
169 | 0 | recent.addBlock(tools); |
170 | 0 | layout.addContentBlock(recent); |
171 | 0 | }} |
172 | |
); |
173 | 0 | return layout; |
174 | |
} |
175 | |
|
176 | |
private Widget getViewCredentialProgramWidget() { |
177 | |
final Widget searchWidget; |
178 | 0 | if (searchMetadata != null) { |
179 | 0 | Metadata metadata = searchMetadata.getProperties().get("findCredentialProgram"); |
180 | 0 | searchWidget = new KSPicker(metadata.getInitialLookup(), metadata.getAdditionalLookups()); |
181 | 0 | SearchPanel panel = ((KSPicker) searchWidget).getSearchPanel(); |
182 | 0 | if (panel != null) { |
183 | 0 | panel.setMutipleSelect(false); |
184 | |
} |
185 | 0 | ((KSPicker) searchWidget).setAdvancedSearchCallback(new Callback<List<SelectedResults>>() { |
186 | |
|
187 | |
@Override |
188 | |
public void exec(List<SelectedResults> result) { |
189 | 0 | SelectedResults value = result.get(0); |
190 | 0 | ViewContext viewContext = new ViewContext(); |
191 | 0 | viewContext.setId(value.getResultRow().getId()); |
192 | 0 | String cluType = value.getResultRow().getValue("lu.resultColumn.luOptionalType"); |
193 | 0 | if (cluType != null) { |
194 | 0 | viewContext.setAttribute(ProgramConstants.TYPE, cluType); |
195 | |
} |
196 | 0 | viewContext.setIdType(IdType.OBJECT_ID); |
197 | 0 | ProgramRegistry.setCreateNew(true); |
198 | 0 | Application.navigate(AppLocations.Locations.VIEW_BACC_PROGRAM.getLocation(), viewContext); |
199 | 0 | ((KSPicker) searchWidget).getSearchWindow().hide(); |
200 | 0 | } |
201 | |
}); |
202 | |
|
203 | 0 | } else { |
204 | 0 | searchWidget = new Label(getMessage(FIND_CREDENTIALS)); |
205 | 0 | searchWidget.setStyleName("contentBlock-navLink-disabled"); |
206 | |
} |
207 | 0 | searchWidget.setStyleName("contentBlock-navLink"); |
208 | 0 | return searchWidget; |
209 | |
} |
210 | |
|
211 | |
private Widget getViewCoreProgramWidget() { |
212 | |
final Widget searchWidget; |
213 | 0 | if (searchMetadata != null) { |
214 | 0 | Metadata metadata = searchMetadata.getProperties().get("findCoreProgram"); |
215 | 0 | searchWidget = new KSPicker(metadata.getInitialLookup(), metadata.getAdditionalLookups()); |
216 | 0 | SearchPanel panel = ((KSPicker) searchWidget).getSearchPanel(); |
217 | 0 | if (panel != null) { |
218 | 0 | panel.setMutipleSelect(false); |
219 | |
} |
220 | 0 | ((KSPicker) searchWidget).setAdvancedSearchCallback(new Callback<List<SelectedResults>>() { |
221 | |
|
222 | |
@Override |
223 | |
public void exec(List<SelectedResults> result) { |
224 | 0 | SelectedResults value = result.get(0); |
225 | 0 | ViewContext viewContext = new ViewContext(); |
226 | 0 | viewContext.setId(value.getResultRow().getId()); |
227 | 0 | String cluType = value.getResultRow().getValue("lu.resultColumn.luOptionalType"); |
228 | 0 | if (cluType != null) { |
229 | 0 | viewContext.setAttribute(ProgramConstants.TYPE, cluType); |
230 | |
} |
231 | 0 | viewContext.setIdType(IdType.OBJECT_ID); |
232 | 0 | ProgramRegistry.setCreateNew(true); |
233 | 0 | Application.navigate(AppLocations.Locations.VIEW_CORE_PROGRAM.getLocation(), viewContext); |
234 | 0 | ((KSPicker) searchWidget).getSearchWindow().hide(); |
235 | 0 | } |
236 | |
}); |
237 | |
|
238 | 0 | } else { |
239 | 0 | searchWidget = new Label(getMessage(FIND_CORES)); |
240 | 0 | searchWidget.setStyleName("contentBlock-navLink-disabled"); |
241 | |
} |
242 | 0 | searchWidget.setStyleName("contentBlock-navLink"); |
243 | 0 | return searchWidget; |
244 | |
} |
245 | |
|
246 | |
|
247 | |
|
248 | |
|
249 | |
|
250 | |
|
251 | |
|
252 | |
|
253 | |
|
254 | |
|
255 | |
protected Widget getFindCourseProposalsWidget(){ |
256 | 0 | return getFindProposalsWidget(true); |
257 | |
} |
258 | |
|
259 | |
|
260 | |
|
261 | |
|
262 | |
|
263 | |
|
264 | |
|
265 | |
protected Widget getFindProgramProposalsWidget(){ |
266 | 0 | return getFindProposalsWidget(false); |
267 | |
} |
268 | |
|
269 | |
|
270 | |
|
271 | |
|
272 | |
|
273 | |
|
274 | |
|
275 | |
|
276 | |
|
277 | |
|
278 | |
|
279 | |
|
280 | |
protected Widget getFindProposalsWidget(boolean isCourseSearch) { |
281 | |
final Widget searchWidget; |
282 | |
|
283 | |
|
284 | 0 | String searchMetadataPropName = ""; |
285 | 0 | if (isCourseSearch){ |
286 | 0 | searchMetadataPropName = "findCourseProposal"; |
287 | |
} |
288 | |
else { |
289 | 0 | searchMetadataPropName = "findProgramProposal"; |
290 | |
} |
291 | |
|
292 | 0 | if (searchMetadata != null) { |
293 | |
|
294 | |
|
295 | |
|
296 | 0 | Metadata metadata = searchMetadata.getProperties().get(searchMetadataPropName); |
297 | |
|
298 | 0 | searchWidget = new KSPicker(metadata.getInitialLookup(), metadata.getAdditionalLookups()); |
299 | 0 | SearchPanel panel = ((KSPicker) searchWidget).getSearchPanel(); |
300 | 0 | if (panel != null) { |
301 | 0 | panel.setMutipleSelect(false); |
302 | |
} |
303 | 0 | ((KSPicker) searchWidget).setAdvancedSearchCallback(new Callback<List<SelectedResults>>() { |
304 | |
|
305 | |
@Override |
306 | |
public void exec(List<SelectedResults> result) { |
307 | 0 | if (result != null && result.size() > 0) { |
308 | 0 | SelectedResults value = result.get(0); |
309 | 0 | ViewContext viewContext = new ViewContext(); |
310 | 0 | viewContext.setId(value.getResultRow().getId()); |
311 | 0 | String proposalType = value.getResultRow().getValue("proposal.resultColumn.proposalOptionalType"); |
312 | 0 | viewContext.setAttribute(StudentIdentityConstants.DOCUMENT_TYPE_NAME, proposalType); |
313 | 0 | viewContext.setIdType(IdType.KS_KEW_OBJECT_ID); |
314 | 0 | if("kuali.proposal.type.course.create.admin".equals(proposalType)||"kuali.proposal.type.course.modify.admin".equals(proposalType)){ |
315 | 0 | Application.navigate(AppLocations.Locations.COURSE_ADMIN.getLocation(), viewContext); |
316 | 0 | }else if (proposalType.startsWith("kuali.proposal.type.course")){ |
317 | 0 | Application.navigate(AppLocations.Locations.COURSE_PROPOSAL.getLocation(), viewContext); |
318 | |
} else { |
319 | 0 | ProgramRegistry.setCreateNew(true); |
320 | 0 | Application.navigate(AppLocations.Locations.PROGRAM_PROPOSAL.getLocation(), viewContext); |
321 | |
} |
322 | 0 | ((KSPicker) searchWidget).getSearchWindow().hide(); |
323 | |
} |
324 | 0 | } |
325 | |
}); |
326 | 0 | } else { |
327 | 0 | searchWidget = new Label(getMessage(FIND_PROPOSALS)); |
328 | 0 | searchWidget.setStyleName("contentBlock-navLink-disabled"); |
329 | |
} |
330 | 0 | searchWidget.setStyleName("contentBlock-navLink"); |
331 | 0 | return searchWidget; |
332 | |
} |
333 | |
|
334 | |
protected Widget getFindCoursesWidget() { |
335 | |
Widget searchWidget; |
336 | 0 | if (searchMetadata != null) { |
337 | 0 | Metadata metadata = searchMetadata.getProperties().get("findCourse"); |
338 | 0 | searchWidget = new KSPicker(metadata.getInitialLookup(), metadata.getAdditionalLookups()); |
339 | 0 | SearchPanel panel = ((KSPicker) searchWidget).getSearchPanel(); |
340 | 0 | if (panel != null) { |
341 | 0 | panel.setMutipleSelect(false); |
342 | |
} |
343 | 0 | ((KSPicker) searchWidget).addValuesChangeHandler(new ValueChangeHandler<List<String>>() { |
344 | |
public void onValueChange(ValueChangeEvent<List<String>> event) { |
345 | 0 | List<String> selection = event.getValue(); |
346 | 0 | ViewContext viewContext = new ViewContext(); |
347 | 0 | viewContext.setId(selection.get(0)); |
348 | 0 | viewContext.setIdType(IdType.OBJECT_ID); |
349 | 0 | Application.navigate(AppLocations.Locations.VIEW_COURSE.getLocation(), viewContext); |
350 | 0 | } |
351 | |
}); |
352 | 0 | searchWidget.setStyleName("contentBlock-navLink"); |
353 | 0 | } else { |
354 | 0 | searchWidget = new Label(getMessage(FIND_COURSES)); |
355 | 0 | searchWidget.setStyleName("contentBlock-navLink-disabled"); |
356 | |
} |
357 | 0 | return searchWidget; |
358 | |
} |
359 | |
|
360 | |
protected ClickHandler getCreateCourseClickHandler() { |
361 | 0 | return new ClickHandler(){ |
362 | |
|
363 | |
@Override |
364 | |
public void onClick(ClickEvent event) { |
365 | |
|
366 | |
|
367 | 0 | final KSLightBox dialog = new KSLightBox(getMessage("createCourse"),KSLightBox.Size.MEDIUM); |
368 | 0 | final VerticalPanel layout = new VerticalPanel(); |
369 | 0 | layout.addStyleName("ks-form-module-fields"); |
370 | |
|
371 | 0 | final KSButton startProposalButton = new KSButton(getMessage("startProposal")); |
372 | |
|
373 | 0 | dialog.addButton(startProposalButton); |
374 | 0 | KSButton cancelLink = new KSButton("Cancel", ButtonStyle.ANCHOR_LARGE_CENTERED, new ClickHandler(){ |
375 | |
public void onClick(ClickEvent event) { |
376 | 0 | dialog.hide(); |
377 | 0 | } |
378 | |
}); |
379 | 0 | dialog.addButton(cancelLink); |
380 | |
|
381 | 0 | HorizontalPanel titlePanel = new HorizontalPanel(); |
382 | 0 | KSLabel titleLabel = new KSLabel(getMessage("createCourseSubTitle")); |
383 | 0 | titleLabel.addStyleName("bold"); |
384 | 0 | AbbrButton helpButton = new AbbrButton(AbbrButtonType.HELP); |
385 | 0 | helpButton.setHoverHTML(getMessage("createCourseSubTitle-help")); |
386 | 0 | helpButton.getHoverPopup().getElement().getStyle().setZIndex(999999); |
387 | 0 | titlePanel.add(titleLabel); |
388 | 0 | titlePanel.add(helpButton); |
389 | |
|
390 | 0 | layout.add(titlePanel); |
391 | |
|
392 | 0 | KSLabel instructionText = new KSLabel(getMessage("createCourseSubTitle-instruct")); |
393 | |
|
394 | 0 | layout.add(instructionText); |
395 | |
|
396 | 0 | final CopyCourseSearchPanel copyCourseSearchPanel = new CopyCourseSearchPanel(searchMetadata, new Callback<Boolean>(){ |
397 | |
public void exec(Boolean result) { |
398 | 0 | if(result){ |
399 | 0 | startProposalButton.setEnabled(true); |
400 | |
}else{ |
401 | 0 | startProposalButton.setEnabled(false); |
402 | |
} |
403 | 0 | } |
404 | |
}, getMessage("courseToCopy"), getMessage("courseInvalidValue"), new String[]{getMessage("selectByCourseCode"), getMessage("selectByCourseTitle")}, new String[]{"approvedCourses", "approvedCoursesByTitle"}); |
405 | |
|
406 | |
|
407 | 0 | final CopyCourseSearchPanel copyProposalSearchPanel = new CopyCourseSearchPanel(searchMetadata, new Callback<Boolean>(){ |
408 | |
public void exec(Boolean result) { |
409 | 0 | if(result){ |
410 | 0 | startProposalButton.setEnabled(true); |
411 | |
}else{ |
412 | 0 | startProposalButton.setEnabled(false); |
413 | |
} |
414 | 0 | } |
415 | |
}, getMessage("proposalToCopy"), getMessage("proposalInvalidValue"), new String[]{getMessage("selectByProposalTitle"), getMessage("selectByProposedCourse")}, new String[]{"proposedCoursesByTitle", "proposedCoursesByCode"}); |
416 | |
|
417 | 0 | final KSRadioButton radioOptionBlank = new KSRadioButton("createNewCreditCourseButtonGroup", getMessage("startBlankProposal")); |
418 | 0 | final KSRadioButton radioOptionCopyCourse = new KSRadioButton("createNewCreditCourseButtonGroup", getMessage("copyApprovedCourse")); |
419 | 0 | final KSRadioButton radioOptionCopyProposal = new KSRadioButton("createNewCreditCourseButtonGroup", getMessage("copyProposedCourse")); |
420 | |
|
421 | 0 | radioOptionBlank.addValueChangeHandler(new ValueChangeHandler<Boolean>(){ |
422 | |
public void onValueChange(ValueChangeEvent<Boolean> event) { |
423 | |
|
424 | 0 | copyCourseSearchPanel.setVisible(false); |
425 | 0 | copyProposalSearchPanel.setVisible(false); |
426 | 0 | startProposalButton.setEnabled(true); |
427 | 0 | useCurricReviewCheckbox.setEnabled(true); |
428 | |
|
429 | 0 | } |
430 | |
}); |
431 | 0 | radioOptionBlank.setValue(true); |
432 | |
|
433 | 0 | radioOptionCopyCourse.addValueChangeHandler(new ValueChangeHandler<Boolean>(){ |
434 | |
public void onValueChange(ValueChangeEvent<Boolean> event) { |
435 | 0 | if(event.getValue()){ |
436 | 0 | copyCourseSearchPanel.setVisible(true); |
437 | 0 | copyProposalSearchPanel.setVisible(false); |
438 | 0 | useCurricReviewCheckbox.setEnabled(false); |
439 | 0 | copyCourseSearchPanel.clear(); |
440 | 0 | copyProposalSearchPanel.clear(); |
441 | 0 | startProposalButton.setEnabled(false); |
442 | |
} |
443 | 0 | } |
444 | |
}); |
445 | |
|
446 | 0 | radioOptionCopyProposal.addValueChangeHandler(new ValueChangeHandler<Boolean>(){ |
447 | |
public void onValueChange(ValueChangeEvent<Boolean> event) { |
448 | 0 | if(event.getValue()){ |
449 | 0 | copyCourseSearchPanel.setVisible(false); |
450 | 0 | copyProposalSearchPanel.setVisible(true); |
451 | 0 | useCurricReviewCheckbox.setEnabled(false); |
452 | 0 | copyCourseSearchPanel.clear(); |
453 | 0 | copyProposalSearchPanel.clear(); |
454 | 0 | startProposalButton.setEnabled(false); |
455 | |
} |
456 | 0 | } |
457 | |
}); |
458 | |
|
459 | |
|
460 | 0 | Application.getApplicationContext().getSecurityContext().checkScreenPermission("useCurriculumReview", new Callback<Boolean>() { |
461 | |
|
462 | |
@Override |
463 | |
public void exec(Boolean result) { |
464 | |
|
465 | 0 | final boolean isAuthorized = result; |
466 | |
|
467 | |
|
468 | 0 | if (isAuthorized){ |
469 | |
|
470 | |
|
471 | 0 | useCurricReviewCheckbox.setValue(false); |
472 | 0 | useCurricReviewCheckbox.setVisible(true); |
473 | |
} else { |
474 | |
|
475 | 0 | useCurricReviewCheckbox.setValue(true); |
476 | 0 | useCurricReviewCheckbox.setVisible(false); |
477 | |
} |
478 | |
|
479 | |
|
480 | 0 | layout.add(radioOptionBlank); |
481 | 0 | layout.add(radioOptionCopyCourse); |
482 | 0 | layout.add(copyCourseSearchPanel); |
483 | 0 | layout.add(radioOptionCopyProposal); |
484 | 0 | layout.add(copyProposalSearchPanel); |
485 | 0 | layout.add(new KSLabel("")); |
486 | 0 | layout.add(useCurricReviewCheckbox); |
487 | |
|
488 | |
|
489 | 0 | startProposalButton.addClickHandler(new ClickHandler(){ |
490 | |
public void onClick(ClickEvent event) { |
491 | |
|
492 | |
|
493 | |
|
494 | 0 | ViewContext viewContext = new ViewContext(); |
495 | |
|
496 | |
|
497 | 0 | if(radioOptionBlank.getValue()) { |
498 | |
|
499 | |
|
500 | |
|
501 | 0 | } else if (radioOptionCopyCourse.getValue()) { |
502 | |
|
503 | 0 | viewContext.setId(copyCourseSearchPanel.getValue()); |
504 | 0 | viewContext.setIdType(IdType.COPY_OF_OBJECT_ID); |
505 | |
|
506 | |
|
507 | 0 | } else if(radioOptionCopyProposal.getValue()){ |
508 | |
|
509 | 0 | viewContext.setId(copyProposalSearchPanel.getValue()); |
510 | 0 | viewContext.setIdType(IdType.COPY_OF_KS_KEW_OBJECT_ID); |
511 | |
} |
512 | |
|
513 | |
|
514 | 0 | if (useCurricReviewCheckbox.getValue()){ |
515 | 0 | Application.navigate(AppLocations.Locations.COURSE_PROPOSAL.getLocation(),viewContext); |
516 | |
} else { |
517 | 0 | Application.navigate(AppLocations.Locations.COURSE_ADMIN.getLocation(),viewContext); |
518 | |
} |
519 | |
|
520 | 0 | dialog.hide(); |
521 | 0 | } |
522 | |
}); |
523 | |
|
524 | 0 | dialog.setWidget(layout); |
525 | 0 | dialog.show(); |
526 | 0 | } |
527 | |
}); |
528 | 0 | } |
529 | |
}; |
530 | |
} |
531 | |
|
532 | |
protected Widget getFindMajorsWidget() { |
533 | |
final Widget searchWidget; |
534 | 0 | if (searchMetadata != null) { |
535 | 0 | Metadata metadata = searchMetadata.getProperties().get("findMajor"); |
536 | 0 | searchWidget = new KSPicker(metadata.getInitialLookup(), metadata.getAdditionalLookups()); |
537 | 0 | SearchPanel panel = ((KSPicker) searchWidget).getSearchPanel(); |
538 | 0 | if (panel != null) { |
539 | 0 | panel.setMutipleSelect(false); |
540 | |
} |
541 | 0 | ((KSPicker) searchWidget).setAdvancedSearchCallback(new Callback<List<SelectedResults>>() { |
542 | |
|
543 | |
@Override |
544 | |
public void exec(List<SelectedResults> result) { |
545 | 0 | SelectedResults value = result.get(0); |
546 | 0 | ViewContext viewContext = new ViewContext(); |
547 | 0 | viewContext.setId(value.getResultRow().getId()); |
548 | 0 | String cluType = value.getResultRow().getValue("lu.resultColumn.luOptionalType"); |
549 | 0 | if (cluType != null) { |
550 | 0 | viewContext.setAttribute(ProgramConstants.TYPE, cluType); |
551 | |
} |
552 | 0 | String variationId = value.getResultRow().getValue("lu.resultColumn.variationId"); |
553 | 0 | if (variationId != null && !variationId.trim().isEmpty()) { |
554 | 0 | viewContext.setAttribute(ProgramConstants.VARIATION_ID, variationId); |
555 | |
} |
556 | 0 | viewContext.setIdType(IdType.OBJECT_ID); |
557 | 0 | ProgramRegistry.setCreateNew(true); |
558 | 0 | Application.navigate(AppLocations.Locations.VIEW_PROGRAM.getLocation(), viewContext); |
559 | 0 | ((KSPicker) searchWidget).getSearchWindow().hide(); |
560 | 0 | } |
561 | |
}); |
562 | |
|
563 | 0 | } else { |
564 | 0 | searchWidget = new Label(getMessage(FIND_MAJORS)); |
565 | 0 | searchWidget.setStyleName("contentBlock-navLink-disabled"); |
566 | |
} |
567 | 0 | searchWidget.setStyleName("contentBlock-navLink"); |
568 | 0 | return searchWidget; |
569 | |
} |
570 | |
|
571 | |
protected Widget getHowToWidget() { |
572 | 0 | Anchor widget = new Anchor(getMessage(HOW_TO)); |
573 | 0 | widget.addClickHandler(new ClickHandler() { |
574 | |
|
575 | |
@Override |
576 | |
public void onClick(ClickEvent event) { |
577 | 0 | final KSLightBox pop = new KSLightBox(); |
578 | 0 | pop.setWidget((Widget)GWT.create(CurriculumHomeHelpTable.class)); |
579 | |
|
580 | 0 | pop.setSize(800, 680); |
581 | 0 | pop.show(); |
582 | 0 | } |
583 | |
}); |
584 | 0 | widget.setStyleName("contentBlock-navLink"); |
585 | 0 | return widget; |
586 | |
} |
587 | |
|
588 | |
protected Widget getActionListLink() { |
589 | 0 | Hyperlink widget = new Hyperlink(getMessage(ACTIONLIST), AppLocations.Locations.HOME.getLocation()); |
590 | 0 | widget.setStyleName("contentBlock-navLink"); |
591 | 0 | return widget; |
592 | |
} |
593 | |
|
594 | |
private String getMessage(String key) { |
595 | 0 | return Application.getApplicationContext().getMessage(key); |
596 | |
} |
597 | |
|
598 | |
} |