changeset 70:954d6200336d

display live reference from Drupal in edit form (ticket #71).
author casties
date Wed, 16 Dec 2015 20:53:12 +0100
parents 608f5303cb46
children 38dc1f0e2451
files src/main/webapp/imageServer/resources/js/diva4ismi.js src/main/webapp/resources/components/ismi/refWidget.xhtml src/main/webapp/search/displayAuthor.xhtml src/main/webapp/search/displayTitle.xhtml
diffstat 4 files changed, 114 insertions(+), 78 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/webapp/imageServer/resources/js/diva4ismi.js	Wed Dec 16 18:26:34 2015 +0100
+++ b/src/main/webapp/imageServer/resources/js/diva4ismi.js	Wed Dec 16 20:53:12 2015 +0100
@@ -108,31 +108,32 @@
 
 
 
-function showBibliographyEntryFormatted(bibId, bibInf, bibLoc){
-	// extract endnote id number, call formatbiblioNumeric
-	var numIdPat = /#(\d+)/;
-	var numIdRes = numIdPat.exec(bibId);
-	var id = numIdRes[1];
+function showBibliographyEntryFormatted(bibId, bibInf, bibLoc) {
+    // extract endnote id number, call formatbiblioNumeric
+    var numIdPat = /#(\d+)/;
+    var numIdRes = numIdPat.exec(bibId);
+    var id = numIdRes[1];
     var loc = bibLoc;
-    console.debug("setting up bib id="+id+" at loc="+loc);
-	$.ajax({
-		url: divaGlobal.drupal_url+"/formatbiblioNumeric/"+id,
-		type: 'GET',
-		success: function(data){ 
-		    console.debug("got bib id="+id+" for loc="+loc);
-			//inserting the template in this document
-    		//mache rel urls zu absoluten
-			if (data.nodes.length > 0) {
-				// FIXME: better handling of relative URLs 
-				var ref = data.nodes[0].node.citation.replace(new RegExp("/drupal-ismi","g"),divaGlobal.drupal_url);  	
-			    var bib =  $(loc);
-			   bib.html(ref);
-			}
-		},
-		error: function(data) {
-			console.error('unable to load formatted bib entry ' + id);
-		}
-	});	
+    console.debug("setting up bib id=" + id + " at loc=" + loc);
+    $.ajax({
+        url : divaGlobal.drupal_url + "/formatbiblioNumeric/" + id,
+        type : 'GET',
+        success : function(data) {
+            console.debug("got bib id=" + id + " for loc=" + loc);
+            // inserting the template in this document
+            // mache rel urls zu absoluten
+            if (data.nodes.length > 0) {
+                // FIXME: better handling of relative URLs
+                var ref = data.nodes[0].node.citation.replace(new RegExp(
+                        "/drupal-ismi", "g"), divaGlobal.drupal_url);
+                var bib = $(loc);
+                bib.html(ref);
+            }
+        },
+        error : function(data) {
+            console.error('unable to load formatted bib entry ' + id);
+        }
+    });
 }
 
 function loadWitnessInformation(json, titleId){
--- a/src/main/webapp/resources/components/ismi/refWidget.xhtml	Wed Dec 16 18:26:34 2015 +0100
+++ b/src/main/webapp/resources/components/ismi/refWidget.xhtml	Wed Dec 16 20:53:12 2015 +0100
@@ -13,6 +13,9 @@
 
 <composite:implementation>
 
+<!-- TODO: fix this! -->
+<script type="text/javascript" src="../imageServer/resources/js/diva4ismi.js"></script>
+
 	<h:panelGrid columns="3" styleClass="createPanel" columnClasses="createPanelFirstColumn" 
 		id="refArea">
 		
@@ -39,11 +42,19 @@
 
 					<rich:column>
 						<f:facet name="header">
-							<h:outputText value="EndNote Id" />
+							<h:outputText value="Reference Id" />
 						</f:facet>
 						<h:outputText value="#{item.obj.endNoteId}" />
 					</rich:column>
 
+                    <rich:column>
+                        <f:facet name="header">
+                            <h:outputText value="Reference display (Drupal)" />
+                        </f:facet>
+                        <script>showBibliographyEntryFormatted("#{item.obj.endNoteId}", null, "#bibl-entry-#{item.obj.ent.id}")</script>
+                        <span id="bibl-entry-#{item.obj.ent.id}">(loading reference...)</span>
+                    </rich:column>
+
 					<rich:column>
 						<f:facet name="header">
 							<h:outputText value="Additional Information" />
--- a/src/main/webapp/search/displayAuthor.xhtml	Wed Dec 16 18:26:34 2015 +0100
+++ b/src/main/webapp/search/displayAuthor.xhtml	Wed Dec 16 20:53:12 2015 +0100
@@ -7,11 +7,15 @@
 	xmlns:rich="http://richfaces.org/rich">
 
 <body>
+
 	<ui:composition template="/templates/publicTemplate.xhtml">
 
 		<ui:define name="publicContent">
 
 			<h:outputStylesheet name="/css/ismi-db/display.css" />
+<!-- TODO: fix this! -->
+<script type="text/javascript" src="../imageServer/resources/js/diva4ismi.js"></script>
+
 
 			<div id="pageTitle">
 				<h:outputText
@@ -108,20 +112,23 @@
 						rendered="#{!empty Session.displayAuthor.author.referenceList}" />
 					<rich:dataTable var="item" style="border:none;width: 700px;"
 						value="#{Session.displayAuthor.author.referenceList}"
-						rendered="#{!empty Session.displayAuthor.author.referenceList}">
+						rendered="#{!empty Session.displayAuthor.author.referenceList}"
+                        rowKeyVar="cnt">
+                        
 						<h:column>
 							<f:facet name="header">
-								<h:outputText value="endnote-id" />
+								<h:outputText value="Reference id" />
 							</f:facet>
 							<h:outputText value="#{item.endnoteId}" />
 						</h:column>
 
-						<h:column>
-							<f:facet name="header">
-								<h:outputText value="endnote-content" />
-							</f:facet>
-							<h:outputText value="#{item.endnoteContent}" />
-						</h:column>
+                        <h:column>
+                            <f:facet name="header">
+                                <h:outputText value="Reference display (Drupal)" />
+                            </f:facet>
+                            <script>showBibliographyEntryFormatted("#{item.endnoteId}", null, "#bibl-entry-person-#{cnt}")</script>
+                            <span id="bibl-entry-person-#{cnt}">(loading reference...)</span>
+                        </h:column>
 
 						<h:column>
 							<f:facet name="header">
@@ -241,25 +248,29 @@
 								value="#{Session.displayAuthor.title.tableOfContents}"
 								escape="false" />
 
-							<h:outputText value="Bibliographical References" />
-							<h:panelGrid columns="1">
+							<h:outputText value="Bibliographical References" 
+							    rendered="#{!empty Session.displayAuthor.title.referenceList}"/>
+							<h:panelGrid columns="1" 
+                                rendered="#{!empty Session.displayAuthor.title.referenceList}" >
 								<rich:dataTable var="item" style="border:none;width: 700px;"
 									value="#{Session.displayAuthor.title.referenceList}"
-									rendered="#{!empty Session.displayAuthor.title.referenceList}">
+									rendered="#{!empty Session.displayAuthor.title.referenceList}"
+                                    rowKeyVar="cnt">
 
 									<h:column>
 										<f:facet name="header">
-											<h:outputText value="endnote-id" />
+											<h:outputText value="Reference id" />
 										</f:facet>
 										<h:outputText value="#{item.endnoteId}" />
 									</h:column>
 
-									<h:column>
-										<f:facet name="header">
-											<h:outputText value="endnote-content" />
-										</f:facet>
-										<h:outputText value="#{item.endnoteContent}" />
-									</h:column>
+                                    <h:column>
+                                        <f:facet name="header">
+                                            <h:outputText value="Reference display (Drupal)" />
+                                        </f:facet>
+                                        <script>showBibliographyEntryFormatted("#{item.endnoteId}", null, "#bibl-entry-text-#{cnt}")</script>
+                                        <span id="bibl-entry-text-#{cnt}">(loading reference...)</span>
+                                    </h:column>
 
 									<h:column>
 										<f:facet name="header">
@@ -272,7 +283,7 @@
 
 						</h:panelGrid>
 
-						<!-- Titles -->
+						<!-- WITNESS -->
 						<h:panelGrid id="witnessesPanel">
 							<a name="witnesses" />
 							<h:outputText
@@ -350,7 +361,7 @@
 								<h:outputText value="Codex Identifier" />
 								<h:outputText value="#{Session.displayAuthor.witness.codex}" />
 
-								<h:outputText value="Codex Owned by" />
+								<h:outputText value="Witness Owned by" />
 								<h:panelGrid columns="1">
 									<h:dataTable var="item" style="border:none;"
 										value="#{Session.displayAuthor.witness.ownedByList}"
@@ -374,7 +385,7 @@
 								</h:panelGrid>
 
 
-								<h:outputText value="Codex Read by" />
+								<h:outputText value="Witness Read by" />
 								<h:panelGrid columns="1">
 									<h:dataTable var="item" style="border:none;"
 										value="#{Session.displayAuthor.witness.readByList}"
@@ -412,24 +423,28 @@
 									value="#{Session.displayAuthor.witness.tableOfContents}"
 									escape="false" />
 
-								<h:outputText value="Bibliographical References" />
-								<h:panelGrid columns="1">
+								<h:outputText value="Bibliographical References"
+								        rendered="#{!empty Session.displayAuthor.witness.referenceList}" />
+								<h:panelGrid columns="1"
+                                        rendered="#{!empty Session.displayAuthor.witness.referenceList}">
 									<rich:dataTable var="item" style="border:none;width: 700px;"
 										value="#{Session.displayAuthor.witness.referenceList}"
-										rendered="#{!empty Session.displayAuthor.title.referenceList}">
+										rendered="#{!empty Session.displayAuthor.witness.referenceList}"
+										rowKeyVar="cnt">
 
 										<h:column>
 											<f:facet name="header">
-												<h:outputText value="endnote-id" />
+												<h:outputText value="Reference id" />
 											</f:facet>
 											<h:outputText value="#{item.endnoteId}" />
 										</h:column>
 
 										<h:column>
 											<f:facet name="header">
-												<h:outputText value="endnote-content" />
+												<h:outputText value="Reference display (Drupal)" />
 											</f:facet>
-											<h:outputText value="#{item.endnoteContent}" />
+                                            <script>showBibliographyEntryFormatted("#{item.endnoteId}", null, "#bibl-entry-witness-#{cnt}")</script>
+                                            <span id="bibl-entry-witness-#{cnt}">(loading reference...)</span>
 										</h:column>
 
 										<h:column>
--- a/src/main/webapp/search/displayTitle.xhtml	Wed Dec 16 18:26:34 2015 +0100
+++ b/src/main/webapp/search/displayTitle.xhtml	Wed Dec 16 20:53:12 2015 +0100
@@ -13,6 +13,9 @@
 
 			<h:outputStylesheet name="/css/ismi-db/display.css" />
 
+<!-- TODO: fix this! -->
+<script type="text/javascript" src="../imageServer/resources/js/diva4ismi.js"></script>
+
 			<div id="pageTitle">
 				<h:outputText
 					value="Title [#{Session.displayTitle.selectedTitleId}]" />
@@ -109,25 +112,29 @@
 					<h:outputText value="#{Session.displayTitle.title.tableOfContents}"
 						escape="false" />
 
-					<h:outputText value="Bibliographical References" />
-					<h:panelGrid columns="1">
+					<h:outputText value="Bibliographical References"
+                            rendered="#{!empty Session.displayTitle.title.referenceList}" />
+					<h:panelGrid columns="1"
+                            rendered="#{!empty Session.displayTitle.title.referenceList}">
 						<rich:dataTable var="item" style="border:none;width: 700px;"
 							value="#{Session.displayTitle.title.referenceList}"
-							rendered="#{!empty Session.displayTitle.title.referenceList}">
+							rendered="#{!empty Session.displayTitle.title.referenceList}"
+                            rowKeyVar="cnt">
 
 							<h:column>
 								<f:facet name="header">
-									<h:outputText value="endnote-id" />
+									<h:outputText value="Reference id" />
 								</f:facet>
 								<h:outputText value="#{item.endnoteId}" />
 							</h:column>
 
-							<h:column>
-								<f:facet name="header">
-									<h:outputText value="endnote-content" />
-								</f:facet>
-								<h:outputText value="#{item.endnoteContent}" />
-							</h:column>
+                            <h:column>
+                                <f:facet name="header">
+                                    <h:outputText value="Reference display (Drupal)" />
+                                </f:facet>
+                                <script>showBibliographyEntryFormatted("#{item.endnoteId}", null, "#bibl-entry-title-#{cnt}")</script>
+                                <span id="bibl-entry-title-#{cnt}">(loading reference...)</span>
+                            </h:column>
 
 							<h:column>
 								<f:facet name="header">
@@ -216,7 +223,7 @@
 						<h:outputText value="Codex Identifier" />
 						<h:outputText value="#{Session.displayTitle.witness.codex}" />
 
-						<h:outputText value="Codex Owned by" />
+						<h:outputText value="Witness Owned by" />
 						<h:panelGrid columns="1">
 							<h:dataTable var="item" style="border:none;"
 								value="#{Session.displayTitle.witness.ownedByList}"
@@ -240,7 +247,7 @@
 						</h:panelGrid>
 
 
-						<h:outputText value="Codex Read by" />
+						<h:outputText value="Witness Read by" />
 						<h:panelGrid columns="1">
 							<h:dataTable var="item" style="border:none;"
 								value="#{Session.displayTitle.witness.readByList}"
@@ -274,21 +281,23 @@
 						<h:panelGrid columns="1">
 							<rich:dataTable var="item" style="border:none;width: 700px;"
 								value="#{Session.displayTitle.witness.referenceList}"
-								rendered="#{!empty Session.displayTitle.title.referenceList}">
+								rendered="#{!empty Session.displayTitle.witness.referenceList}"
+								rowKeyVar="cnt">
 
-								<h:column>
-									<f:facet name="header">
-										<h:outputText value="endnote-id" />
-									</f:facet>
-									<h:outputText value="#{item.endnoteId}" />
-								</h:column>
-
-								<h:column>
-									<f:facet name="header">
-										<h:outputText value="endnote-content" />
-									</f:facet>
-									<h:outputText value="#{item.endnoteContent}" />
-								</h:column>
+	                            <h:column>
+	                                <f:facet name="header">
+	                                    <h:outputText value="Reference id" />
+	                                </f:facet>
+	                                <h:outputText value="#{item.endnoteId}" />
+	                            </h:column>
+	
+	                            <h:column>
+	                                <f:facet name="header">
+	                                    <h:outputText value="Reference display (Drupal)" />
+	                                </f:facet>
+	                                <script>showBibliographyEntryFormatted("#{item.endnoteId}", null, "#bibl-entry-title-#{cnt}")</script>
+	                                <span id="bibl-entry-title-#{cnt}">(loading reference...)</span>
+	                            </h:column>
 
 								<h:column>
 									<f:facet name="header">