page management updates
This commit is contained in:
parent
297e943635
commit
4e96cd318d
16 changed files with 756 additions and 28 deletions
|
@ -2,20 +2,42 @@
|
|||
|
||||
var pageManagementUtils = {
|
||||
dataGetterLabelToURI:null,//initialized by custom data
|
||||
dataGetterURIToLabel:null, //initialized from custom data
|
||||
processDataGetterUtils:processDataGetterUtils,//an external class that should exist before this one
|
||||
dataGetterMap:null,
|
||||
menuAction:null,
|
||||
// on initial page setup
|
||||
onLoad:function(){
|
||||
if (this.disableFormInUnsupportedBrowsers()) {
|
||||
return;
|
||||
}
|
||||
this.mixIn();
|
||||
this.initDataGetterProcessors(),
|
||||
this.initReverseURIToLabel();
|
||||
this.initDataGetterProcessors();
|
||||
this.initObjects();
|
||||
this.bindEventListeners();
|
||||
this.initDisplay();
|
||||
|
||||
},
|
||||
//if edit, then generate existing content
|
||||
if(this.menuAction != null) {
|
||||
this.initExistingContent();
|
||||
}
|
||||
},
|
||||
initExistingContent:function() {
|
||||
this.generateExistingContentSections();
|
||||
},
|
||||
initReverseURIToLabel:function() {
|
||||
if(this.dataGetterLabelToURI != null) {
|
||||
this.dataGetterURIToLabel = {};
|
||||
for(var label in this.dataGetterLabelToURI) {
|
||||
if(label != undefined) {
|
||||
var uri = this.dataGetterLabelToURI[label];
|
||||
this.dataGetterURIToLabel[uri] = label;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//Error condition.
|
||||
}
|
||||
},
|
||||
initDataGetterProcessors:function() {
|
||||
//data getter processor map should come in from custom data
|
||||
//Go through each and initialize with their class
|
||||
|
@ -268,11 +290,25 @@ var pageManagementUtils = {
|
|||
$newContentObj.find('section#classesInSelectedGroup' + counter).removeClass('hidden');
|
||||
varOrClass = $newContentObj.find('select#selectClassGroup' + counter + ' option:selected').text();
|
||||
}
|
||||
|
||||
//For cases where varOrClass might be empty, pass an empty string
|
||||
if(varOrClass == null || varOrClass==undefined) {
|
||||
varOrClass = "";
|
||||
}
|
||||
pageManagementUtils.createClonedContentContainer($newContentObj, counter, contentTypeLabel, varOrClass);
|
||||
//previously increased by 10, just increasing by 1 here
|
||||
pageManagementUtils.counter++;
|
||||
},
|
||||
//For edit, need to have text passed in
|
||||
//Returns new content object itself
|
||||
cloneContentAreaForEdit: function(contentType, contentTypeLabel, labelText) {
|
||||
var counter = pageManagementUtils.counter;
|
||||
//Clone the object, renaming ids and copying text area values as well
|
||||
$newContentObj = pageManagementUtils.createCloneObject(contentType, counter);
|
||||
pageManagementUtils.createClonedContentContainer($newContentObj, counter, contentTypeLabel, labelText);
|
||||
//previously increased by 10, just increasing by 1 here
|
||||
pageManagementUtils.counter++;
|
||||
return $newContentObj;
|
||||
},
|
||||
createClonedContentContainer:function($newContentObj, counter, contentTypeLabel, varOrClass) {
|
||||
//Create the container for the new content
|
||||
$newDivContainer = $("<div></div>", {
|
||||
|
@ -530,6 +566,42 @@ var pageManagementUtils = {
|
|||
var newId = originalId + counter;
|
||||
$(this).attr("id", newId);
|
||||
});
|
||||
},
|
||||
//To actually generate the content for existing values
|
||||
generateExistingContentSections:function() {
|
||||
if(pageManagementUtils.menuAction == "Edit") {
|
||||
var $existingContent = $("#existingPageContentUnits");
|
||||
//create json object from string version json2.
|
||||
if($existingContent.length > 0) {
|
||||
var jsonObjectString = $existingContent.val();
|
||||
//this returns an array
|
||||
var JSONContentObjectArray = JSON.parse(jsonObjectString);
|
||||
var len = JSONContentObjectArray.length;
|
||||
var i;
|
||||
for(i = 0; i < len; i++) {
|
||||
//Get the type of data getter and create the appropriate section/populate
|
||||
var JSONContentObject = JSONContentObjectArray[i];
|
||||
var dataGetterClass = JSONContentObject["dataGetterClass"];
|
||||
if(dataGetterClass != null) {
|
||||
//Get the Label for the URI
|
||||
var contentType = pageManagementUtils.dataGetterURIToLabel[dataGetterClass];
|
||||
//Get the label for this content t
|
||||
var contentTypeLabel = "test label";
|
||||
//Get the processor class for this type
|
||||
var dataGetterProcessorObject = pageManagementUtils.processDataGetterUtils.dataGetterProcessorMap[contentType];
|
||||
var additionalLabelText = dataGetterProcessorObject.retrieveAdditionalLabelText(JSONContentObject);
|
||||
//Clone the appropriate section for the label
|
||||
var $newContentObj = pageManagementUtils.cloneContentAreaForEdit(contentType, contentTypeLabel, additionalLabelText);
|
||||
//Populate the section with the values
|
||||
dataGetterProcessorObject.populatePageContentSection(JSONContentObject, $newContentObj);
|
||||
} else {
|
||||
//error condition
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -14,6 +14,19 @@ var processFixedHTMLDataGetterContent = {
|
|||
//query model should also be an input
|
||||
var returnObject = {saveToVar:saveToVarValue, htmlValue:htmlValue, dataGetterClass:this.dataGetterClass};
|
||||
return returnObject;
|
||||
},
|
||||
//For an existing set of content where form is already set, fill in the values
|
||||
populatePageContentSection:function(existingContentObject, pageContentSection) {
|
||||
var saveToVarValue = existingContentObject["saveToVar"];
|
||||
var htmlValue = existingContentObject["htmlValue"];
|
||||
//Now find and set value
|
||||
pageContentSection.find("input[name='saveToVar']").val(saveToVarValue);
|
||||
pageContentSection.find("textarea[name='htmlValue']").val(htmlValue);
|
||||
},
|
||||
//For the label of the content section for editing, need to add additional value
|
||||
retrieveAdditionalLabelText:function(existingContentObject) {
|
||||
var saveToVarValue = existingContentObject["saveToVar"];
|
||||
return saveToVarValue;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -26,6 +26,9 @@
|
|||
<td>
|
||||
<#if pagex.pageUri?has_content>
|
||||
<a href="${urls.base}/individual?uri=${pagex.pageUri?url}&switchToDisplayModel=1">${(pagex.title)!'-untitled-'}</a>
|
||||
|
||||
<a href="${urls.base}/editRequestDispatch?subjectUri=${pagex.pageUri?url}&switchToDisplayModel=1&editForm=edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.ManagePageGenerator">Edit</a>
|
||||
|
||||
<#else>
|
||||
No URI defined for page.
|
||||
</#if>
|
||||
|
|
|
@ -5,6 +5,7 @@ scripts list.-->
|
|||
|
||||
<script type="text/javascript">
|
||||
var customFormData = {
|
||||
menuAction:"${menuAction}",
|
||||
dataGetterLabelToURI:{
|
||||
//maps labels to URIs
|
||||
"browseClassGroup": "java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.ClassGroupPageData",
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||
<#import "lib-vivo-form.ftl" as lvf>
|
||||
|
||||
<#--------Set up variables-------->
|
||||
<#assign pageData = editConfiguration.pageData />
|
||||
<#assign menuAction = pageData.menuAction />
|
||||
|
@ -9,6 +11,23 @@
|
|||
<#assign associatedPage = ""/>
|
||||
<#assign associatedPageURI = ""/>
|
||||
<#assign menuItem = ""/>
|
||||
<#assign menuLinkText = "" />
|
||||
<#assign menuPosition = "" />
|
||||
<#--Existing Values For Editing condition-->
|
||||
<#assign literalValues = editConfiguration.existingLiteralValues />
|
||||
<#assign uriValues = editConfiguration.existingUriValues />
|
||||
<#if menuAction == "Edit">
|
||||
<#assign pageName = lvf.getFormFieldValue(editSubmission, editConfiguration, "pageName")/>
|
||||
<#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" />
|
||||
</#if>
|
||||
|
||||
</#if>
|
||||
|
||||
<#------------HTML Portion------------->
|
||||
<section id="error-alert" role="alert" class="hidden">
|
||||
|
@ -63,13 +82,13 @@
|
|||
<input type="radio" name="selectedTemplate" class="custom-template" value="custom" <#if selectedTemplateType = "custom">checked</#if> role="input" />
|
||||
<label class="inline" for="custom"> Custom template</label>
|
||||
<section id="custom-template" <#if selectedTemplateType != 'custom'>class="hidden" </#if>role="region">
|
||||
<input type="text" name="customTemplate" value="${customTemplate!}" size="40" role="input" /><span class="requiredHint"> *</span>
|
||||
<input type="text" name="customTemplate" value="${customTemplate!''}" size="40" role="input" /><span class="requiredHint"> *</span>
|
||||
</section>
|
||||
<p style="margin-top:10px;margin-bottom:0px"><input id="menuCheckbox" type="checkbox" name="menuCheckbox"> This is a menu page</p>
|
||||
<section id="menu" role="region" style="margin-top:10px">
|
||||
<label for="default">Menu Item Name</label>
|
||||
<input type="text" id="menuLinkText" name="menuLinkText" value="" size="28" role="input" />
|
||||
<input type="text" id="menuPosition" name="menuPosition" value="6" />
|
||||
<input type="text" id="menuLinkText" name="menuLinkText" value="${menuLinkText!''}" size="28" role="input" />
|
||||
<input type="text" id="menuPosition" name="menuPosition" value="${menuPosition!''}" />
|
||||
<p class="note">If left blank, the page title will be used.</p>
|
||||
</section>
|
||||
<br />
|
||||
|
@ -84,10 +103,15 @@
|
|||
<!--Hidden input with JSON objects added will be included here. This is the field with the page content information
|
||||
mirroring what is required by the Data getter server side objects. -->
|
||||
<div id="pageContentSubmissionInputs" style="display:none"></div>
|
||||
<!--For existing content, will have div to save existing content-->
|
||||
<div id="existingPageContent" style="display:none">
|
||||
<#if pageData.existingPageContentUnits?has_content>
|
||||
<input type='hidden' id='existingPageContentUnits' value='${pageData.existingPageContentUnits}'/>
|
||||
</#if>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<!-
|
||||
|
||||
<!--Hardcoding for now but should be retrieved from generator: Custom data-->
|
||||
<#include "pageManagement--customDataScript.ftl">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue