diff --git a/productMods/edit/forms/css/customForm.css b/productMods/edit/forms/css/customForm.css index a11563df..a240eee9 100644 --- a/productMods/edit/forms/css/customForm.css +++ b/productMods/edit/forms/css/customForm.css @@ -16,12 +16,14 @@ #addNewLink { float: right; - margin-right: 18em; + /* This right margin works pretty well for both the add and edit version of the form. + Could customize for each of these versions later. */ + margin-right: 15em; margin-top: .8em; width: 30%; padding: .6em 0 .6em 1.5em; border: 1px solid #9c9c9c; - + display: none; /* Hide if Javascript disabled. Javascript will show. */ } #content form #existing { @@ -33,6 +35,7 @@ #new { padding: .6em 0 .6em 1.5em; border: 1px solid #9c9c9c; + width: 70%; } /* #content form p.inline span,*/ diff --git a/productMods/edit/forms/js/customForm.js b/productMods/edit/forms/js/customForm.js index 2513c6cb..5df8a6da 100644 --- a/productMods/edit/forms/js/customForm.js +++ b/productMods/edit/forms/js/customForm.js @@ -2,8 +2,6 @@ var customForm = { - - onLoad: function() { // Create references to form elements. @@ -25,13 +23,27 @@ var customForm = { this.newType = $("input[name='newType']").val().capitalize(); if (this.editType == 'add') { //adding a new entry - this.initAddForm(); - + this.initAddForm(); + } else { // editing existing entry this.initEditForm(); - } + } }, + // Reset add form to initial state (step 1) + // Should only be needed after returning to step 1 from step 2, + // but sometimes seems to be needed on page load as well, so call it from initAddForm() + resetAddForm: function() { + // Clear all form data and error messages + $('input:text').val(''); + $('.error').text(''); + + // Remove previously bound event handlers + this.cancel.unbind('click'); + this.button.unbind('click'); + + this.toggleRequiredHints('remove', this.addNew, this.existing); + }, // Set up add form on page load, or when returning to initial state // (The latter is not yet implemented, but we are preparing for it. Note @@ -39,22 +51,7 @@ var customForm = { // RY *** SOME of this will be shared with the edit form - figure out which initAddForm: function() { - // Reset form to initial state - // Resetting should only need to be done after we've gone to step 2 and back to step 1, - // but for some reason it can be required on a page reload as well. - // Clear all form data and error messages - $('input:text').val(''); - $('.error').text(''); - - // Remove previously bound event handlers - this.cancel.unbind('click'); - this.button.unbind('click'); - - // RY Make toggleRequiredHints take multiple args - //this.toggleRequiredHints('remove', this.existing, this.addNew); - this.toggleRequiredHints('remove', this.addNew, this.existing); - //this.toggleRequiredHints('remove', this.addNew); - // end reset + this.resetAddForm(); // Step 1 of the form this.addNewLink.show(); @@ -96,7 +93,22 @@ var customForm = { }, initEditForm: function() { - + + this.showFields(this.existing); + this.addNewLink.show(); + this.addNew.hide(); + this.showFields(this.entry); + this.requiredLegend.show(); + this.button.val('Save Changes'); + + this.addNewLink.bind('click', function() { + $(this).hide(); + customForm.existing.hide(); + customForm.showFields(customForm.addNew); + + customForm.button.val('Create ' + customForm.newType + ' & Save Changes'); + }); + }, // Add required hints to required fields in element array elArray. diff --git a/productMods/edit/forms/personHasPositionHistory.jsp b/productMods/edit/forms/personHasPositionHistory.jsp index e862ebb0..9abf5ac0 100644 --- a/productMods/edit/forms/personHasPositionHistory.jsp +++ b/productMods/edit/forms/personHasPositionHistory.jsp @@ -214,7 +214,7 @@ "objectClassUri" : "", "rangeDatatypeUri" : "${stringDatatypeUriJson}", "rangeLang" : "", - "assertions" : [ "${newOrgNameAssertion}" ] + "assertions" : [ "${n3ForNewOrg}" ] }, "newOrgType" : { "newResource" : "false", @@ -308,13 +308,10 @@