updates for page management
This commit is contained in:
parent
491c4f6d9a
commit
c338c9025b
10 changed files with 260 additions and 86 deletions
|
@ -8,6 +8,7 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.servlet.ServletContext;
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
import net.sf.json.JSONArray;
|
import net.sf.json.JSONArray;
|
||||||
|
@ -79,17 +80,20 @@ public class ManagePageGenerator extends BaseEditConfigurationGenerator implemen
|
||||||
setUrisAndLiteralsOnForm(conf, vreq);
|
setUrisAndLiteralsOnForm(conf, vreq);
|
||||||
//Set the fields
|
//Set the fields
|
||||||
setFields(conf);
|
setFields(conf);
|
||||||
|
|
||||||
//Adding additional data, specifically edit mode
|
//Adding additional data, specifically edit mode
|
||||||
addFormSpecificData(conf, vreq);
|
addFormSpecificData(conf, vreq);
|
||||||
//Add preprocessor
|
//Add preprocessor
|
||||||
conf.addEditSubmissionPreprocessor(new ManagePagePreprocessor(conf));
|
conf.addEditSubmissionPreprocessor(new ManagePagePreprocessor(conf));
|
||||||
//Prepare
|
//Prepare: add literals/uris in scope based on sparql queries
|
||||||
prepare(vreq, conf);
|
prepare(vreq, conf);
|
||||||
|
//This method specifically retrieves information for edit
|
||||||
|
populateExistingDataGetter(vreq, conf, session.getServletContext());
|
||||||
|
|
||||||
return conf ;
|
return conf ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void setUrisAndLiteralsOnForm(EditConfigurationVTwo conf,
|
private void setUrisAndLiteralsOnForm(EditConfigurationVTwo conf,
|
||||||
VitroRequest vreq) {
|
VitroRequest vreq) {
|
||||||
conf.setUrisOnForm(new String[]{"page", "menuItem"}); //new resources: should this be on form for new - should be for existing
|
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
|
@Override
|
||||||
void prepare(VitroRequest vreq, EditConfigurationVTwo editConfig) {
|
void prepare(VitroRequest vreq, EditConfigurationVTwo editConfig) {
|
||||||
//setup the model selectors for query, write and display models on 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);
|
setupModelSelectorsFromVitroRequest(vreq, editConfig);
|
||||||
OntModel queryModel = (OntModel)vreq.getAttribute("jenaOntModel");
|
OntModel queryModel = (OntModel)vreq.getAttribute("jenaOntModel");
|
||||||
if (editConfig.isParamUpdate()) {
|
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);
|
editConfig.prepareForParamUpdate(queryModel);
|
||||||
retrieveExistingDataGetterInfo(editConfig, queryModel);
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
//if no subject uri, this is creating a new page
|
//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
|
//This method will get the data getters related to this page
|
||||||
//And retrieve the current information for each of those data getters
|
//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();
|
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
|
//Create json array to be set within form specific data
|
||||||
JSONArray jsonArray = new JSONArray();
|
JSONArray jsonArray = new JSONArray();
|
||||||
String querystr = getExistingDataGettersQuery();
|
String querystr = getExistingDataGettersQuery();
|
||||||
|
@ -246,7 +262,7 @@ public class ManagePageGenerator extends BaseEditConfigurationGenerator implemen
|
||||||
//json representation to be returned to template saved in json array
|
//json representation to be returned to template saved in json array
|
||||||
processExistingDataGetter(counter,
|
processExistingDataGetter(counter,
|
||||||
dg.getURI(),
|
dg.getURI(),
|
||||||
dgClassName, editConfig, queryModel, jsonArray);
|
dgClassName, editConfig, queryModel, jsonArray, servletContext);
|
||||||
|
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
|
@ -266,7 +282,7 @@ public class ManagePageGenerator extends BaseEditConfigurationGenerator implemen
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processExistingDataGetter(int counter, String dataGetterURI, String dgClassName,
|
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);
|
ProcessDataGetterN3 pn = ProcessDataGetterN3Utils.getDataGetterProcessorN3(dgClassName, null);
|
||||||
|
|
||||||
//Add N3 Optional as well
|
//Add N3 Optional as well
|
||||||
|
@ -279,14 +295,18 @@ public class ManagePageGenerator extends BaseEditConfigurationGenerator implemen
|
||||||
addExistingDataGetterNewResources(editConfig, pn, counter);
|
addExistingDataGetterNewResources(editConfig, pn, counter);
|
||||||
//Add values in scope
|
//Add values in scope
|
||||||
addValuesInScope(editConfig, pn, counter, dataGetterURI, queryModel);
|
addValuesInScope(editConfig, pn, counter, dataGetterURI, queryModel);
|
||||||
//create JSON object and return in form specific dadta
|
//Get data getter-specific form specific data should it exist
|
||||||
addJSONObjectToArray(dataGetterURI, pn, queryModel, jsonArray);
|
addDataGetterSpecificFormData(dataGetterURI, pn, queryModel, jsonArray, context);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Takes data getter information, packs within JSON object to send back to the form
|
//Any data that needs to be placed within form specific data
|
||||||
private void addJSONObjectToArray(String dataGetterURI, ProcessDataGetterN3 pn, OntModel queryModel, JSONArray jsonArray) {
|
//including: (i) The JSON object representing the existing information to be returned to template
|
||||||
JSONObject jo = pn.getExistingValuesJSON(dataGetterURI, queryModel);
|
|
||||||
|
//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);
|
jsonArray.add(jo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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.Literal;
|
||||||
import com.hp.hpl.jena.rdf.model.Resource;
|
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.DisplayVocabulary;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.VClassGroupCache;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
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.JSONObject;
|
||||||
import net.sf.json.JSONSerializer;
|
import net.sf.json.JSONSerializer;
|
||||||
//Returns the appropriate n3 based on data getter
|
//Returns the appropriate n3 based on data getter
|
||||||
|
@ -139,9 +145,17 @@ public class ProcessClassGroupDataGetterN3 extends ProcessDataGetterAbstract {
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject getExistingValuesJSON(String dataGetterURI, OntModel queryModel) {
|
public JSONObject getExistingValuesJSON(String dataGetterURI, OntModel queryModel, ServletContext context) {
|
||||||
JSONObject jObject = new JSONObject();
|
JSONObject jObject = new JSONObject();
|
||||||
jObject.element("dataGetterClass", classType);
|
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);
|
String querystr = getExistingValuesClassGroup(dataGetterURI);
|
||||||
QueryExecution qe = null;
|
QueryExecution qe = null;
|
||||||
try{
|
try{
|
||||||
|
@ -157,7 +171,41 @@ public class ProcessClassGroupDataGetterN3 extends ProcessDataGetterAbstract {
|
||||||
} catch(Exception ex) {
|
} catch(Exception ex) {
|
||||||
log.error("Exception occurred in retrieving existing values with query " + querystr, 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import net.sf.json.JSONObject;
|
import net.sf.json.JSONObject;
|
||||||
|
import javax.servlet.ServletContext;
|
||||||
|
|
||||||
import com.hp.hpl.jena.ontology.OntModel;
|
import com.hp.hpl.jena.ontology.OntModel;
|
||||||
import com.hp.hpl.jena.rdf.model.Literal;
|
import com.hp.hpl.jena.rdf.model.Literal;
|
||||||
|
@ -33,6 +34,6 @@ public interface ProcessDataGetterN3 {
|
||||||
public Map<String, List<Literal>> retrieveExistingLiteralValues();
|
public Map<String, List<Literal>> retrieveExistingLiteralValues();
|
||||||
public Map<String, List<String>> retrieveExistingUriValues();
|
public Map<String, List<String>> retrieveExistingUriValues();
|
||||||
public void populateExistingValues(String dataGetterURI, int counter, OntModel queryModel);
|
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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocess
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import javax.servlet.ServletContext;
|
||||||
|
|
||||||
import net.sf.json.JSONObject;
|
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
|
//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
|
//There may be a better way to do this without having to run the query twice
|
||||||
//TODO: Refactor code if required
|
//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();
|
JSONObject jObject = new JSONObject();
|
||||||
jObject.element("dataGetterClass", classType);
|
jObject.element("dataGetterClass", classType);
|
||||||
String querystr = getExistingValuesSparqlQuery(dataGetterURI);
|
String querystr = getExistingValuesSparqlQuery(dataGetterURI);
|
||||||
|
|
|
@ -21,6 +21,7 @@ import com.hp.hpl.jena.query.QuerySolution;
|
||||||
import com.hp.hpl.jena.query.ResultSet;
|
import com.hp.hpl.jena.query.ResultSet;
|
||||||
import com.hp.hpl.jena.rdf.model.Literal;
|
import com.hp.hpl.jena.rdf.model.Literal;
|
||||||
import com.hp.hpl.jena.rdf.model.Resource;
|
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.dao.DisplayVocabulary;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
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();
|
JSONObject jObject = new JSONObject();
|
||||||
jObject.element("dataGetterClass", classType);
|
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);
|
String querystr = getExistingValuesIndividualsForClasses(dataGetterURI);
|
||||||
QueryExecution qe = null;
|
QueryExecution qe = null;
|
||||||
try{
|
try{
|
||||||
|
@ -225,7 +234,6 @@ public class ProcessIndividualsForClassesDataGetterN3 extends ProcessClassGroup
|
||||||
} catch(Exception ex) {
|
} catch(Exception ex) {
|
||||||
log.error("Exception occurred in retrieving existing values with query " + querystr, ex);
|
log.error("Exception occurred in retrieving existing values with query " + querystr, ex);
|
||||||
}
|
}
|
||||||
return jObject;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ import com.hp.hpl.jena.query.QuerySolution;
|
||||||
import com.hp.hpl.jena.query.ResultSet;
|
import com.hp.hpl.jena.query.ResultSet;
|
||||||
import com.hp.hpl.jena.rdf.model.Literal;
|
import com.hp.hpl.jena.rdf.model.Literal;
|
||||||
import com.hp.hpl.jena.rdf.model.Resource;
|
import com.hp.hpl.jena.rdf.model.Resource;
|
||||||
|
import javax.servlet.ServletContext;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
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();
|
JSONObject jObject = new JSONObject();
|
||||||
jObject.element("dataGetterClass", classType);
|
jObject.element("dataGetterClass", classType);
|
||||||
String querystr = getExistingValuesSparqlQuery(dataGetterURI);
|
String querystr = getExistingValuesSparqlQuery(dataGetterURI);
|
||||||
|
|
|
@ -359,7 +359,8 @@ var pageManagementUtils = {
|
||||||
$newRemoveButton = $innerDiv.find('input#remove' + counter);
|
$newRemoveButton = $innerDiv.find('input#remove' + counter);
|
||||||
// this will have to disable submitted fields as well as hide them.
|
// this will have to disable submitted fields as well as hide them.
|
||||||
$newRemoveButton.click(function() {
|
$newRemoveButton.click(function() {
|
||||||
$innerDiv.parent("div").css("display","none");
|
//$innerDiv.parent("div").css("display","none");
|
||||||
|
$innerDiv.parent("div").remove();
|
||||||
pageManagementUtils.adjustSaveButtonHeight();
|
pageManagementUtils.adjustSaveButtonHeight();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -387,40 +388,46 @@ var pageManagementUtils = {
|
||||||
url += encodeURIComponent(vclassUri);
|
url += encodeURIComponent(vclassUri);
|
||||||
//Make ajax call to retrieve vclasses
|
//Make ajax call to retrieve vclasses
|
||||||
$.getJSON(url, function(results) {
|
$.getJSON(url, function(results) {
|
||||||
|
//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 ) {
|
||||||
|
|
||||||
if ( results.classes.length == 0 ) {
|
} else {
|
||||||
|
//update existing content type with correct class group name and hide class group select again
|
||||||
|
// pageManagementUtils.hideClassGroups();
|
||||||
|
|
||||||
} else {
|
pageManagementUtils.selectedGroupForPage.html(results.classGroupName);
|
||||||
//update existing content type with correct class group name and hide class group select again
|
//update content type in message to "display x within my institution"
|
||||||
// pageManagementUtils.hideClassGroups();
|
//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');
|
||||||
|
|
||||||
pageManagementUtils.selectedGroupForPage.html(results.classGroupName);
|
selectedClassesList.empty();
|
||||||
//update content type in message to "display x within my institution"
|
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>');
|
||||||
pageManagementUtils.updateInternalClassMessage(results.classGroupName);
|
|
||||||
//retrieve classes for class group and display with all selected
|
|
||||||
var selectedClassesList = pageManagementUtils.classesForClassGroup.children('ul#selectedClasses');
|
|
||||||
|
|
||||||
selectedClassesList.empty();
|
$.each(results.classes, function(i, item) {
|
||||||
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>');
|
var thisClass = results.classes[i];
|
||||||
|
var thisClassName = thisClass.name;
|
||||||
$.each(results.classes, function(i, item) {
|
//For the class group, ALL classes should be selected
|
||||||
var thisClass = results.classes[i];
|
appendHtml = ' <li class="ui-state-default">' +
|
||||||
var thisClassName = thisClass.name;
|
'<input type="checkbox" checked="checked" name="classInClassGroup" value="' + thisClass.URI + '" />' +
|
||||||
//When first selecting new content type, all classes should be selected
|
'<label class="inline" for="' + thisClassName + '"> ' + thisClassName + '</label>' +
|
||||||
appendHtml = ' <li class="ui-state-default">' +
|
'</li>';
|
||||||
'<input type="checkbox" checked="checked" name="classInClassGroup" value="' + thisClass.URI + '" />' +
|
selectedClassesList.append(appendHtml);
|
||||||
'<label class="inline" for="' + thisClassName + '"> ' + thisClassName + '</label>' +
|
});
|
||||||
'</li>';
|
pageManagementUtils.toggleClassSelection();
|
||||||
selectedClassesList.append(appendHtml);
|
|
||||||
});
|
|
||||||
pageManagementUtils.toggleClassSelection();
|
|
||||||
|
|
||||||
|
|
||||||
//From NEW code
|
//From NEW code
|
||||||
if (pageManagementUtils.selectClassGroupDropdown.val() == "" ) {
|
if (pageManagementUtils.selectClassGroupDropdown.val() == "" ) {
|
||||||
pageManagementUtils.classesForClassGroup.addClass('hidden');
|
pageManagementUtils.classesForClassGroup.addClass('hidden');
|
||||||
$("div#leftSide").css("height","");
|
$("div#leftSide").css("height","");
|
||||||
pageManagementUtils.moreContentButton.hide();
|
pageManagementUtils.moreContentButton.hide();
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -430,11 +437,7 @@ var pageManagementUtils = {
|
||||||
$("div#leftSide").css("height",$("div#rightSide").height() + "px");
|
$("div#leftSide").css("height",$("div#rightSide").height() + "px");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
toggleClassSelection: function() {
|
toggleClassSelection: function() {
|
||||||
// Check/unckeck all classes for selection
|
// Check/unckeck all classes for selection
|
||||||
|
@ -544,6 +547,7 @@ var pageManagementUtils = {
|
||||||
var originalObjectPath = 'section#' + contentType;
|
var originalObjectPath = 'section#' + contentType;
|
||||||
var $newContentObj = $(originalObjectPath).clone();
|
var $newContentObj = $(originalObjectPath).clone();
|
||||||
$newContentObj.addClass("pageContent");
|
$newContentObj.addClass("pageContent");
|
||||||
|
$newContentObj.attr("contentNumber", counter);
|
||||||
//Save content type
|
//Save content type
|
||||||
$newContentObj.attr("contentType", contentType);
|
$newContentObj.attr("contentType", contentType);
|
||||||
//Set id for object
|
//Set id for object
|
||||||
|
|
|
@ -8,6 +8,7 @@ var processClassGroupDataGetterContent = {
|
||||||
initProcessor:function(dataGetterClassInput) {
|
initProcessor:function(dataGetterClassInput) {
|
||||||
this.dataGetterClass = dataGetterClassInput;
|
this.dataGetterClass = dataGetterClassInput;
|
||||||
},
|
},
|
||||||
|
|
||||||
//Do we need a separate content type for each of the others?
|
//Do we need a separate content type for each of the others?
|
||||||
processPageContentSection:function(pageContentSection) {
|
processPageContentSection:function(pageContentSection) {
|
||||||
//Will look at classes etc.
|
//Will look at classes etc.
|
||||||
|
@ -20,13 +21,112 @@ var processClassGroupDataGetterContent = {
|
||||||
populatePageContentSection:function(existingContentObject, pageContentSection) {
|
populatePageContentSection:function(existingContentObject, pageContentSection) {
|
||||||
var classGroupValue = existingContentObject["classGroup"];
|
var classGroupValue = existingContentObject["classGroup"];
|
||||||
pageContentSection.find("select[name='selectClassGroup']").val(classGroupValue);
|
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
|
//For the label of the content section for editing, need to add additional value
|
||||||
retrieveAdditionalLabelText:function(existingContentObject) {
|
retrieveAdditionalLabelText:function(existingContentObject) {
|
||||||
//Right now return empty but can hook this into a hashmap with labels and uris
|
var label = "";
|
||||||
//set up in browse class group
|
var results = existingContentObject["results"];
|
||||||
return "";
|
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
|
//For an existing set of content where form is already set, fill in the values
|
||||||
populatePageContentSection:function(existingContentObject, pageContentSection) {
|
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 classesSelected = existingContenetObject["classesSelectedInClassGroup"];
|
||||||
var numberSelected = classesSelected.length;
|
var numberSelected = classesSelected.length;
|
||||||
var i;
|
var i;
|
||||||
|
//Uncheck all since default is checked
|
||||||
|
pageContentSection.find("input[name='classInClassGroup']").removeAttr("checked");
|
||||||
for(i = 0; i < numberSelected; i++) {
|
for(i = 0; i < numberSelected; i++) {
|
||||||
var classSelected = classesSelected[i];
|
var classSelected = classesSelected[i];
|
||||||
pageContentSection.find("input[name='classInClassGroup'][value='" + classSelected + "']").attr("checked", "checked");
|
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
|
//For the label of the content section for editing, need to add additional value
|
||||||
retrieveAdditionalLabelText:function(existingContentObject) {
|
retrieveAdditionalLabelText:function(existingContentObject) {
|
||||||
//Right now return empty but can hook this into a hashmap with labels and uris
|
return processClassGroupDataGetterContent.retrieveAdditionalLabelText(existingContentObject);
|
||||||
//set up in browse class group
|
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -4,7 +4,6 @@
|
||||||
<#--Requires Menu action be defined in parent template-->
|
<#--Requires Menu action be defined in parent template-->
|
||||||
<#assign classGroup = pageData.classGroup />
|
<#assign classGroup = pageData.classGroup />
|
||||||
<#assign classGroups = pageData.classGroups />
|
<#assign classGroups = pageData.classGroups />
|
||||||
<#assign isClassGroupPage = false/>
|
|
||||||
<#assign includeAllClasses = false/>
|
<#assign includeAllClasses = false/>
|
||||||
<#-- some additional processing here which shows or hides the class group selection and classes based on initial action-->
|
<#-- some additional processing here which shows or hides the class group selection and classes based on initial action-->
|
||||||
<#assign existingClassGroupStyle = " " />
|
<#assign existingClassGroupStyle = " " />
|
||||||
|
@ -41,20 +40,12 @@
|
||||||
<ul id="selectedClasses" name="selectedClasses" role="menu">
|
<ul id="selectedClasses" name="selectedClasses" role="menu">
|
||||||
<#--Adding a default class for "ALL" in case all classes selected-->
|
<#--Adding a default class for "ALL" in case all classes selected-->
|
||||||
<li class="ui-state-default" role="menuitem">
|
<li class="ui-state-default" role="menuitem">
|
||||||
<input type="checkbox" name="allSelected" id="allSelected" value="all" <#if !isIndividualsForClassesPage?has_content>checked</#if> />
|
<input type="checkbox" name="allSelected" id="allSelected" value="all" checked="checked" />
|
||||||
<label class="inline" for="All"> All</label>
|
<label class="inline" for="All"> All</label>
|
||||||
</li>
|
</li>
|
||||||
<#list classGroup as classInClassGroup>
|
<#list classGroup as classInClassGroup>
|
||||||
<li class="ui-state-default" role="menuitem">
|
<li class="ui-state-default" role="menuitem">
|
||||||
<input type="checkbox" id="classInClassGroup" name="classInClassGroup" value="${classInClassGroup.URI}"
|
<input type="checkbox" id="classInClassGroup" name="classInClassGroup" value="${classInClassGroup.URI}" checked="checked" />
|
||||||
<#if includeAllClasses = true>checked</#if>
|
|
||||||
<#if isIndividualsForClassesPage?has_content>
|
|
||||||
<#list includeClasses as includeClass>
|
|
||||||
<#if includeClass = classInClassGroup.URI>
|
|
||||||
checked
|
|
||||||
</#if>
|
|
||||||
</#list>
|
|
||||||
</#if> />
|
|
||||||
<label class="inline" for="${classInClassGroup.name}"> ${classInClassGroup.name}</label>
|
<label class="inline" for="${classInClassGroup.name}"> ${classInClassGroup.name}</label>
|
||||||
<span class="ui-icon-sortable"></span>
|
<span class="ui-icon-sortable"></span>
|
||||||
</li>
|
</li>
|
||||||
|
|
Loading…
Add table
Reference in a new issue