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