Holger Knublauch

Grid improvements

...@@ -1911,18 +1911,6 @@ app:ImageResourceViewer ...@@ -1911,18 +1911,6 @@ app:ImageResourceViewer
1911 ] 1911 ]
1912 ] . 1912 ] .
1913 1913
1914 -app:InstancesGrid
1915 - rdf:type ui:NodeClass ;
1916 - rdfs:comment "A grid displaying all instances of a class."^^xsd:string ;
1917 - rdfs:label "Instances grid"^^xsd:string ;
1918 - rdfs:subClassOf app:GridElements ;
1919 - spin:constraint
1920 - [ rdf:type spl:Argument ;
1921 - rdfs:comment "The class to display the instances of."^^xsd:string ;
1922 - spl:predicate arg:class ;
1923 - spl:valueType rdfs:Class
1924 - ] .
1925 -
1926 app:Label 1914 app:Label
1927 rdf:type ui:NodeClass ; 1915 rdf:type ui:NodeClass ;
1928 rdfs:label "Label"^^xsd:string ; 1916 rdfs:label "Label"^^xsd:string ;
...@@ -3849,6 +3837,13 @@ app:SearchForm ...@@ -3849,6 +3837,13 @@ app:SearchForm
3849 ] ; 3837 ] ;
3850 spin:constraint 3838 spin:constraint
3851 [ rdf:type spl:Argument ; 3839 [ rdf:type spl:Argument ;
3840 + rdfs:comment "The onSelect handler of the generated SearchResultsGrid."^^xsd:string ;
3841 + spl:optional "true"^^xsd:boolean ;
3842 + spl:predicate arg:onSelect ;
3843 + spl:valueType xsd:string
3844 + ] ;
3845 + spin:constraint
3846 + [ rdf:type spl:Argument ;
3852 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 ; 3847 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 ;
3853 spl:optional "true"^^xsd:boolean ; 3848 spl:optional "true"^^xsd:boolean ;
3854 spl:predicate arg:queryGraph ; 3849 spl:predicate arg:queryGraph ;
...@@ -3883,7 +3878,7 @@ app:SearchForm ...@@ -3883,7 +3878,7 @@ app:SearchForm
3883 ui:child 3878 ui:child
3884 [ rdf:type html:Form ; 3879 [ rdf:type html:Form ;
3885 html:class 3880 html:class
3886 - [ rdf:type fn:concat ; 3881 + [ rdf:type ui:concat ;
3887 sp:arg1 "appForm "^^xsd:string ; 3882 sp:arg1 "appForm "^^xsd:string ;
3888 sp:arg2 [ rdf:type sp:if ; 3883 sp:arg2 [ rdf:type sp:if ;
3889 sp:arg1 [ rdf:type sp:or ; 3884 sp:arg1 [ rdf:type sp:or ;
...@@ -3922,7 +3917,7 @@ app:SearchForm ...@@ -3922,7 +3917,7 @@ app:SearchForm
3922 html:name "type"^^xsd:string ; 3917 html:name "type"^^xsd:string ;
3923 html:type "hidden"^^xsd:string ; 3918 html:type "hidden"^^xsd:string ;
3924 html:value 3919 html:value
3925 - [ rdf:type fn:concat ; 3920 + [ rdf:type ui:concat ;
3926 sp:arg1 "<"^^xsd:string ; 3921 sp:arg1 "<"^^xsd:string ;
3927 sp:arg2 [ sp:varName "resourceType"^^xsd:string 3922 sp:arg2 [ sp:varName "resourceType"^^xsd:string
3928 ] ; 3923 ] ;
...@@ -3967,7 +3962,7 @@ app:SearchForm ...@@ -3967,7 +3962,7 @@ app:SearchForm
3967 ui:child 3962 ui:child
3968 [ rdf:type html:Input ; 3963 [ rdf:type html:Input ;
3969 html:name 3964 html:name
3970 - [ rdf:type fn:concat ; 3965 + [ rdf:type ui:concat ;
3971 sp:arg1 "keyProperty"^^xsd:string ; 3966 sp:arg1 "keyProperty"^^xsd:string ;
3972 sp:arg2 [ sp:varName "index"^^xsd:string 3967 sp:arg2 [ sp:varName "index"^^xsd:string
3973 ] 3968 ]
...@@ -4024,7 +4019,7 @@ app:SearchForm ...@@ -4024,7 +4019,7 @@ app:SearchForm
4024 ui:child 4019 ui:child
4025 [ rdf:type html:Input ; 4020 [ rdf:type html:Input ;
4026 html:onclick 4021 html:onclick
4027 - [ rdf:type fn:concat ; 4022 + [ rdf:type ui:concat ;
4028 sp:arg1 "appLoadSearchResultsGrid('"^^xsd:string ; 4023 sp:arg1 "appLoadSearchResultsGrid('"^^xsd:string ;
4029 sp:arg2 [ sp:varName "fid"^^xsd:string 4024 sp:arg2 [ sp:varName "fid"^^xsd:string
4030 ] ; 4025 ] ;
...@@ -4032,7 +4027,9 @@ app:SearchForm ...@@ -4032,7 +4027,9 @@ app:SearchForm
4032 sp:arg4 [ sp:varName "resultsId"^^xsd:string 4027 sp:arg4 [ sp:varName "resultsId"^^xsd:string
4033 ] ; 4028 ] ;
4034 sp:arg5 "', '"^^xsd:string ; 4029 sp:arg5 "', '"^^xsd:string ;
4035 - sp:arg6 [ rdf:type ui:currentQueryGraph 4030 + sp:arg6 [ rdf:type ui:escapeJSON ;
4031 + sp:arg1 [ sp:varName "onSelect"^^xsd:string
4032 + ]
4036 ] ; 4033 ] ;
4037 sp:arg7 "')"^^xsd:string 4034 sp:arg7 "')"^^xsd:string
4038 ] ; 4035 ] ;
...@@ -4040,6 +4037,18 @@ app:SearchForm ...@@ -4040,6 +4037,18 @@ app:SearchForm
4040 html:value "Search"^^xsd:string ; 4037 html:value "Search"^^xsd:string ;
4041 ui:childIndex 0 4038 ui:childIndex 0
4042 ] ; 4039 ] ;
4040 + ui:child
4041 + [ rdf:type ui:TextNode ;
4042 + ui:childIndex 1 ;
4043 + ui:text """ 
4044 +"""^^xsd:string
4045 + ] ;
4046 + ui:child
4047 + [ rdf:type html:Input ;
4048 + html:type "reset"^^xsd:string ;
4049 + html:value "Reset"^^xsd:string ;
4050 + ui:childIndex 2
4051 + ] ;
4043 ui:childIndex 6 4052 ui:childIndex 6
4044 ] ; 4053 ] ;
4045 ui:childIndex 0 ; 4054 ui:childIndex 0 ;
...@@ -4082,6 +4091,13 @@ app:SearchResultsGrid ...@@ -4082,6 +4091,13 @@ app:SearchResultsGrid
4082 rdfs:subClassOf app:GridElements ; 4091 rdfs:subClassOf app:GridElements ;
4083 spin:constraint 4092 spin:constraint
4084 [ rdf:type spl:Argument ; 4093 [ rdf:type spl:Argument ;
4094 + 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 ;
4095 + spl:optional "true"^^xsd:boolean ;
4096 + spl:predicate arg:onSelect ;
4097 + spl:valueType xsd:string
4098 + ] ;
4099 + spin:constraint
4100 + [ rdf:type spl:Argument ;
4085 rdfs:comment "A URL-encoded string of the parameters produced by a SearchForm."^^xsd:string ; 4101 rdfs:comment "A URL-encoded string of the parameters produced by a SearchForm."^^xsd:string ;
4086 spl:predicate arg:params ; 4102 spl:predicate arg:params ;
4087 spl:valueType xsd:string 4103 spl:valueType xsd:string
......
...@@ -123,11 +123,29 @@ function appInitDatePicker(id, altId) { ...@@ -123,11 +123,29 @@ function appInitDatePicker(id, altId) {
123 if(!altId) { 123 if(!altId) {
124 altId = 'new-' + id; 124 altId = 'new-' + id;
125 } 125 }
126 - $('#dateEditor' + id).datepicker({ 126 + var eid = '#dateEditor' + id;
127 + $(eid).datepicker({
127 altField: '#' + altId, 128 altField: '#' + altId,
128 altFormat: 'yy-mm-dd', 129 altFormat: 'yy-mm-dd',
129 dateFormat: 'yy-mm-dd', 130 dateFormat: 'yy-mm-dd',
130 }); 131 });
132 +
133 + // Work-around to bug: Make sure that hidden field is cleared if field is empty
134 + $(eid).change(function() {
135 + if('' == $(eid).val()) {
136 + $('#' + altId).val('');
137 + }
138 + });
139 +}
140 +
141 +
142 +/**
143 + * Replaces the content of a given jQuery element with a loading indicator
144 + * (spinning wheel).
145 + * @param e the jQuery element
146 + */
147 +function appInsertLoadingIndicator(e) {
148 + e.html('<div class="appLoadingIndicator" />');
131 } 149 }
132 150
133 151
...@@ -156,7 +174,7 @@ function appLoad(id, args) { ...@@ -156,7 +174,7 @@ function appLoad(id, args) {
156 var p = jQuery.param(c); 174 var p = jQuery.param(c);
157 url = p + "&" + base; 175 url = p + "&" + base;
158 } 176 }
159 - e.html('<div class="appLoadingIndicator" />'); 177 + appInsertLoadingIndicator(e);
160 e.load(uispinServlet, url); 178 e.load(uispinServlet, url);
161 } 179 }
162 180
...@@ -187,6 +205,7 @@ function appLoadForm(formId, mode, resourceURI, resourceTypeURI, queryGraphURI) ...@@ -187,6 +205,7 @@ function appLoadForm(formId, mode, resourceURI, resourceTypeURI, queryGraphURI)
187 if(queryGraphURI) { 205 if(queryGraphURI) {
188 data._base = '<' + queryGraphURI + '>'; 206 data._base = '<' + queryGraphURI + '>';
189 } 207 }
208 + appInsertLoadingIndicator($('#' + formId).parent());
190 $.get(uispinServlet, data, function(data) { 209 $.get(uispinServlet, data, function(data) {
191 $('#' + formId).parent().html(data); 210 $('#' + formId).parent().html(data);
192 }); 211 });
...@@ -199,16 +218,35 @@ function appLoadForm(formId, mode, resourceURI, resourceTypeURI, queryGraphURI) ...@@ -199,16 +218,35 @@ function appLoadForm(formId, mode, resourceURI, resourceTypeURI, queryGraphURI)
199 * a given id. Will replace the content of a given target element. 218 * a given id. Will replace the content of a given target element.
200 * @param formId the form id 219 * @param formId the form id
201 * @param targetId the target id 220 * @param targetId the target id
202 - * @returns false 221 + * @param onSelect the value for onSelect of the generated grid
203 */ 222 */
204 -function appLoadSearchResultsGrid(formId, targetId) { 223 +function appLoadSearchResultsGrid(formId, targetId, onSelect) {
205 var params = $('#' + formId).serialize(); 224 var params = $('#' + formId).serialize();
206 var escaped = '&params=' + escape(params); 225 var escaped = '&params=' + escape(params);
226 + if(onSelect) {
227 + escaped += '&onSelect=' + escape(onSelect);
228 + }
229 + appInsertLoadingIndicator($('#' + targetId));
207 $.get(uispinServlet + '?_viewClass=app:SearchResultsGrid&_snippet=true&' + 230 $.get(uispinServlet + '?_viewClass=app:SearchResultsGrid&_snippet=true&' +
208 params + escaped, function(data) { 231 params + escaped, function(data) {
209 $('#' + targetId).html(data); 232 $('#' + targetId).html(data);
210 }); 233 });
211 - return false; 234 +}
235 +
236 +
237 +/**
238 + * Loads a given ui:loadable with a given variable pre-bound to
239 + * a given URI resource.
240 + * This can be used as onSelect handler of tree and grid elements,
241 + * e.g. onSelect="appLoadWithResource('form', 'resource', resource)"
242 + * @param loadId the id of the ui:loadable
243 + * @param varName the name of the variable to set
244 + * @param resourceURI the URI of the resource
245 + */
246 +function appLoadWithResource(loadId, varName, resourceURI) {
247 + var params = {};
248 + params[varName] = '<' + resourceURI + '>';
249 + appLoad(loadId, params);
212 } 250 }
213 251
214 252
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
6 <div id="{= ?pagerId }" /> 6 <div id="{= ?pagerId }" />
7 <script> 7 <script>
8 $("#{= ?tableId }").jqGrid({ 8 $("#{= ?tableId }").jqGrid({
9 - <swon:NameValuePair arg:name="url" arg:value="{= fn:concat('getSearchResults?', ?params) }" />, 9 + <swon:NameValuePair arg:name="url" arg:value="getSearchResults?{= ?params }" />,
10 <swon:NameValuePair arg:name="datatype" arg:value="json" />, 10 <swon:NameValuePair arg:name="datatype" arg:value="json" />,
11 colNames:[ 11 colNames:[
12 <ui:if ui:condition="{= bound(?keyProperties) }"> 12 <ui:if ui:condition="{= bound(?keyProperties) }">
...@@ -48,11 +48,16 @@ ...@@ -48,11 +48,16 @@
48 } 48 }
49 </ui:else> 49 </ui:else>
50 ], 50 ],
51 + <ui:if ui:condition="{= bound(?onSelect) }">
52 + onSelectRow: function(resource) {
53 + {= ?onSelect }
54 + },
55 + </ui:if>
51 rowNum: 10, 56 rowNum: 10,
52 rowList:[5,10,20], 57 rowList:[5,10,20],
53 pager: '#{= ?pagerId }', 58 pager: '#{= ?pagerId }',
54 viewrecords: true, 59 viewrecords: true,
55 - sortorder: "desc", 60 + sortorder: "asc",
56 height: "100%", 61 height: "100%",
57 width: "100%" 62 width: "100%"
58 }).jqGrid('navGrid', '#{= ?pagerId }', { add:false, edit:false, del:false}); 63 }).jqGrid('navGrid', '#{= ?pagerId }', { add:false, edit:false, del:false});
......
This diff is collapsed. Click to expand it.
...@@ -47,7 +47,7 @@ log:LogBrowser ...@@ -47,7 +47,7 @@ log:LogBrowser
47 [ rdf:type app:Tree ; 47 [ rdf:type app:Tree ;
48 arg:dataProvider log:LogEventClassTreeDataProvider ; 48 arg:dataProvider log:LogEventClassTreeDataProvider ;
49 arg:id "classTree"^^xsd:string ; 49 arg:id "classTree"^^xsd:string ;
50 - arg:onSelect "appLoad('form', {resourceType: '<' + resource + '>'})"^^xsd:string ; 50 + arg:onSelect "appLoadWithResource('form', 'resourceType', resource)"^^xsd:string ;
51 ui:childIndex 1 51 ui:childIndex 1
52 ] ; 52 ] ;
53 ui:childIndex 0 53 ui:childIndex 0
......