Holger Knublauch

Grid improvements

......@@ -1911,18 +1911,6 @@ app:ImageResourceViewer
]
] .
app:InstancesGrid
rdf:type ui:NodeClass ;
rdfs:comment "A grid displaying all instances of a class."^^xsd:string ;
rdfs:label "Instances grid"^^xsd:string ;
rdfs:subClassOf app:GridElements ;
spin:constraint
[ rdf:type spl:Argument ;
rdfs:comment "The class to display the instances of."^^xsd:string ;
spl:predicate arg:class ;
spl:valueType rdfs:Class
] .
app:Label
rdf:type ui:NodeClass ;
rdfs:label "Label"^^xsd:string ;
......@@ -3849,6 +3837,13 @@ app:SearchForm
] ;
spin:constraint
[ rdf:type spl:Argument ;
rdfs:comment "The onSelect handler of the generated SearchResultsGrid."^^xsd:string ;
spl:optional "true"^^xsd:boolean ;
spl:predicate arg:onSelect ;
spl:valueType xsd:string
] ;
spin:constraint
[ rdf:type spl:Argument ;
rdfs:comment "An optional graph that contains the schema (needed to determine whether an instance has a class that is the subclass of the resource type)."^^xsd:string ;
spl:optional "true"^^xsd:boolean ;
spl:predicate arg:queryGraph ;
......@@ -3883,7 +3878,7 @@ app:SearchForm
ui:child
[ rdf:type html:Form ;
html:class
[ rdf:type fn:concat ;
[ rdf:type ui:concat ;
sp:arg1 "appForm "^^xsd:string ;
sp:arg2 [ rdf:type sp:if ;
sp:arg1 [ rdf:type sp:or ;
......@@ -3922,7 +3917,7 @@ app:SearchForm
html:name "type"^^xsd:string ;
html:type "hidden"^^xsd:string ;
html:value
[ rdf:type fn:concat ;
[ rdf:type ui:concat ;
sp:arg1 "<"^^xsd:string ;
sp:arg2 [ sp:varName "resourceType"^^xsd:string
] ;
......@@ -3967,7 +3962,7 @@ app:SearchForm
ui:child
[ rdf:type html:Input ;
html:name
[ rdf:type fn:concat ;
[ rdf:type ui:concat ;
sp:arg1 "keyProperty"^^xsd:string ;
sp:arg2 [ sp:varName "index"^^xsd:string
]
......@@ -4024,7 +4019,7 @@ app:SearchForm
ui:child
[ rdf:type html:Input ;
html:onclick
[ rdf:type fn:concat ;
[ rdf:type ui:concat ;
sp:arg1 "appLoadSearchResultsGrid('"^^xsd:string ;
sp:arg2 [ sp:varName "fid"^^xsd:string
] ;
......@@ -4032,7 +4027,9 @@ app:SearchForm
sp:arg4 [ sp:varName "resultsId"^^xsd:string
] ;
sp:arg5 "', '"^^xsd:string ;
sp:arg6 [ rdf:type ui:currentQueryGraph
sp:arg6 [ rdf:type ui:escapeJSON ;
sp:arg1 [ sp:varName "onSelect"^^xsd:string
]
] ;
sp:arg7 "')"^^xsd:string
] ;
......@@ -4040,6 +4037,18 @@ app:SearchForm
html:value "Search"^^xsd:string ;
ui:childIndex 0
] ;
ui:child
[ rdf:type ui:TextNode ;
ui:childIndex 1 ;
ui:text """ 
"""^^xsd:string
] ;
ui:child
[ rdf:type html:Input ;
html:type "reset"^^xsd:string ;
html:value "Reset"^^xsd:string ;
ui:childIndex 2
] ;
ui:childIndex 6
] ;
ui:childIndex 0 ;
......@@ -4082,6 +4091,13 @@ app:SearchResultsGrid
rdfs:subClassOf app:GridElements ;
spin:constraint
[ rdf:type spl:Argument ;
rdfs:comment "JavaScript code that shall be executed if the user selects a row in the grid. In this JavaScript code, the variable resource contains the URI of the selected resource."^^xsd:string ;
spl:optional "true"^^xsd:boolean ;
spl:predicate arg:onSelect ;
spl:valueType xsd:string
] ;
spin:constraint
[ rdf:type spl:Argument ;
rdfs:comment "A URL-encoded string of the parameters produced by a SearchForm."^^xsd:string ;
spl:predicate arg:params ;
spl:valueType xsd:string
......
......@@ -123,11 +123,29 @@ function appInitDatePicker(id, altId) {
if(!altId) {
altId = 'new-' + id;
}
$('#dateEditor' + id).datepicker({
var eid = '#dateEditor' + id;
$(eid).datepicker({
altField: '#' + altId,
altFormat: 'yy-mm-dd',
dateFormat: 'yy-mm-dd',
});
// Work-around to bug: Make sure that hidden field is cleared if field is empty
$(eid).change(function() {
if('' == $(eid).val()) {
$('#' + altId).val('');
}
});
}
/**
* Replaces the content of a given jQuery element with a loading indicator
* (spinning wheel).
* @param e the jQuery element
*/
function appInsertLoadingIndicator(e) {
e.html('<div class="appLoadingIndicator" />');
}
......@@ -156,7 +174,7 @@ function appLoad(id, args) {
var p = jQuery.param(c);
url = p + "&" + base;
}
e.html('<div class="appLoadingIndicator" />');
appInsertLoadingIndicator(e);
e.load(uispinServlet, url);
}
......@@ -187,6 +205,7 @@ function appLoadForm(formId, mode, resourceURI, resourceTypeURI, queryGraphURI)
if(queryGraphURI) {
data._base = '<' + queryGraphURI + '>';
}
appInsertLoadingIndicator($('#' + formId).parent());
$.get(uispinServlet, data, function(data) {
$('#' + formId).parent().html(data);
});
......@@ -199,16 +218,35 @@ function appLoadForm(formId, mode, resourceURI, resourceTypeURI, queryGraphURI)
* a given id. Will replace the content of a given target element.
* @param formId the form id
* @param targetId the target id
* @returns false
* @param onSelect the value for onSelect of the generated grid
*/
function appLoadSearchResultsGrid(formId, targetId) {
function appLoadSearchResultsGrid(formId, targetId, onSelect) {
var params = $('#' + formId).serialize();
var escaped = '&params=' + escape(params);
if(onSelect) {
escaped += '&onSelect=' + escape(onSelect);
}
appInsertLoadingIndicator($('#' + targetId));
$.get(uispinServlet + '?_viewClass=app:SearchResultsGrid&_snippet=true&' +
params + escaped, function(data) {
$('#' + targetId).html(data);
});
return false;
}
/**
* Loads a given ui:loadable with a given variable pre-bound to
* a given URI resource.
* This can be used as onSelect handler of tree and grid elements,
* e.g. onSelect="appLoadWithResource('form', 'resource', resource)"
* @param loadId the id of the ui:loadable
* @param varName the name of the variable to set
* @param resourceURI the URI of the resource
*/
function appLoadWithResource(loadId, varName, resourceURI) {
var params = {};
params[varName] = '<' + resourceURI + '>';
appLoad(loadId, params);
}
......
......@@ -6,7 +6,7 @@
<div id="{= ?pagerId }" />
<script>
$("#{= ?tableId }").jqGrid({
<swon:NameValuePair arg:name="url" arg:value="{= fn:concat('getSearchResults?', ?params) }" />,
<swon:NameValuePair arg:name="url" arg:value="getSearchResults?{= ?params }" />,
<swon:NameValuePair arg:name="datatype" arg:value="json" />,
colNames:[
<ui:if ui:condition="{= bound(?keyProperties) }">
......@@ -48,11 +48,16 @@
}
</ui:else>
],
<ui:if ui:condition="{= bound(?onSelect) }">
onSelectRow: function(resource) {
{= ?onSelect }
},
</ui:if>
rowNum: 10,
rowList:[5,10,20],
pager: '#{= ?pagerId }',
viewrecords: true,
sortorder: "desc",
sortorder: "asc",
height: "100%",
width: "100%"
}).jqGrid('navGrid', '#{= ?pagerId }', { add:false, edit:false, del:false});
......
This diff is collapsed. Click to expand it.
......@@ -47,7 +47,7 @@ log:LogBrowser
[ rdf:type app:Tree ;
arg:dataProvider log:LogEventClassTreeDataProvider ;
arg:id "classTree"^^xsd:string ;
arg:onSelect "appLoad('form', {resourceType: '<' + resource + '>'})"^^xsd:string ;
arg:onSelect "appLoadWithResource('form', 'resourceType', resource)"^^xsd:string ;
ui:childIndex 1
] ;
ui:childIndex 0
......