updates for page management, and replacing empty options with Constant empty options for pageData in EditConfigurationTemplateModel in populateDropdowns and also logging error if name in pageData already in use for that field name

This commit is contained in:
hjkhjk54 2012-06-24 01:39:58 +00:00
parent a3fec6ed18
commit 7e2a5d22d4
14 changed files with 403 additions and 50 deletions

View file

@ -214,6 +214,8 @@ var pageManagementUtils = {
//Submission: validate as well as create appropriate hidden json inputs
$("form").submit(function (event) {
var validationError = pageManagementUtils.validateMenuItemForm();
//Add any errors from page content sections
validationError += pageManagementUtils.validatePageContentSections();
if (validationError == "") {
//Create the appropriate json objects
pageManagementUtils.createPageContentForSubmission();
@ -273,8 +275,6 @@ var pageManagementUtils = {
pageManagementUtils.adjustSaveButtonHeight();
},
collapseAllExistingContent:function() {
var $clickableSpan = $newDivContainer.children('span#clickable' + counter);
var $innerDiv = $newDivContainer.children('div#innerContainer' + counter);
var spanArrows = pageManagementUtils.savedContentDivs.find("span.pageContentExpand div.arrow");
spanArrows.removeClass("collapseArrow");
spanArrows.addClass("expandArrow");
@ -682,8 +682,38 @@ var pageManagementUtils = {
if(pageManagementUtils.contentTypeSelect.find("option[value='browseClassGroup']").length == 0) {
//if removed, add browse class group back
var classGroupOption = '<option value="browseClassGroup">Browse Class Group</option>';
pageManagementUtils.contentTypeSelect.find('option:eq(0)').after(classGroupGroupOption);
pageManagementUtils.contentTypeSelect.find('option:eq(0)').after(classGroupOption);
}
},
//get label of page content section
getPageContentSectionLabel:function(pageContentSection) {
var label = pageContentSection.closest("div.pageContentContainer").find("span.pageContentTypeLabel").html();
if(label == null) {
label = "";
}
return label;
},
//Validation across different content types
validatePageContentSections:function() {
//Get all page content sections
var pageContentSections = $("section[class='pageContent']");
var validationErrorMsg = "";
//For each, based on type, validate if a validation function exists
$.each(pageContentSections, function(i) {
if(pageManagementUtils.processDataGetterUtils != null) {
var dataGetterType = pageManagementUtils.processDataGetterUtils.selectDataGetterType($(this));
if(pageManagementUtils.dataGetterProcessorMap != null) {
var dataGetterProcessor = pageManagementUtils.dataGetterProcessorMap[dataGetterType];
//the content type specific processor will create the json object to be returned
if($.isFunction(dataGetterProcessor.validateFormSubmission)) {
//Get label of page content section
var label = pageManagementUtils.getPageContentSectionLabel($(this));
validationErrorMsg += dataGetterProcessor.validateFormSubmission($(this), label);
}
}
}
});
return validationErrorMsg;
}
};

View file

@ -126,6 +126,22 @@ var processClassGroupDataGetterContent = {
//Should probably remove this entire method and copy there
processClassGroupDataGetterContent.displayClassesForClassGroup(results, pageContentSection);
});
},
//Validation on form submit: Check to see that class group has been selected
validateFormSubmission: function(pageContentSection, pageContentSectionLabel) {
var validationError = "";
if (pageContentSection.find('select[name="selectClassGroup"]').val() =='-1') {
validationError += pageContentSectionLabel + ": You must supply a class group <br />";
} else {
//class group has been selected, make sure there is at least one class selected
var allSelected = pageContentSection.find('input[name="allSelected"]:checked').length;
var noClassesSelected = pageContentSection.find('input[name="classInClassGroup"]:checked').length;
if (allSelected == 0 && noClassesSelected == 0) {
//at least one class should be selected
validationError += pageContentSectionLabel + ":You must select the classes to display<br />";
}
}
return validationError;
}

View file

@ -27,7 +27,21 @@ var processFixedHTMLDataGetterContent = {
retrieveAdditionalLabelText:function(existingContentObject) {
var saveToVarValue = existingContentObject["saveToVar"];
return saveToVarValue;
}
},
//Validation on form submit: Check to see that class group has been selected
validateFormSubmission: function(pageContentSection, pageContentSectionLabel) {
var validationError = "";
//Check that query and saveToVar have been input
var variableValue = pageContentSection.find("input[name='saveToVar']").val();
if(variableValue == "") {
validationError += pageContentSectionLabel + ": You must supply a variable to save HTML content. <br />"
}
var htmlValue = pageContentSection.find("textarea[name='htmlValue']").val();
if(htmlValue == "") {
validationError += pageContentSectionLabel + ": You must supply some HTML or text. <br />";
}
return validationError;
}
}

View file

@ -37,6 +37,10 @@ var processIndividualsForClassesDataGetterContent = {
//For the label of the content section for editing, need to add additional value
retrieveAdditionalLabelText:function(existingContentObject) {
return processClassGroupDataGetterContent.retrieveAdditionalLabelText(existingContentObject);
}
},
//Validation on form submit: Check to see that class group has been selected
validateFormSubmission: function(pageContentSection) {
return processClassGroupDataGetterContent.validateFormSubmission(pageContentSection);
}
}

View file

@ -32,7 +32,21 @@ var processSparqlDataGetterContent = {
retrieveAdditionalLabelText:function(existingContentObject) {
var saveToVarValue = existingContentObject["saveToVar"];
return saveToVarValue;
}
},
//Validation on form submit: Check to see that class group has been selected
validateFormSubmission: function(pageContentSection, pageContentSectionLabel) {
var validationError = "";
//Check that query and saveToVar have been input
var variableValue = pageContentSection.find("input[name='saveToVar']").val();
if(variableValue == "") {
validationError += pageContentSectionLabel + ": You must supply a variable to save query results. <br />"
}
var queryValue = pageContentSection.find("textarea[name='query']").val();
if(queryValue == "") {
validationError += pageContentSectionLabel + ": You must supply a Sparql query. <br />";
}
return validationError;
}
};

View file

@ -0,0 +1,49 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
var pageDeletion = {
// on initial page setup
onLoad:function(){
if (this.disableFormInUnsupportedBrowsers()) {
return;
}
this.initObjects();
this.bindEventListeners();
},
initObjects:function() {
this.deleteLinks = $("a[cmd='deletePage']");
},
bindEventListeners:function() {
this.deleteLinks.click(function(event) {
var href=$(this).attr("href");
var pageTitle = $(this).attr("pageTitle");
var confirmResult = confirm("Are you sure you wish to delete this page: " + pageTitle + "?");
if(confirmResult) {
//Continue with the link
return true;
} else {
event.preventDefault();
return false;
}
});
},
disableFormInUnsupportedBrowsers: function() {
var disableWrapper = $('#ie67DisableWrapper');
// Check for unsupported browsers only if the element exists on the page
if (disableWrapper.length) {
if (vitro.browserUtils.isIELessThan8()) {
disableWrapper.show();
$('.noIE67').hide();
return true;
}
}
return false;
}
};
$(document).ready(function() {
pageDeletion.onLoad();
});