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.Controller; |
12 | |
import org.kuali.student.common.ui.client.mvc.DataModelDefinition; |
13 | |
import org.kuali.student.common.ui.client.mvc.View; |
14 | |
import org.kuali.student.common.ui.client.widgets.KSButton; |
15 | |
import org.kuali.student.common.ui.client.widgets.KSButtonAbstract.ButtonStyle; |
16 | |
import org.kuali.student.common.ui.client.widgets.KSCheckBox; |
17 | |
import org.kuali.student.core.comments.ui.client.widgets.commenttool.CommentTool; |
18 | |
import org.kuali.student.core.document.ui.client.widgets.documenttool.DocumentTool; |
19 | |
import org.kuali.student.lum.common.client.lu.LUUIConstants; |
20 | |
import org.kuali.student.lum.lu.ui.course.client.controllers.CourseAdminController; |
21 | |
import org.kuali.student.lum.lu.ui.course.client.controllers.CourseProposalController; |
22 | |
import org.kuali.student.lum.lu.ui.course.client.requirements.CourseRequirementsViewController; |
23 | |
|
24 | |
import com.google.gwt.event.dom.client.ClickEvent; |
25 | |
import com.google.gwt.event.dom.client.ClickHandler; |
26 | |
import com.google.gwt.user.client.ui.Composite; |
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | 0 | public class CourseAdminConfigurer extends CourseProposalConfigurer{ |
36 | |
|
37 | |
protected CourseRequirementsViewController requisitesSection; |
38 | |
|
39 | 0 | private RequiredContainer requiredContainer = new RequiredContainer(); |
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
public void configure(final CourseProposalController layout) { |
49 | 0 | type = "course"; |
50 | 0 | state = DtoConstants.STATE_DRAFT; |
51 | 0 | nextState = DtoConstants.STATE_ACTIVE; |
52 | |
|
53 | 0 | groupName = LUUIConstants.COURSE_GROUP_NAME; |
54 | |
|
55 | 0 | layout.addContentWidget(layout.getWfUtilities().getWorkflowStatusLabel()); |
56 | 0 | if (modelDefinition.getMetadata().isCanEdit()) { |
57 | 0 | layout.addInfoWidget(requiredContainer); |
58 | 0 | layout.addView(generateCourseAdminView((CourseAdminController) layout)); |
59 | |
} else { |
60 | 0 | CourseSummaryConfigurer summaryConfigurer = new CourseSummaryConfigurer(type, state, groupName, (DataModelDefinition) modelDefinition, stmtTypes, (Controller) layout, COURSE_PROPOSAL_MODEL); |
61 | 0 | layout.removeMenuNavigation(); |
62 | 0 | layout.addView(summaryConfigurer.generateProposalSummarySection(false)); |
63 | |
} |
64 | 0 | } |
65 | |
|
66 | |
|
67 | |
|
68 | |
|
69 | |
|
70 | |
|
71 | |
protected View generateCourseAdminView(final CourseAdminController layout) { |
72 | 0 | VerticalSectionView view = |
73 | |
new VerticalSectionView(CourseSections.COURSE_INFO, getLabel(LUUIConstants.INFORMATION_LABEL_KEY), COURSE_PROPOSAL_MODEL, false); |
74 | 0 | view.addStyleName(LUUIConstants.STYLE_SECTION); |
75 | |
|
76 | |
|
77 | 0 | Section courseSection = generateCourseInfoSection(initSection(LUUIConstants.INFORMATION_LABEL_KEY)); |
78 | 0 | Section governanceSection = generateGovernanceSection(initSection(LUUIConstants.GOVERNANCE_LABEL_KEY)); |
79 | 0 | Section logisticsSection = generateCourseLogisticsSection(initSection(LUUIConstants.LOGISTICS_LABEL_KEY)); |
80 | 0 | Section loSection = initSection(LUUIConstants.LEARNING_OBJECTIVES_LABEL_KEY); |
81 | 0 | loSection.addSection(generateLearningObjectivesNestedSection()); |
82 | 0 | Section activeDatesSection = generateActiveDatesSection(initSection(LUUIConstants.ACTIVE_DATES_LABEL_KEY)); |
83 | 0 | Section financialSection = generateFinancialsSection(initSection(LUUIConstants.FINANCIALS_LABEL_KEY)); |
84 | |
|
85 | |
|
86 | 0 | requisitesSection = new CourseRequirementsViewController(layout, getLabel(LUUIConstants.REQUISITES_LABEL_KEY), CourseSections.COURSE_REQUISITES, false, false); |
87 | |
|
88 | |
|
89 | 0 | documentTool = new DocumentTool(LUUIConstants.REF_DOC_RELATION_PROPOSAL_TYPE,CourseSections.DOCUMENTS, getLabel(LUUIConstants.TOOL_DOCUMENTS_LABEL_KEY)); |
90 | 0 | documentTool.setModelDefinition((DataModelDefinition)modelDefinition); |
91 | 0 | documentTool.setController(layout); |
92 | 0 | documentTool.setTitle(getLabel(LUUIConstants.TOOL_DOCUMENTS_LABEL_KEY)); |
93 | 0 | documentTool.addStyleName(LUUIConstants.STYLE_SECTION); |
94 | |
|
95 | |
|
96 | 0 | final CommentTool commentTool = new CommentTool(CourseSections.COMMENTS, getLabel(LUUIConstants.TOOL_COMMENTS_LABEL_KEY), "kuali.comment.type.generalRemarks", "Proposal Comments"); |
97 | 0 | commentTool.setController(layout); |
98 | 0 | layout.addContentWidget(new KSButton("Comments", ButtonStyle.DEFAULT_ANCHOR, new ClickHandler() { |
99 | |
|
100 | |
@Override |
101 | |
public void onClick(ClickEvent event) { |
102 | 0 | commentTool.show(); |
103 | 0 | } |
104 | |
})); |
105 | |
|
106 | |
|
107 | |
|
108 | 0 | view.addSection(courseSection); |
109 | 0 | view.addSection(governanceSection); |
110 | 0 | view.addSection(logisticsSection); |
111 | 0 | view.addSection(loSection); |
112 | 0 | view.addView(requisitesSection); |
113 | 0 | view.addSection(this.createHiddenRequisitesSection()); |
114 | 0 | view.addSection(LUUIConstants.ACTIVE_DATES_LABEL_KEY,activeDatesSection); |
115 | 0 | view.addSection(financialSection); |
116 | 0 | view.addView(documentTool); |
117 | |
|
118 | |
|
119 | 0 | String sections = getLabel(LUUIConstants.COURSE_SECTIONS); |
120 | 0 | layout.addMenu(sections); |
121 | 0 | layout.addMenuItemSection(sections, getLabel(LUUIConstants.INFORMATION_LABEL_KEY), LUUIConstants.INFORMATION_LABEL_KEY, courseSection.getLayout()); |
122 | 0 | layout.addMenuItemSection(sections, getLabel(LUUIConstants.GOVERNANCE_LABEL_KEY), LUUIConstants.GOVERNANCE_LABEL_KEY, governanceSection.getLayout()); |
123 | 0 | layout.addMenuItemSection(sections, getLabel(LUUIConstants.LOGISTICS_LABEL_KEY), LUUIConstants.LOGISTICS_LABEL_KEY, logisticsSection.getLayout()); |
124 | 0 | layout.addMenuItemSection(sections, getLabel(LUUIConstants.LEARNING_OBJECTIVE_LABEL_KEY), LUUIConstants.LEARNING_OBJECTIVE_LABEL_KEY, loSection.getLayout()); |
125 | 0 | layout.addMenuItemSection(sections, getLabel(LUUIConstants.REQUISITES_LABEL_KEY), LUUIConstants.REQUISITES_LABEL_KEY, requisitesSection); |
126 | 0 | layout.addMenuItemSection(sections, getLabel(LUUIConstants.ACTIVE_DATES_LABEL_KEY), LUUIConstants.ACTIVE_DATES_LABEL_KEY, activeDatesSection.getLayout()); |
127 | 0 | layout.addMenuItemSection(sections, getLabel(LUUIConstants.FINANCIALS_LABEL_KEY), LUUIConstants.FINANCIALS_LABEL_KEY, financialSection.getLayout()); |
128 | 0 | layout.addMenuItemSection(sections, getLabel(LUUIConstants.TOOL_DOCUMENTS_LABEL_KEY), LUUIConstants.TOOL_DOCUMENTS_LABEL_KEY, financialSection.getLayout()); |
129 | |
|
130 | |
|
131 | 0 | layout.addButtonForView(CourseSections.COURSE_INFO, layout.getApproveAndActivateButton()); |
132 | 0 | layout.addButtonForView(CourseSections.COURSE_INFO, layout.getSaveButton()); |
133 | 0 | layout.addButtonForView(CourseSections.COURSE_INFO, layout.getCancelButton()); |
134 | 0 | layout.addTopButtonForView(CourseSections.COURSE_INFO, layout.getApproveAndActivateButton()); |
135 | 0 | layout.addTopButtonForView(CourseSections.COURSE_INFO, layout.getSaveButton()); |
136 | 0 | layout.addTopButtonForView(CourseSections.COURSE_INFO, layout.getCancelButton()); |
137 | |
|
138 | |
|
139 | 0 | this.addDocToolLink(); |
140 | 0 | requiredContainer.setMainSection(view); |
141 | |
|
142 | 0 | return view; |
143 | |
} |
144 | |
|
145 | |
|
146 | |
|
147 | |
|
148 | |
@Override |
149 | |
protected Section generateActiveDatesSection(Section section) { |
150 | 0 | FieldDescriptor fd = addField(section, PROPOSAL_PATH + "/" + PREV_START_TERM, generateMessageInfo(LUUIConstants.PROPOSAL_PREV_START_TERM)); |
151 | 0 | fd.getFieldWidget().setVisible(false); |
152 | 0 | fd.hideLabel(); |
153 | |
|
154 | 0 | addField(section, COURSE + "/" + START_TERM, generateMessageInfo(LUUIConstants.START_TERM_LABEL_KEY)); |
155 | |
|
156 | 0 | addField(section, COURSE + "/" + PILOT_COURSE, generateMessageInfo(LUUIConstants.PILOT_COURSE_LABEL_KEY), new KSCheckBox(getLabel(LUUIConstants.PILOT_COURSE_TEXT_LABEL_KEY))); |
157 | 0 | addField(section, COURSE + "/" + END_TERM, generateMessageInfo(LUUIConstants.END_TERM_LABEL_KEY)); |
158 | |
|
159 | 0 | return section; |
160 | |
} |
161 | |
|
162 | |
|
163 | |
|
164 | |
|
165 | |
|
166 | |
|
167 | |
|
168 | |
public CourseRequirementsViewController getRequisitesSection() { |
169 | 0 | return requisitesSection; |
170 | |
} |
171 | |
|
172 | |
|
173 | |
|
174 | |
|
175 | |
|
176 | |
|
177 | |
|
178 | |
public DocumentTool getDocumentTool() { |
179 | 0 | return documentTool; |
180 | |
} |
181 | |
|
182 | |
protected VerticalSection initSection(String labelKey) { |
183 | 0 | final VerticalSection section = initSection(SectionTitle.generateH2Title(getLabel(labelKey)), NO_DIVIDER); |
184 | |
|
185 | 0 | section.addShowAllLink(requiredContainer.createShowAllLink(new ClickHandler() { |
186 | |
|
187 | |
@Override |
188 | |
public void onClick(ClickEvent event) { |
189 | 0 | requiredContainer.processInnerSection(section, true); |
190 | 0 | section.getShowAllLink().setVisible(false); |
191 | 0 | } |
192 | |
})); |
193 | |
|
194 | 0 | return section; |
195 | |
} |
196 | |
|
197 | |
private VerticalSection createHiddenRequisitesSection() { |
198 | 0 | final VerticalSection section = initSection(SectionTitle.generateH2Title(getLabel(LUUIConstants.REQUISITES_LABEL_KEY)), NO_DIVIDER); |
199 | |
|
200 | 0 | section.addShowAllLink(requiredContainer.createShowAllLink(new ClickHandler() { |
201 | |
|
202 | |
@Override |
203 | |
public void onClick(ClickEvent event) { |
204 | 0 | requisitesSection.asWidget().setVisible(true); |
205 | 0 | section.getLayout().setVisible(false); |
206 | 0 | } |
207 | |
})); |
208 | |
|
209 | |
|
210 | 0 | requiredContainer.addCallback(new Callback<Boolean>() { |
211 | |
|
212 | |
@Override |
213 | |
public void exec(Boolean result) { |
214 | 0 | requisitesSection.asWidget().setVisible(result); |
215 | 0 | section.getLayout().setVisible(!result); |
216 | 0 | } |
217 | |
}); |
218 | 0 | return section; |
219 | |
} |
220 | |
|
221 | |
private void addDocToolLink(){ |
222 | 0 | Composite container = requiredContainer.createShowAllLink(new ClickHandler() { |
223 | |
|
224 | |
@Override |
225 | |
public void onClick(ClickEvent event) { |
226 | 0 | documentTool.showShowAllLink(false); |
227 | 0 | } |
228 | |
}); |
229 | |
|
230 | |
|
231 | 0 | requiredContainer.addCallback(new Callback<Boolean>() { |
232 | |
|
233 | |
@Override |
234 | |
public void exec(Boolean result) { |
235 | 0 | documentTool.showShowAllLink(!result); |
236 | 0 | } |
237 | |
}); |
238 | 0 | documentTool.setShowAllLink(container); |
239 | 0 | } |
240 | |
} |