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.SectionTitle; |
5 | |
import org.kuali.student.common.ui.client.configurable.mvc.sections.RequiredContainer; |
6 | |
import org.kuali.student.common.ui.client.configurable.mvc.sections.Section; |
7 | |
import org.kuali.student.common.ui.client.configurable.mvc.sections.VerticalSection; |
8 | |
import org.kuali.student.common.ui.client.configurable.mvc.views.VerticalSectionView; |
9 | |
import org.kuali.student.common.ui.client.mvc.Callback; |
10 | |
import org.kuali.student.common.ui.client.mvc.Controller; |
11 | |
import org.kuali.student.common.ui.client.mvc.DataModelDefinition; |
12 | |
import org.kuali.student.common.ui.client.mvc.View; |
13 | |
import org.kuali.student.common.ui.client.widgets.KSButton; |
14 | |
import org.kuali.student.common.ui.client.widgets.KSButtonAbstract.ButtonStyle; |
15 | |
import org.kuali.student.core.comments.ui.client.widgets.commenttool.CommentTool; |
16 | |
import org.kuali.student.core.document.ui.client.widgets.documenttool.DocumentTool; |
17 | |
import org.kuali.student.lum.common.client.lu.LUUIConstants; |
18 | |
import org.kuali.student.lum.lu.ui.course.client.controllers.CourseAdminController; |
19 | |
import org.kuali.student.lum.lu.ui.course.client.controllers.CourseProposalController; |
20 | |
import org.kuali.student.lum.lu.ui.course.client.requirements.CourseRequirementsViewController; |
21 | |
|
22 | |
import com.google.gwt.event.dom.client.ClickEvent; |
23 | |
import com.google.gwt.event.dom.client.ClickHandler; |
24 | |
import com.google.gwt.user.client.ui.Composite; |
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | 0 | public class CourseAdminConfigurer extends CourseProposalConfigurer{ |
34 | |
|
35 | |
protected CourseRequirementsViewController requisitesSection; |
36 | |
|
37 | 0 | private RequiredContainer requiredContainer = new RequiredContainer(); |
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
public void configure(final CourseProposalController layout) { |
47 | 0 | type = "course"; |
48 | 0 | state = DtoConstants.STATE_DRAFT; |
49 | 0 | nextState = DtoConstants.STATE_ACTIVE; |
50 | |
|
51 | 0 | groupName = LUUIConstants.COURSE_GROUP_NAME; |
52 | |
|
53 | 0 | layout.addContentWidget(layout.getWfUtilities().getWorkflowStatusLabel()); |
54 | 0 | if (modelDefinition.getMetadata().isCanEdit()) { |
55 | 0 | layout.addInfoWidget(requiredContainer); |
56 | 0 | layout.addView(generateCourseAdminView((CourseAdminController) layout)); |
57 | |
} else { |
58 | 0 | CourseSummaryConfigurer summaryConfigurer = new CourseSummaryConfigurer(type, state, groupName, (DataModelDefinition) modelDefinition, stmtTypes, (Controller) layout, COURSE_PROPOSAL_MODEL); |
59 | 0 | layout.removeMenuNavigation(); |
60 | 0 | layout.addView(summaryConfigurer.generateProposalSummarySection(false)); |
61 | |
} |
62 | 0 | } |
63 | |
|
64 | |
|
65 | |
|
66 | |
|
67 | |
|
68 | |
|
69 | |
protected View generateCourseAdminView(final CourseAdminController layout) { |
70 | 0 | VerticalSectionView view = |
71 | |
new VerticalSectionView(CourseSections.COURSE_INFO, getLabel(LUUIConstants.INFORMATION_LABEL_KEY), COURSE_PROPOSAL_MODEL, false); |
72 | 0 | view.addStyleName(LUUIConstants.STYLE_SECTION); |
73 | |
|
74 | |
|
75 | 0 | Section courseSection = generateCourseInfoSection(initSection(LUUIConstants.INFORMATION_LABEL_KEY)); |
76 | 0 | Section governanceSection = generateGovernanceSection(initSection(LUUIConstants.GOVERNANCE_LABEL_KEY)); |
77 | 0 | Section logisticsSection = generateCourseLogisticsSection(initSection(LUUIConstants.LOGISTICS_LABEL_KEY)); |
78 | 0 | Section loSection = initSection(LUUIConstants.LEARNING_OBJECTIVES_LABEL_KEY); |
79 | 0 | loSection.addSection(generateLearningObjectivesNestedSection()); |
80 | 0 | Section activeDatesSection = generateActiveDatesSection(initSection(LUUIConstants.ACTIVE_DATES_LABEL_KEY)); |
81 | 0 | Section financialSection = generateFinancialsSection(initSection(LUUIConstants.FINANCIALS_LABEL_KEY)); |
82 | |
|
83 | |
|
84 | 0 | requisitesSection = new CourseRequirementsViewController(layout, getLabel(LUUIConstants.REQUISITES_LABEL_KEY), CourseSections.COURSE_REQUISITES, false, false); |
85 | |
|
86 | |
|
87 | 0 | documentTool = new DocumentTool(LUUIConstants.REF_DOC_RELATION_PROPOSAL_TYPE,CourseSections.DOCUMENTS, getLabel(LUUIConstants.TOOL_DOCUMENTS_LABEL_KEY)); |
88 | 0 | documentTool.setModelDefinition((DataModelDefinition)modelDefinition); |
89 | 0 | documentTool.setController(layout); |
90 | 0 | documentTool.setTitle(getLabel(LUUIConstants.TOOL_DOCUMENTS_LABEL_KEY)); |
91 | 0 | documentTool.addStyleName(LUUIConstants.STYLE_SECTION); |
92 | |
|
93 | |
|
94 | 0 | final CommentTool commentTool = new CommentTool(CourseSections.COMMENTS, getLabel(LUUIConstants.TOOL_COMMENTS_LABEL_KEY), "kuali.comment.type.generalRemarks", "Proposal Comments"); |
95 | 0 | commentTool.setController(layout); |
96 | 0 | layout.addContentWidget(new KSButton("Comments", ButtonStyle.DEFAULT_ANCHOR, new ClickHandler() { |
97 | |
|
98 | |
@Override |
99 | |
public void onClick(ClickEvent event) { |
100 | 0 | commentTool.show(); |
101 | 0 | } |
102 | |
})); |
103 | |
|
104 | |
|
105 | |
|
106 | 0 | view.addSection(courseSection); |
107 | 0 | view.addSection(governanceSection); |
108 | 0 | view.addSection(logisticsSection); |
109 | 0 | view.addSection(loSection); |
110 | 0 | view.addView(requisitesSection); |
111 | 0 | view.addSection(this.createHiddenRequisitesSection()); |
112 | 0 | view.addSection(LUUIConstants.ACTIVE_DATES_LABEL_KEY,activeDatesSection); |
113 | 0 | view.addSection(financialSection); |
114 | 0 | view.addView(documentTool); |
115 | |
|
116 | |
|
117 | 0 | String sections = getLabel(LUUIConstants.COURSE_SECTIONS); |
118 | 0 | layout.addMenu(sections); |
119 | 0 | layout.addMenuItemSection(sections, getLabel(LUUIConstants.INFORMATION_LABEL_KEY), LUUIConstants.INFORMATION_LABEL_KEY, courseSection.getLayout()); |
120 | 0 | layout.addMenuItemSection(sections, getLabel(LUUIConstants.GOVERNANCE_LABEL_KEY), LUUIConstants.GOVERNANCE_LABEL_KEY, governanceSection.getLayout()); |
121 | 0 | layout.addMenuItemSection(sections, getLabel(LUUIConstants.LOGISTICS_LABEL_KEY), LUUIConstants.LOGISTICS_LABEL_KEY, logisticsSection.getLayout()); |
122 | 0 | layout.addMenuItemSection(sections, getLabel(LUUIConstants.LEARNING_OBJECTIVE_LABEL_KEY), LUUIConstants.LEARNING_OBJECTIVE_LABEL_KEY, loSection.getLayout()); |
123 | 0 | layout.addMenuItemSection(sections, getLabel(LUUIConstants.REQUISITES_LABEL_KEY), LUUIConstants.REQUISITES_LABEL_KEY, requisitesSection); |
124 | 0 | layout.addMenuItemSection(sections, getLabel(LUUIConstants.ACTIVE_DATES_LABEL_KEY), LUUIConstants.ACTIVE_DATES_LABEL_KEY, activeDatesSection.getLayout()); |
125 | 0 | layout.addMenuItemSection(sections, getLabel(LUUIConstants.FINANCIALS_LABEL_KEY), LUUIConstants.FINANCIALS_LABEL_KEY, financialSection.getLayout()); |
126 | 0 | layout.addMenuItemSection(sections, getLabel(LUUIConstants.TOOL_DOCUMENTS_LABEL_KEY), LUUIConstants.TOOL_DOCUMENTS_LABEL_KEY, financialSection.getLayout()); |
127 | |
|
128 | |
|
129 | 0 | layout.addButtonForView(CourseSections.COURSE_INFO, layout.getApproveAndActivateButton()); |
130 | 0 | layout.addButtonForView(CourseSections.COURSE_INFO, layout.getSaveButton()); |
131 | 0 | layout.addButtonForView(CourseSections.COURSE_INFO, layout.getCancelButton()); |
132 | 0 | layout.addTopButtonForView(CourseSections.COURSE_INFO, layout.getApproveAndActivateButton()); |
133 | 0 | layout.addTopButtonForView(CourseSections.COURSE_INFO, layout.getSaveButton()); |
134 | 0 | layout.addTopButtonForView(CourseSections.COURSE_INFO, layout.getCancelButton()); |
135 | |
|
136 | |
|
137 | 0 | this.addDocToolLink(); |
138 | 0 | requiredContainer.setMainSection(view); |
139 | |
|
140 | 0 | return view; |
141 | |
} |
142 | |
|
143 | |
|
144 | |
|
145 | |
|
146 | |
|
147 | |
|
148 | |
|
149 | |
public CourseRequirementsViewController getRequisitesSection() { |
150 | 0 | return requisitesSection; |
151 | |
} |
152 | |
|
153 | |
|
154 | |
|
155 | |
|
156 | |
|
157 | |
|
158 | |
|
159 | |
public DocumentTool getDocumentTool() { |
160 | 0 | return documentTool; |
161 | |
} |
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 | |
private void addDocToolLink(){ |
203 | 0 | Composite container = requiredContainer.createShowAllLink(new ClickHandler() { |
204 | |
|
205 | |
@Override |
206 | |
public void onClick(ClickEvent event) { |
207 | 0 | documentTool.showShowAllLink(false); |
208 | 0 | } |
209 | |
}); |
210 | |
|
211 | |
|
212 | 0 | requiredContainer.addCallback(new Callback<Boolean>() { |
213 | |
|
214 | |
@Override |
215 | |
public void exec(Boolean result) { |
216 | 0 | documentTool.showShowAllLink(!result); |
217 | 0 | } |
218 | |
}); |
219 | 0 | documentTool.setShowAllLink(container); |
220 | 0 | } |
221 | |
} |