From 028d367461bf8797fc0dcdc56fa398eb3197010b Mon Sep 17 00:00:00 2001 From: tworrall Date: Fri, 6 Apr 2012 19:04:25 +0000 Subject: [PATCH] NIHVIVO-3709: updates to support editable autocomplete fields --- .../edit/forms/addGrantRoleToPerson.ftl | 43 +++++++-- .../edit/forms/addPresenterRoleToPerson.ftl | 4 +- .../edit/forms/addPublicationToPerson.ftl | 13 ++- .../forms/js/customFormWithAutocomplete.js | 3 +- .../edit/forms/js/publicationToPersonUtils.js | 42 +++++--- .../forms/organizationHasPositionHistory.ftl | 39 +++++++- .../edit/forms/personHasAwardOrHonor.ftl | 1 - .../forms/personHasEducationalTraining.ftl | 35 ++++++- .../edit/forms/personHasPositionHistory.ftl | 34 ++++++- .../OrganizationHasPositionValidator.java | 95 +++++++++++++++++++ .../PersonHasPublicationValidator.java | 49 +++++----- .../AddGrantRoleToPersonGenerator.java | 84 ++++++++++------ .../AddPublicationToPersonGenerator.java | 12 +++ .../AddRoleToPersonTwoStageGenerator.java | 71 ++++++++++---- ...ganizationHasPositionHistoryGenerator.java | 59 +++++++++--- .../PersonHasAwardOrHonorGenerator.java | 2 +- .../PersonHasEducationalTraining.java | 61 ++++++------ .../PersonHasPositionHistoryGenerator.java | 59 +++++++----- 18 files changed, 519 insertions(+), 187 deletions(-) create mode 100644 src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/OrganizationHasPositionValidator.java diff --git a/productMods/templates/freemarker/edit/forms/addGrantRoleToPerson.ftl b/productMods/templates/freemarker/edit/forms/addGrantRoleToPerson.ftl index dd34288d..e6deaee4 100644 --- a/productMods/templates/freemarker/edit/forms/addGrantRoleToPerson.ftl +++ b/productMods/templates/freemarker/edit/forms/addGrantRoleToPerson.ftl @@ -17,6 +17,19 @@ <#assign disabledVal = "disabled=\"disabled\"" /> + +<#--The blank sentinel indicates what value should be put in a URI when no autocomplete result has been selected. +If the blank value is non-null or non-empty, n3 editing for an existing object will remove the original relationship +if nothing is selected for that object--> +<#assign blankSentinel = "" /> +<#if editConfigurationConstants?has_content && editConfigurationConstants?keys?seq_contains("BLANK_SENTINEL")> + <#assign blankSentinel = editConfigurationConstants["BLANK_SENTINEL"] /> + + +<#--This flag is for clearing the label field on submission for an existing object being selected from autocomplete. +Set this flag on the input acUriReceiver where you would like this behavior to occur. --> +<#assign flagClearLabelForExisting = "flagClearLabelForExisting" /> + <#--the heading and submit button label depend on the predicate uri--> <#assign formHeading = "investigator entry for "/> @@ -43,11 +56,10 @@ <#--Get selected activity type value if it exists, this is alternative to below--> -<#assign grantLabel = lvf.getFormFieldValue(editSubmission, editConfiguration, "grantLabel")/> -<#--Get existing grant label value--> -<#assign existingGrantLabel = lvf.getFormFieldValue(editSubmission, editConfiguration, "existingGrantLabel")/> +<#assign grantLabelValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "grantLabel")/> +<#assign grantLabelDisplayValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "grantLabelDisplay")/> <#--Get existing grant value--> -<#assign existingGrantValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "grant")/> +<#assign existingGrantValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "existingGrant")/> <#assign requiredHint = " *" /> @@ -62,6 +74,10 @@ <#--Display error messages if any--> <#if submissionErrors?has_content> + <#if grantLabelDisplayValue?has_content > + <#assign grantLabelValue = grantLabelDisplayValue /> + + @@ -222,7 +225,7 @@ Set this flag on the input acUriReceiver where you would like this behavior to o <#-- Editor -->

- +
diff --git a/productMods/templates/freemarker/edit/forms/js/customFormWithAutocomplete.js b/productMods/templates/freemarker/edit/forms/js/customFormWithAutocomplete.js index f96ba126..b5481af9 100644 --- a/productMods/templates/freemarker/edit/forms/js/customFormWithAutocomplete.js +++ b/productMods/templates/freemarker/edit/forms/js/customFormWithAutocomplete.js @@ -492,7 +492,8 @@ var customForm = { $acSelector.parent('p').show(); this.resetAcSelection($acSelectionObj); if ( clearAcSelectorVal == true ) { - $acSelector.val(''); + $acSelector.val(''); + $("input.display[acGroupName='" + $acSelectionObj.attr('acGroupName') + "']").val(""); } customForm.addAcHelpText($acSelector); diff --git a/productMods/templates/freemarker/edit/forms/js/publicationToPersonUtils.js b/productMods/templates/freemarker/edit/forms/js/publicationToPersonUtils.js index f28d94f3..fd1aebb8 100644 --- a/productMods/templates/freemarker/edit/forms/js/publicationToPersonUtils.js +++ b/productMods/templates/freemarker/edit/forms/js/publicationToPersonUtils.js @@ -381,23 +381,35 @@ var publicationToPersonUtils = { // If editorUri contains the sentinel value, we need to process the name fields // otherwise, disable them so they are not submitted - if ( this.editorUri.val() == this.sentinel ) { - firstName = this.firstName.val(); - lastName = this.editor.val(); - name = lastName; - if (firstName) { - name += ', ' + firstName; - } - this.editor.val(name); - this.lastName.val(lastName); - } - else { - this.firstName.attr('disabled', 'disabled'); - this.lastName.attr('disabled', 'disabled'); - } - + if (this.editor.parent('p').is(':visible') ) { + if ( this.editor.val().indexOf('Select an existing') != -1 ) { + this.editor.val(''); + } + if ( this.editorUri.val() == '' || this.editorUri.val() == this.sentinel ) { + firstName = this.firstName.val(); + lastName = this.editor.val(); + name = lastName; + if (firstName) { + name += ', ' + firstName; + } + this.editor.val(name); + this.lastName.val(lastName); + } + else { + this.disableNameFields(); + } + } + else { + this.disableNameFields(); + } + }, + disableNameFields: function() { + this.firstName.attr('disabled', 'disabled'); + this.lastName.attr('disabled', 'disabled'); + }, + resetLastNameLabel: function() { var indx = this.editor.val().indexOf(", "); if ( indx != -1 ) { diff --git a/productMods/templates/freemarker/edit/forms/organizationHasPositionHistory.ftl b/productMods/templates/freemarker/edit/forms/organizationHasPositionHistory.ftl index 5245f0f3..41d69e48 100644 --- a/productMods/templates/freemarker/edit/forms/organizationHasPositionHistory.ftl +++ b/productMods/templates/freemarker/edit/forms/organizationHasPositionHistory.ftl @@ -23,10 +23,22 @@ <#assign requiredHint = " *" /> <#assign yearHint = "(YYYY)" /> +<#assign blankSentinel = "" /> +<#if editConfigurationConstants?has_content && editConfigurationConstants?keys?seq_contains("BLANK_SENTINEL")> + <#assign blankSentinel = editConfigurationConstants["BLANK_SENTINEL"] /> + + +<#--This flag is for clearing the label field on submission for an existing object being selected from autocomplete. +Set this flag on the input acUriReceiver where you would like this behavior to occur. --> +<#assign flagClearLabelForExisting = "flagClearLabelForExisting" /> + <#assign positionTitleValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "positionTitle") /> <#assign positionTypeValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "positionType") /> -<#assign personValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "person") /> +<#assign existingPersonValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "existingPerson") /> <#assign personLabelValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "personLabel") /> +<#assign personLabelDisplayValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "personLabelDisplay") /> +<#assign firstNameValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "firstName") /> +<#assign lastNameValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "lastName") /> <#if editSubmission?has_content && editSubmission.submissionExists = true && editSubmission.validationErrors?has_content> <#assign submissionErrors = editSubmission.validationErrors/> @@ -35,6 +47,9 @@

${titleVerb} position history entry for ${editConfiguration.subjectName}

<#if submissionErrors?has_content> + <#if personLabelDisplayValue?has_content > + <#assign personLabelValue = personLabelDisplayValue /> + + ${stylesheets.add('')} ${stylesheets.add('')} @@ -153,6 +181,7 @@ ${stylesheets.add('', '', '', + '', '', '', '')} diff --git a/productMods/templates/freemarker/edit/forms/personHasAwardOrHonor.ftl b/productMods/templates/freemarker/edit/forms/personHasAwardOrHonor.ftl index e0bb2679..187d4ed8 100644 --- a/productMods/templates/freemarker/edit/forms/personHasAwardOrHonor.ftl +++ b/productMods/templates/freemarker/edit/forms/personHasAwardOrHonor.ftl @@ -25,7 +25,6 @@ if nothing is selected for that object--> Set this flag on the input acUriReceiver where you would like this behavior to occur. --> <#assign flagClearLabelForExisting = "flagClearLabelForExisting" /> - <#assign htmlForElements = editConfiguration.pageData.htmlForElements /> <#--Retrieve variables needed--> diff --git a/productMods/templates/freemarker/edit/forms/personHasEducationalTraining.ftl b/productMods/templates/freemarker/edit/forms/personHasEducationalTraining.ftl index 63ea38f1..4a4b5c1e 100644 --- a/productMods/templates/freemarker/edit/forms/personHasEducationalTraining.ftl +++ b/productMods/templates/freemarker/edit/forms/personHasEducationalTraining.ftl @@ -14,14 +14,27 @@ <#assign editMode = editConfiguration.pageData.editMode /> <#assign htmlForElements = editConfiguration.pageData.htmlForElements /> +<#--The blank sentinel indicates what value should be put in a URI when no autocomplete result has been selected. +If the blank value is non-null or non-empty, n3 editing for an existing object will remove the original relationship +if nothing is selected for that object--> +<#assign blankSentinel = "" /> +<#if editConfigurationConstants?has_content && editConfigurationConstants?keys?seq_contains("BLANK_SENTINEL")> + <#assign blankSentinel = editConfigurationConstants["BLANK_SENTINEL"] /> + + +<#--This flag is for clearing the label field on submission for an existing object being selected from autocomplete. +Set this flag on the input acUriReceiver where you would like this behavior to occur. --> +<#assign flagClearLabelForExisting = "flagClearLabelForExisting" /> + <#--Retrieve variables needed--> <#assign orgTypeValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "orgType")/> <#assign orgLabelValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "orgLabel") /> +<#assign orgLabelDisplayValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "orgLabelDisplay") /> <#assign deptValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "dept") /> <#assign infoValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "info") /> <#assign majorFieldValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "majorField") /> <#assign degreeValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "degree") /> -<#assign existingOrgValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "org") /> +<#assign existingOrgValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "existingOrg") /> <#assign trainingTypeValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "trainingType")/> <#--If edit submission exists, then retrieve validation errors if they exist--> @@ -47,6 +60,9 @@ <#--Display error messages if any--> <#if submissionErrors?has_content> + <#if orgLabelDisplayValue?has_content > + <#assign orgLabelValue = orgLabelDisplayValue /> +