updates for page management
This commit is contained in:
parent
491c4f6d9a
commit
c338c9025b
10 changed files with 260 additions and 86 deletions
|
@ -359,7 +359,8 @@ var pageManagementUtils = {
|
|||
$newRemoveButton = $innerDiv.find('input#remove' + counter);
|
||||
// this will have to disable submitted fields as well as hide them.
|
||||
$newRemoveButton.click(function() {
|
||||
$innerDiv.parent("div").css("display","none");
|
||||
//$innerDiv.parent("div").css("display","none");
|
||||
$innerDiv.parent("div").remove();
|
||||
pageManagementUtils.adjustSaveButtonHeight();
|
||||
});
|
||||
},
|
||||
|
@ -387,41 +388,47 @@ var pageManagementUtils = {
|
|||
url += encodeURIComponent(vclassUri);
|
||||
//Make ajax call to retrieve vclasses
|
||||
$.getJSON(url, function(results) {
|
||||
|
||||
if ( results.classes.length == 0 ) {
|
||||
|
||||
} else {
|
||||
//update existing content type with correct class group name and hide class group select again
|
||||
// pageManagementUtils.hideClassGroups();
|
||||
|
||||
pageManagementUtils.selectedGroupForPage.html(results.classGroupName);
|
||||
//update content type in message to "display x within my institution"
|
||||
pageManagementUtils.updateInternalClassMessage(results.classGroupName);
|
||||
//retrieve classes for class group and display with all selected
|
||||
var selectedClassesList = pageManagementUtils.classesForClassGroup.children('ul#selectedClasses');
|
||||
|
||||
selectedClassesList.empty();
|
||||
selectedClassesList.append('<li class="ui-state-default"> <input type="checkbox" name="allSelected" id="allSelected" value="all" checked="checked" /> <label class="inline" for="All"> All</label> </li>');
|
||||
|
||||
$.each(results.classes, function(i, item) {
|
||||
var thisClass = results.classes[i];
|
||||
var thisClassName = thisClass.name;
|
||||
//When first selecting new content type, all classes should be selected
|
||||
appendHtml = ' <li class="ui-state-default">' +
|
||||
'<input type="checkbox" checked="checked" name="classInClassGroup" value="' + thisClass.URI + '" />' +
|
||||
'<label class="inline" for="' + thisClassName + '"> ' + thisClassName + '</label>' +
|
||||
'</li>';
|
||||
selectedClassesList.append(appendHtml);
|
||||
});
|
||||
pageManagementUtils.toggleClassSelection();
|
||||
|
||||
|
||||
//From NEW code
|
||||
if (pageManagementUtils.selectClassGroupDropdown.val() == "" ) {
|
||||
pageManagementUtils.classesForClassGroup.addClass('hidden');
|
||||
$("div#leftSide").css("height","");
|
||||
pageManagementUtils.moreContentButton.hide();
|
||||
|
||||
//Moved the function to processClassGroupDataGetterContent
|
||||
//Should probably remove this entire method and copy there
|
||||
processClassGroupDataGetterContent.displayClassesForClassGroup(results);
|
||||
});
|
||||
},
|
||||
displayClassesForClassGroup:function(results) {
|
||||
if ( results.classes.length == 0 ) {
|
||||
|
||||
} else {
|
||||
//update existing content type with correct class group name and hide class group select again
|
||||
// pageManagementUtils.hideClassGroups();
|
||||
|
||||
pageManagementUtils.selectedGroupForPage.html(results.classGroupName);
|
||||
//update content type in message to "display x within my institution"
|
||||
//SPECIFIC TO VIVO: So include in internal CLASS section instead
|
||||
pageManagementUtils.updateInternalClassMessage(results.classGroupName);
|
||||
//retrieve classes for class group and display with all selected
|
||||
var selectedClassesList = pageManagementUtils.classesForClassGroup.children('ul#selectedClasses');
|
||||
|
||||
selectedClassesList.empty();
|
||||
selectedClassesList.append('<li class="ui-state-default"> <input type="checkbox" name="allSelected" id="allSelected" value="all" checked="checked" /> <label class="inline" for="All"> All</label> </li>');
|
||||
|
||||
$.each(results.classes, function(i, item) {
|
||||
var thisClass = results.classes[i];
|
||||
var thisClassName = thisClass.name;
|
||||
//For the class group, ALL classes should be selected
|
||||
appendHtml = ' <li class="ui-state-default">' +
|
||||
'<input type="checkbox" checked="checked" name="classInClassGroup" value="' + thisClass.URI + '" />' +
|
||||
'<label class="inline" for="' + thisClassName + '"> ' + thisClassName + '</label>' +
|
||||
'</li>';
|
||||
selectedClassesList.append(appendHtml);
|
||||
});
|
||||
pageManagementUtils.toggleClassSelection();
|
||||
|
||||
|
||||
//From NEW code
|
||||
if (pageManagementUtils.selectClassGroupDropdown.val() == "" ) {
|
||||
pageManagementUtils.classesForClassGroup.addClass('hidden');
|
||||
$("div#leftSide").css("height","");
|
||||
pageManagementUtils.moreContentButton.hide();
|
||||
|
||||
}
|
||||
else {
|
||||
pageManagementUtils.classesForClassGroup.removeClass('hidden');
|
||||
|
@ -430,11 +437,7 @@ var pageManagementUtils = {
|
|||
$("div#leftSide").css("height",$("div#rightSide").height() + "px");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
},
|
||||
toggleClassSelection: function() {
|
||||
// Check/unckeck all classes for selection
|
||||
|
@ -544,6 +547,7 @@ var pageManagementUtils = {
|
|||
var originalObjectPath = 'section#' + contentType;
|
||||
var $newContentObj = $(originalObjectPath).clone();
|
||||
$newContentObj.addClass("pageContent");
|
||||
$newContentObj.attr("contentNumber", counter);
|
||||
//Save content type
|
||||
$newContentObj.attr("contentType", contentType);
|
||||
//Set id for object
|
||||
|
|
|
@ -8,6 +8,7 @@ var processClassGroupDataGetterContent = {
|
|||
initProcessor:function(dataGetterClassInput) {
|
||||
this.dataGetterClass = dataGetterClassInput;
|
||||
},
|
||||
|
||||
//Do we need a separate content type for each of the others?
|
||||
processPageContentSection:function(pageContentSection) {
|
||||
//Will look at classes etc.
|
||||
|
@ -20,14 +21,113 @@ var processClassGroupDataGetterContent = {
|
|||
populatePageContentSection:function(existingContentObject, pageContentSection) {
|
||||
var classGroupValue = existingContentObject["classGroup"];
|
||||
pageContentSection.find("select[name='selectClassGroup']").val(classGroupValue);
|
||||
//For now, will utilize the function in pageManagementUtils
|
||||
//But should move over any class group specific event handlers etc. into this javascript section
|
||||
//Get 'results' from content object
|
||||
var results = existingContentObject["results"];
|
||||
if(results != null) {
|
||||
processClassGroupDataGetterContent.displayClassesForClassGroup(results, pageContentSection);
|
||||
//Bind event handlers
|
||||
processClassGroupDataGetterContent.bindEventHandlers(pageContentSection);
|
||||
//Show hidden class
|
||||
}
|
||||
},
|
||||
//For the label of the content section for editing, need to add additional value
|
||||
retrieveAdditionalLabelText:function(existingContentObject) {
|
||||
//Right now return empty but can hook this into a hashmap with labels and uris
|
||||
//set up in browse class group
|
||||
return "";
|
||||
}
|
||||
|
||||
var label = "";
|
||||
var results = existingContentObject["results"];
|
||||
if(results != null && results["classGroupName"] != null) {
|
||||
label = results["classGroupName"];
|
||||
}
|
||||
return label;
|
||||
},
|
||||
//this is copied from pageManagementUtils but eventually
|
||||
//we should move all event bindings etc. specific to a content type into its own
|
||||
//processing methods
|
||||
//TODO: Refine so no references to pageManagementUtils required
|
||||
//Page content section specific methods
|
||||
displayClassesForClassGroup:function(results, pageContentSection) {
|
||||
if ( results.classes.length == 0 ) {
|
||||
|
||||
} else {
|
||||
var contentNumber = pageContentSection.attr("contentNumber");
|
||||
var classesForClassGroup = pageContentSection.find('section[name="classesInSelectedGroup"]');
|
||||
|
||||
//retrieve classes for class group and display with all selected
|
||||
var selectedClassesList = classesForClassGroup.children('ul[name="selectedClasses"]');
|
||||
|
||||
selectedClassesList.empty();
|
||||
var newId = "allSelected" + contentNumber;
|
||||
selectedClassesList.append('<li class="ui-state-default"> <input type="checkbox" name="allSelected" id="' + contentNumber + '" value="all" checked="checked" /> <label class="inline" for="All"> All</label> </li>');
|
||||
|
||||
$.each(results.classes, function(i, item) {
|
||||
var thisClass = results.classes[i];
|
||||
var thisClassName = thisClass.name;
|
||||
//For the class group, ALL classes should be selected
|
||||
appendHtml = ' <li class="ui-state-default">' +
|
||||
'<input type="checkbox" checked="checked" name="classInClassGroup" value="' + thisClass.URI + '" />' +
|
||||
'<label class="inline" for="' + thisClassName + '"> ' + thisClassName + '</label>' +
|
||||
'</li>';
|
||||
selectedClassesList.append(appendHtml);
|
||||
});
|
||||
|
||||
//Need a way of handling this without it being in the internal class data getter
|
||||
var displayInternalMessage = pageContentSection.find('label[for="display-internalClass"] em');
|
||||
if(displayInternalMessage != null) {
|
||||
displayInternalMessage.filter(":first").html(results.classGroupName);
|
||||
}
|
||||
//This is an EXISTING selection, so value should not be empty
|
||||
classesForClassGroup.removeClass('hidden');
|
||||
if ( $("div#leftSide").height() < $("div#rightSide").height() ) {
|
||||
$("div#leftSide").css("height",$("div#rightSide").height() + "px");
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
//Toggle class selection already deals with names but want to attach that event
|
||||
//handler to THIS new section
|
||||
toggleClassSelection: function(pageContentSection) {
|
||||
// Check/unckeck all classes for selection
|
||||
pageContentSection.find('input:checkbox[name=allSelected]').click(function(){
|
||||
if ( this.checked ) {
|
||||
// if checked, select all the checkboxes for this particular section
|
||||
$(this).closest("ul").find('input:checkbox[name=classInClassGroup]').attr('checked','checked');
|
||||
//$('input:checkbox[name=classInClassGroup]').attr('checked','checked');
|
||||
|
||||
} else {
|
||||
// if not checked, deselect all the checkboxes
|
||||
$(this).closest("ul").find('input:checkbox[name=classInClassGroup]').removeAttr('checked');
|
||||
|
||||
// $('input:checkbox[name=classInClassGroup]').removeAttr('checked');
|
||||
}
|
||||
});
|
||||
|
||||
pageContentSection.find('input:checkbox[name=classInClassGroup]').click(function(){
|
||||
$(this).closest(ul).find('input:checkbox[name=allSelected]').removeAttr('checked');
|
||||
});
|
||||
},
|
||||
bindEventHandlers:function(pageContentSection) {
|
||||
processClassGroupDataGetterContent.toggleClassSelection(pageContentSection);
|
||||
|
||||
var selectClassGroupDropdown = pageContentSection.find("select[name='selectClassGroup']");
|
||||
selectClassGroupDropdown.change(function(e, el) {
|
||||
processClassGroupDataGetterContent.chooseClassGroup(pageContentSection);
|
||||
});
|
||||
},
|
||||
chooseClassGroup: function(pageContentSection) {
|
||||
var selectClassGroupDropdown = pageContentSection.find("select[name='selectClassGroup']");
|
||||
var url = "dataservice?getVClassesForVClassGroup=1&classgroupUri=";
|
||||
var vclassUri = selectClassGroupDropdown.val();
|
||||
url += encodeURIComponent(vclassUri);
|
||||
//Get the page content section
|
||||
//Make ajax call to retrieve vclasses
|
||||
$.getJSON(url, function(results) {
|
||||
//Moved the function to processClassGroupDataGetterContent
|
||||
//Should probably remove this entire method and copy there
|
||||
processClassGroupDataGetterContent.displayClassesForClassGroup(results, pageContentSection);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -22,21 +22,21 @@ var processIndividualsForClassesDataGetterContent = {
|
|||
},
|
||||
//For an existing set of content where form is already set, fill in the values
|
||||
populatePageContentSection:function(existingContentObject, pageContentSection) {
|
||||
var classGroupValue = existingContentObject["classGroup"];
|
||||
//select class group in dropdown and append the classes within that class group
|
||||
processClassGroupDataGetterContent.populatePageContentSection(existingContentObject, pageContentSection);
|
||||
var classesSelected = existingContenetObject["classesSelectedInClassGroup"];
|
||||
var numberSelected = classesSelected.length;
|
||||
var i;
|
||||
//Uncheck all since default is checked
|
||||
pageContentSection.find("input[name='classInClassGroup']").removeAttr("checked");
|
||||
for(i = 0; i < numberSelected; i++) {
|
||||
var classSelected = classesSelected[i];
|
||||
pageContentSection.find("input[name='classInClassGroup'][value='" + classSelected + "']").attr("checked", "checked");
|
||||
}
|
||||
pageContentSection.find("select[name='selectClassGroup']").val(classGroupValue);
|
||||
},
|
||||
//For the label of the content section for editing, need to add additional value
|
||||
retrieveAdditionalLabelText:function(existingContentObject) {
|
||||
//Right now return empty but can hook this into a hashmap with labels and uris
|
||||
//set up in browse class group
|
||||
return "";
|
||||
return processClassGroupDataGetterContent.retrieveAdditionalLabelText(existingContentObject);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue