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