NIHVIVO-194. Replaced string values for view types with Javascript "enum."
This commit is contained in:
parent
ae9fabdf8e
commit
01deac8aa7
1 changed files with 21 additions and 11 deletions
|
@ -48,6 +48,12 @@
|
||||||
|
|
||||||
var customForm = {
|
var customForm = {
|
||||||
|
|
||||||
|
views: {
|
||||||
|
ADD_NEW: 1,
|
||||||
|
SELECT_EXISTING: 2,
|
||||||
|
COMBINED: 3
|
||||||
|
},
|
||||||
|
|
||||||
onLoad: function() {
|
onLoad: function() {
|
||||||
|
|
||||||
this.initObjects();
|
this.initObjects();
|
||||||
|
@ -149,29 +155,33 @@ var customForm = {
|
||||||
|
|
||||||
// Assign event listeners
|
// Assign event listeners
|
||||||
customForm.button.bind('click', function() {
|
customForm.button.bind('click', function() {
|
||||||
customForm.doAddFormStep2SelectExisting();
|
//customForm.doAddFormStep2SelectExisting();
|
||||||
|
customForm.doAddFormStep2(customForm.views.SELECT_EXISTING);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
// Note that addNewLink event listener is different
|
// Note that addNewLink event listener is different
|
||||||
// in different views.
|
// in different views.
|
||||||
customForm.addNewLink.bind('click', function() {
|
customForm.addNewLink.bind('click', function() {
|
||||||
customForm.doAddFormStep2AddNew();
|
//customForm.doAddFormStep2AddNew();
|
||||||
|
customForm.doAddFormStep2(customForm.views.ADD_NEW);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// Set up form when returning directly to step 2, such as after validation errors
|
// Set up form when returning directly to step 2, such as after validation errors
|
||||||
// on the form submission.
|
// on the form submission.
|
||||||
doAddFormStep2: function() {
|
doAddFormStep2: function(view) {
|
||||||
|
|
||||||
var view = customForm.getPreviousViewFromFormData();
|
if (!view) {
|
||||||
|
view = customForm.getPreviousViewFromFormData();
|
||||||
|
}
|
||||||
|
|
||||||
switch (view) {
|
switch (view) {
|
||||||
case "existing": { fn = this.doAddFormStep2SelectExisting; break; }
|
case customForm.views.SELECT_EXISTING: { fn = this.doAddFormStep2SelectExisting; break; }
|
||||||
case "addNew": { fn = this.doAddFormStep2AddNew; break; }
|
case customForm.views.ADD_NEW: { fn = this.doAddFormStep2AddNew; break; }
|
||||||
default: { fn = this.doAddFormStep2Combined; break; }
|
default: { fn = this.doAddFormStep2Combined; break; }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn.call();
|
fn.call(customForm);
|
||||||
},
|
},
|
||||||
|
|
||||||
// Most methods below use 'customForm' rather than 'this', because 'this' doesn't reference
|
// Most methods below use 'customForm' rather than 'this', because 'this' doesn't reference
|
||||||
|
@ -222,8 +232,8 @@ var customForm = {
|
||||||
view = this.getPreviousViewFromFormData();
|
view = this.getPreviousViewFromFormData();
|
||||||
|
|
||||||
switch (view) {
|
switch (view) {
|
||||||
case "existing": { fn = this.doEditFormSelectExisting; break; }
|
case this.views.SELECT_EXISTING: { fn = this.doEditFormSelectExisting; break; }
|
||||||
case "addNew": { fn = this.doEditFormAddNew; break; }
|
case this.views.ADD_NEW: { fn = this.doEditFormAddNew; break; }
|
||||||
default: { fn = this.doEditFormDefaultView; break; }
|
default: { fn = this.doEditFormDefaultView; break; }
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -451,7 +461,7 @@ var customForm = {
|
||||||
for (i = 0; i < addNewInputsLen; i++) {
|
for (i = 0; i < addNewInputsLen; i++) {
|
||||||
input = $(addNewInputs[i]);
|
input = $(addNewInputs[i]);
|
||||||
if (input.val() != '') {
|
if (input.val() != '') {
|
||||||
view = "addNew";
|
view = customForm.views.ADD_NEW;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -461,7 +471,7 @@ var customForm = {
|
||||||
for (i = 0; i < existingInputsLen; i++) {
|
for (i = 0; i < existingInputsLen; i++) {
|
||||||
input = $(existingInputs[i]);
|
input = $(existingInputs[i]);
|
||||||
if (input.val() != '') {
|
if (input.val() != '') {
|
||||||
view = "existing";
|
view = customForm.views.SELECT_EXISTING;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue