Project

General

Profile

« Previous | Next » 

Revision 4387

can now select and save metadata fields from a document and use them when merging across documents in the "cart"

View differences:

lib/style/skins/first/search.js
3 3
* @param form containing the neceassary input items
4 4
* @return true/false for form submission
5 5
*****************************************************************************/
6
function multipleAssessmentSearch(submitFormObj) {
6
function multipleAssessmentSearch(submitFormObj, fieldFormObj) {
7 7
	
8 8
	//alert("submitFormObj=" + submitFormObj);
9 9
	//harvest the metadata fields we want to include
10 10
	var metadataObjs = new Array();
11
	/*
12 11
	var index = 0;
13
	for (var i=0; i < submitFormObj.length; i++) {
14
		var formElement = submitFormObj.elements[i];
15
		if (formElement.type == "checkbox" && formElement.checked) {
16
			//ignore certain other checkboxes, kind of a hack 
17
			if (formElement.name == "includeQuestions") {
18
				continue;
19
			}
20
			var metadataObj = new Object();
21
			metadataObj.name = formElement.name;
22
			metadataObj.value = formElement.value;
23
			metadataObjs[index] = metadataObj;
24
			index++;
25
		}
12
	for (var i=0; i < fieldFormObj.length; i++) {
13
		var formElement = fieldFormObj.elements[i];
14
		var metadataObj = new Object();
15
		metadataObj.name = formElement.name;
16
		metadataObj.value = formElement.value;
17
		metadataObjs[index] = metadataObj;
18
		index++;
26 19
	}
27
	*/
28 20
	
29 21
	//TODO option for all questions vs. just one
30 22
	var questionId = submitFormObj.questionId.value;
......
134 126
}
135 127

  
136 128
/****************************************************************************
129
* Save fields for the attribute maping
130
* @param formId containing the neceassary input items
131
* @return true/false for form submission
132
*****************************************************************************/
133
function saveFields(formId, metacatURL) {
134

  
135
	var submitFormObj = document.getElementById(formId);
136
	
137
	//send the request to clear
138
	var myRequest = new Ajax.Request(
139
	metacatURL,
140
	{	method: 'post',
141
		parameters: { 
142
			action: 'editcart', 
143
			operation: 'clearfields'},
144
		evalScripts: true, 
145
		//onSuccess: function(transport) {alert('success: ' + transport.status);},
146
		onFailure: function(transport) {alert('failure clearing fields');}
147
	 });
148
	
149
	//go through the check boxes and set the ones we want
150
	var count = 0;
151
	for (var i=0; i < submitFormObj.length; i++) {
152
		var formElement = submitFormObj.elements[i];
153
		if (formElement.type == "checkbox" && formElement.checked) {
154
			//ignore certain other checkboxes, kind of a hack 
155
			if (formElement.name == "includeQuestions") {
156
				continue;
157
			}
158
			
159
			//send the request
160
			var myRequest = new Ajax.Request(
161
			metacatURL,
162
			{	method: 'post',
163
				parameters: { 
164
					action: 'editcart', 
165
					operation: 'addfield', 
166
					field: formElement.name, 
167
					path: formElement.value},
168
				evalScripts: true, 
169
				//onSuccess: function(transport) {alert('Selections saved: ' + operation); window.document.getElementById("iframeheaderclass").src=window.document.getElementById("iframeheaderclass").src;}, 
170
				onFailure: function(transport) {alert('failure saving field: ' + formElement.name);}
171
			 });
172
		 	count++;
173
		}
174
	}
175
	
176
	window.document.getElementById("iframeheaderclass").src = window.document.getElementById("iframeheaderclass").src;
177
	
178
	alert(count + ' Field selections saved.'); 
179
	
180
	return true;
181
		
182
}
183

  
184
/****************************************************************************
137 185
* Query Generation function
138 186
* @param docObjs is an Array of Objects with "docid" (String) and "questionIds" (Array) properties
139 187
* @param metadataObjs is an Array of Objects with "name" and "value" properties (both String)
lib/style/skins/first/header.jsp
28 28
<%@ include file="../../common/common-settings.jsp"%>
29 29
<%@ include file="../../common/configure-check.jsp"%>
30 30
<%@page import="edu.ucsb.nceas.metacat.service.SessionService"%>
31
<%@page import="java.util.Map"%>
31 32

  
33

  
32 34
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
35
<%@page import="java.util.Iterator"%>
33 36
<html>
34 37
<head>
35 38
<title>FIRST Data Repository</title>
......
38 41
</head>
39 42

  
40 43
<body>
41
<table width="760" border="0" cellspacing="0" cellpadding="0">
44
<table width="100%" border="0" cellspacing="0" cellpadding="0">
42 45
	<tr valign="top">
43
		<td>
46
		<td width="400">
44 47
			<img src="<%=STYLE_SKINS_URL%>/first/images/first2banner.jpg">	
45 48
		</td>
46 49
		<td>
47
			<table>
50
			<table width="100%">
48 51
				<tr>
49 52
					<th colspan="3" class="title">
50 53
						FIRST Data Repository
......
68 71
						<%
69 72
						String[] docids = 
70 73
							SessionService.getRegisteredSession(request.getSession().getId()).getDocumentCart().getDocids();
74
						Map fields = 
75
							SessionService.getRegisteredSession(request.getSession().getId()).getDocumentCart().getFields();
71 76
						%>
72 77
						<a href="cart.jsp" target="_top">
73
							Cart Items: 
78
							Cart 
74 79
						</a>	
75
							<%=docids.length %>	
80
							(Items: <%=docids.length %>, Fields: <%=fields.size() %>)
76 81
					</td>
77 82
				</tr>
83
				<tr>
84
					<td colspan="3">
85
						<!-- for use when downloading merged data -->
86
						<form id='fieldForm'>
87
						<%
88
						Iterator fieldIter =  fields.keySet().iterator();
89
						while (fieldIter.hasNext()) {
90
							String key = (String) fieldIter.next();
91
							String value = (String) fields.get(key);
92
						%>
93
							<input type="hidden" name="<%=key %>" value="<%=value %>" />
94
						<%	
95
						}
96
						%>	
97
						</form>
98
					</td>
99
				</tr>
78 100
			</table>
79 101
		</td>
80 102
	</tr>
lib/style/skins/first/cart.jsp
69 69
          insertSearchBox("<%=CONTEXT_URL%>");
70 70
      </script>
71 71

  
72
<table width="760" border="0" cellspacing="0" cellpadding="0">
72
<table width="100%" border="0" cellspacing="0" cellpadding="0">
73 73
	<tr>
74 74
		<th>
75 75
			Shopping Cart
......
85 85
					<input name="@packageId" value="<%=docids[i] %>" type="hidden"> 
86 86
				<%} %>	
87 87
			</form>
88
		</th>
89
	</tr>
90
	<tr>
91
		<td>
92
			Fields:
93
			<ul>
94
				<%
95
				String[] labels = 
96
					SessionService.getRegisteredSession(request.getSession().getId()).getDocumentCart().getLabels();
97
				for (int i = 0; i < labels.length; i++) {
98
				%>							
99
					<li><%=labels[i] %></li>
100
				<%} %>
101
			</ul>
88 102
		</td>
89 103
	</tr>
90 104
	<tr>
lib/style/skins/first/first-assessment-resultset.xsl
58 58
        </script>
59 59
        <script type="text/javascript" language="Javascript">
60 60
			<![CDATA[
61
			downloadMergedResponseData = function(formId) {
61
			downloadMergedResponseData = function(formId, fieldFormId) {
62 62
			
63 63
				if (!areItemsSelected('docid')) {
64 64
					alert("Please select at least one dataset");
......
73 73
				submitFormObj.qformat.value = 'csv';
74 74
				submitFormObj.action.value = 'dataquery';
75 75
				
76
				multipleAssessmentSearch(submitFormObj);
76
				//the form that holds the metadata field mappings - but in the header!
77
				var fieldFormObj = 
78
					window.document.getElementById("iframeheaderclass").contentDocument.getElementById(fieldFormId);
79
				//alert("fieldFormObj: " + fieldFormObj);
77 80
				
81
				multipleAssessmentSearch(submitFormObj, fieldFormObj);
82
				
78 83
				submitFormObj.submit();
79 84
			}
80 85
			editCart = function(formId, operation) {
......
154 159
			Download Selected as:
155 160
			<a>
156 161
				<xsl:attribute name="href">#</xsl:attribute>
157
				<xsl:attribute name="onClick">javascript:downloadMergedResponseData('assessmentForm')</xsl:attribute>
162
				<xsl:attribute name="onClick">javascript:downloadMergedResponseData('assessmentForm', 'fieldForm')</xsl:attribute>
158 163
				<xsl:text>Datafile (.csv)</xsl:text>
159 164
			</a>
160 165
			<br/>

Also available in: Unified diff