1 | <?xml version="1.0" encoding="ISO-8859-1"?> |
---|
2 | |
---|
3 | <xsl:stylesheet version="3.0" |
---|
4 | xmlns:xsl ="http://www.w3.org/1999/XSL/Transform" |
---|
5 | xmlns:ibis="http://www.ibisph.org" |
---|
6 | |
---|
7 | exclude-result-prefixes="ibis" |
---|
8 | > |
---|
9 | <xsl:import href="../Page.xslt"/> |
---|
10 | <xsl:import href="../../../Graphic.xslt"/> |
---|
11 | <xsl:import href="../../../../json/Dataset.xslt"/> |
---|
12 | <xsl:import href="../../../../json/Kendo.xslt"/> |
---|
13 | <xsl:import href="../../../../json/LeafletMap.xslt"/> |
---|
14 | <xsl:import href="SectionSelections.xslt"/> |
---|
15 | <xsl:import href="Builder.xslt"/> |
---|
16 | |
---|
17 | |
---|
18 | <ibis:doc> |
---|
19 | <name>html/query/module/builder/Page</name> |
---|
20 | <summary>Default core code that produces the query module builder pages</summary> |
---|
21 | <description> |
---|
22 | Creates the module query builder type HTML pages. The user |
---|
23 | steps through a series of questions and answers which are then submitted |
---|
24 | to the Query servlet which then builds a URL and accesses/calls the CGI |
---|
25 | app to query the SAS datasets. The pages built with this XSLT are highly |
---|
26 | dependent on the selection javascritps, the Query servlet controllers, |
---|
27 | and the IBIS-PH module XML data files which control the way the questions |
---|
28 | and answers are presented and which define all the name/value pairs passed |
---|
29 | to IBISQ CGI app (via the URL). |
---|
30 | |
---|
31 | NOTE: SECTION and DIMENSION exclusions are all handled by the |
---|
32 | ConfigurationIncludeCriteriaExclude XSLT templates. It also handles |
---|
33 | only including the selected CONFIGURATION. |
---|
34 | </description> |
---|
35 | </ibis:doc> |
---|
36 | |
---|
37 | |
---|
38 | <!-- ~~~~~~~~~~~~~~~~~~~~~~~ PARAMS / VARIABLES ~~~~~~~~~~~~~~~~~~~~~~~~ --> |
---|
39 | <xsl:param name="Page.pageTitle" ibis:doc="Page's title text which is based on the 'queryModule/TITLE' element."> |
---|
40 | <xsl:value-of select="/QUERY_MODULE/TITLE"/> - <xsl:value-of select="$Page.configuration/TITLE"/> Query Builder |
---|
41 | </xsl:param> |
---|
42 | <xsl:param name="Page.contentTitle" ibis:doc="Page's content title text which is based on the '$selections.queryModule/TITLE' element."> |
---|
43 | Query Builder for <xsl:value-of select="/QUERY_MODULE/TITLE"/> - <xsl:value-of select="$Page.configuration/TITLE"/> |
---|
44 | <!-- |
---|
45 | Query Builder for <xsl:value-of select="$Page.configuration/TITLE"/> |
---|
46 | Query Builder for <xsl:value-of select="concat($Page.configuration/TITLE, '-', /QUERY_MODULE/TITLE)"/> |
---|
47 | --> |
---|
48 | </xsl:param> |
---|
49 | <xsl:param name="Page.queryDefinitionFromBuilderPath" select="'query/definition/from/builder'"/> |
---|
50 | |
---|
51 | |
---|
52 | <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ TEMPLATES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --> |
---|
53 | <xsl:template name="Page.specificHeadContent" |
---|
54 | ibis:doc="HTML API implementation that provides hook for the |
---|
55 | query modules to be able to specify any extra CSS, meta tags, or |
---|
56 | javascript functions that need to be included specific to that |
---|
57 | module. The module element '/QUERY_MODULE/CRITERIA/OTHER_HTML_HEAD_CONTENT' |
---|
58 | contents are simply copied into the HTML 'head' element as is. |
---|
59 | This code also handles a special parameter called 'AutoSubmit' which |
---|
60 | can be used for testing." |
---|
61 | > |
---|
62 | <xsl:if test="exists(/QUERY_MODULE/CRITERIA/OTHER_HTML_HEAD_CONTENT)"> |
---|
63 | <xsl:apply-templates select="/QUERY_MODULE/CRITERIA/OTHER_HTML_HEAD_CONTENT/text() | /QUERY_MODULE/CRITERIA/OTHER_HTML_HEAD_CONTENT/*" mode="ibis.copy"/> |
---|
64 | </xsl:if> |
---|
65 | |
---|
66 | <meta http-equiv="Cache-Control" content="max-age=300"/> |
---|
67 | </xsl:template> |
---|
68 | |
---|
69 | |
---|
70 | |
---|
71 | <xsl:template name="Page.specificScript" |
---|
72 | ibis:doc="Provides the javascript file links and submit related functions |
---|
73 | for the query module builder pages." |
---|
74 | > |
---|
75 | <script type="text/javascript" src="{$ibis.contextPath}js/InputSelections.js"/> |
---|
76 | <script type="text/javascript"> |
---|
77 | var saveCriteriaURL = "<xsl:value-of select="concat($ibis.contextPath, $Page.queryDefinitionFromBuilderPath)"/>"; |
---|
78 | window.inputSelections = new InputSelections(); // all input elements on the page. |
---|
79 | |
---|
80 | // <![CDATA[ |
---|
81 | // init code - jquery way: $(document).ready(initializeQueryBuilderPage); |
---|
82 | $(document).ready(function() |
---|
83 | { |
---|
84 | if(location.href.indexOf("PrinterFriendly") == -1) |
---|
85 | { |
---|
86 | window.inputSelections.registerOnChange(); |
---|
87 | setupStepSelections(); |
---|
88 | } |
---|
89 | }); |
---|
90 | |
---|
91 | |
---|
92 | // set all 3 or 4 selection options onchange to this. Then simply |
---|
93 | // get the title values into the InputSelections CSV build and put |
---|
94 | // into the display steps SelectedValues element. |
---|
95 | function displayOptionsChangeHandler() |
---|
96 | { |
---|
97 | var categoryGroupByElement = document.getElementById("_CategoryGroupByDimensionName"); |
---|
98 | var selectedCategoryOptionElement = categoryGroupByElement.options[categoryGroupByElement.selectedIndex]; |
---|
99 | |
---|
100 | var seriesGroupByElement = document.getElementById("_SeriesGroupByDimensionName"); |
---|
101 | var selectedSeriesGroupBy = ((null != seriesGroupByElement) ? seriesGroupByElement.options[seriesGroupByElement.selectedIndex].value : ""); |
---|
102 | |
---|
103 | var otherGroupByElement = document.getElementById("_OtherGroupByDimensionName"); |
---|
104 | var selectedOtherGroupBy = ((null != otherGroupByElement) ? otherGroupByElement.options[otherGroupByElement.selectedIndex].value : ""); |
---|
105 | |
---|
106 | var chartNameElement = document.getElementById("chartName"); |
---|
107 | var selectedChart = ((null != chartNameElement) ? chartNameElement.options[chartNameElement.selectedIndex].text : ""); |
---|
108 | |
---|
109 | var mapNameElement = document.getElementById("mapName"); |
---|
110 | var selectedMap = ((null != mapNameElement) ? mapNameElement.options[mapNameElement.selectedIndex].text : ""); |
---|
111 | |
---|
112 | var showMapSelections = |
---|
113 | (" " >= selectedSeriesGroupBy) |
---|
114 | && |
---|
115 | (" " >= selectedOtherGroupBy) |
---|
116 | && |
---|
117 | (" " < selectedCategoryOptionElement.getAttribute("geographyflag")) |
---|
118 | ; |
---|
119 | if(null != mapNameElement) mapNameElement.disabled = !showMapSelections; |
---|
120 | |
---|
121 | var selectedValues = "Grouped By: " + selectedCategoryOptionElement.text; |
---|
122 | if(" " < selectedSeriesGroupBy) selectedValues = selectedValues + " x " + seriesGroupByElement.options[seriesGroupByElement.selectedIndex].text; |
---|
123 | if(" " < selectedOtherGroupBy) selectedValues = selectedValues + " x " + otherGroupByElement.options[otherGroupByElement.selectedIndex].text; |
---|
124 | |
---|
125 | if( " " < selectedChart) selectedValues = selectedValues + ". Chart: " + selectedChart; |
---|
126 | if((" " < selectedMap) && showMapSelections) selectedValues = selectedValues + ". Map: " + selectedMap; |
---|
127 | |
---|
128 | var selectedValuesElement = $("#displayControlSectionSelectedValues"); |
---|
129 | selectedValuesElement.html( "(" + selectedValues + ")" ); |
---|
130 | } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~ End of Function ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
131 | |
---|
132 | |
---|
133 | // function to check to see if cross1 and cross2 are set the same. If |
---|
134 | // so popup an alert notifying the user that they are both the same. |
---|
135 | function isGroupByDimensionsSame() |
---|
136 | { |
---|
137 | var categoryGroupByDimensionValue = $("#_CategoryGroupByDimensionName").val(); |
---|
138 | var seriesGroupByDimensionValue = $("#_SeriesGroupByDimensionName").val(); |
---|
139 | if((categoryGroupByDimensionValue != null) && (categoryGroupByDimensionValue == seriesGroupByDimensionValue)) |
---|
140 | { |
---|
141 | alert |
---|
142 | ( |
---|
143 | "--Duplicate Category/Series Grouping Selections Notice--\n" + |
---|
144 | "\nBoth the row and column grouping selections" + |
---|
145 | "\nare set to the same value. This will work but" + |
---|
146 | "\nprobably will not produce the desired results."+ |
---|
147 | "\nIt is recommended that you change one of the"+ |
---|
148 | "\nselections before submitting the query." |
---|
149 | ); |
---|
150 | return(true); |
---|
151 | } |
---|
152 | return(false); |
---|
153 | } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~ End of Function ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
154 | |
---|
155 | |
---|
156 | function setupStepSelections() |
---|
157 | { |
---|
158 | // fire the change event to show current selections. |
---|
159 | var section = $(".ExpandableContent"); |
---|
160 | for(i=0; i<section.length; i++) |
---|
161 | window.inputSelections.updateSectionSelectionsTitlesCSV(section[i]); |
---|
162 | displayOptionsChangeHandler(); |
---|
163 | } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~ End of Function ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
164 | |
---|
165 | |
---|
166 | function resetForm() |
---|
167 | { |
---|
168 | document.form.reset(); |
---|
169 | setupStepSelections(); |
---|
170 | } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~ End of Function ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
171 | |
---|
172 | |
---|
173 | // Main function that pressing the submit button executes. This |
---|
174 | // function's main purpose is to clear unselected values so that |
---|
175 | // they are NOT submitted to the server for inclusion in the |
---|
176 | // query. This can be handled on the backend but it would be |
---|
177 | // messy and error prone. |
---|
178 | function submitQuery() |
---|
179 | { |
---|
180 | if(isGroupByDimensionsSame()) return; // can't return null or false... |
---|
181 | window.inputSelections.clearAllNonSelectedSelections(); |
---|
182 | if(!window.inputSelections.validateAllTextInputs()) return; |
---|
183 | |
---|
184 | // submit the page's form contents... |
---|
185 | document.form.submit(); |
---|
186 | } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~ End of Function ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
187 | |
---|
188 | |
---|
189 | function saveCriteria() |
---|
190 | { |
---|
191 | window.inputSelections.clearAllNonSelectedSelections(); |
---|
192 | if(!window.inputSelections.validateAllTextInputs()) return; |
---|
193 | document.form.action = saveCriteriaURL; |
---|
194 | document.form.submit(); |
---|
195 | } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~ End of Function ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
196 | |
---|
197 | |
---|
198 | // according to: http://www.hunlock.com/blogs/Mastering_The_Back_Button_With_Javascript |
---|
199 | // having a window.onbeforeunload tells the browser to NOT cache the |
---|
200 | // page so that the back button doesn't impact cleared non selected |
---|
201 | // query selection values. On the modern browsers that were tested |
---|
202 | // this never was an issue as modern browsers pick up the "post" |
---|
203 | // and understand to reset the page as it was prior to submitting. |
---|
204 | window.onbeforeunload = function() {} |
---|
205 | |
---|
206 | // ]]> |
---|
207 | </script> |
---|
208 | </xsl:template> |
---|
209 | |
---|
210 | |
---|
211 | |
---|
212 | <!-- main page content template --> |
---|
213 | <xsl:template name="Page.contentBody" |
---|
214 | ibis:doc="Main page content template that creates the overview |
---|
215 | section, upper steps control bar, all the Q/A steps, the display |
---|
216 | step, and the submission control." |
---|
217 | > |
---|
218 | <xsl:param name="sections" select="/QUERY_MODULE/CRITERIA/SECTIONS"/> |
---|
219 | |
---|
220 | |
---|
221 | <div class="ContentOptions"> |
---|
222 | <h3><xsl:value-of select="'Query Builder Page Options'"/></h3> |
---|
223 | <button type="button" accesskey="S" id="submitButton" title="Submit the query and display the result page"> |
---|
224 | <xsl:attribute name="onclick" select=" |
---|
225 | if(exists($Page.configuration/CRITERIA/SUBMIT_JAVASCRIPT_FUNCTION_CALL)) |
---|
226 | then $Page.configuration/CRITERIA/SUBMIT_JAVASCRIPT_FUNCTION_CALL |
---|
227 | else 'submitQuery()' |
---|
228 | " |
---|
229 | /> |
---|
230 | Submit |
---|
231 | <xsl:call-template name="Help.content"> |
---|
232 | <xsl:with-param name="help"> |
---|
233 | <TEXT> |
---|
234 | This submits your query definition. Once submitted |
---|
235 | the data will be processed and the result page will |
---|
236 | be presented. From the result page you can return |
---|
237 | to this page and refineany data filtering criteria |
---|
238 | and data grouping selections. |
---|
239 | </TEXT> |
---|
240 | </xsl:with-param> |
---|
241 | </xsl:call-template> |
---|
242 | </button> |
---|
243 | |
---|
244 | <button type="button" accesskey="M" id="defaultQuery" title="Reloads the default query definition" |
---|
245 | onclick="location.href='{concat($ibis.contextPath, 'query/builder/', /QUERY_MODULE/REQUEST/CONFIGURATION_PATH, '.html?Reload=x')}'" |
---|
246 | > |
---|
247 | Load Default Query |
---|
248 | <xsl:call-template name="Help.content"> |
---|
249 | <xsl:with-param name="help"> |
---|
250 | <TEXT> |
---|
251 | Resets your query definition to the default selections |
---|
252 | and settings. This is different from the [Reset] button |
---|
253 | located at the bottom of the page. The [Reset] restores |
---|
254 | immediate page selections made. This option actually |
---|
255 | reloads the query definition to it's default state. |
---|
256 | </TEXT> |
---|
257 | </xsl:with-param> |
---|
258 | </xsl:call-template> |
---|
259 | </button> |
---|
260 | |
---|
261 | <button type="button" accesskey="M" id="selectQueryMeasure" title="Select a new query dataset measure" |
---|
262 | onclick="location.href='{concat($ibis.contextPath, /QUERY_MODULE/QUERY_CONFIGURATION_SELECTION/LOCAL_URL)}'" |
---|
263 | > |
---|
264 | Select Query Measure |
---|
265 | <xsl:call-template name="Help.content"> |
---|
266 | <xsl:with-param name="help"> |
---|
267 | <TEXT> |
---|
268 | Allows you to change the measure to be queried. |
---|
269 | </TEXT> |
---|
270 | </xsl:with-param> |
---|
271 | </xsl:call-template> |
---|
272 | </button> |
---|
273 | |
---|
274 | <button type="button" accesskey="D" id="saveDefinition" |
---|
275 | title="Click this button to save the selections as a saved criteria definition" |
---|
276 | onclick="saveCriteria()" |
---|
277 | > |
---|
278 | Save Query Definition |
---|
279 | <xsl:call-template name="Help.content"> |
---|
280 | <xsl:with-param name="help"> |
---|
281 | <TEXT> |
---|
282 | Allows you to save your current filtering criteria and |
---|
283 | display selections. These saved query definitions can |
---|
284 | then be ran later and can even be shared with others. |
---|
285 | </TEXT> |
---|
286 | </xsl:with-param> |
---|
287 | </xsl:call-template> |
---|
288 | </button> |
---|
289 | |
---|
290 | <button type="button" accesskey="L" id="loadDefinition" |
---|
291 | title="Click this button to access all query definitions" |
---|
292 | onclick="location.href='{concat($ibis.contextPath, 'query/definition/index/MyDefinitions.html')}'" |
---|
293 | > |
---|
294 | Load Query Definition |
---|
295 | <xsl:call-template name="Help.content"> |
---|
296 | <xsl:with-param name="help"> |
---|
297 | <TEXT> |
---|
298 | Takes you to a page that shows a list of all of your |
---|
299 | saved query defintions. You can then choose several |
---|
300 | options to run the definition, refine it, or delete it. |
---|
301 | |
---|
302 | NOTE: you will need to be logged in to be able to see |
---|
303 | your definitions. |
---|
304 | </TEXT> |
---|
305 | </xsl:with-param> |
---|
306 | </xsl:call-template> |
---|
307 | </button> |
---|
308 | </div> |
---|
309 | |
---|
310 | <!-- if dup names, then show an error and exit the page. note the next |
---|
311 | match enable the page to be displayed. Otherwise it simply blows... |
---|
312 | --> |
---|
313 | <xsl:if test="count($Page.configuration/NAME) > 1"> |
---|
314 | <div class="Error"> |
---|
315 | <h2>ERROR: Duplicate Module Configuration Names!!! Please |
---|
316 | contact the owners of this system and report this problem. |
---|
317 | <br/><br/> |
---|
318 | |
---|
319 | Duplicate Configuration Name: <xsl:value-of select="distinct-values($Page.configuration/NAME)"/> |
---|
320 | </h2> |
---|
321 | </div><br/> |
---|
322 | |
---|
323 | <xsl:next-match/> |
---|
324 | <xsl:message terminate="yes"> |
---|
325 | QUERY MODULE ERROR: Duplicate Module Configuration Names: <xsl:value-of select="concat(/QUERY_MODULE/NAME, '/', distinct-values($Page.configuration/NAME))"/> |
---|
326 | </xsl:message> |
---|
327 | </xsl:if> |
---|
328 | |
---|
329 | |
---|
330 | <!-- MAIN FORM that contains all user selectable input elements. --> |
---|
331 | <form id="form" name="form" method="post" action="{$Builder.postURL}"> |
---|
332 | |
---|
333 | <!-- Put in any dynamic IBISQ parameters. If a HIDDEN_INPUT_FLAG |
---|
334 | element exists then this parameter is put into the form as a |
---|
335 | hidden so that javascript can modify it's value before |
---|
336 | submitting to the servlet. |
---|
337 | --> |
---|
338 | <xsl:apply-templates mode="Builder.hiddenInput" select="/QUERY_MODULE//PARAMETERS/PARAMETER[exists(HIDDEN_INPUT_FLAG)]"/> |
---|
339 | |
---|
340 | <xsl:call-template name="ContentContainer.contentBlockWithDelimitedTitleTextsNodesets"> |
---|
341 | <xsl:with-param name="title" select="'Overview'"/> |
---|
342 | <xsl:with-param name="additionalClasses" select="'Overview'"/> |
---|
343 | <xsl:with-param name="contentBlockType" select="'expandable'"/> |
---|
344 | <xsl:with-param name="expandableContentShow" select="true()"/> |
---|
345 | <xsl:with-param name="addWikiAttribute" select="true()"/> |
---|
346 | <xsl:with-param name="titleAndTextsNodeset" select="/QUERY_MODULE/CRITERIA/OVERVIEWS/OVERVIEW"/> |
---|
347 | </xsl:call-template> |
---|
348 | |
---|
349 | <!-- do the step sections - questions and answers --> |
---|
350 | <xsl:for-each select="/QUERY_MODULE/CRITERIA/SECTIONS/SECTION"> |
---|
351 | <xsl:call-template name="SectionSelections.expandableContentSection"> |
---|
352 | <xsl:with-param name="section" select="."/> |
---|
353 | <xsl:with-param name="sectionNumber" select="position()"/> |
---|
354 | </xsl:call-template> |
---|
355 | </xsl:for-each> |
---|
356 | |
---|
357 | <!-- show the display options section next --> |
---|
358 | <xsl:call-template name="ContentContainer.expandable"> |
---|
359 | <xsl:with-param name="title" select="concat('Step ', count($sections/SECTION) + 1, ': How to display the data')"/> |
---|
360 | <xsl:with-param name="description" select="'Show/hide display options'"/> |
---|
361 | <xsl:with-param name="subTitleContent"> |
---|
362 | <span id="displayControlSectionSelectedValues" class="SelectedValues"/> |
---|
363 | </xsl:with-param> |
---|
364 | <xsl:with-param name="accesskey" select="'D'"/> |
---|
365 | <xsl:with-param name="content"> |
---|
366 | <xsl:call-template name="Builder.displayControl"/> |
---|
367 | </xsl:with-param> |
---|
368 | </xsl:call-template> |
---|
369 | |
---|
370 | <!-- finally the finish/submit section --> |
---|
371 | <div style="margin-top: 1rem;"> |
---|
372 | <xsl:call-template name="Builder.submitControl"/> |
---|
373 | </div> |
---|
374 | |
---|
375 | </form> |
---|
376 | |
---|
377 | <xsl:call-template name="Builder.initContent"/> |
---|
378 | </xsl:template> |
---|
379 | |
---|
380 | </xsl:stylesheet> |
---|
381 | <!-- ============================= End of File ============================= --> |
---|
382 | |
---|