Coverage Report - org.kuali.student.lum.lu.ui.course.client.configuration.CourseAdminConfigurer
 
Classes in this File Line Coverage Branch Coverage Complexity
CourseAdminConfigurer
0%
0/77
0%
0/2
1.071
CourseAdminConfigurer$1
0%
0/3
N/A
1.071
CourseAdminConfigurer$2
0%
0/4
N/A
1.071
CourseAdminConfigurer$3
0%
0/4
N/A
1.071
CourseAdminConfigurer$4
0%
0/4
0%
0/2
1.071
CourseAdminConfigurer$5
0%
0/3
N/A
1.071
CourseAdminConfigurer$6
0%
0/3
0%
0/2
1.071
 
 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.layouts.MenuSectionController;
 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.core.comments.ui.client.widgets.commenttool.CommentTool;
 17  
 import org.kuali.student.core.comments.ui.client.widgets.commenttool.CommentTool.EditMode;
 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  
  * This is the screen configuration and layout for the create/modify admin screens
 31  
  * 
 32  
  * @author Will
 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  
      * Sets up all the views, sections, and views of the CourseAdminController.  This should be called
 44  
      * once for initialization and setup per CourseAdminController instance.
 45  
      * 
 46  
      * @param layout
 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().getProposalStatusLabel());
 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  0
             final CommentTool commentTool = createCommentTool(layout);
 64  0
             commentTool.setEditMode(EditMode.VIEW_COMMENT);
 65  
         }
 66  0
     }
 67  
 
 68  
         /**
 69  
          * Configuration for the course admin screens
 70  
          * 
 71  
          * @return view 
 72  
          */
 73  
     protected View generateCourseAdminView(final CourseAdminController layout) {
 74  0
         VerticalSectionView view = 
 75  
                 new VerticalSectionView(CourseSections.COURSE_INFO, getLabel(LUUIConstants.INFORMATION_LABEL_KEY), COURSE_PROPOSAL_MODEL, false);
 76  0
         view.addStyleName(LUUIConstants.STYLE_SECTION);
 77  
 
 78  
         // Create course admin sections
 79  0
         Section courseSection = generateCourseInfoSection(initSection(LUUIConstants.INFORMATION_LABEL_KEY)); 
 80  0
         Section governanceSection = generateGovernanceSection(initSection(LUUIConstants.GOVERNANCE_LABEL_KEY));
 81  0
         Section logisticsSection = generateCourseLogisticsSection(initSection(LUUIConstants.LOGISTICS_LABEL_KEY));
 82  0
         Section loSection = initSection(LUUIConstants.LEARNING_OBJECTIVES_LABEL_KEY);
 83  0
         loSection.addSection(generateLearningObjectivesNestedSection());
 84  0
         Section activeDatesSection = generateActiveDatesSection(initSection(LUUIConstants.ACTIVE_DATES_LABEL_KEY));
 85  0
         Section financialSection = generateFinancialsSection(initSection(LUUIConstants.FINANCIALS_LABEL_KEY));
 86  
         
 87  
         //Create the requisite section
 88  0
         requisitesSection = new CourseRequirementsViewController(layout, getLabel(LUUIConstants.REQUISITES_LABEL_KEY), CourseSections.COURSE_REQUISITES, false, false);
 89  
 
 90  
         //Create the document upload section
 91  
         
 92  0
         documentTool = new DocumentTool(LUUIConstants.REF_DOC_RELATION_PROPOSAL_TYPE,CourseSections.DOCUMENTS, getLabel(LUUIConstants.TOOL_DOCUMENTS_LABEL_KEY));
 93  0
         documentTool.setModelDefinition((DataModelDefinition)modelDefinition);
 94  0
         documentTool.setController(layout);
 95  0
         documentTool.setTitle(getLabel(LUUIConstants.TOOL_DOCUMENTS_LABEL_KEY));
 96  0
         documentTool.addStyleName(LUUIConstants.STYLE_SECTION);
 97  
 
 98  0
         createCommentTool(layout);
 99  
 
 100  
         
 101  
         //Add course admin sections to view
 102  0
         view.addSection(courseSection);
 103  0
         view.addSection(governanceSection);
 104  0
         view.addSection(logisticsSection);
 105  0
         view.addSection(loSection);
 106  0
         view.addView(requisitesSection);
 107  0
         view.addSection(this.createHiddenRequisitesSection());
 108  0
         view.addSection(LUUIConstants.ACTIVE_DATES_LABEL_KEY,activeDatesSection);
 109  0
         view.addSection(financialSection);
 110  0
         view.addView(documentTool);
 111  
         
 112  
         //Add menu items for sections
 113  0
         String sections = getLabel(LUUIConstants.COURSE_SECTIONS);
 114  0
         layout.addMenu(sections);
 115  0
         layout.addMenuItemSection(sections, getLabel(LUUIConstants.INFORMATION_LABEL_KEY), LUUIConstants.INFORMATION_LABEL_KEY, courseSection.getLayout());
 116  0
         layout.addMenuItemSection(sections, getLabel(LUUIConstants.GOVERNANCE_LABEL_KEY), LUUIConstants.GOVERNANCE_LABEL_KEY, governanceSection.getLayout());
 117  0
         layout.addMenuItemSection(sections, getLabel(LUUIConstants.LOGISTICS_LABEL_KEY), LUUIConstants.LOGISTICS_LABEL_KEY, logisticsSection.getLayout());
 118  0
         layout.addMenuItemSection(sections, getLabel(LUUIConstants.LEARNING_OBJECTIVE_LABEL_KEY), LUUIConstants.LEARNING_OBJECTIVE_LABEL_KEY, loSection.getLayout());
 119  0
         layout.addMenuItemSection(sections, getLabel(LUUIConstants.REQUISITES_LABEL_KEY), LUUIConstants.REQUISITES_LABEL_KEY, requisitesSection);
 120  0
         layout.addMenuItemSection(sections, getLabel(LUUIConstants.ACTIVE_DATES_LABEL_KEY), LUUIConstants.ACTIVE_DATES_LABEL_KEY, activeDatesSection.getLayout());
 121  0
         layout.addMenuItemSection(sections, getLabel(LUUIConstants.FINANCIALS_LABEL_KEY), LUUIConstants.FINANCIALS_LABEL_KEY, financialSection.getLayout());
 122  0
         layout.addMenuItemSection(sections, getLabel(LUUIConstants.TOOL_DOCUMENTS_LABEL_KEY), LUUIConstants.TOOL_DOCUMENTS_LABEL_KEY, documentTool);
 123  
         
 124  
         //Add buttons to top and bottom of view
 125  0
         layout.addButtonForView(CourseSections.COURSE_INFO, layout.getApproveAndActivateButton());
 126  0
         layout.addButtonForView(CourseSections.COURSE_INFO, layout.getSaveButton());
 127  0
         layout.addButtonForView(CourseSections.COURSE_INFO, layout.getCancelButton());
 128  0
         layout.addTopButtonForView(CourseSections.COURSE_INFO, layout.getApproveAndActivateButton());
 129  0
         layout.addTopButtonForView(CourseSections.COURSE_INFO, layout.getSaveButton());
 130  0
         layout.addTopButtonForView(CourseSections.COURSE_INFO, layout.getCancelButton());
 131  
 
 132  
         // Setup show/hide non-required fields configuration.
 133  0
         this.addDocToolLink();
 134  0
         requiredContainer.setMainSection(view);
 135  
 
 136  0
         return view;
 137  
     }
 138  
 
 139  
     private CommentTool createCommentTool(final MenuSectionController layout) {
 140  
         //Create and add the comment tool
 141  0
         final CommentTool commentTool = new CommentTool(CourseSections.COMMENTS, getLabel(LUUIConstants.TOOL_COMMENTS_LABEL_KEY), "kuali.comment.type.generalRemarks", "Proposal Comments");
 142  0
         commentTool.setController(layout);        
 143  0
         layout.addContentWidget(new KSButton("Comments", ButtonStyle.DEFAULT_ANCHOR, new ClickHandler() {
 144  
             
 145  
             @Override
 146  
             public void onClick(ClickEvent event) {
 147  0
                 commentTool.show();
 148  0
             }
 149  
         }));
 150  0
         return commentTool;
 151  
     }
 152  
     
 153  
     /**
 154  
      * Gets the requisite view associated with the CourseAdminConfigurer
 155  
      * 
 156  
      * @param layout
 157  
      * @return The requisite view used by this configurer
 158  
      */
 159  
     public CourseRequirementsViewController getRequisitesSection() {
 160  0
             return requisitesSection;
 161  
         }
 162  
     
 163  
     /**
 164  
      * Gets the Document Tool View associated with the CourseAdminConfigurer
 165  
      * 
 166  
      * @param layout
 167  
      * @return The DocumentTool used by this configurer
 168  
      */
 169  
     public DocumentTool getDocumentTool() {
 170  0
         return documentTool;
 171  
     }
 172  
 
 173  
     protected VerticalSection initSection(String labelKey) {
 174  0
         final VerticalSection section = initSection(SectionTitle.generateH2Title(getLabel(labelKey)), NO_DIVIDER);
 175  
         // Add Show All Link on the sections.
 176  0
         section.addShowAllLink(requiredContainer.createShowAllLink(new ClickHandler() {
 177  
 
 178  
             @Override
 179  
             public void onClick(ClickEvent event) {
 180  0
                 requiredContainer.processInnerSection(section, true);
 181  0
                 section.getShowAllLink().setVisible(false);
 182  0
             }
 183  
         }));
 184  
 
 185  0
         return section;
 186  
     }
 187  
     
 188  
     private VerticalSection createHiddenRequisitesSection() {
 189  0
         final VerticalSection section = initSection(SectionTitle.generateH2Title(getLabel(LUUIConstants.REQUISITES_LABEL_KEY)), NO_DIVIDER);
 190  
         // Add Show All Link on the sections.
 191  0
         section.addShowAllLink(requiredContainer.createShowAllLink(new ClickHandler() {
 192  
 
 193  
             @Override
 194  
             public void onClick(ClickEvent event) {
 195  0
                 requisitesSection.asWidget().setVisible(true);
 196  0
                 section.getLayout().setVisible(false);
 197  0
             }
 198  
         }));
 199  
         
 200  
         // Setup show/hide non-required fields configuration.
 201  0
         requiredContainer.addCallback(new Callback<Boolean>() {
 202  
 
 203  
             @Override
 204  
             public void exec(Boolean result) {
 205  0
                 requisitesSection.asWidget().setVisible(result);
 206  0
                 section.getLayout().setVisible(!result);
 207  0
             }
 208  
         });
 209  0
         return section;
 210  
     }
 211  
     
 212  
     private void addDocToolLink(){
 213  0
         Composite container = requiredContainer.createShowAllLink(new ClickHandler() {
 214  
 
 215  
             @Override
 216  
             public void onClick(ClickEvent event) {
 217  0
                 documentTool.showShowAllLink(false);
 218  0
             }
 219  
         });
 220  
         
 221  
         // Setup show/hide non-required fields configuration.
 222  0
         requiredContainer.addCallback(new Callback<Boolean>() {
 223  
 
 224  
             @Override
 225  
             public void exec(Boolean result) {
 226  0
                 documentTool.showShowAllLink(!result);
 227  0
             }
 228  
         });
 229  0
         documentTool.setShowAllLink(container);
 230  0
     }
 231  
 }