NIHVIVO-797 Javascript support for edit mode in roles forms

This commit is contained in:
rjy7 2010-07-15 12:02:36 +00:00
parent 0fc16eee1f
commit b4cddb53e5
5 changed files with 62 additions and 13 deletions

View file

@ -284,6 +284,7 @@ SPARQL queries for existing values. --%>
<jsp:include page="${preForm}" /> <jsp:include page="${preForm}" />
<%-- DO NOT CHANGE IDS, CLASSES, OR HTML STRUCTURE ON THIS PAGE WITHOUT UNDERSTANDING THE IMPACT ON THE JAVASCRIPT! --%>
<h2>${title}</h2> <h2>${title}</h2>
<h3>Manage Authors</h3> <h3>Manage Authors</h3>
@ -380,6 +381,7 @@ SPARQL queries for existing values. --%>
<v:input type="submit" value="Add Author" id="showAddFormButton" cancel="true" cancelLabel="Return to Publication" cancelUrl="/individual" /> <v:input type="submit" value="Add Author" id="showAddFormButton" cancel="true" cancelLabel="Return to Publication" cancelUrl="/individual" />
</div> </div>
<%-- DO NOT CHANGE IDS, CLASSES, OR HTML STRUCTURE IN THIS FORM WITHOUT UNDERSTANDING THE IMPACT ON THE JAVASCRIPT! --%>
<form id="addAuthorForm" action="<c:url value="/edit/processRdfForm2.jsp"/>" > <form id="addAuthorForm" action="<c:url value="/edit/processRdfForm2.jsp"/>" >
<h3>Add an Author</h3> <h3>Add an Author</h3>

View file

@ -256,6 +256,7 @@ PREFIX core: <${vivoCore}>
<h2>${formHeading}</h2> <h2>${formHeading}</h2>
<%-- DO NOT CHANGE IDS, CLASSES, OR HTML STRUCTURE IN THIS FORM WITHOUT UNDERSTANDING THE IMPACT ON THE JAVASCRIPT! --%>
<form id="addGrantRoleToPerson" action="<c:url value="/edit/processRdfForm2.jsp"/>" > <form id="addGrantRoleToPerson" action="<c:url value="/edit/processRdfForm2.jsp"/>" >
<p><v:input type="text" id="label" name="grantLabel" label="Grant Name ${requiredHint}" cssClass="acSelector" size="50" /></p> <p><v:input type="text" id="label" name="grantLabel" label="Grant Name ${requiredHint}" cssClass="acSelector" size="50" /></p>

View file

@ -206,6 +206,7 @@ SPARQL queries for existing values. --%>
<h2>Create a new publication entry for <%= subjectName %></h2> <h2>Create a new publication entry for <%= subjectName %></h2>
<%-- DO NOT CHANGE IDS, CLASSES, OR HTML STRUCTURE IN THIS FORM WITHOUT UNDERSTANDING THE IMPACT ON THE JAVASCRIPT! --%>
<form id="addPublicationForm" action="<c:url value="/edit/processRdfForm2.jsp"/>" > <form id="addPublicationForm" action="<c:url value="/edit/processRdfForm2.jsp"/>" >
<p class="inline"><v:input type="select" label="Publication Type ${requiredHint}" name="pubType" id="typeSelector" /></p> <p class="inline"><v:input type="select" label="Publication Type ${requiredHint}" name="pubType" id="typeSelector" /></p>

View file

@ -303,17 +303,30 @@
<c:set var="requiredHint" value="<span class='requiredHint'> *</span>" /> <c:set var="requiredHint" value="<span class='requiredHint'> *</span>" />
<c:set var="yearMonthHint" value="<span class='hint'>(YYYY-MM)</span>" /> <c:set var="yearMonthHint" value="<span class='hint'>(YYYY-MM)</span>" />
<c:choose>
<c:when test="<%= request.getAttribute("objectUri")!=null %>">
<c:set var="titleText" value="Edit" />
<c:set var="buttonText" value="Edit" />
<c:set var="editMode" value="edit" />
</c:when>
<c:otherwise>
<c:set var="titleText" value="Create a new" />
<c:set var="buttonText" value="Create" />
<c:set var="editMode" value="add" />
</c:otherwise>
</c:choose>
<jsp:include page="${preForm}" /> <jsp:include page="${preForm}" />
<h2>Create a new ${roleActivityTypeLabel} entry for <%= subjectName %></h2> <h2>${titleText}&nbsp;${roleActivityTypeLabel} entry for <%= subjectName %></h2>
<%-- DO NOT CHANGE IDS, CLASSES, OR HTML STRUCTURE IN THIS FORM WITHOUT UNDERSTANDING THE IMPACT ON THE JAVASCRIPT! --%>
<form id="addPublicationForm" action="<c:url value="/edit/processRdfForm2.jsp"/>" > <form id="addPublicationForm" action="<c:url value="/edit/processRdfForm2.jsp"/>" >
<p class="inline"><v:input type="select" label="${roleActivityTitleCase} Type ${requiredHint}" name="roleActivityType" id="typeSelector" /></p> <p class="inline"><v:input type="select" label="${roleActivityTitleCase} Type ${requiredHint}" name="roleActivityType" id="typeSelector" /></p>
<div class="fullViewOnly"> <div class="fullViewOnly">
<p><v:input type="text" id="activityLabel" name="activityLabel" label="Title" cssClass="acSelector" size="50" /></p> <p><v:input type="text" id="label" name="activityLabel" label="Title" cssClass="acSelector" size="50" /></p>
<div class="acSelection"> <div class="acSelection">
<%-- RY maybe make this a label and input field. See what looks best. --%> <%-- RY maybe make this a label and input field. See what looks best. --%>
@ -321,7 +334,7 @@
<input type="hidden" id="roleActivityURI" name="roleActivity" class="acReceiver" value="" /> <!-- Field value populated by JavaScript --> <input type="hidden" id="roleActivityURI" name="roleActivity" class="acReceiver" value="" /> <!-- Field value populated by JavaScript -->
</div> </div>
<p><v:input type="text" id="roleLabel" name="roleLabel" label="Role in X ${requiredHint}" size="50" /></p> <p><v:input type="text" id="newIndividualLabel" name="roleLabel" label="Role Name ${requiredHint}" size="50" /></p>
<h4>Dates of Participation</h4> <h4>Dates of Participation</h4>
<v:input type="text" label="Start Year ${requiredHint} ${yearHint}" id="startYear" size="7"/> <v:input type="text" label="Start Year ${requiredHint} ${yearHint}" id="startYear" size="7"/>
@ -345,7 +358,8 @@ SELECT ?indUri WHERE {<${subjectUri}> <${predicateUri}> ?role . ?role <${vivoCor
var customFormData = { var customFormData = {
sparqlForAcFilter: '${sparqlForAcFilter}', sparqlForAcFilter: '${sparqlForAcFilter}',
sparqlQueryUrl: '${sparqlQueryUrl}', sparqlQueryUrl: '${sparqlQueryUrl}',
acUrl: '${acUrl}' acUrl: '${acUrl}',
editMode: '${editMode}'
}; };
</script> </script>
<jsp:include page="${postForm}"/> <jsp:include page="${postForm}"/>

View file

@ -45,6 +45,10 @@ var customForm = {
// because it may have already been modified for a previous selection. // because it may have already been modified for a previous selection.
this.baseLabelText = this.labelFieldLabel.html(); this.baseLabelText = this.labelFieldLabel.html();
// Label field for new individual being created
// this.newIndLabelFieldLabel = $('label[for=' + $('#newIndividualLabel').attr('id') + ']');
// this.newIndBaseLabelText = this.newIndLabelFieldLabel.html();
this.or = $('span.or'); this.or = $('span.or');
this.cancel = this.form.find('.cancel'); this.cancel = this.form.find('.cancel');
@ -53,7 +57,11 @@ var customForm = {
// Set up the form on page load // Set up the form on page load
initPage: function() { initPage: function() {
if (!this.typeSelector.length) { if (!this.editMode) {
this.editMode = "add"; // edit vs add: default to add
}
if (!this.typeSelector.length || this.editMode == "edit") {
this.formSteps = 1; this.formSteps = 1;
// there's also going to be a 3-step form - look for this.subTypeSelector // there's also going to be a 3-step form - look for this.subTypeSelector
} else { } else {
@ -80,7 +88,7 @@ var customForm = {
// twice to get to full view. // twice to get to full view.
else if (typeVal.length) { else if (typeVal.length) {
this.acType = typeVal; this.acType = typeVal;
this.setLabelFieldLabel(); this.setLabelFieldLabels();
this.initFormFullView(); this.initFormFullView();
} }
else { else {
@ -104,7 +112,7 @@ var customForm = {
this.or.show(); this.or.show();
this.requiredLegend.show(); this.requiredLegend.show();
this.button.show(); this.button.show();
this.button.val('Create ' + this.baseButtonText); this.toggleButtonText("new");
this.cancel.unbind('click'); this.cancel.unbind('click');
if( this.formSteps > 1 ){ if( this.formSteps > 1 ){
@ -131,7 +139,7 @@ var customForm = {
customForm.acType = typeVal; customForm.acType = typeVal;
if (typeVal.length) { if (typeVal.length) {
customForm.setLabelFieldLabel(); customForm.setLabelFieldLabels();
customForm.initFormFullView(); customForm.initFormFullView();
} else { } else {
// If no selection, go back to type view. This prevents problems like trying to run autocomplete // If no selection, go back to type view. This prevents problems like trying to run autocomplete
@ -262,7 +270,7 @@ var customForm = {
this.acSelectionInfo.html(ui.item.label); this.acSelectionInfo.html(ui.item.label);
this.verifyMatch.attr('href', this.verifyMatchBaseHref + uri); this.verifyMatch.attr('href', this.verifyMatchBaseHref + uri);
this.button.val('Add ' + this.baseButtonText); this.toggleButtonText('existing');
this.cancel.unbind('click'); this.cancel.unbind('click');
this.cancel.click(function() { this.cancel.click(function() {
@ -283,7 +291,7 @@ var customForm = {
this.acReceiver.val(''); this.acReceiver.val('');
this.acSelectionInfo.html(''); this.acSelectionInfo.html('');
this.verifyMatch.attr('href', this.verifyMatchBaseHref); this.verifyMatch.attr('href', this.verifyMatchBaseHref);
this.button.val('Create ' + this.baseButtonText) this.toggleButtonText('new');
if (this.formSteps > 1) { if (this.formSteps > 1) {
this.acSelection.find('label').html('Selected '); this.acSelection.find('label').html('Selected ');
@ -295,8 +303,31 @@ var customForm = {
return this.typeSelector.find(':selected').html(); return this.typeSelector.find(':selected').html();
}, },
setLabelFieldLabel: function() { setLabelFieldLabels: function() {
// var newLabelTextForNewInd;
this.labelFieldLabel.html(this.getSelectedTypeName() + ' ' + this.baseLabelText); this.labelFieldLabel.html(this.getSelectedTypeName() + ' ' + this.baseLabelText);
// if (this.newIndLabelFieldLabel.length) {
// newLabelTextForNewInd = this.newIndBaseLabelText.replace('X', this.getSelectedTypeName);
// this.newIndLabelFieldLabel.html(newLabelTextForNewInd);
// }
},
toggleButtonText: function(newOrExisting) {
if (this.editMode == "edit") {
this.button.val("Edit " + this.baseButtonText);
}
// RY Make this better for roles and grants forms later. The verbs
// don't quite work. It should be "Create X and <role>" vs.
// "Create <role>" or "Add <role>"
else if (newOrExisting == "new") {
this.button.val("Create " + this.baseButtonText);
}
else {
this.button.val("Add " + this.baseButtonText);
}
} }
}; };