NIHVIVO-797 Javascript support for edit mode in roles forms
This commit is contained in:
parent
b4cddb53e5
commit
78fa2cf4e8
2 changed files with 26 additions and 15 deletions
|
@ -315,6 +315,7 @@
|
||||||
<c:set var="editMode" value="add" />
|
<c:set var="editMode" value="add" />
|
||||||
</c:otherwise>
|
</c:otherwise>
|
||||||
</c:choose>
|
</c:choose>
|
||||||
|
|
||||||
<jsp:include page="${preForm}" />
|
<jsp:include page="${preForm}" />
|
||||||
|
|
||||||
<h2>${titleText} ${roleActivityTypeLabel} entry for <%= subjectName %></h2>
|
<h2>${titleText} ${roleActivityTypeLabel} entry for <%= subjectName %></h2>
|
||||||
|
@ -326,7 +327,7 @@
|
||||||
|
|
||||||
<div class="fullViewOnly">
|
<div class="fullViewOnly">
|
||||||
|
|
||||||
<p><v:input type="text" id="label" name="activityLabel" label="Title" cssClass="acSelector" size="50" /></p>
|
<p><v:input type="text" id="label" name="activityLabel" label="Name ${requiredHint}" 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. --%>
|
||||||
|
|
|
@ -39,8 +39,9 @@ var customForm = {
|
||||||
this.verifyMatchBaseHref = this.verifyMatch.attr('href');
|
this.verifyMatchBaseHref = this.verifyMatch.attr('href');
|
||||||
this.acSelectorWrapper = this.acSelector.parent();
|
this.acSelectorWrapper = this.acSelector.parent();
|
||||||
|
|
||||||
|
this.existingIndividualLabel = $('#label');
|
||||||
// This is the label element for the field with name 'label'
|
// This is the label element for the field with name 'label'
|
||||||
this.labelFieldLabel = $('label[for=' + $('#label').attr('id') + ']');
|
this.labelFieldLabel = $('label[for=' + this.existingIndividualLabel.attr('id') + ']');
|
||||||
// Get this on page load, so we can prepend to it. We can't just prepend to the current label text,
|
// 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.
|
// because it may have already been modified for a previous selection.
|
||||||
this.baseLabelText = this.labelFieldLabel.html();
|
this.baseLabelText = this.labelFieldLabel.html();
|
||||||
|
@ -58,10 +59,10 @@ var customForm = {
|
||||||
initPage: function() {
|
initPage: function() {
|
||||||
|
|
||||||
if (!this.editMode) {
|
if (!this.editMode) {
|
||||||
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.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 {
|
||||||
|
@ -108,15 +109,18 @@ var customForm = {
|
||||||
|
|
||||||
initFormFullView: function() {
|
initFormFullView: function() {
|
||||||
|
|
||||||
|
if (this.editMode == 'edit') {
|
||||||
|
this.initFormEditView();
|
||||||
|
}
|
||||||
|
|
||||||
this.fullViewOnly.show();
|
this.fullViewOnly.show();
|
||||||
this.or.show();
|
this.or.show();
|
||||||
this.requiredLegend.show();
|
this.requiredLegend.show();
|
||||||
this.button.show();
|
this.button.show();
|
||||||
this.toggleButtonText("new");
|
this.toggleButtonText('new');
|
||||||
this.cancel.unbind('click');
|
this.cancel.unbind('click');
|
||||||
|
|
||||||
if( this.formSteps > 1 ){
|
if( this.formSteps > 1 ){
|
||||||
|
|
||||||
this.cancel.click(function() {
|
this.cancel.click(function() {
|
||||||
customForm.clearFormData(); // clear any input and validation errors
|
customForm.clearFormData(); // clear any input and validation errors
|
||||||
customForm.initFormTypeView();
|
customForm.initFormTypeView();
|
||||||
|
@ -125,6 +129,12 @@ var customForm = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
initFormEditView: function() {
|
||||||
|
// These should not be editable: only properties of the role are editable.
|
||||||
|
this.typeSelector.attr('disabled', 'disabled');
|
||||||
|
this.existingIndividualLabel.attr('disabled', 'disabled');
|
||||||
|
},
|
||||||
|
|
||||||
// Bind event listeners that persist over the life of the page.
|
// Bind event listeners that persist over the life of the page.
|
||||||
bindEventListeners: function() {
|
bindEventListeners: function() {
|
||||||
|
|
||||||
|
@ -231,11 +241,11 @@ var customForm = {
|
||||||
filteredResults = [];
|
filteredResults = [];
|
||||||
$.each(results, function() {
|
$.each(results, function() {
|
||||||
if ($.inArray(this.uri, customForm.acFilter) == -1) {
|
if ($.inArray(this.uri, customForm.acFilter) == -1) {
|
||||||
// console.log("adding " + this.label + " to filtered results");
|
// console.log('adding ' + this.label + ' to filtered results');
|
||||||
filteredResults.push(this);
|
filteredResults.push(this);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// console.log("filtering out " + this.label);
|
// console.log('filtering out ' + this.label);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return filteredResults;
|
return filteredResults;
|
||||||
|
@ -316,17 +326,17 @@ var customForm = {
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleButtonText: function(newOrExisting) {
|
toggleButtonText: function(newOrExisting) {
|
||||||
if (this.editMode == "edit") {
|
if (this.editMode == 'edit') {
|
||||||
this.button.val("Edit " + this.baseButtonText);
|
this.button.val('Edit ' + this.baseButtonText);
|
||||||
}
|
}
|
||||||
// RY Make this better for roles and grants forms later. The verbs
|
// RY Make this better for roles and grants forms later. The verbs
|
||||||
// don't quite work. It should be "Create X and <role>" vs.
|
// don't quite work. It should be "Create X and <role>" vs.
|
||||||
// "Create <role>" or "Add <role>"
|
// "Create <role>" or "Add <role>"
|
||||||
else if (newOrExisting == "new") {
|
else if (newOrExisting == 'new') {
|
||||||
this.button.val("Create " + this.baseButtonText);
|
this.button.val('Create ' + this.baseButtonText);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.button.val("Add " + this.baseButtonText);
|
this.button.val('Add ' + this.baseButtonText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue