View Javadoc

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   * This is the screen configuration and layout for the modify without version admin screens
25   * 
26   * @author Will
27   *
28   */
29  public class CourseAdminWithoutVersionConfigurer extends CourseProposalConfigurer{
30  	protected CourseRequirementsViewController requisitesSection;
31  	
32  	private RequiredContainer requiredContainer = new RequiredContainer();
33  	
34      /**
35       * Sets up all the views, sections, and views of the CourseAdminController.  This should be called
36       * once for initialization and setup per CourseAdminController instance.
37       * 
38       * @param layout
39       */
40      @Override
41  	public void configure(final CourseProposalController layout) {
42      	type = "course";
43          state = DtoConstants.STATE_APPROVED;
44          nextState = DtoConstants.STATE_ACTIVE;
45          
46      	groupName = LUUIConstants.COURSE_GROUP_NAME;
47  
48          KSLabel courseStatusLabel = new KSLabel("");
49          if (layout.getCourseState() != null)
50          	courseStatusLabel.setText("Status: " + layout.getCourseState());
51          else
52          	courseStatusLabel.setText("Status: Unknown");
53          layout.addContentWidget(courseStatusLabel); 
54          		
55          layout.addInfoWidget(requiredContainer);
56      	layout.addView(generateCourseAdminView((CourseAdminWithoutVersionController)layout));
57      }
58  
59  	/**
60  	 * Configuration for the course admin screens
61  	 * 
62  	 * @return view 
63  	 */
64      protected View generateCourseAdminView(final CourseAdminWithoutVersionController layout) {
65          VerticalSectionView view = 
66          	new VerticalSectionView(CourseSections.COURSE_INFO, getLabel(LUUIConstants.INFORMATION_LABEL_KEY), COURSE_PROPOSAL_MODEL, false);
67          view.addStyleName(LUUIConstants.STYLE_SECTION);
68  
69          // Create course admin sections
70          Section courseSection = generateCourseInfoSection(initSection(LUUIConstants.INFORMATION_LABEL_KEY)); 
71          Section governanceSection = generateGovernanceSection(initSection(LUUIConstants.GOVERNANCE_LABEL_KEY));
72          Section logisticsSection = generateCourseLogisticsSection(initSection(LUUIConstants.LOGISTICS_LABEL_KEY));
73          Section loSection = initSection(LUUIConstants.LEARNING_OBJECTIVES_LABEL_KEY);
74          loSection.addSection(generateLearningObjectivesNestedSection());
75          Section activeDatesSection = generateActiveDatesSection(initSection(LUUIConstants.ACTIVE_DATES_LABEL_KEY));
76          Section financialSection = generateFinancialsSection(initSection(LUUIConstants.FINANCIALS_LABEL_KEY));
77          Section retireSection = generateRetirementSection(initSection(LUUIConstants.RETIREMENT_LABEL_KEY));
78          
79          //Create requisite sections.
80          requisitesSection = new CourseRequirementsViewController(layout, getLabel(LUUIConstants.REQUISITES_LABEL_KEY), CourseSections.COURSE_REQUISITES, false, false);
81          
82          //Add course admin sections to view
83          view.addSection(courseSection);
84          view.addSection(governanceSection);
85          view.addSection(logisticsSection);
86          view.addSection(loSection);   
87          view.addView(requisitesSection);
88          view.addSection(this.createHiddenRequisitesSection());
89          view.addSection(activeDatesSection);
90          view.addSection(financialSection);
91          view.addSection(retireSection);
92          
93          //Add menu items for sections
94          String sections = getLabel(LUUIConstants.COURSE_SECTIONS);
95          layout.addMenu(sections);
96          layout.addMenuItemSection(sections, getLabel(LUUIConstants.INFORMATION_LABEL_KEY), LUUIConstants.INFORMATION_LABEL_KEY, courseSection.getLayout());
97          layout.addMenuItemSection(sections, getLabel(LUUIConstants.GOVERNANCE_LABEL_KEY), LUUIConstants.GOVERNANCE_LABEL_KEY, governanceSection.getLayout());
98          layout.addMenuItemSection(sections, getLabel(LUUIConstants.LOGISTICS_LABEL_KEY), LUUIConstants.LOGISTICS_LABEL_KEY, logisticsSection.getLayout());
99          layout.addMenuItemSection(sections, getLabel(LUUIConstants.LEARNING_OBJECTIVE_LABEL_KEY), LUUIConstants.LEARNING_OBJECTIVE_LABEL_KEY, loSection.getLayout());
100         layout.addMenuItemSection(sections, getLabel(LUUIConstants.REQUISITES_LABEL_KEY), LUUIConstants.REQUISITES_LABEL_KEY, requisitesSection);
101         layout.addMenuItemSection(sections, getLabel(LUUIConstants.ACTIVE_DATES_LABEL_KEY), LUUIConstants.ACTIVE_DATES_LABEL_KEY, activeDatesSection.getLayout());
102         layout.addMenuItemSection(sections, getLabel(LUUIConstants.FINANCIALS_LABEL_KEY), LUUIConstants.FINANCIALS_LABEL_KEY, financialSection.getLayout());
103         layout.addMenuItemSection(sections, getLabel(LUUIConstants.RETIREMENT_LABEL_KEY), LUUIConstants.RETIREMENT_LABEL_KEY, retireSection.getLayout());        
104         
105         //Add buttons to top and bottom of view
106         layout.addButtonForView(CourseSections.COURSE_INFO, layout.getSaveButton());
107         layout.addButtonForView(CourseSections.COURSE_INFO, layout.getCancelButton());
108         layout.addTopButtonForView(CourseSections.COURSE_INFO, layout.getSaveButton());        
109         layout.addTopButtonForView(CourseSections.COURSE_INFO, layout.getCancelButton());    
110 
111         requiredContainer.setMainSection(view);
112         
113         return view;
114 	}
115     
116     /**
117      * Override {@link CourseProposalConfigurer#generateCourseInfoSection(Section)} to remove configuration
118      * of proposal fields.
119      *  
120      */
121     @Override
122     public Section generateCourseInfoSection(Section section) {
123         addField(section, COURSE + "/" + COURSE_TITLE, generateMessageInfo(LUUIConstants.COURSE_TITLE_LABEL_KEY));
124         addField(section, COURSE + "/" + TRANSCRIPT_TITLE, generateMessageInfo(LUUIConstants.SHORT_TITLE_LABEL_KEY));
125         section.addSection(generateCourseNumberSection());
126     	FieldDescriptor instructorsFd = addField(section, COURSE + "/" + INSTRUCTORS, generateMessageInfo(LUUIConstants.INSTRUCTORS_LABEL_KEY));
127         instructorsFd.setWidgetBinding(new KeyListModelWigetBinding("personId"));
128 
129         section.addSection(generateDescriptionRationaleSection());
130         
131         return section;
132     }
133     
134     /**
135      * Override  {@link CourseProposalConfigurer#generateDescriptionRationaleSection()} to remove configuration of
136      * proposal fields.
137      * 
138      */
139     @Override
140     protected VerticalSection generateDescriptionRationaleSection() {
141         SectionTitle title = getH4Title(LUUIConstants.PROPOSAL_TITLE_SECTION_LABEL_KEY);
142         VerticalSection description = initSection(title, !WITH_DIVIDER);
143         title.setStyleName("cluProposalTitleSection");
144         addField(description, COURSE + "/" + DESCRIPTION + "/" + RichTextInfoConstants.PLAIN, generateMessageInfo(LUUIConstants.DESCRIPTION_LABEL_KEY));
145         return description;
146     }
147     
148     public CourseRequirementsViewController getRequisitesSection(CourseAdminController layout) {
149 		if(requisitesSection == null){
150 			requisitesSection = new CourseRequirementsViewController(layout, getLabel(LUUIConstants.REQUISITES_LABEL_KEY), CourseSections.COURSE_REQUISITES, false, false);
151 		}
152     	return requisitesSection;
153 	}
154 
155     protected Section generateRetirementSection(Section section) {
156         addField(section, COURSE + "/" + RETIREMENT_RATIONALE, generateMessageInfo(LUUIConstants.RETIREMENT_RATIONALE_LABEL_KEY));
157         addField(section, COURSE + "/" + LAST_TERM_OFFERED, generateMessageInfo(LUUIConstants.LAST_TERM_OFFERED_LABEL_KEY));
158         addField(section, COURSE + "/" + LAST_PUBLICATION_YEAR, generateMessageInfo(LUUIConstants.LAST_PUBLICATION_YEAR_LABEL_KEY));
159         addField(section, COURSE + "/" + SPECIAL_CIRCUMSTANCES, generateMessageInfo(LUUIConstants.SPECIAL_CIRCUMSTANCES_LABEL_KEY));
160         
161         return section;
162     }    
163     protected VerticalSection initSection(String labelKey) {
164         final VerticalSection section = initSection(SectionTitle.generateH2Title(getLabel(labelKey)), NO_DIVIDER);
165         // Add Show All Link on the sections.
166         section.addShowAllLink(requiredContainer.createShowAllLink(new ClickHandler() {
167 
168             @Override
169             public void onClick(ClickEvent event) {
170                 requiredContainer.processInnerSection(section, true);
171                 section.getShowAllLink().setVisible(false);
172             }
173         }));
174 
175         return section;
176     }
177     
178     private VerticalSection createHiddenRequisitesSection() {
179         final VerticalSection section = initSection(SectionTitle.generateH2Title(getLabel(LUUIConstants.REQUISITES_LABEL_KEY)), NO_DIVIDER);
180         // Add Show All Link on the sections.
181         section.addShowAllLink(requiredContainer.createShowAllLink(new ClickHandler() {
182 
183             @Override
184             public void onClick(ClickEvent event) {
185                 requisitesSection.asWidget().setVisible(true);
186                 section.getLayout().setVisible(false);
187             }
188         }));
189         
190         // Setup show/hide non-required fields configuration.
191         requiredContainer.addCallback(new Callback<Boolean>() {
192 
193             @Override
194             public void exec(Boolean result) {
195                 requisitesSection.asWidget().setVisible(result);
196                 section.getLayout().setVisible(!result);
197             }
198         });
199         return section;
200     }
201 
202 	public CourseRequirementsViewController getRequisitesSection() {
203 		return requisitesSection;
204 	}
205     
206 }