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