1 | |
package org.kuali.student.lum.lu.ui.course.client.configuration; |
2 | |
|
3 | |
import org.kuali.student.common.dto.DtoConstants; |
4 | |
import org.kuali.student.common.ui.client.configurable.mvc.FieldDescriptor; |
5 | |
import org.kuali.student.common.ui.client.configurable.mvc.SectionTitle; |
6 | |
import org.kuali.student.common.ui.client.configurable.mvc.sections.RequiredContainer; |
7 | |
import org.kuali.student.common.ui.client.configurable.mvc.sections.Section; |
8 | |
import org.kuali.student.common.ui.client.configurable.mvc.sections.VerticalSection; |
9 | |
import org.kuali.student.common.ui.client.configurable.mvc.views.VerticalSectionView; |
10 | |
import org.kuali.student.common.ui.client.mvc.Callback; |
11 | |
import org.kuali.student.common.ui.client.mvc.View; |
12 | |
import org.kuali.student.common.ui.client.widgets.KSLabel; |
13 | |
import org.kuali.student.lum.common.client.lu.LUUIConstants; |
14 | |
import org.kuali.student.lum.lu.assembly.data.client.constants.base.RichTextInfoConstants; |
15 | |
import org.kuali.student.lum.lu.ui.course.client.controllers.CourseAdminController; |
16 | |
import org.kuali.student.lum.lu.ui.course.client.controllers.CourseAdminWithoutVersionController; |
17 | |
import org.kuali.student.lum.lu.ui.course.client.controllers.CourseProposalController; |
18 | |
import org.kuali.student.lum.lu.ui.course.client.requirements.CourseRequirementsViewController; |
19 | |
|
20 | |
import com.google.gwt.event.dom.client.ClickEvent; |
21 | |
import com.google.gwt.event.dom.client.ClickHandler; |
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | 0 | public class CourseAdminWithoutVersionConfigurer extends CourseProposalConfigurer{ |
30 | |
protected CourseRequirementsViewController requisitesSection; |
31 | |
|
32 | 0 | private RequiredContainer requiredContainer = new RequiredContainer(); |
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
@Override |
41 | |
public void configure(final CourseProposalController layout) { |
42 | 0 | type = "course"; |
43 | 0 | state = DtoConstants.STATE_APPROVED; |
44 | 0 | nextState = DtoConstants.STATE_ACTIVE; |
45 | |
|
46 | 0 | groupName = LUUIConstants.COURSE_GROUP_NAME; |
47 | |
|
48 | 0 | KSLabel courseStatusLabel = new KSLabel(""); |
49 | 0 | if (layout.getCourseState() != null) |
50 | 0 | courseStatusLabel.setText("Status: " + layout.getCourseState()); |
51 | |
else |
52 | 0 | courseStatusLabel.setText("Status: Unknown"); |
53 | 0 | layout.addContentWidget(courseStatusLabel); |
54 | |
|
55 | 0 | layout.addInfoWidget(requiredContainer); |
56 | 0 | layout.addView(generateCourseAdminView((CourseAdminWithoutVersionController)layout)); |
57 | 0 | } |
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
|
64 | |
protected View generateCourseAdminView(final CourseAdminWithoutVersionController layout) { |
65 | 0 | VerticalSectionView view = |
66 | |
new VerticalSectionView(CourseSections.COURSE_INFO, getLabel(LUUIConstants.INFORMATION_LABEL_KEY), COURSE_PROPOSAL_MODEL, false); |
67 | 0 | view.addStyleName(LUUIConstants.STYLE_SECTION); |
68 | |
|
69 | |
|
70 | 0 | Section courseSection = generateCourseInfoSection(initSection(LUUIConstants.INFORMATION_LABEL_KEY)); |
71 | 0 | Section governanceSection = generateGovernanceSection(initSection(LUUIConstants.GOVERNANCE_LABEL_KEY)); |
72 | 0 | Section logisticsSection = generateCourseLogisticsSection(initSection(LUUIConstants.LOGISTICS_LABEL_KEY)); |
73 | 0 | Section loSection = initSection(LUUIConstants.LEARNING_OBJECTIVES_LABEL_KEY); |
74 | 0 | loSection.addSection(generateLearningObjectivesNestedSection()); |
75 | 0 | Section activeDatesSection = generateActiveDatesSection(initSection(LUUIConstants.ACTIVE_DATES_LABEL_KEY)); |
76 | 0 | Section financialSection = generateFinancialsSection(initSection(LUUIConstants.FINANCIALS_LABEL_KEY)); |
77 | 0 | Section retireSection = generateRetirementSection(initSection(LUUIConstants.RETIREMENT_LABEL_KEY)); |
78 | |
|
79 | |
|
80 | 0 | requisitesSection = new CourseRequirementsViewController(layout, getLabel(LUUIConstants.REQUISITES_LABEL_KEY), CourseSections.COURSE_REQUISITES, false, false); |
81 | |
|
82 | |
|
83 | 0 | view.addSection(courseSection); |
84 | 0 | view.addSection(governanceSection); |
85 | 0 | view.addSection(logisticsSection); |
86 | 0 | view.addSection(loSection); |
87 | 0 | view.addView(requisitesSection); |
88 | 0 | view.addSection(this.createHiddenRequisitesSection()); |
89 | 0 | view.addSection(activeDatesSection); |
90 | 0 | view.addSection(financialSection); |
91 | 0 | view.addSection(retireSection); |
92 | |
|
93 | |
|
94 | 0 | String sections = getLabel(LUUIConstants.COURSE_SECTIONS); |
95 | 0 | layout.addMenu(sections); |
96 | 0 | layout.addMenuItemSection(sections, getLabel(LUUIConstants.INFORMATION_LABEL_KEY), LUUIConstants.INFORMATION_LABEL_KEY, courseSection.getLayout()); |
97 | 0 | layout.addMenuItemSection(sections, getLabel(LUUIConstants.GOVERNANCE_LABEL_KEY), LUUIConstants.GOVERNANCE_LABEL_KEY, governanceSection.getLayout()); |
98 | 0 | layout.addMenuItemSection(sections, getLabel(LUUIConstants.LOGISTICS_LABEL_KEY), LUUIConstants.LOGISTICS_LABEL_KEY, logisticsSection.getLayout()); |
99 | 0 | layout.addMenuItemSection(sections, getLabel(LUUIConstants.LEARNING_OBJECTIVE_LABEL_KEY), LUUIConstants.LEARNING_OBJECTIVE_LABEL_KEY, loSection.getLayout()); |
100 | 0 | layout.addMenuItemSection(sections, getLabel(LUUIConstants.REQUISITES_LABEL_KEY), LUUIConstants.REQUISITES_LABEL_KEY, requisitesSection); |
101 | 0 | layout.addMenuItemSection(sections, getLabel(LUUIConstants.ACTIVE_DATES_LABEL_KEY), LUUIConstants.ACTIVE_DATES_LABEL_KEY, activeDatesSection.getLayout()); |
102 | 0 | layout.addMenuItemSection(sections, getLabel(LUUIConstants.FINANCIALS_LABEL_KEY), LUUIConstants.FINANCIALS_LABEL_KEY, financialSection.getLayout()); |
103 | 0 | layout.addMenuItemSection(sections, getLabel(LUUIConstants.RETIREMENT_LABEL_KEY), LUUIConstants.RETIREMENT_LABEL_KEY, retireSection.getLayout()); |
104 | |
|
105 | |
|
106 | 0 | layout.addButtonForView(CourseSections.COURSE_INFO, layout.getSaveButton()); |
107 | 0 | layout.addButtonForView(CourseSections.COURSE_INFO, layout.getCancelButton()); |
108 | 0 | layout.addTopButtonForView(CourseSections.COURSE_INFO, layout.getSaveButton()); |
109 | 0 | layout.addTopButtonForView(CourseSections.COURSE_INFO, layout.getCancelButton()); |
110 | |
|
111 | 0 | requiredContainer.setMainSection(view); |
112 | |
|
113 | 0 | return view; |
114 | |
} |
115 | |
|
116 | |
|
117 | |
|
118 | |
|
119 | |
|
120 | |
|
121 | |
@Override |
122 | |
public Section generateCourseInfoSection(Section section) { |
123 | 0 | addField(section, COURSE + "/" + COURSE_TITLE, generateMessageInfo(LUUIConstants.COURSE_TITLE_LABEL_KEY)); |
124 | 0 | addField(section, COURSE + "/" + TRANSCRIPT_TITLE, generateMessageInfo(LUUIConstants.SHORT_TITLE_LABEL_KEY)); |
125 | 0 | section.addSection(generateCourseNumberSection()); |
126 | 0 | FieldDescriptor instructorsFd = addField(section, COURSE + "/" + INSTRUCTORS, generateMessageInfo(LUUIConstants.INSTRUCTORS_LABEL_KEY)); |
127 | 0 | instructorsFd.setWidgetBinding(new KeyListModelWigetBinding("personId")); |
128 | |
|
129 | 0 | section.addSection(generateDescriptionRationaleSection()); |
130 | |
|
131 | 0 | return section; |
132 | |
} |
133 | |
|
134 | |
|
135 | |
|
136 | |
|
137 | |
|
138 | |
|
139 | |
@Override |
140 | |
protected VerticalSection generateDescriptionRationaleSection() { |
141 | 0 | SectionTitle title = getH4Title(LUUIConstants.PROPOSAL_TITLE_SECTION_LABEL_KEY); |
142 | 0 | VerticalSection description = initSection(title, !WITH_DIVIDER); |
143 | 0 | title.setStyleName("cluProposalTitleSection"); |
144 | 0 | addField(description, COURSE + "/" + DESCRIPTION + "/" + RichTextInfoConstants.PLAIN, generateMessageInfo(LUUIConstants.DESCRIPTION_LABEL_KEY)); |
145 | 0 | return description; |
146 | |
} |
147 | |
|
148 | |
public CourseRequirementsViewController getRequisitesSection(CourseAdminController layout) { |
149 | 0 | if(requisitesSection == null){ |
150 | 0 | requisitesSection = new CourseRequirementsViewController(layout, getLabel(LUUIConstants.REQUISITES_LABEL_KEY), CourseSections.COURSE_REQUISITES, false, false); |
151 | |
} |
152 | 0 | return requisitesSection; |
153 | |
} |
154 | |
|
155 | |
protected Section generateRetirementSection(Section section) { |
156 | 0 | addField(section, COURSE + "/" + RETIREMENT_RATIONALE, generateMessageInfo(LUUIConstants.RETIREMENT_RATIONALE_LABEL_KEY)); |
157 | 0 | addField(section, COURSE + "/" + LAST_TERM_OFFERED, generateMessageInfo(LUUIConstants.LAST_TERM_OFFERED_LABEL_KEY)); |
158 | 0 | addField(section, COURSE + "/" + LAST_PUBLICATION_YEAR, generateMessageInfo(LUUIConstants.LAST_PUBLICATION_YEAR_LABEL_KEY)); |
159 | 0 | addField(section, COURSE + "/" + SPECIAL_CIRCUMSTANCES, generateMessageInfo(LUUIConstants.SPECIAL_CIRCUMSTANCES_LABEL_KEY)); |
160 | |
|
161 | 0 | return section; |
162 | |
} |
163 | |
protected VerticalSection initSection(String labelKey) { |
164 | 0 | final VerticalSection section = initSection(SectionTitle.generateH2Title(getLabel(labelKey)), NO_DIVIDER); |
165 | |
|
166 | 0 | section.addShowAllLink(requiredContainer.createShowAllLink(new ClickHandler() { |
167 | |
|
168 | |
@Override |
169 | |
public void onClick(ClickEvent event) { |
170 | 0 | requiredContainer.processInnerSection(section, true); |
171 | 0 | section.getShowAllLink().setVisible(false); |
172 | 0 | } |
173 | |
})); |
174 | |
|
175 | 0 | return section; |
176 | |
} |
177 | |
|
178 | |
private VerticalSection createHiddenRequisitesSection() { |
179 | 0 | final VerticalSection section = initSection(SectionTitle.generateH2Title(getLabel(LUUIConstants.REQUISITES_LABEL_KEY)), NO_DIVIDER); |
180 | |
|
181 | 0 | section.addShowAllLink(requiredContainer.createShowAllLink(new ClickHandler() { |
182 | |
|
183 | |
@Override |
184 | |
public void onClick(ClickEvent event) { |
185 | 0 | requisitesSection.asWidget().setVisible(true); |
186 | 0 | section.getLayout().setVisible(false); |
187 | 0 | } |
188 | |
})); |
189 | |
|
190 | |
|
191 | 0 | requiredContainer.addCallback(new Callback<Boolean>() { |
192 | |
|
193 | |
@Override |
194 | |
public void exec(Boolean result) { |
195 | 0 | requisitesSection.asWidget().setVisible(result); |
196 | 0 | section.getLayout().setVisible(!result); |
197 | 0 | } |
198 | |
}); |
199 | 0 | return section; |
200 | |
} |
201 | |
|
202 | |
public CourseRequirementsViewController getRequisitesSection() { |
203 | 0 | return requisitesSection; |
204 | |
} |
205 | |
|
206 | |
} |