Coverage Report - org.kuali.student.lum.program.client.major.proposal.MajorProposalSummaryConfiguration
 
Classes in this File Line Coverage Branch Coverage Complexity
MajorProposalSummaryConfiguration
0%
0/48
0%
0/14
2
MajorProposalSummaryConfiguration$1
0%
0/3
N/A
2
MajorProposalSummaryConfiguration$1$1
0%
0/6
0%
0/2
2
MajorProposalSummaryConfiguration$1$1$1
0%
0/3
N/A
2
MajorProposalSummaryConfiguration$1$1$1$1
0%
0/8
0%
0/2
2
MajorProposalSummaryConfiguration$2
0%
0/4
0%
0/2
2
MajorProposalSummaryConfiguration$3
0%
0/14
0%
0/4
2
 
 1  
 package org.kuali.student.lum.program.client.major.proposal;
 2  
 
 3  
 import java.util.List;
 4  
 
 5  
 import org.kuali.student.common.ui.client.configurable.mvc.Configurer;
 6  
 import org.kuali.student.common.ui.client.configurable.mvc.sections.Section;
 7  
 import org.kuali.student.common.ui.client.configurable.mvc.sections.WarnContainer;
 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.DataModel;
 11  
 import org.kuali.student.common.ui.client.mvc.ModelRequestCallback;
 12  
 import org.kuali.student.common.validation.dto.ValidationResultInfo;
 13  
 import org.kuali.student.common.validation.dto.ValidationResultInfo.ErrorLevel;
 14  
 import org.kuali.student.core.workflow.ui.client.widgets.WorkflowEnhancedNavController;
 15  
 import org.kuali.student.core.workflow.ui.client.widgets.WorkflowUtilities;
 16  
 import org.kuali.student.lum.common.client.configuration.AbstractControllerConfiguration;
 17  
 import org.kuali.student.lum.common.client.configuration.Configuration;
 18  
 import org.kuali.student.lum.common.client.configuration.ConfigurationManager;
 19  
 import org.kuali.student.lum.program.client.ProgramConstants;
 20  
 import org.kuali.student.lum.program.client.ProgramMsgConstants;
 21  
 import org.kuali.student.lum.program.client.ProgramSections;
 22  
 import org.kuali.student.lum.program.client.major.view.CatalogInformationViewConfiguration;
 23  
 import org.kuali.student.lum.program.client.major.view.LearningObjectivesViewConfiguration;
 24  
 import org.kuali.student.lum.program.client.major.view.MajorKeyProgramInfoViewConfiguration;
 25  
 import org.kuali.student.lum.program.client.major.view.ManagingBodiesViewConfiguration;
 26  
 import org.kuali.student.lum.program.client.major.view.ProgramRequirementsViewConfiguration;
 27  
 import org.kuali.student.lum.program.client.major.view.ProposalChangeImpactViewConfiguration;
 28  
 import org.kuali.student.lum.program.client.major.view.ProposalInformationViewConfiguration;
 29  
 import org.kuali.student.lum.program.client.major.view.SpecializationsViewConfiguration;
 30  
 import org.kuali.student.lum.program.client.major.view.SupportingDocsViewConfiguration;
 31  
 
 32  
 import com.google.gwt.user.client.ui.Widget;
 33  
 
 34  
 /**
 35  
  * This configuration is used to define what widgets should appear on the screen
 36  
  * for the major proposal controller.  
 37  
  * <p>
 38  
  * Note that this is pretty much a copy of the major discipline controller, 
 39  
  * but this controller has a couple extra tabs .
 40  
  * 
 41  
  * @author cmann
 42  
  */
 43  0
 public class MajorProposalSummaryConfiguration extends AbstractControllerConfiguration {
 44  
 
 45  0
         boolean showEditLinks = false;
 46  
         
 47  
         public MajorProposalSummaryConfiguration(Configurer configurer, boolean showEditLinks) {
 48  0
             super();
 49  0
             this.setConfigurer(configurer);
 50  0
         this.showEditLinks = showEditLinks;
 51  0
     }
 52  
 
 53  
     /**
 54  
      * This is an inherited method called by the framework to layout components on the screen.
 55  
      */
 56  
     @Override
 57  
     protected void buildLayout() {
 58  
             
 59  0
         if (controller instanceof WorkflowEnhancedNavController
 60  
                 && ((WorkflowEnhancedNavController) controller).getWfUtilities() != null) {
 61  
                 final WarnContainer infoContainerHeader; // Header widget (with warnings if necessary)
 62  
                 //WarnContainers initialized with buttons common to all states (error or otherwise)
 63  0
                 infoContainerHeader = generateWorkflowWidgetContainer(((WorkflowEnhancedNavController) controller)
 64  
                             .getWfUtilities().getWorkflowActionsWidget());
 65  0
                 rootSection = new VerticalSectionView(ProgramSections.SUMMARY, getLabel(ProgramMsgConstants.PROPOSAL_MENU_SECTIONS_SUMMARY), ProgramConstants.PROGRAM_MODEL_ID, true){
 66  
         
 67  
                                 @Override
 68  
                                 public void beforeShow(final Callback<Boolean> onReadyCallback) {
 69  0
                                         super.beforeShow(new Callback<Boolean>() {
 70  
         
 71  
                                                 @Override
 72  
                                                 public void exec(final Boolean result) {
 73  0
                                 if (result) {
 74  
                                     // Make sure workflow actions and status updated before showing.
 75  0
                                     ((WorkflowEnhancedNavController) controller).getWfUtilities().refresh();
 76  0
                                     ((WorkflowEnhancedNavController) controller).getWfUtilities().requestAndSetupModel(new Callback<Boolean>(){
 77  
                                                                         public void exec(Boolean modelReadyResult) {
 78  
                                                     // Show validation error if they exist
 79  0
                                                     ((WorkflowEnhancedNavController) controller).getWfUtilities().doValidationCheck(new Callback<List<ValidationResultInfo>>() {
 80  
                                                 @Override
 81  
                                                 public void exec(List<ValidationResultInfo> validationResult) { //Don't place a breakpoint here:  It will stall debugging for some unknown reason!
 82  0
                                                     ErrorLevel isValid = rootSection.processValidationResults(
 83  
                                                             validationResult, true);
 84  
         
 85  0
                                                     if (isValid == ErrorLevel.OK) {
 86  0
                                                         infoContainerHeader.showWarningLayout(false);
 87  0
                                                         ((WorkflowEnhancedNavController) controller)
 88  
                                                                         .getWfUtilities()
 89  
                                                                         .enableWorkflowActionsWidgets(true);
 90  
                                                     } else { //KSLAB-1985
 91  0
                                                     ((WorkflowEnhancedNavController) controller).getWfUtilities()
 92  
                                                     .enableWorkflowActionsWidgets(false);
 93  
                                                     }
 94  0
                                                         onReadyCallback.exec(result);
 95  0
                                                 }
 96  
                                             });
 97  0
                                                                         }
 98  
                                                                 });
 99  
                                 }else{
 100  0
                                         onReadyCallback.exec(result);
 101  
                                 }
 102  0
                                                 }
 103  
                                         });
 104  0
                                 }
 105  
                         
 106  
                 };
 107  
                 
 108  0
                 rootSection.addWidget(infoContainerHeader); // Header widget (with warnings if necessary)
 109  
         }
 110  
             
 111  
             
 112  
             
 113  
             
 114  0
         ConfigurationManager configurationManager = new ConfigurationManager();
 115  
             
 116  
         // Initialize tabs on left of screen
 117  0
         if (showEditLinks){
 118  0
                 configureSectionsWithEditLinks(configurationManager);
 119  
         } else {
 120  0
                 configureSectionsWithoutEditLinks(configurationManager);
 121  
         }
 122  
         
 123  
         // Add the work flow utilities to the screen light box to the screen
 124  
         // Instance of check ensures we only do this for majors
 125  0
         if (controller instanceof MajorProposalController){
 126  
             
 127  
             // Grab the work flow utilities widget we initialized in the controller
 128  0
             final WorkflowUtilities workflowUtilities = ((MajorProposalController) controller).getWfUtilities();
 129  0
             workflowUtilities.addSubmitCallback(new Callback<Boolean>() {
 130  
 
 131  
                 @Override
 132  
                 public void exec(Boolean result) {
 133  0
                     if (result) {
 134  0
                         ((MajorProposalController) controller).setStatus();
 135  
                     }
 136  
 
 137  0
                 }
 138  
             });
 139  
             //Add fields to workflow utils screens
 140  0
             if(workflowUtilities!=null){
 141  0
                     controller.requestModel(new ModelRequestCallback<DataModel>(){
 142  
                                         public void onModelReady(DataModel model) {
 143  
                                                 //Only display if this is a modification
 144  0
                                                 String versionedFromId = model.get("versionInfo/versionedFromId");
 145  0
                                                 if(versionedFromId!=null && !versionedFromId.isEmpty()){
 146  
                                                         //Add the previous start term since we need it as a widget so it can act as a cross field constraint
 147  0
                                                         workflowUtilities.addApproveDialogField("", "startTerm",  generateMessageInfo(ProgramMsgConstants.PROGRAMINFORMATION_STARTTERM), MajorProposalSummaryConfiguration.this.configurer.getModelDefinition(), true, true);
 148  0
                                                     workflowUtilities.addApproveDialogField("proposal", "prevEndTerm", generateMessageInfo(ProgramMsgConstants.MAJORDISCIPLINE_PREVENDTERM), MajorProposalSummaryConfiguration.this.configurer.getModelDefinition(),false);
 149  0
                                                         workflowUtilities.addApproveDialogField("proposal", "prevEndProgramEntryTerm", generateMessageInfo(ProgramMsgConstants.MAJORDISCIPLINE_PREVENDPROGRAMENTRYTERM), MajorProposalSummaryConfiguration.this.configurer.getModelDefinition(),false);
 150  0
                                                         workflowUtilities.addApproveDialogField("proposal", "prevEndInstAdmitTerm", generateMessageInfo(ProgramMsgConstants.MAJORDISCIPLINE_PREVENDINSTADMITTERM), MajorProposalSummaryConfiguration.this.configurer.getModelDefinition(),false);
 151  0
                                                         workflowUtilities.updateApproveFields();
 152  0
                                                         workflowUtilities.progressiveEnableFields();        
 153  
                                                 }else{
 154  
                                                         //Ignore this field (so blanket approve works if this is a new course proposal and not modifiaction)
 155  0
                                                         workflowUtilities.addIgnoreDialogField("proposal/prevEndTerm");
 156  0
                                                         workflowUtilities.addIgnoreDialogField("proposal/prevEndProgramEntryTerm");
 157  0
                                                         workflowUtilities.addIgnoreDialogField("proposal/prevEndInstAdmitTerm");
 158  
                                                 }
 159  0
                                         }
 160  
                                         public void onRequestFail(Throwable cause) {
 161  0
                                         }
 162  
                     });
 163  
             }
 164  
             
 165  
         }
 166  
  
 167  
         
 168  
         // Loop over all configurations in the configuration manager
 169  0
         for (Configuration configuration : configurationManager.getConfigurations()) {
 170  0
             if (configuration instanceof AbstractControllerConfiguration) {
 171  0
                 ((AbstractControllerConfiguration) configuration).setController(controller);
 172  
             }
 173  0
             rootSection.addSection((Section) configuration.getView());
 174  
         }    
 175  0
      }
 176  
     
 177  
     protected void configureSectionsWithEditLinks(ConfigurationManager configurationManager){
 178  0
             configurationManager.registerConfiguration(ProposalInformationViewConfiguration.createSpecial(configurer, controller));
 179  0
             configurationManager.registerConfiguration(ProposalChangeImpactViewConfiguration.createSpecial(configurer, controller));
 180  0
             configurationManager.registerConfiguration(MajorKeyProgramInfoViewConfiguration.createSpecial(configurer, controller));
 181  0
             configurationManager.registerConfiguration(ManagingBodiesViewConfiguration.createSpecial(configurer, controller));
 182  0
             configurationManager.registerConfiguration(SpecializationsViewConfiguration.createSpecial(configurer, controller));
 183  0
             configurationManager.registerConfiguration(CatalogInformationViewConfiguration.createSpecial(configurer, controller));
 184  0
             configurationManager.registerConfiguration(new ProgramRequirementsViewConfiguration(configurer, controller, true));
 185  0
             configurationManager.registerConfiguration(LearningObjectivesViewConfiguration.createSpecial(configurer, controller));
 186  0
             configurationManager.registerConfiguration(SupportingDocsViewConfiguration.createSpecial(configurer, controller));
 187  0
     }
 188  
     
 189  
     protected void configureSectionsWithoutEditLinks(ConfigurationManager configurationManager){
 190  0
             configurationManager.registerConfiguration(ProposalInformationViewConfiguration.create(configurer));
 191  0
             configurationManager.registerConfiguration(ProposalChangeImpactViewConfiguration.create(configurer));
 192  0
             configurationManager.registerConfiguration(MajorKeyProgramInfoViewConfiguration.create(configurer));
 193  0
             configurationManager.registerConfiguration(ManagingBodiesViewConfiguration.create(configurer));
 194  0
             configurationManager.registerConfiguration(SpecializationsViewConfiguration.create(configurer));
 195  0
             configurationManager.registerConfiguration(CatalogInformationViewConfiguration.create(configurer));
 196  0
             configurationManager.registerConfiguration(new ProgramRequirementsViewConfiguration(configurer, controller, false));
 197  0
             configurationManager.registerConfiguration(LearningObjectivesViewConfiguration.create(configurer));
 198  0
             configurationManager.registerConfiguration(SupportingDocsViewConfiguration.create(configurer));    
 199  0
     }    
 200  
     
 201  
     // Initializes a WarnContainer with Action options dropdown, and Curriculum Management link 
 202  
     private WarnContainer generateWorkflowWidgetContainer(Widget w) {
 203  
 
 204  0
         WarnContainer warnContainer = new WarnContainer();
 205  
 
 206  0
         warnContainer.add(w);
 207  0
         w.addStyleName("ks-button-spacing");
 208  
 //        warnContainer.add(new KSButton("Return to Curriculum Management",
 209  
 //                ButtonStyle.DEFAULT_ANCHOR, new ClickHandler() {
 210  
 //
 211  
 //                    @Override
 212  
 //                    public void onClick(ClickEvent event) { //Don't place a breakpoint here:  It will stall debugging for some unknown reason!
 213  
 //                        Application
 214  
 //                                .navigate(AppLocations.Locations.CURRICULUM_MANAGEMENT
 215  
 //                                        .getLocation());
 216  
 //                    }
 217  
 //                }));
 218  
 
 219  
         // KSLAB-1985:  Warning logic/display moved to generateProposalSummarySection() where error states are established
 220  
 
 221  0
         return warnContainer;
 222  
     }
 223  
 }