NIHVIVO-1024 Modified the way placeholder text in labels is handled to make it more general and apply to any label or text in the form.
This commit is contained in:
parent
6fb1e6bf02
commit
45b1545b3a
5 changed files with 28 additions and 40 deletions
|
@ -286,7 +286,7 @@ PREFIX core: <${vivoCore}>
|
|||
<%-- DO NOT CHANGE IDS, CLASSES, OR HTML STRUCTURE IN THIS FORM WITHOUT UNDERSTANDING THE IMPACT ON THE JAVASCRIPT! --%>
|
||||
<form id="addGrantRoleToPerson" class="noIE67" action="<c:url value="/edit/processRdfForm2.jsp"/>" >
|
||||
|
||||
<p><v:input type="text" id="relatedIndLabel" name="grantLabel" label="Name ${requiredHint}" cssClass="acSelector" size="50" disabled="${disabledVal}" /></p>
|
||||
<p><v:input type="text" id="relatedIndLabel" name="grantLabel" label="Grant Name ${requiredHint}" cssClass="acSelector" size="50" disabled="${disabledVal}" /></p>
|
||||
|
||||
<%-- Store this value in a hidden field, because the displayed field is disabled and don't submit. This ensures that when
|
||||
returning from a validation error, we retain the value. --%>
|
||||
|
|
|
@ -394,7 +394,7 @@ public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.
|
|||
|
||||
<div class="fullViewOnly">
|
||||
|
||||
<p><v:input type="text" id="relatedIndLabel" name="activityLabel" label="Name ${requiredHint}" cssClass="acSelector" disabled="${disabledVal}" size="50" /></p>
|
||||
<p><v:input type="text" id="relatedIndLabel" name="activityLabel" label="### Name ${requiredHint}" cssClass="acSelector" disabled="${disabledVal}" size="50" /></p>
|
||||
|
||||
<%-- Store these values in hidden fields, because the displayed fields are disabled and don't submit. This ensures that when
|
||||
returning from a validation error, we retain the values. --%>
|
||||
|
@ -409,14 +409,14 @@ public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.
|
|||
<v:input type="hidden" id="roleActivityUri" name="roleActivity" cssClass="acUriReceiver" /> <!-- Field value populated by JavaScript -->
|
||||
</div>
|
||||
|
||||
<p><v:input type="text" id="newIndLabel" name="roleLabel" label="Role in ### ${requiredHint}" size="50" /></p>
|
||||
<p><v:input type="text" id="roleLabel" label="Role in ### ${requiredHint}" size="50" /></p>
|
||||
|
||||
<c:choose>
|
||||
<c:when test="${numDateFields == 1}">
|
||||
<v:input type="text" label="Year ${requiredHint} ${yearHint}" id="startYear" size="7"/>
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
<h4 id="dateHeader">Years of Participation in </h4>
|
||||
<h4 class="label">Years of Participation in ###</h4>
|
||||
<v:input type="text" label="Start Year ${requiredHint} ${yearHint}" id="startYear" size="7"/>
|
||||
<v:input type="text" label="End Year ${yearHint}" id="endYear" size="7"/>
|
||||
</c:otherwise>
|
||||
|
|
|
@ -58,25 +58,8 @@ var customForm = {
|
|||
this.verifyMatchBaseHref = this.verifyMatch.attr('href');
|
||||
this.acSelectorWrapper = this.acSelector.parent();
|
||||
|
||||
this.relatedIndLabel = $('#relatedIndLabel');
|
||||
this.labelFieldLabel = $('label[for=' + this.relatedIndLabel.attr('id') + ']');
|
||||
// Get this on page load, so we can prepend to it. We can't just prepend to the current label text,
|
||||
// because it may have already been modified for a previous selection.
|
||||
this.baseLabelText = this.labelFieldLabel.html();
|
||||
|
||||
// Label field for new individual being created
|
||||
this.newIndLabel = $('#newIndLabel');
|
||||
this.newIndLabelFieldLabel = $('label[for=' + this.newIndLabel.attr('id') + ']');
|
||||
this.newIndBaseLabelText = this.newIndLabelFieldLabel.html();
|
||||
|
||||
this.dateHeader = $('#dateHeader');
|
||||
this.baseDateHeaderText = this.dateHeader.html();
|
||||
|
||||
this.or = $('span.or');
|
||||
this.cancel = this.form.find('.cancel');
|
||||
|
||||
this.placeHolderText = '###';
|
||||
|
||||
},
|
||||
|
||||
// Set up the form on page load
|
||||
|
@ -87,7 +70,7 @@ var customForm = {
|
|||
}
|
||||
|
||||
if (!this.formSteps) { // Don't override formSteps specified in form data
|
||||
if (!this.typeSelector.length || !this.fullViewOnly.length || this.editMode === 'edit' || this.editMode === 'repair') {
|
||||
if ( !this.fullViewOnly.length || this.editMode === 'edit' || this.editMode === 'repair' ) {
|
||||
this.formSteps = 1;
|
||||
// there may also be a 3-step form - look for this.subTypeSelector
|
||||
}
|
||||
|
@ -100,6 +83,8 @@ var customForm = {
|
|||
|
||||
this.initAutocomplete();
|
||||
|
||||
this.initPlaceholderData();
|
||||
|
||||
this.initFormView();
|
||||
|
||||
},
|
||||
|
@ -252,6 +237,17 @@ var customForm = {
|
|||
});
|
||||
},
|
||||
|
||||
initPlaceholderData: function() {
|
||||
this.placeholderText = '###';
|
||||
this.labelsWithPlaceholders = this.form.find('label, .label').filter(function() {
|
||||
return $(this).html().match(customForm.placeholderText);
|
||||
});
|
||||
|
||||
this.labelsWithPlaceholders.each(function(){
|
||||
$(this).data('originalLabel', $(this).html());
|
||||
});
|
||||
},
|
||||
|
||||
getAcFilter: function() {
|
||||
|
||||
if (!this.sparqlForAcFilter) {
|
||||
|
@ -391,20 +387,12 @@ var customForm = {
|
|||
// Set field labels based on type selection. Although these won't change in edit
|
||||
// mode, it's easier to specify the text here than in the jsp.
|
||||
setLabels: function() {
|
||||
var newLabelTextForNewInd,
|
||||
typeText = this.getTypeNameForLabels();
|
||||
|
||||
|
||||
this.labelFieldLabel.html(typeText + ' ' + this.baseLabelText);
|
||||
|
||||
if (this.dateHeader.length) {
|
||||
this.dateHeader.html(this.baseDateHeaderText + typeText);
|
||||
}
|
||||
|
||||
if (this.newIndLabel.length) {
|
||||
newLabelTextForNewInd = this.newIndBaseLabelText.replace(this.placeHolderText, typeText);
|
||||
this.newIndLabelFieldLabel.html(newLabelTextForNewInd);
|
||||
}
|
||||
var typeName = this.getTypeNameForLabels();
|
||||
|
||||
this.labelsWithPlaceholders.each(function() {
|
||||
var newLabel = $(this).data('originalLabel').replace(customForm.placeholderText, typeName);
|
||||
$(this).html(newLabel);
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
|
|
|
@ -395,7 +395,7 @@ core:dateTimePrecision (DateTimeValue : DateTimeValuePrecision)
|
|||
|
||||
<p class="inline"><v:input type="select" label="Organization Type ${requiredHint}" name="orgType" disabled="${disabledVal}" id="typeSelector" /></p>
|
||||
|
||||
<p><v:input type="text" id="relatedIndLabel" name="orgLabel" label="Name ${requiredHint}" cssClass="acSelector" disabled="${disabledVal}" size="50" /></p>
|
||||
<p><v:input type="text" id="relatedIndLabel" name="orgLabel" label="### Name ${requiredHint}" cssClass="acSelector" disabled="${disabledVal}" size="50" /></p>
|
||||
|
||||
<%-- Store these values in hidden fields, because the displayed fields are disabled and don't submit. This ensures that when
|
||||
returning from a validation error, we retain the values. --%>
|
||||
|
@ -410,7 +410,7 @@ core:dateTimePrecision (DateTimeValue : DateTimeValuePrecision)
|
|||
<v:input type="hidden" id="org" cssClass="acUriReceiver" /> <!-- Field value populated by JavaScript -->
|
||||
</div>
|
||||
|
||||
<v:input type="text" label="Department or School Name within the Organization" id="dept" size="50" />
|
||||
<v:input type="text" label="Department or School Name within the ###" id="dept" size="50" />
|
||||
|
||||
<v:input type="text" label="Supplemental Information" id="info" size="50" />
|
||||
<p>e.g., <em>Postdoctoral training</em> or <em>Transferred</em></p>
|
||||
|
|
|
@ -320,7 +320,7 @@
|
|||
<div class="fullViewOnly">
|
||||
|
||||
<%-- <p> needed to create wrapper for show/hide --%>
|
||||
<p><v:input type="text" id="relatedIndLabel" name="orgLabel" label="Name ${requiredHint}" cssClass="acSelector" disabled="${disabledVal}" size="50" /></p>
|
||||
<p><v:input type="text" id="relatedIndLabel" name="orgLabel" label="### Name ${requiredHint}" cssClass="acSelector" disabled="${disabledVal}" size="50" /></p>
|
||||
|
||||
<%-- Store these values in hidden fields, because the displayed fields are disabled and don't submit. This ensures that when
|
||||
returning from a validation error, we retain the values. --%>
|
||||
|
@ -335,7 +335,7 @@
|
|||
<v:input type="hidden" id="org" cssClass="acUriReceiver" /> <!-- Field value populated by JavaScript -->
|
||||
</div>
|
||||
|
||||
<v:input type="text" label="Position Title ${requiredHint}" name="positionTitle" id="newIndLabel" size="30" />
|
||||
<v:input type="text" label="Position Title ${requiredHint}" id="positionTitle" size="30" />
|
||||
<v:input type="select" label="Position Type ${requiredHint}" id="positionType" />
|
||||
|
||||
<v:input type="text" label="Start Year ${requiredHint} <span class='hint'>(YYYY)</span>" id="startYear" size="4" />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue