Coverage Report - org.kuali.student.lum.lu.ui.course.client.configuration.CourseAdminConfigurer
 
Classes in this File Line Coverage Branch Coverage Complexity
CourseAdminConfigurer
0%
0/73
0%
0/2
1.077
CourseAdminConfigurer$1
0%
0/3
N/A
1.077
CourseAdminConfigurer$2
0%
0/4
N/A
1.077
CourseAdminConfigurer$3
0%
0/4
N/A
1.077
CourseAdminConfigurer$4
0%
0/4
0%
0/2
1.077
CourseAdminConfigurer$5
0%
0/3
N/A
1.077
CourseAdminConfigurer$6
0%
0/3
0%
0/2
1.077
 
 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  
  * This is the screen configuration and layout for the create/modify admin screens
 29  
  * 
 30  
  * @author Will
 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  
      * Sets up all the views, sections, and views of the CourseAdminController.  This should be called
 42  
      * once for initialization and setup per CourseAdminController instance.
 43  
      * 
 44  
      * @param layout
 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  
          * Configuration for the course admin screens
 66  
          * 
 67  
          * @return view 
 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  
         // Create course admin sections
 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  
         //Create the requisite section
 84  0
         requisitesSection = new CourseRequirementsViewController(layout, getLabel(LUUIConstants.REQUISITES_LABEL_KEY), CourseSections.COURSE_REQUISITES, false, false);
 85  
 
 86  
         //Create the document upload section
 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  
         //Create and add the comment tool
 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  
         //Add course admin sections to view
 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  
         //Add menu items for sections
 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  
         //Add buttons to top and bottom of view
 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  
         // Setup show/hide non-required fields configuration.
 137  0
         this.addDocToolLink();
 138  0
         requiredContainer.setMainSection(view);
 139  
 
 140  0
         return view;
 141  
     }
 142  
     
 143  
     /**
 144  
      * Gets the requisite view associated with the CourseAdminConfigurer
 145  
      * 
 146  
      * @param layout
 147  
      * @return The requisite view used by this configurer
 148  
      */
 149  
     public CourseRequirementsViewController getRequisitesSection() {
 150  0
             return requisitesSection;
 151  
         }
 152  
     
 153  
     /**
 154  
      * Gets the Document Tool View associated with the CourseAdminConfigurer
 155  
      * 
 156  
      * @param layout
 157  
      * @return The DocumentTool used by this configurer
 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  
         // Add Show All Link on the sections.
 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  
         // Add Show All Link on the sections.
 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  
         // Setup show/hide non-required fields configuration.
 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  
         // Setup show/hide non-required fields configuration.
 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  
 }