diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/ManagePageGenerator.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/ManagePageGenerator.java index 92e5cdd1d..622cbae5e 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/ManagePageGenerator.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/ManagePageGenerator.java @@ -8,6 +8,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.servlet.ServletContext; import javax.servlet.http.HttpSession; import net.sf.json.JSONArray; @@ -79,17 +80,20 @@ public class ManagePageGenerator extends BaseEditConfigurationGenerator implemen setUrisAndLiteralsOnForm(conf, vreq); //Set the fields setFields(conf); - //Adding additional data, specifically edit mode addFormSpecificData(conf, vreq); //Add preprocessor conf.addEditSubmissionPreprocessor(new ManagePagePreprocessor(conf)); - //Prepare + //Prepare: add literals/uris in scope based on sparql queries prepare(vreq, conf); + //This method specifically retrieves information for edit + populateExistingDataGetter(vreq, conf, session.getServletContext()); return conf ; } + + private void setUrisAndLiteralsOnForm(EditConfigurationVTwo conf, VitroRequest vreq) { conf.setUrisOnForm(new String[]{"page", "menuItem"}); //new resources: should this be on form for new - should be for existing @@ -198,15 +202,11 @@ public class ManagePageGenerator extends BaseEditConfigurationGenerator implemen @Override void prepare(VitroRequest vreq, EditConfigurationVTwo editConfig) { //setup the model selectors for query, write and display models on editConfig - //Double-check if this will even work with over-written model in the case of display model? setupModelSelectorsFromVitroRequest(vreq, editConfig); OntModel queryModel = (OntModel)vreq.getAttribute("jenaOntModel"); if (editConfig.isParamUpdate()) { - //editConfig.prepareForObjPropUpdate(queryModel); - //Set up edit configuration with all the values required - //Retrieve existing values for page and menu item level editConfig.prepareForParamUpdate(queryModel); - retrieveExistingDataGetterInfo(editConfig, queryModel); + } else{ //if no subject uri, this is creating a new page @@ -214,17 +214,33 @@ public class ManagePageGenerator extends BaseEditConfigurationGenerator implemen } } + private void populateExistingDataGetter(VitroRequest vreq, + EditConfigurationVTwo editConfig, + ServletContext context) { + if (editConfig.isParamUpdate()) { + //setup the model selectors for query, write and display models on editConfig + setupModelSelectorsFromVitroRequest(vreq, editConfig); + OntModel queryModel = (OntModel)vreq.getAttribute("jenaOntModel"); + retrieveExistingDataGetterInfo(context, editConfig, queryModel); + } + + } //This method will get the data getters related to this page //And retrieve the current information for each of those data getters - private void retrieveExistingDataGetterInfo(EditConfigurationVTwo editConfig, OntModel queryModel) { + private void retrieveExistingDataGetterInfo(ServletContext context, + EditConfigurationVTwo editConfig, + OntModel queryModel) { String pageUri = editConfig.getSubjectUri(); - executeExistingDataGettersInfo(editConfig, pageUri, queryModel); + executeExistingDataGettersInfo(context, editConfig, pageUri, queryModel); } - private void executeExistingDataGettersInfo(EditConfigurationVTwo editConfig, String pageUri, OntModel queryModel) { + private void executeExistingDataGettersInfo(ServletContext servletContext, + EditConfigurationVTwo editConfig, + String pageUri, + OntModel queryModel) { //Create json array to be set within form specific data JSONArray jsonArray = new JSONArray(); String querystr = getExistingDataGettersQuery(); @@ -246,7 +262,7 @@ public class ManagePageGenerator extends BaseEditConfigurationGenerator implemen //json representation to be returned to template saved in json array processExistingDataGetter(counter, dg.getURI(), - dgClassName, editConfig, queryModel, jsonArray); + dgClassName, editConfig, queryModel, jsonArray, servletContext); counter++; } @@ -266,7 +282,7 @@ public class ManagePageGenerator extends BaseEditConfigurationGenerator implemen } private void processExistingDataGetter(int counter, String dataGetterURI, String dgClassName, - EditConfigurationVTwo editConfig, OntModel queryModel, JSONArray jsonArray) { + EditConfigurationVTwo editConfig, OntModel queryModel, JSONArray jsonArray, ServletContext context) { ProcessDataGetterN3 pn = ProcessDataGetterN3Utils.getDataGetterProcessorN3(dgClassName, null); //Add N3 Optional as well @@ -279,14 +295,18 @@ public class ManagePageGenerator extends BaseEditConfigurationGenerator implemen addExistingDataGetterNewResources(editConfig, pn, counter); //Add values in scope addValuesInScope(editConfig, pn, counter, dataGetterURI, queryModel); - //create JSON object and return in form specific dadta - addJSONObjectToArray(dataGetterURI, pn, queryModel, jsonArray); + //Get data getter-specific form specific data should it exist + addDataGetterSpecificFormData(dataGetterURI, pn, queryModel, jsonArray, context); + } - //Takes data getter information, packs within JSON object to send back to the form - private void addJSONObjectToArray(String dataGetterURI, ProcessDataGetterN3 pn, OntModel queryModel, JSONArray jsonArray) { - JSONObject jo = pn.getExistingValuesJSON(dataGetterURI, queryModel); + //Any data that needs to be placed within form specific data + //including: (i) The JSON object representing the existing information to be returned to template + + //Takes data getter information, packs within JSON object to send back to the form + private void addDataGetterSpecificFormData(String dataGetterURI, ProcessDataGetterN3 pn, OntModel queryModel, JSONArray jsonArray, ServletContext context) { + JSONObject jo = pn.getExistingValuesJSON(dataGetterURI, queryModel, context); jsonArray.add(jo); } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/preprocessors/utils/ProcessClassGroupDataGetterN3.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/preprocessors/utils/ProcessClassGroupDataGetterN3.java index 2a0db5974..eff3dcd13 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/preprocessors/utils/ProcessClassGroupDataGetterN3.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/preprocessors/utils/ProcessClassGroupDataGetterN3.java @@ -21,9 +21,15 @@ import com.hp.hpl.jena.query.ResultSet; import com.hp.hpl.jena.rdf.model.Literal; import com.hp.hpl.jena.rdf.model.Resource; +import edu.cornell.mannlib.vitro.webapp.beans.VClass; +import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup; +import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary; +import edu.cornell.mannlib.vitro.webapp.dao.jena.VClassGroupCache; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo; +import javax.servlet.ServletContext; +import net.sf.json.JSONArray; import net.sf.json.JSONObject; import net.sf.json.JSONSerializer; //Returns the appropriate n3 based on data getter @@ -139,9 +145,17 @@ public class ProcessClassGroupDataGetterN3 extends ProcessDataGetterAbstract { return query; } - public JSONObject getExistingValuesJSON(String dataGetterURI, OntModel queryModel) { + public JSONObject getExistingValuesJSON(String dataGetterURI, OntModel queryModel, ServletContext context) { JSONObject jObject = new JSONObject(); jObject.element("dataGetterClass", classType); + //Get class group + getExistingClassGroup(dataGetterURI, jObject, queryModel); + //Get classes within class group + getExistingClassesInClassGroup(context, dataGetterURI, jObject); + return jObject; + } + + private void getExistingClassGroup(String dataGetterURI, JSONObject jObject, OntModel queryModel) { String querystr = getExistingValuesClassGroup(dataGetterURI); QueryExecution qe = null; try{ @@ -157,7 +171,41 @@ public class ProcessClassGroupDataGetterN3 extends ProcessDataGetterAbstract { } catch(Exception ex) { log.error("Exception occurred in retrieving existing values with query " + querystr, ex); } - return jObject; + + + } + + //Assumes JSON Object received will have the class group resource URI within it + //TODO: Refactor to take advantage of existing code that uses OTHER JSON library + protected void getExistingClassesInClassGroup(ServletContext context, String dataGetterURI, JSONObject jObject) { + //Check for class group resource within json object + if(jObject.containsKey(classGroupVarBase)) { + String classGroupURI = jObject.getString(classGroupVarBase); + //Get classes for classGroupURI and include in + VClassGroupCache vcgc = VClassGroupCache.getVClassGroupCache(context); + VClassGroup group = vcgc.getGroup(classGroupURI); + populateClassesInClassGroupJSON(jObject, group); + } else { + log.error("JSONObject does not have class group URI included. "); + } + } + + //JSONObject will include results JSON object that will include classes JSON Arrya as well as + //class group information + protected void populateClassesInClassGroupJSON(JSONObject jObject, VClassGroup group) { + JSONArray classes = new JSONArray(); + for( VClass vc : group){ + JSONObject vcObj = new JSONObject(); + vcObj.element("name", vc.getName()); + vcObj.element("URI", vc.getURI()); + classes.add(vcObj); + } + JSONObject results = new JSONObject(); + + results.element("classes", classes); + results.element("classGroupName", group.getPublicName()); + results.element("classGroupUri", group.getURI()); + jObject.element("results", results); } } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/preprocessors/utils/ProcessDataGetterN3.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/preprocessors/utils/ProcessDataGetterN3.java index 2c909e3d1..d14eafe90 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/preprocessors/utils/ProcessDataGetterN3.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/preprocessors/utils/ProcessDataGetterN3.java @@ -7,6 +7,7 @@ import java.util.List; import java.util.Map; import net.sf.json.JSONObject; +import javax.servlet.ServletContext; import com.hp.hpl.jena.ontology.OntModel; import com.hp.hpl.jena.rdf.model.Literal; @@ -33,6 +34,6 @@ public interface ProcessDataGetterN3 { public Map> retrieveExistingLiteralValues(); public Map> retrieveExistingUriValues(); public void populateExistingValues(String dataGetterURI, int counter, OntModel queryModel); - public JSONObject getExistingValuesJSON(String dataGetterURI, OntModel queryModel); + public JSONObject getExistingValuesJSON(String dataGetterURI, OntModel queryModel, ServletContext context); } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/preprocessors/utils/ProcessFixedHTMLN3.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/preprocessors/utils/ProcessFixedHTMLN3.java index e4ac768c6..7b4a74788 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/preprocessors/utils/ProcessFixedHTMLN3.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/preprocessors/utils/ProcessFixedHTMLN3.java @@ -5,6 +5,7 @@ package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocess import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import javax.servlet.ServletContext; import net.sf.json.JSONObject; @@ -128,7 +129,7 @@ public class ProcessFixedHTMLN3 extends ProcessDataGetterAbstract { //Method to create a JSON object with existing values to return to form //There may be a better way to do this without having to run the query twice //TODO: Refactor code if required - public JSONObject getExistingValuesJSON(String dataGetterURI, OntModel queryModel) { + public JSONObject getExistingValuesJSON(String dataGetterURI, OntModel queryModel, ServletContext context) { JSONObject jObject = new JSONObject(); jObject.element("dataGetterClass", classType); String querystr = getExistingValuesSparqlQuery(dataGetterURI); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/preprocessors/utils/ProcessIndividualsForClassesDataGetterN3.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/preprocessors/utils/ProcessIndividualsForClassesDataGetterN3.java index 1ff854d22..92aaf4e0c 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/preprocessors/utils/ProcessIndividualsForClassesDataGetterN3.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/preprocessors/utils/ProcessIndividualsForClassesDataGetterN3.java @@ -21,6 +21,7 @@ import com.hp.hpl.jena.query.QuerySolution; import com.hp.hpl.jena.query.ResultSet; import com.hp.hpl.jena.rdf.model.Literal; import com.hp.hpl.jena.rdf.model.Resource; +import javax.servlet.ServletContext; import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo; @@ -196,9 +197,17 @@ public class ProcessIndividualsForClassesDataGetterN3 extends ProcessClassGroup } - public JSONObject getExistingValuesJSON(String dataGetterURI, OntModel queryModel) { + public JSONObject getExistingValuesJSON(String dataGetterURI, OntModel queryModel, ServletContext context) { JSONObject jObject = new JSONObject(); jObject.element("dataGetterClass", classType); + //Get selected class group and which classes were selected + getExistingClassGroupAndIndividuals(dataGetterURI, jObject, queryModel); + //Get all classes within the class group + super.getExistingClassesInClassGroup(context, dataGetterURI, jObject); + return jObject; + } + + private void getExistingClassGroupAndIndividuals(String dataGetterURI, JSONObject jObject, OntModel queryModel) { String querystr = getExistingValuesIndividualsForClasses(dataGetterURI); QueryExecution qe = null; try{ @@ -225,7 +234,6 @@ public class ProcessIndividualsForClassesDataGetterN3 extends ProcessClassGroup } catch(Exception ex) { log.error("Exception occurred in retrieving existing values with query " + querystr, ex); } - return jObject; } } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/preprocessors/utils/ProcessSparqlDataGetterN3.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/preprocessors/utils/ProcessSparqlDataGetterN3.java index 6bc8e05f3..3098cdb73 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/preprocessors/utils/ProcessSparqlDataGetterN3.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/preprocessors/utils/ProcessSparqlDataGetterN3.java @@ -20,6 +20,7 @@ import com.hp.hpl.jena.query.QuerySolution; import com.hp.hpl.jena.query.ResultSet; import com.hp.hpl.jena.rdf.model.Literal; import com.hp.hpl.jena.rdf.model.Resource; +import javax.servlet.ServletContext; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo; @@ -160,7 +161,7 @@ public class ProcessSparqlDataGetterN3 extends ProcessDataGetterAbstract { - public JSONObject getExistingValuesJSON(String dataGetterURI, OntModel queryModel) { + public JSONObject getExistingValuesJSON(String dataGetterURI, OntModel queryModel, ServletContext context) { JSONObject jObject = new JSONObject(); jObject.element("dataGetterClass", classType); String querystr = getExistingValuesSparqlQuery(dataGetterURI); diff --git a/webapp/web/js/menupage/pageManagementUtils.js b/webapp/web/js/menupage/pageManagementUtils.js index 0f2eeb2d8..f4aaad3ee 100644 --- a/webapp/web/js/menupage/pageManagementUtils.js +++ b/webapp/web/js/menupage/pageManagementUtils.js @@ -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('
  • '); - - $.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 = '
  • ' + - '' + - '' + - '
  • '; - 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('
  • '); + + $.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 = '
  • ' + + '' + + '' + + '
  • '; + 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 diff --git a/webapp/web/js/menupage/processClassGroupDataGetterContent.js b/webapp/web/js/menupage/processClassGroupDataGetterContent.js index 5cdbdfc3a..853bfbbb5 100644 --- a/webapp/web/js/menupage/processClassGroupDataGetterContent.js +++ b/webapp/web/js/menupage/processClassGroupDataGetterContent.js @@ -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('
  • '); + + $.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 = '
  • ' + + '' + + '' + + '
  • '; + 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); + }); + } + } \ No newline at end of file diff --git a/webapp/web/js/menupage/processIndividualsForClassesDataGetterContent.js b/webapp/web/js/menupage/processIndividualsForClassesDataGetterContent.js index f37d1f034..631af7da9 100644 --- a/webapp/web/js/menupage/processIndividualsForClassesDataGetterContent.js +++ b/webapp/web/js/menupage/processIndividualsForClassesDataGetterContent.js @@ -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); } } \ No newline at end of file diff --git a/webapp/web/templates/freemarker/edit/forms/pageManagement--browseClassGroups.ftl b/webapp/web/templates/freemarker/edit/forms/pageManagement--browseClassGroups.ftl index 6fde98c7f..f2d2960df 100644 --- a/webapp/web/templates/freemarker/edit/forms/pageManagement--browseClassGroups.ftl +++ b/webapp/web/templates/freemarker/edit/forms/pageManagement--browseClassGroups.ftl @@ -4,7 +4,6 @@ <#--Requires Menu action be defined in parent template--> <#assign classGroup = pageData.classGroup /> <#assign classGroups = pageData.classGroups /> -<#assign isClassGroupPage = false/> <#assign includeAllClasses = false/> <#-- some additional processing here which shows or hides the class group selection and classes based on initial action--> <#assign existingClassGroupStyle = " " /> @@ -41,20 +40,12 @@