This commit is contained in:
rjy7 2010-07-23 18:43:02 +00:00
parent 54da0ca235
commit c5031fc9a7

View file

@ -86,16 +86,12 @@ var customForm = {
this.editMode = 'add'; // edit vs add: default to add this.editMode = 'add'; // edit vs add: default to add
} }
if (!this.typeSelector.length || this.editMode == 'edit') { if (!this.typeSelector.length || this.editMode == 'edit' || this.editMode == 'repair') {
this.formSteps = 1; this.formSteps = 1;
// there may also be a 3-step form - look for this.subTypeSelector // there may also be a 3-step form - look for this.subTypeSelector
} else { } else {
this.formSteps = 2; this.formSteps = 2;
} }
// RY This should probably be done from initFormFullView, since there
// are not two form steps in this case.
if( this.editMode == 'repair')
this.formSteps = 2;
this.bindEventListeners(); this.bindEventListeners();
@ -210,8 +206,9 @@ var customForm = {
customForm.undoAutocompleteSelection(); customForm.undoAutocompleteSelection();
// 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
// or submitting form without a type selection. // or submitting form without a type selection. Exception: in repair editMode, stay in full view,
typeVal.length ? customForm.initFormFullView() : customForm.initFormTypeView(); // else we lose the role information.
(typeVal.length || customForm.editMode == 'repair') ? customForm.initFormFullView() : customForm.initFormTypeView();
}); });
@ -403,16 +400,20 @@ var customForm = {
// Set field labels based on type selection. Although these won't change in edit // 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. // mode, it's easier to specify the text here than in the jsp.
setLabels: function() { setLabels: function() {
var newLabelTextForNewInd; var newLabelTextForNewInd,
// if this.acType is empty, we are in repair mode with no activity type selected.
// Prevent the labels from showing 'Select one' by using the generic term 'Activity'
typeText = this.acType ? this.typeName : 'Activity';
this.labelFieldLabel.html(this.typeName + ' ' + this.baseLabelText);
this.labelFieldLabel.html(typeText + ' ' + this.baseLabelText);
if (this.dateHeader.length) { if (this.dateHeader.length) {
this.dateHeader.html(this.baseDateHeaderText + this.typeName); this.dateHeader.html(this.baseDateHeaderText + typeText);
} }
if (this.newIndLabel.length) { if (this.newIndLabel.length) {
newLabelTextForNewInd = this.newIndBaseLabelText.replace(this.placeHolderText, this.typeName); newLabelTextForNewInd = this.newIndBaseLabelText.replace(this.placeHolderText, typeText);
this.newIndLabelFieldLabel.html(newLabelTextForNewInd); this.newIndLabelFieldLabel.html(newLabelTextForNewInd);
} }
@ -422,17 +423,22 @@ var customForm = {
// or a new related individual. Called when setting up full view of form, and after // or a new related individual. Called when setting up full view of form, and after
// an autocomplete selection. // an autocomplete selection.
setButtonText: function(newOrExisting) { setButtonText: function(newOrExisting) {
var typeText;
// Edit mode button doesn't change, so it's specified in the jsp // Edit mode button doesn't change, so it's specified in the jsp
if (this.editMode === 'edit') { if (this.editMode === 'edit') {
return; return;
} }
// if this.acType is empty, we are in repair mode with no activity type selected.
// Prevent the labels from showing 'Select one' by using the generic term 'Activity'
typeText = this.acType ? this.typeName : 'Activity';
// Creating new related individual // Creating new related individual
if (newOrExisting === 'new') { if (newOrExisting === 'new') {
if (this.submitButtonTextType == 'compound') { // use == to tolerate nulls if (this.submitButtonTextType == 'compound') { // use == to tolerate nulls
// e.g., 'Create Grant & Principal Investigator' // e.g., 'Create Grant & Principal Investigator'
this.button.val('Create ' + this.typeName + ' & ' + this.baseButtonText); this.button.val('Create ' + typeText + ' & ' + this.baseButtonText);
} else { } else {
// e.g., 'Create Publication' // e.g., 'Create Publication'
this.button.val('Create ' + this.baseButtonText); this.button.val('Create ' + this.baseButtonText);