From 4587642a81ff8a01d4fde71c55ddaa9d6c01ee65 Mon Sep 17 00:00:00 2001 From: rjy7 Date: Thu, 2 Sep 2010 19:54:05 +0000 Subject: [PATCH] NIHVIVO-1024 Implement educational training custom form as a single-step form. Merged two css files. --- .../edit/forms/addGrantRoleToPerson.jsp | 1 - .../edit/forms/addRoleToPersonTwoStage.jsp | 5 +- productMods/edit/forms/css/autocomplete.css | 21 ------- .../forms/css/customFormWithAutocomplete.css | 30 ++++++++-- .../forms/js/customFormWithAutocomplete.js | 44 +++++++++------ .../forms/personHasEducationalTraining.jsp | 55 +++++++++---------- .../edit/forms/personHasPositionHistory.jsp | 2 +- 7 files changed, 84 insertions(+), 74 deletions(-) delete mode 100644 productMods/edit/forms/css/autocomplete.css diff --git a/productMods/edit/forms/addGrantRoleToPerson.jsp b/productMods/edit/forms/addGrantRoleToPerson.jsp index d6bac5fa..25ab5c27 100644 --- a/productMods/edit/forms/addGrantRoleToPerson.jsp +++ b/productMods/edit/forms/addGrantRoleToPerson.jsp @@ -269,7 +269,6 @@ PREFIX core: <${vivoCore}> List customCss = new ArrayList(Arrays.asList(Css.JQUERY_UI.path(), Css.CUSTOM_FORM.path(), - "/edit/forms/css/autocomplete.css", "/edit/forms/css/customFormWithAutocomplete.css" )); request.setAttribute("customCss", customCss); diff --git a/productMods/edit/forms/addRoleToPersonTwoStage.jsp b/productMods/edit/forms/addRoleToPersonTwoStage.jsp index d786b0fb..d60b7d78 100644 --- a/productMods/edit/forms/addRoleToPersonTwoStage.jsp +++ b/productMods/edit/forms/addRoleToPersonTwoStage.jsp @@ -355,7 +355,6 @@ public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp. List customCss = new ArrayList(Arrays.asList(Css.JQUERY_UI.path(), Css.CUSTOM_FORM.path(), - "/edit/forms/css/autocomplete.css", "/edit/forms/css/customFormWithAutocomplete.css" )); request.setAttribute("customCss", customCss); @@ -388,6 +387,7 @@ public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.

${titleVerb} ${roleActivityTypeLabel} entry for <%= subjectName %>

<%-- DO NOT CHANGE IDS, CLASSES, OR HTML STRUCTURE IN THIS FORM WITHOUT UNDERSTANDING THE IMPACT ON THE JAVASCRIPT! --%> +
" >

@@ -435,7 +435,8 @@ public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp. var customFormData = { acUrl: '${acUrl}', editMode: '${editMode}', - submitButtonTextType: 'compound' + submitButtonTextType: 'compound', + defaultTypeName: 'activity' // used in repair mode, to generate button text and org name field label }; <% } %> diff --git a/productMods/edit/forms/css/autocomplete.css b/productMods/edit/forms/css/autocomplete.css deleted file mode 100644 index 46519f7d..00000000 --- a/productMods/edit/forms/css/autocomplete.css +++ /dev/null @@ -1,21 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -.acSelection { - display: none; -} - -.acSelectionInfo { - background-color: #d9d9d9; - padding: .5em 1em; -} - - -/* jQuery UI autocomplete */ -ul.ui-autocomplete { - font-size: .95em; -} - -li.ui-menu-item a.ui-corner-all { - text-align: left; - padding-left: .25em; -} \ No newline at end of file diff --git a/productMods/edit/forms/css/customFormWithAutocomplete.css b/productMods/edit/forms/css/customFormWithAutocomplete.css index fd603423..d47a688b 100644 --- a/productMods/edit/forms/css/customFormWithAutocomplete.css +++ b/productMods/edit/forms/css/customFormWithAutocomplete.css @@ -1,5 +1,26 @@ /* $This file is distributed under the terms of the license in /doc/license.txt$ */ +.acSelection { + display: none; + margin-top: 2em; +} + +.acSelectionInfo { + background-color: #d9d9d9; + padding: .5em 1em; +} + + +/* jQuery UI autocomplete */ +ul.ui-autocomplete { + font-size: .95em; +} + +li.ui-menu-item a.ui-corner-all { + text-align: left; + padding-left: .25em; +} + /* Although Javascript hides these on page load, hide here as well to avoid the flash on page load. This needs to be removed to support a non-JS version of the form. */ .fullViewOnly, @@ -16,11 +37,12 @@ margin-right: 1em; } -.acSelection { - margin-top: 2em; -} - .verifyMatch { margin-left: .5em; } +#content form h4 { + margin-top: 1em; + margin-bottom: .75em; +} + diff --git a/productMods/edit/forms/js/customFormWithAutocomplete.js b/productMods/edit/forms/js/customFormWithAutocomplete.js index 712be1dc..58d47e67 100644 --- a/productMods/edit/forms/js/customFormWithAutocomplete.js +++ b/productMods/edit/forms/js/customFormWithAutocomplete.js @@ -85,12 +85,15 @@ var customForm = { if (!this.editMode) { this.editMode = 'add'; // edit vs add: default to add } - - if (!this.typeSelector.length || this.editMode == 'edit' || this.editMode == 'repair') { - this.formSteps = 1; - // there may also be a 3-step form - look for this.subTypeSelector - } else { - this.formSteps = 2; + + if (!this.formSteps) { // Don't override formSteps specified in form data + if (!this.typeSelector.length || !this.fullViewOnly.length || this.editMode === 'edit' || this.editMode === 'repair') { + this.formSteps = 1; + // there may also be a 3-step form - look for this.subTypeSelector + } + else { + this.formSteps = 2; + } } this.bindEventListeners(); @@ -145,13 +148,19 @@ var customForm = { this.setButtonText('new'); this.setLabels(); - if( this.formSteps > 1 ){ // NB includes this.editMode == 1 + if (this.formSteps > 1) { // includes this.editMode == 1 this.cancel.unbind('click'); this.cancel.click(function() { customForm.clearFormData(); // clear any input and validation errors customForm.initFormTypeView(); return false; }); + // In one-step forms, if there is a type selection field, but no value is selected, + // hide the acSelector field. The type selection must be made first so that the + // autocomplete type can be determined. If a type selection has been made, + // unhide the acSelector field. + } else if (this.typeSelector.length) { + this.typeSelector.val() ? this.acSelectorWrapper.show() : this.acSelectorWrapper.hide(); } }, @@ -189,9 +198,9 @@ var customForm = { customForm.undoAutocompleteSelection(); // If no selection, go back to type view. This prevents problems like trying to run autocomplete - // or submitting form without a type selection. Exception: in repair editMode, stay in full view, - // else we lose the role information. - (typeVal.length || customForm.editMode == 'repair') ? customForm.initFormFullView() : customForm.initFormTypeView(); + // or submitting form without a type selection. Exception: if formSteps == 1 (e.g., a one-step form, + // or a two-step form in repair editMode) stay in full view, else we lose the role information. + (typeVal.length || customForm.formSteps === 1) ? customForm.initFormFullView() : customForm.initFormTypeView(); }); @@ -383,9 +392,7 @@ var customForm = { // mode, it's easier to specify the text here than in the jsp. setLabels: function() { var newLabelTextForNewInd, - // if this.acType is empty, we are in repair mode with no activity type selected. - // Prevent the labels from showing 'Select one' by using the generic term 'Activity' - typeText = this.acType ? this.typeName : 'Activity'; + typeText = this.getTypeNameForLabels(); this.labelFieldLabel.html(typeText + ' ' + this.baseLabelText); @@ -412,9 +419,7 @@ var customForm = { return; } - // if this.acType is empty, we are in repair mode with no activity type selected. - // Prevent the labels from showing 'Select one' by using the generic term 'Activity' - typeText = this.acType ? this.typeName : 'Activity'; + typeText = this.getTypeNameForLabels(); // Creating new related individual if (newOrExisting === 'new') { @@ -433,6 +438,13 @@ var customForm = { } this.button.val(buttonText); + }, + + getTypeNameForLabels: function() { + // If this.acType is empty, we are either in a one-step form with no type yet selected, + // or in repair mode in a two-step form with no type selected. Use the default type + // name specified in the form data (this.typeName is 'Select one'). + return this.acType ? this.typeName : this.capitalize(this.defaultTypeName); } }; diff --git a/productMods/edit/forms/personHasEducationalTraining.jsp b/productMods/edit/forms/personHasEducationalTraining.jsp index 3423bfe2..5234d19a 100644 --- a/productMods/edit/forms/personHasEducationalTraining.jsp +++ b/productMods/edit/forms/personHasEducationalTraining.jsp @@ -373,7 +373,6 @@ core:dateTimePrecision (DateTimeValue : DateTimeValuePrecision) List customCss = new ArrayList(Arrays.asList(Css.JQUERY_UI.path(), Css.CUSTOM_FORM.path(), - "/edit/forms/css/autocomplete.css", "/edit/forms/css/customFormWithAutocomplete.css" )); request.setAttribute("customCss", customCss); @@ -388,36 +387,33 @@ core:dateTimePrecision (DateTimeValue : DateTimeValuePrecision) " > + + + + + +

- -
- -

- - <%-- Store these values in hidden fields, because the displayed fields are disabled and don't submit. This ensures that when - returning from a validation error, we retain the values. --%> - - - - - -
- <%-- RY maybe make this a label and input field. See what looks best. --%> -

(Verify this match)

- -
- - - - - - - - - -

e.g., Postdoctoral training or Transferred

+

+ + <%-- Store these values in hidden fields, because the displayed fields are disabled and don't submit. This ensures that when + returning from a validation error, we retain the values. --%> + + + + + +
+ <%-- RY maybe make this a label and input field. See what looks best. --%> +

(Verify this match)

+
+ + + + +

e.g., Postdoctoral training or Transferred

@@ -430,7 +426,8 @@ core:dateTimePrecision (DateTimeValue : DateTimeValuePrecision) var customFormData = { acUrl: '${acUrl}', editMode: '${editMode}', - submitButtonTextType: 'compound' + submitButtonTextType: 'compound', + defaultTypeName: 'organization' }; diff --git a/productMods/edit/forms/personHasPositionHistory.jsp b/productMods/edit/forms/personHasPositionHistory.jsp index 571b29e4..84f9e20a 100644 --- a/productMods/edit/forms/personHasPositionHistory.jsp +++ b/productMods/edit/forms/personHasPositionHistory.jsp @@ -301,7 +301,6 @@ List customCss = new ArrayList(Arrays.asList(Css.JQUERY_UI.path(), Css.CUSTOM_FORM.path(), - "/edit/forms/css/autocomplete.css", "/edit/forms/css/customFormWithAutocomplete.css" )); request.setAttribute("customCss", customCss); @@ -320,6 +319,7 @@
+ <%--

needed to create wrapper for show/hide --%>

<%-- Store these values in hidden fields, because the displayed fields are disabled and don't submit. This ensures that when