NIHVIVO-646 Add cancelUrl parameter to submit tag in InputElementFormattingTags so that the cancel button can redirect to a different page from the form submission. Change cancel values in submit tags in vitro and vivo forms to "true" where previously they specified a uri, because the uri is misleading (it doesn't control the redirect location). Removed edit submission preprocessing due to problems with cloning.

This commit is contained in:
rjy7 2010-06-17 14:27:03 +00:00
parent bd45d55237
commit 13c57446dd
6 changed files with 60 additions and 14 deletions

View file

@ -125,13 +125,13 @@ SPARQL queries for existing values. --%>
?newPerson core:authorInAuthorship ?authorshipUri .
</v:jsonset>
<c:set var="returnPath" value="/edit/editRequestDispatch.jsp?subjectUri=${subjectUri}&predicateUri=${predicateUri}" />
<c:set var="returnPathAfterSubmit" value="/edit/editRequestDispatch.jsp?subjectUri=${subjectUri}&predicateUri=${predicateUri}" />
<c:set var="editjson" scope="request">
{
"formUrl" : "${formUrl}",
"editKey" : "${editKey}",
"urlPatternToReturnTo" : "${returnPath}",
"urlPatternToReturnTo" : "${returnPathAfterSubmit}",
"subject" : ["infoResource", "${subjectUriJson}" ],
"predicate" : ["predicate", "${predicateUriJson}" ],
@ -224,10 +224,11 @@ SPARQL queries for existing values. --%>
EditConfiguration.putConfigInSession(editConfig,session);
}
// Doing this in Javascript instead.
// For now the field names in CreateLabelFromFieldNames.processEditSubmission() are
// hard-coded. If we want the flexibility in naming them, we can pass in a map of
// hard-coded. If we want flexibility in naming them, we can pass in a map of
// the field names when creating the preprocessor.
editConfig.addEditSubmissionPreprocessor(new CreateLabelFromNameFields(editConfig));
// editConfig.addEditSubmissionPreprocessor(new CreateLabelFromNameFields(editConfig));
Model model = (Model) application.getAttribute("jenaOntModel");
String objectUri = (String) request.getAttribute("objectUri");
@ -295,7 +296,7 @@ SPARQL queries for existing values. --%>
</ul>
<div id="showAddForm">
<v:input type="submit" value="Add Author" id="showAddFormButton" cancel="${param.subjectUri}" cancelLabel="Return to Publication" />
<v:input type="submit" value="Add Author" id="showAddFormButton" cancel="true" cancelLabel="Return to Publication" cancelUrl="/individual" />
</div>
@ -305,10 +306,13 @@ SPARQL queries for existing values. --%>
<p class="inline"><v:input type="text" id="firstName" label="First name ${requiredHint}" size="20" />${initialHint}</p>
<p class="inline"><v:input type="text" id="middleName" label="Middle name" size="20" />${initialHint}</p>
<input type="hidden" name="personUri" value="" /> <!-- Field value populated by JavaScript -->
<input type="hidden" name="rank" value="${rank}" />
<p class="submit"><v:input type="submit" id="submit" value="Add Author" cancel="${param.subjectUri}" /></p>
<!-- Field values populated by JavaScript -->
<input type="hidden" id="label" name="label" value="" />
<input type="hidden" id="personUri" name="personUri" value="" />
<p class="submit"><v:input type="submit" id="submit" value="Add Author" cancel="true" /></p>
<p id="requiredLegend" class="requiredHint">* required fields</p>
</form>

View file

@ -23,7 +23,15 @@ var addAuthorForm = {
this.showFormDiv = $('#showAddForm');
this.showFormButton = $('#showAddFormButton');
this.removeLinks = $('a.remove');
this.submit = this.form.find(':submit');
this.cancel = this.form.find('.cancel');
this.labelField = $('#label');
this.firstNameField = $('#firstName');
this.middleNameField = $('#middleName');
this.lastNameField = $('#lastName');
this.personUriField = $('#personUri');
this.firstNameWrapper = this.firstNameField.parent();
this.middleNameWrapper = this.middleNameField.parent();
},
// On page load, make changes to the non-Javascript version for the Javascript version.
@ -39,12 +47,19 @@ var addAuthorForm = {
initForm: function() {
//this.firstNameWrapper.hide();
//this.middleNameWrapper.hide();
this.showFormButton.click(function() {
addAuthorForm.showFormDiv.hide();
addAuthorForm.form.show();
return false;
});
this.submit.click(function() {
addAuthorForm.insertLabel(); // might be insertLabelOrPersonUri
});
this.cancel.click(function() {
addAuthorForm.hideFields(addAuthorForm.form);
addAuthorForm.showFormDiv.show();
@ -52,6 +67,7 @@ var addAuthorForm = {
});
// this.setUpAutocomplete();
},
// setUpAutocomplete: function() {
@ -63,6 +79,32 @@ var addAuthorForm = {
//
// },
insertLabel: function() {
var firstName,
middleName,
lastName,
name;
if (!this.firstNameField.is(':hidden')) {
firstName = this.firstNameField.val();
middleName = this.middleNameField.val();
lastName = this.lastNameField.val();
name = lastName;
if (firstName) {
name += ", " + firstName;
}
if (middleName) {
name += " " + middleName;
}
this.labelField.val(name);
}
else {
}
},
toggleRemoveLink: function() {
// when clicking remove: remove the author, and change link text to "undo"
// when clicking undo: add the author back, and change link text to "remove"

View file

@ -198,7 +198,7 @@
<v:input type="select" label="person" id="personUri" />
<v:input type="text" label="start year (YYYY)" id="startYear" size="4"/>
<v:input type="text" label="end year (YYYY)" id="endYear" size="4"/>
<p class="submit"><v:input type="submit" id="submit" value="<%=submitLabel%>" cancel="${param.subjectUri}"/></p>
<p class="submit"><v:input type="submit" id="submit" value="<%=submitLabel%>" cancel="true"/></p>
</form>
<jsp:include page="${postForm}"/>

View file

@ -310,7 +310,7 @@
<v:input type="text" label="Start Year and Month ${yearMonthHint}" id="startYearMonth" size="7"/>
<v:input type="text" label="End Year and Month ${yearMonthHint}" id="endYearMonth" size="7"/>
<p class="submit"><v:input type="submit" id="submit" value="${submitLabel}" cancel="${param.subjectUri}"/></p>
<p class="submit"><v:input type="submit" id="submit" value="${submitLabel}" cancel="true"/></p>
<p id="requiredLegend" class="requiredHint">* required fields</p>
</form>

View file

@ -421,7 +421,7 @@ the org type still gets asserted. --%>
<input type="hidden" name="steps" value="1" />
<input type="hidden" name="view" value="${view}" />
<p class="submit"><v:input type="submit" id="submit" value="${submitLabel}" cancel="${param.subjectUri}"/></p>
<p class="submit"><v:input type="submit" id="submit" value="${submitLabel}" cancel="true"/></p>
<p id="requiredLegend" class="requiredHint">* required fields</p>
</form>

View file

@ -350,7 +350,7 @@
<input type="hidden" name="steps" value="${formSteps}" />
<input type="hidden" name="view" value="${view}" />
<p class="submit"><v:input type="submit" id="submit" value="${submitLabel}" cancel="${param.subjectUri}"/></p>
<p class="submit"><v:input type="submit" id="submit" value="${submitLabel}" cancel="true"/></p>
<p id="requiredLegend" class="requiredHint">* required fields</p>
</form>