From 7e2a5d22d448e8720dbdef5a9058eae255e0c1c2 Mon Sep 17 00:00:00 2001 From: hjkhjk54 Date: Sun, 24 Jun 2012 01:39:58 +0000 Subject: [PATCH] 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 --- .../controller/edit/DeletePageController.java | 171 ++++++++++++++++++ .../generators/ManagePageGenerator.java | 89 ++++++--- .../edit/EditConfigurationTemplateModel.java | 9 +- webapp/web/WEB-INF/ontologies/app/menu.n3 | 2 +- webapp/web/WEB-INF/web.xml | 11 ++ webapp/web/js/menupage/pageManagementUtils.js | 36 +++- .../processClassGroupDataGetterContent.js | 16 ++ .../processFixedHTMLDataGetterContent.js | 16 +- ...sIndividualsForClassesDataGetterContent.js | 6 +- .../processSparqlDataGetterContent.js | 16 +- webapp/web/js/pageDeletion.js | 49 +++++ .../body/pagemanagement/pageList.ftl | 15 +- .../pageManagement--browseClassGroups.ftl | 4 +- .../freemarker/edit/forms/pageManagement.ftl | 13 +- 14 files changed, 403 insertions(+), 50 deletions(-) create mode 100644 webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/DeletePageController.java create mode 100644 webapp/web/js/pageDeletion.js diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/DeletePageController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/DeletePageController.java new file mode 100644 index 000000000..2055a29f5 --- /dev/null +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/DeletePageController.java @@ -0,0 +1,171 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +package edu.cornell.mannlib.vitro.webapp.controller.edit; + + +import java.io.IOException; +import java.io.StringWriter; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import com.hp.hpl.jena.ontology.OntModel; +import com.hp.hpl.jena.rdf.model.Model; +import com.hp.hpl.jena.rdf.model.ModelFactory; +import com.hp.hpl.jena.rdf.model.RDFNode; +import com.hp.hpl.jena.rdf.model.Resource; +import com.hp.hpl.jena.rdf.model.ResourceFactory; +import com.hp.hpl.jena.rdf.model.Statement; +import com.hp.hpl.jena.rdf.model.StmtIterator; +import com.hp.hpl.jena.shared.Lock; + +import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet; +import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; +import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary; + +/** + *Process deletions for page, deleting page, data getters and any associated menu items. + */ +public class DeletePageController extends VitroHttpServlet { + + private final static String REDIRECT_URL = "/pageList"; + private static Model removeStatements = null; + + @Override + protected void doPost(HttpServletRequest rawRequest, HttpServletResponse resp) + throws ServletException, IOException { + removeStatements = ModelFactory.createDefaultModel(); + VitroRequest vreq = new VitroRequest(rawRequest); + String pageUri = vreq.getParameter("pageURI"); + if(pageUri != null) { + doDeletePage(pageUri, vreq, resp); + } + resp.sendRedirect(rawRequest.getContextPath() + REDIRECT_URL); + } + + protected void doGet(HttpServletRequest rawRequest, HttpServletResponse resp) { + doPost(rawRequest, resp); + } + + + //Parameter retrieval is identical, but in one case an entirey new menu item needs to be created + //along with a new page + public void doDeletePage(String pageUri, VitroRequest vreq, HttpServletResponse resp) { + + OntModel displayModel = getDisplayModel(vreq); + if(displayModel == null) { + //Throw some kind of exception + log.error("Display model not being retrieved correctly"); + } + + String errorMessage = ""; + processDelete(pageUri, displayModel, vreq); + + //Edits to model occur here + displayModel.enterCriticalSection(Lock.WRITE); + try { + log.debug("Statement to be removed are "); + StringWriter r = new StringWriter(); + removeStatements.write(r, "N3"); + log.debug(r.toString()); + r.close(); + displayModel.remove(removeStatements); + + } catch(Exception ex) { + log.error("An error occurred in processing command", ex); + errorMessage += "An error occurred and the operation could not be completed successfully."; + }finally { + displayModel.leaveCriticalSection(); + } + } + + + + + + private void processDelete(String pageUri, OntModel displayModel, VitroRequest vreq) { + //get the page resource + Resource pageResource = getExistingPage(pageUri, displayModel); + //if the page is related to a menu item, get the menu item information + Resource menuItemResource = getExistingMenuItem(pageResource, displayModel); + + //What statements should be added and removed + removeStatements.add(getStatementsToRemove(displayModel, menuItemResource, pageResource)); + //No statements to add + } + + + + + + //What statements need to be removed + private Model getStatementsToRemove(OntModel displayModel, + Resource menuItemResource, Resource pageResource) { + Model removeModel = ModelFactory.createDefaultModel(); + removeModel.add(displayModel.listStatements(pageResource, null, (RDFNode) null)); + //if menu item exists for this page, get all statements related to menu item and page + if(menuItemResource != null) { + removeModel.add(displayModel.listStatements(menuItemResource, null, (RDFNode) null)); + //Also remove any statements where menu item resource is an object + removeModel.add(displayModel.listStatements(null, null, menuItemResource)); + } + //Get all data getter statements + Model associatedDataGettersModel = getDataGettersStatements(pageResource, displayModel); + removeModel.add(associatedDataGettersModel); + return removeModel; + } + + //Get all data getters associated with page + private Model getDataGettersStatements(Resource pageResource, OntModel displayModel) { + Model dataGettersModel = ModelFactory.createDefaultModel(); + //To iterate through to get all data getters and then all their statements + //PAge to data getter statements have already been added when all page statements were added + StmtIterator dataGetterIt = displayModel.listStatements( + pageResource, + ResourceFactory.createProperty(DisplayVocabulary.HAS_DATA_GETTER), + (RDFNode) null); + while(dataGetterIt.hasNext()) { + Statement dataGetterStmt = dataGetterIt.nextStatement(); + Resource dataGetterResource = dataGetterStmt.getSubject(); + dataGettersModel.add(displayModel.listStatements(dataGetterResource, null, (RDFNode) null)); + } + return dataGettersModel; + } + + + + + private Resource getExistingPage(String pageUri, OntModel displayModel) { + return ResourceFactory.createResource(pageUri); + } + + private Resource getExistingMenuItem(Resource pageResource, OntModel displayModel) { + Resource menuItemResource = null; + StmtIterator menuItemIt = displayModel.listStatements(null, + DisplayVocabulary.TO_PAGE, + pageResource); + while(menuItemIt.hasNext()) { + Statement menuStmt = menuItemIt.nextStatement(); + menuItemResource = menuStmt.getSubject(); + } + return menuItemResource; + } + + + + //This should be in write mode + //TODO: find better way of doing this + private OntModel getDisplayModel(VitroRequest vreq) { + if(vreq.getAttribute(vreq.SPECIAL_WRITE_MODEL) != null) { + return vreq.getWriteModel(); + } else { + return (OntModel) getServletContext().getAttribute("http://vitro.mannlib.cornell.edu/default/vitro-kb-displayMetadata"); + } + } + + Log log = LogFactory.getLog(MenuManagementEdit.class); +} 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 d23485c37..f0d4b2585 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 @@ -28,6 +28,7 @@ import com.hp.hpl.jena.query.QuerySolution; import com.hp.hpl.jena.query.QuerySolutionMap; import com.hp.hpl.jena.query.ResultSet; import com.hp.hpl.jena.rdf.model.ResourceFactory; +import com.hp.hpl.jena.vocabulary.XSD; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder; @@ -88,7 +89,7 @@ public class ManagePageGenerator extends BaseEditConfigurationGenerator implemen prepare(vreq, conf); //This method specifically retrieves information for edit populateExistingDataGetter(vreq, conf, session.getServletContext()); - + return conf ; } @@ -145,7 +146,7 @@ public class ManagePageGenerator extends BaseEditConfigurationGenerator implemen FieldVTwo menuItemLinkTextField = new FieldVTwo().setName("menuLinkText"); conf.addField(menuItemLinkTextField); - FieldVTwo menuItemPositionField = new FieldVTwo().setName("menuPosition"); + FieldVTwo menuItemPositionField = new FieldVTwo().setName("menuPosition").setRangeDatatypeUri(XSD.integer.getURI()); conf.addField(menuItemPositionField); //The actual page content information is stored in this field, and then @@ -175,18 +176,16 @@ public class ManagePageGenerator extends BaseEditConfigurationGenerator implemen String subjectUri = EditConfigurationUtils.getSubjectUri(vreq); String predicateUri = EditConfigurationUtils.getPredicateUri(vreq); - + editConfiguration.setUrlToReturnTo(UrlBuilder.getUrl("/pageList")); //For the case of a new page if(subjectUri == null) { //Once added, return to pageList - editConfiguration.setUrlToReturnTo(UrlBuilder.getUrl("/pageList")); editConfiguration.setEntityToReturnTo("?page"); editConfiguration.setPredicateUri(predicateUri); } else { //For the case of an existing page //Page title pageName or page hasDataGetter dataGetter - editConfiguration.setUrlPatternToReturnTo("/individual"); editConfiguration.setEntityToReturnTo(subjectUri); //Set update version here //if subject uri = page uri != null or empty, editing existing page @@ -486,22 +485,15 @@ private String getExistingCustomTemplateQuery() { addNewPageData(vreq, formSpecificData); } - + //for menu position, return either existing menu position or get the highest available menu position + retrieveMenuPosition(editConfiguration, vreq, formSpecificData); editConfiguration.setFormSpecificData(formSpecificData); } - private String getTemplate(EditConfigurationVTwo editConfiguration) { - String returnTemplate = "default"; - if(editConfiguration.getSubjectUri() != null) { - //Then template is EXISTING template - //TODO: Get existing template value for page - } - return returnTemplate; - - } - private void addRequiredPageData(VitroRequest vreq, Map data) { MenuManagementDataUtils.includeRequiredSystemData(vreq.getSession().getServletContext(), data); + data.put("classGroup", new ArrayList()); + data.put("classGroups", DataGetterUtils.getClassGroups(vreq.getSession().getServletContext())); } private void addExistingPageData(VitroRequest vreq, Map data) { @@ -514,18 +506,7 @@ private String getExistingCustomTemplateQuery() { private void addNewPageData(VitroRequest vreq, Map data) { data.put("title", "Add Menu Item"); - data.put("menuAction", "Add"); - //Generate empty values for fields - data.put("menuItem", ""); - data.put("pageName", ""); - data.put("prettyUrl", ""); - data.put("associatedPage", ""); - data.put("associatedPageURI", ""); - data.put("classGroup", new ArrayList()); - //not a page already assigned a class group - data.put("isClassGroupPage", false); - data.put("includeAllClasses", false); - data.put("classGroups", DataGetterUtils.getClassGroups(vreq.getSession().getServletContext())); + data.put("menuAction", "Add"); data.put("selectedTemplateType", "default"); //defaults to regular class group page } @@ -563,5 +544,57 @@ private String getExistingCustomTemplateQuery() { return prefixes + "?page display:hasDataGetter " + dataGetterVar + "."; } + public void retrieveMenuPosition(EditConfigurationVTwo editConfig, VitroRequest vreq, Map formSpecificData) { + boolean returnHighestMenuPosition = false; + //if adding a new page or if editing an existing page which does not have an associated + //menu position + int availableMenuPosition = this.getAvailableMenuPosition(editConfig, vreq); + formSpecificData.put("highestMenuPosition", "" + availableMenuPosition); + } + + //Get the highest menu position and return that + 1 for the menu position that can be associated + //for a new menu item + public int getAvailableMenuPosition(EditConfigurationVTwo editConfig, VitroRequest vreq) { + //Execute sparql query to get highest menu position + int maxMenuPosition = getMaxMenuPosition(editConfig, vreq); + return maxMenuPosition + 1; + } + + + private int getMaxMenuPosition(EditConfigurationVTwo editConfig, VitroRequest vreq) { + int maxMenuPosition = 0; + Literal menuPosition = null; + setupModelSelectorsFromVitroRequest(vreq, editConfig); + OntModel queryModel = (OntModel)vreq.getAttribute("jenaOntModel"); + String maxMenuPositionQuery = getMaxMenuPositionQueryString(); + QueryExecution qe = null; + try{ + Query query = QueryFactory.create(maxMenuPositionQuery); + qe = QueryExecutionFactory.create(query, queryModel); + ResultSet results = qe.execSelect(); + while( results.hasNext()){ + QuerySolution qs = results.nextSolution(); + menuPosition = qs.getLiteral("menuPosition"); + } + + } catch(Exception ex) { + log.error("Error occurred in executing query " + maxMenuPositionQuery, ex); + } + + if(menuPosition != null) { + maxMenuPosition = menuPosition.getInt(); + } + return maxMenuPosition; + } + + + + private String getMaxMenuPositionQueryString() { + String query = getSparqlPrefix() + + "SELECT ?menuPosition WHERE {?pageUri display:menuPosition ?menuPosition . } " + + "ORDER BY DESC(?menuPosition) LIMIT 1"; + return query; + } + } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/edit/EditConfigurationTemplateModel.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/edit/EditConfigurationTemplateModel.java index f1a133757..ac49e8812 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/edit/EditConfigurationTemplateModel.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/edit/EditConfigurationTemplateModel.java @@ -33,6 +33,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditElementVTwo; +import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.ConstantFieldOptions; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.SelectListGeneratorVTwo; import edu.cornell.mannlib.vitro.webapp.web.beanswrappers.ReadOnlyBeansWrapper; @@ -95,12 +96,16 @@ public class EditConfigurationTemplateModel extends BaseTemplateModel { WebappDaoFactory wdf = vreq.getWebappDaoFactory(); for(String fieldName: editConfig.getFields().keySet()){ FieldVTwo field = editConfig.getField(fieldName); + //TODO: Check if we even need empty options if field options do not exist if( field.getFieldOptions() == null ){ - //putting empty map in here because FM can't deal - pageData.put(fieldName, Collections.EMPTY_MAP); + //empty options + field.setOptions(new ConstantFieldOptions()); } Map optionsMap = SelectListGeneratorVTwo.getOptions(editConfig, fieldName, wdf); optionsMap = SelectListGeneratorVTwo.getSortedMap(optionsMap); + if(pageData.containsKey(fieldName)) { + log.error("Check the edit configuration setup as pageData already contains " + fieldName + " and this will be overwritten now with empty collection"); + } pageData.put(fieldName, optionsMap); } } diff --git a/webapp/web/WEB-INF/ontologies/app/menu.n3 b/webapp/web/WEB-INF/ontologies/app/menu.n3 index a04b773a1..4f4542760 100644 --- a/webapp/web/WEB-INF/ontologies/app/menu.n3 +++ b/webapp/web/WEB-INF/ontologies/app/menu.n3 @@ -60,7 +60,7 @@ display:pageListData OPTIONAL {?listedPageUri display:requiresBodyTemplate ?listedPageTemplate .} OPTIONAL {?listedPageMenuItem display:toPage ?listedPageUri .} OPTIONAL {?listedPageUri display:cannotDeletePage ?listedPageCannotDeletePage .} - } """ . + } ORDER BY ?listedPageTitle """ . ###Page Management and Data Getters #Data getter type labels rdfs:label "Class Group Page" . diff --git a/webapp/web/WEB-INF/web.xml b/webapp/web/WEB-INF/web.xml index f1a2d2fc7..85e3375d0 100644 --- a/webapp/web/WEB-INF/web.xml +++ b/webapp/web/WEB-INF/web.xml @@ -359,6 +359,8 @@ /deletePropertyController + + PostEditCleanupController edu.cornell.mannlib.vitro.webapp.edit.n3editing.controller.PostEditCleanupController @@ -368,6 +370,15 @@ /postEditCleanupController + + DeletePageController + edu.cornell.mannlib.vitro.webapp.controller.edit.DeletePageController + + + DeletePageController + /deletePageController + + EditRequestDispatch edu.cornell.mannlib.vitro.webapp.edit.n3editing.controller.EditRequestDispatchController diff --git a/webapp/web/js/menupage/pageManagementUtils.js b/webapp/web/js/menupage/pageManagementUtils.js index bb3879737..462990a03 100644 --- a/webapp/web/js/menupage/pageManagementUtils.js +++ b/webapp/web/js/menupage/pageManagementUtils.js @@ -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 = ''; - 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; } }; diff --git a/webapp/web/js/menupage/processClassGroupDataGetterContent.js b/webapp/web/js/menupage/processClassGroupDataGetterContent.js index 1d2bde229..dfc26314e 100644 --- a/webapp/web/js/menupage/processClassGroupDataGetterContent.js +++ b/webapp/web/js/menupage/processClassGroupDataGetterContent.js @@ -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
"; + } 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
"; + } + } + return validationError; } diff --git a/webapp/web/js/menupage/processFixedHTMLDataGetterContent.js b/webapp/web/js/menupage/processFixedHTMLDataGetterContent.js index 6666d07c1..4cb3fbf41 100644 --- a/webapp/web/js/menupage/processFixedHTMLDataGetterContent.js +++ b/webapp/web/js/menupage/processFixedHTMLDataGetterContent.js @@ -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.
" + } + var htmlValue = pageContentSection.find("textarea[name='htmlValue']").val(); + if(htmlValue == "") { + validationError += pageContentSectionLabel + ": You must supply some HTML or text.
"; + } + return validationError; + } } \ No newline at end of file diff --git a/webapp/web/js/menupage/processIndividualsForClassesDataGetterContent.js b/webapp/web/js/menupage/processIndividualsForClassesDataGetterContent.js index 631af7da9..042e78dd6 100644 --- a/webapp/web/js/menupage/processIndividualsForClassesDataGetterContent.js +++ b/webapp/web/js/menupage/processIndividualsForClassesDataGetterContent.js @@ -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); + } } \ No newline at end of file diff --git a/webapp/web/js/menupage/processSparqlDataGetterContent.js b/webapp/web/js/menupage/processSparqlDataGetterContent.js index 851de0aa6..823dc4b36 100644 --- a/webapp/web/js/menupage/processSparqlDataGetterContent.js +++ b/webapp/web/js/menupage/processSparqlDataGetterContent.js @@ -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.
" + } + var queryValue = pageContentSection.find("textarea[name='query']").val(); + if(queryValue == "") { + validationError += pageContentSectionLabel + ": You must supply a Sparql query.
"; + } + return validationError; + } }; \ No newline at end of file diff --git a/webapp/web/js/pageDeletion.js b/webapp/web/js/pageDeletion.js new file mode 100644 index 000000000..feab7c3e4 --- /dev/null +++ b/webapp/web/js/pageDeletion.js @@ -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(); +}); + + diff --git a/webapp/web/templates/freemarker/body/pagemanagement/pageList.ftl b/webapp/web/templates/freemarker/body/pagemanagement/pageList.ftl index deb2557f8..652cd71e6 100644 --- a/webapp/web/templates/freemarker/body/pagemanagement/pageList.ftl +++ b/webapp/web/templates/freemarker/body/pagemanagement/pageList.ftl @@ -46,11 +46,10 @@ profile page    -<#-- <#if pagex.listedPageCannotDeletePage?? > - <#else> - delete + <#if !pagex.listedPageCannotDeletePage?has_content > + delete ---> + @@ -73,7 +72,13 @@ -${stylesheets.add('', +${stylesheets.add('', + '', '')} +${scripts.add('')} +${scripts.add('')} +${scripts.add('')} +${scripts.add('')} + diff --git a/webapp/web/templates/freemarker/edit/forms/pageManagement--browseClassGroups.ftl b/webapp/web/templates/freemarker/edit/forms/pageManagement--browseClassGroups.ftl index f2d2960df..22a14990e 100644 --- a/webapp/web/templates/freemarker/edit/forms/pageManagement--browseClassGroups.ftl +++ b/webapp/web/templates/freemarker/edit/forms/pageManagement--browseClassGroups.ftl @@ -2,9 +2,9 @@ <#--Browse Class Groups Section--> <#-----------Variable assignment--------------> <#--Requires Menu action be defined in parent template--> + <#assign classGroup = pageData.classGroup /> <#assign classGroups = pageData.classGroups /> -<#assign includeAllClasses = false/> <#-- some additional processing here which shows or hides the class group selection and classes based on initial action--> <#assign existingClassGroupStyle = " " /> <#assign selectClassGroupStyle = 'class="hidden"' /> @@ -25,7 +25,7 @@ diff --git a/webapp/web/templates/freemarker/edit/forms/pageManagement.ftl b/webapp/web/templates/freemarker/edit/forms/pageManagement.ftl index 93aa9422f..6ae961e71 100644 --- a/webapp/web/templates/freemarker/edit/forms/pageManagement.ftl +++ b/webapp/web/templates/freemarker/edit/forms/pageManagement.ftl @@ -8,11 +8,9 @@ <#assign pageName = "" /> <#assign selectedTemplateType = "default" /> <#assign prettyUrl = ""/> -<#assign associatedPage = ""/> -<#assign associatedPageURI = ""/> <#assign menuItem = ""/> <#assign menuLinkText = "" /> -<#assign menuPosition = "" /> +<#assign menuPosition = pageData.highestMenuPosition /> <#--Existing Values For Editing condition--> <#assign literalValues = editConfiguration.existingLiteralValues /> <#assign uriValues = editConfiguration.existingUriValues /> @@ -21,12 +19,15 @@ <#assign prettyUrl = lvf.getFormFieldValue(editSubmission, editConfiguration, "prettyUrl")/> <#assign menuItem = lvf.getFormFieldValue(editSubmission, editConfiguration, "menuItem")/> <#assign menuLinkText = lvf.getFormFieldValue(editSubmission, editConfiguration, "menuLinkText")/> - <#assign menuPosition = lvf.getFormFieldValue(editSubmission, editConfiguration, "menuPosition")/> <#assign customTemplate = lvf.getFormFieldValue(editSubmission, editConfiguration, "customTemplate")/> <#if customTemplate?has_content> <#assign selectedTemplateType = "custom" /> - + <#assign editMenuPosition = lvf.getFormFieldValue(editSubmission, editConfiguration, "menuPosition")/> + <#--if menu position exists for a menu item, then use that, otherwise use the highest available menu position number from page data--> + <#if editMenuPosition?has_content && editMenuPosition != ""> + <#assign menuPosition = editMenuPosition/> + <#------------HTML Portion-------------> @@ -97,7 +98,7 @@ - +

If left blank, the page title will be used.