diff --git a/productMods/edit/forms/js/customFormWithAutocomplete.js b/productMods/edit/forms/js/customFormWithAutocomplete.js index e7f46230..8ee7ef2c 100644 --- a/productMods/edit/forms/js/customFormWithAutocomplete.js +++ b/productMods/edit/forms/js/customFormWithAutocomplete.js @@ -77,6 +77,14 @@ var customForm = { this.formSteps = 2; } } + + //Handles special case such as autocomplete which allows for editing with autocomplete + //By default set to false + if(!this.supportEdit) { + this.supportEdit = false; + } else { + this.supportEdit = true; + } this.bindEventListeners(); @@ -94,11 +102,13 @@ var customForm = { // Put this case first, because in edit mode with // validation errors we just want initFormFullView. - if (this.editMode == 'edit' || this.editMode == 'repair') { + if ((!this.supportEdit) && (this.editMode == 'edit' || this.editMode == 'repair')) { this.initFormFullView(); } else if (this.findValidationErrors()) { this.initFormWithValidationErrors(); + } else if(this.supportEdit && this.editMode == 'edit') { + this.initFormWithSupportEdit(); } // If type is already selected when the page loads (Firefox retains value // on a refresh), go directly to full view. Otherwise user has to reselect @@ -165,6 +175,11 @@ var customForm = { } }, + initFormWithSupportEdit: function() { + this.initFormWithValidationErrors(); + //Hide verify match when edit mode + this.verifyMatch.hide(); + }, // Bind event listeners that persist over the life of the page. Event listeners // that depend on the view should be initialized in the view setup method. @@ -209,7 +224,7 @@ var customForm = { initAutocomplete: function() { - if (this.editMode === 'edit') { + if (this.editMode === 'edit' && !this.supportEdit) { return; } @@ -350,7 +365,10 @@ var customForm = { this.acSelector.val(label); this.acSelectionInfo.html(label); this.verifyMatch.attr('href', this.verifyMatch.data('baseHref') + uri); - + //Verify match is hidden in edit mode and support edit so unhide it + if(this.editMode == 'edit' && this.supportEdit) { + this.verifyMatch.show(); + } this.setButtonText('existing'); this.cancel.unbind('click'); @@ -431,6 +449,11 @@ var customForm = { if (this.editMode === 'edit') { return; } + + //if support select editing, keep button label same + if(this.supportEdit) { + return; + } typeText = this.getTypeNameForLabels(); diff --git a/productMods/templates/freemarker/edit/forms/autoCompleteObjectPropForm.ftl b/productMods/templates/freemarker/edit/forms/autoCompleteObjectPropForm.ftl new file mode 100644 index 00000000..4ee228ec --- /dev/null +++ b/productMods/templates/freemarker/edit/forms/autoCompleteObjectPropForm.ftl @@ -0,0 +1,109 @@ +<#-- $This file is distributed under the terms of the license in /doc/license.txt$ --> + +<#--Assign variables from editConfig--> +<#assign rangeOptions = editConfiguration.pageData.objectVar /> +<#assign rangeOptionsExist = false /> +<#if (rangeOptions?keys?size > 0)> + <#assign rangeOptionsExist = true/> +#if> +<#assign objectTypes = editConfiguration.pageData.objectTypes /> +<#assign sparqlForAcFilter = editConfiguration.pageData.sparqlForAcFilter /> +<#assign editMode = editConfiguration.pageData.editMode /> +<#if editMode = "edit" > + <#assign titleVerb = "Edit" /> + <#assign objectLabel = editConfiguration.pageData.objectLabel /> + <#assign selectedObjectUri = editConfiguration.objectUri /> +<#else> + <#assign titleVerb = "Add" > + <#assign objectLabel = "" /> + <#assign selectedObjectUri = ""/> +#if> + + +
There are no entries in the system from which to select.
+ #if> +#if> + +<#if editConfiguration.propertyOfferCreateNewOption = true> +<#include "defaultOfferCreateNewOptionForm.ftl"> + +#if> + +<#if editConfiguration.propertySelectFromExisting = false && editConfiguration.propertyOfferCreateNewOption = false> +This property is currently configured to prohibit editing.
+#if> + + +<#if editConfiguration.includeDeletionForm = true> +<#include "defaultDeletePropertyForm.ftl"> +#if> + + +<#assign sparqlQueryUrl = "${urls.base}/ajax/sparqlQuery" > + + + + + +${stylesheets.add('')} + ${stylesheets.add('')} + ${stylesheets.add('')} + + + ${scripts.add('', + '', + '', + '')} diff --git a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AutocompleteObjectPropertyFormGenerator.java b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AutocompleteObjectPropertyFormGenerator.java new file mode 100644 index 00000000..11ce332d --- /dev/null +++ b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AutocompleteObjectPropertyFormGenerator.java @@ -0,0 +1,86 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import edu.cornell.mannlib.vitro.webapp.beans.Individual; +import edu.cornell.mannlib.vitro.webapp.beans.VClass; +import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; +import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; +import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; +import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils; +import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo; +import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils; +import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils.EditMode; + +/** + * Generates the edit configuration for a default property form. + * + */ +public class AutocompleteObjectPropertyFormGenerator extends DefaultObjectPropertyFormGenerator { + + //The only thing that changes here are the templates + private Log log = LogFactory.getLog(AutocompleteObjectPropertyFormGenerator.class); + + private String objectPropertyTemplate = "autoCompleteObjectPropForm.ftl"; + private String dataPropertyTemplate = "autoCompleteDataPropForm.ftl"; + + @Override + public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) { + HashMap