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