From ffbb917e409acf046db010388bd3850b55ac57cc Mon Sep 17 00:00:00 2001 From: rjy7 Date: Thu, 15 Jul 2010 15:01:40 +0000 Subject: [PATCH] NIHVIVO-630 Javascript modifications for modifying field label text based on type selection in roles form --- .../edit/forms/addRoleToPersonTwoStage.jsp | 2 +- .../js/customFormWithAdvanceTypeSelection.js | 24 ++++++++++++------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/productMods/edit/forms/addRoleToPersonTwoStage.jsp b/productMods/edit/forms/addRoleToPersonTwoStage.jsp index 03019ddb..d9f59565 100644 --- a/productMods/edit/forms/addRoleToPersonTwoStage.jsp +++ b/productMods/edit/forms/addRoleToPersonTwoStage.jsp @@ -338,7 +338,7 @@ -

+

Dates of Participation

diff --git a/productMods/edit/forms/js/customFormWithAdvanceTypeSelection.js b/productMods/edit/forms/js/customFormWithAdvanceTypeSelection.js index 44d7766b..20ec68c8 100644 --- a/productMods/edit/forms/js/customFormWithAdvanceTypeSelection.js +++ b/productMods/edit/forms/js/customFormWithAdvanceTypeSelection.js @@ -46,11 +46,14 @@ var customForm = { 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.newIndLabel = $('#newIndLabel'); + this.newIndLabelFieldLabel = $('label[for=' + this.newIndLabel.attr('id') + ']'); + this.newIndBaseLabelText = this.newIndLabelFieldLabel.html(); this.or = $('span.or'); this.cancel = this.form.find('.cancel'); + + this.placeHolderText = '###'; }, @@ -133,6 +136,8 @@ var customForm = { this.typeSelector.attr('disabled', 'disabled'); this.relatedIndLabel.attr('disabled', 'disabled'); + this.setLabelFieldLabels(); + this.form.submit(function() { // Re-enable these fields so they get submitted, since they are required // in the edit config. @@ -320,14 +325,15 @@ var customForm = { }, setLabelFieldLabels: function() { -// var newLabelTextForNewInd; + var newLabelTextForNewInd, + selectedTypeName = this.getSelectedTypeName(); - this.labelFieldLabel.html(this.getSelectedTypeName() + ' ' + this.baseLabelText); - -// if (this.newIndLabelFieldLabel.length) { -// newLabelTextForNewInd = this.newIndBaseLabelText.replace('X', this.getSelectedTypeName); -// this.newIndLabelFieldLabel.html(newLabelTextForNewInd); -// } + this.labelFieldLabel.html(selectedTypeName + ' ' + this.baseLabelText); + + if (this.newIndLabel.length) { + newLabelTextForNewInd = this.newIndBaseLabelText.replace(this.placeHolderText, selectedTypeName); + this.newIndLabelFieldLabel.html(newLabelTextForNewInd); + } },