3 DATASET CREATION PIPELINE FOR SEACH WIZARD:
4 When provided with the proper query params, the search wizard will walk the user through
5 creating a dataset with the required parameters, save the dataset, and return to the
9 dsp: dataset parameters
10 - a comma separated list of data set parameters for each column
11 - multiple types for a single column can be separated by a |
12 - multiple sets of parameters can be provided by including additional dsp query parameters
14 ?dsp=trials,accessions -- require trials as the first parameter and accessions as the second parameter
15 ?dsp=trials|traits,accessions -- require trials or traits as the first parameter and accessions as the second parameter
16 ?dsp=trials,accessions&dsp=accessions,trials -- require trials as the first and accessions as the second parameters
17 OR accessions as the first and trials as the second parameters
18 dsr: dataset return URL
19 Example: &dsr=/solgs/search
23 <div id="dsp-help-container">
24 <p id="dsp-help-instructions"></p>
25 <button id="dsp-help-next" class='btn btn-primary'><span id="dsp-help-next-label">Next</span> <span class="glyphicon glyphicon-chevron-right"></span></button>
26 <a id="dsp-help-cancel" href="#"><span class='glyphicon glyphicon-remove'></span></a>
30 <script type='text/javascript'>
32 let DSP_ENABLED = false; // Flag to enable the dataset creation pipeline
33 let DSP_COLS = []; // Allowed dataset column types
34 let DSP_RETURN; // Return URL for dataset creation
36 jQuery(document).ready(function() {
42 // Disable the columns (they are enabled as we proceed through the steps)
43 jQuery('.wizard-type-select').prop('disabled', true);
45 // Start the first step (setup the first column)
48 // Add event listener for the selected items lists
49 jQuery('.wizard-list-selected').on('DOMSubtreeModified', selectionListener)
51 // Add cancel button listener
52 jQuery('#dsp-help-cancel').click(disableDatasetPipeline);
56 jQuery('#site_login_dialog').modal("show");
64 * Parse the query parameters for the dataset pipeline arguments
65 * - Set DSP_ENABLED -- flag to indicate the dataset pipeline is enabled
66 * - Set DSP_COLS -- the allowed column type selections
68 function parseArgs() {
70 // Parse query params and get 'dsp' parameter(s)
71 let urlParams = new URLSearchParams(window.location.search);
72 if ( urlParams.has("dsp") ) {
75 // Parse each instance of the 'dsp' parameter
76 let dsp = urlParams.getAll("dsp");
77 for ( let i = 0; i < dsp.length; i++ ) {
79 // Parse each column of the 'dsp' parameter
80 let p = dsp[i].split(',');
82 for ( let j = 0; j < p.length; j++ ) {
83 let c = p[j].split('|');
85 for ( let k = 0; k < c.length; k++ ) {
86 ca.push(c[k].toLowerCase().replaceAll(" ", "_"));
91 // Add the allowed column selections
97 DSP_RETURN = urlParams.get("dsr");
104 * Setup the selections and instructions for selecting items from the specified column
105 * @param {int} col Column indx
107 function setCol(col) {
109 // Get selected data types of previous columns
110 let prev_sel_col_types = [];
111 for ( let i = 0; i < col; i++ ) {
112 let sel = jQuery(jQuery('.wizard-type-select option:selected')[i]);
113 prev_sel_col_types.push((sel.attr("data-type") ? sel.attr("data-type") : sel.html()).toLowerCase().replaceAll(" ", "_"));
116 // Get items from DSP_COLS that match selected data types in previous columns
117 let valid_dsp_cols = DSP_COLS;
118 for ( let i = 0; i < col; i++ ) {
120 let sel = prev_sel_col_types[i];
121 for ( let j = 0; j < DSP_COLS.length; j++ ) {
122 if ( DSP_COLS[j][i] ) {
123 if ( DSP_COLS[j][i].includes(sel) ) {
124 valid_dsp_cols.push(DSP_COLS[j]);
130 // Get valid data types for the current column, from the list of valid_dsp_cols
131 let valid_col_types = [];
132 for ( let i = 0; i < valid_dsp_cols.length; i++ ) {
133 if ( valid_dsp_cols[i][col] ) {
134 for ( let j = 0; j < valid_dsp_cols[i][col].length; j++ ) {
135 let t = valid_dsp_cols[i][col][j];
136 if ( !valid_col_types.includes(t) ) {
137 valid_col_types.push(t);
143 // Update column with valid column types
144 if ( valid_col_types && valid_col_types.length > 0 ) {
147 jQuery(jQuery('.wizard-type-select')[col]).prop('disabled', false);
149 // Disable invalid selection options for the current column
150 jQuery(jQuery('.wizard-type-select')[col]).find('option').each(function () {
151 let enabled = valid_col_types.includes(this.value) || valid_col_types.includes(jQuery(this).attr('data-type'));
152 jQuery(this).attr('disabled', !enabled);
156 jQuery('.wizard-panel').removeClass('wizard-panel-selected');
157 jQuery(jQuery('.wizard-panel')[col]).addClass('wizard-panel-selected');
159 // Update Instructions
161 let html = "<strong>Step " + step + ":</strong> Choose items of type <strong>" + valid_col_types.join(" or ") + "</strong> from column " + step + ".";
162 jQuery('#dsp-help-instructions').html(html);
163 jQuery('#dsp-help-next-label').html("Next");
164 jQuery("#dsp-help-next").prop('disabled', true);
165 jQuery('#dsp-help-next').css('display', 'block');
166 jQuery('#dsp-help-next').off('click').on('click', function() {
169 jQuery('#dsp-help').css('display', 'block');
170 jQuery('#dsp-help-container').css('display', 'flex');
174 // Move on to saving...
181 * Prompt the user to save a new dataset
183 function saveDataset(step) {
186 jQuery('.wizard-panel').removeClass('wizard-panel-selected');
187 jQuery('.wizard-datasets > .panel').addClass('wizard-panel-selected');
189 // Focus dataset name
190 jQuery('.wizard-dataset-name').focus();
192 // Update Instructions
193 let html = "<strong>Step " + step + ":</strong> Enter a name for your dataset and click the <strong>Create</strong> button.";
194 jQuery('#dsp-help-instructions').html(html);
195 jQuery('#dsp-help-next').css('display', 'none');
200 * Return to the source page when dataset is created
202 function returnToSource() {
205 jQuery('.wizard-datasets > .panel').removeClass('wizard-panel-selected');
207 // Update Instructions
208 let html = "<strong>Dataset Created:</strong> Return to the Analysis tool";
209 jQuery('#dsp-help-instructions').html(html);
213 jQuery('#dsp-help-next-label').html("Return");
214 jQuery('#dsp-help-next').off('click').on('click', function() {
215 window.location = DSP_RETURN;
218 jQuery('#dsp-help-next').css('display', 'block');
222 jQuery(window).scrollTop(0);
227 * Listener for the selected item lists
228 * - Enable the next button if there are selected items, disable if none
230 function selectionListener() {
231 let children = jQuery(this).children().length;
232 if ( children > 2 ) {
233 jQuery("#dsp-help-next").prop('disabled', false);
236 jQuery("#dsp-help-next").prop('disabled', true);
241 * Disable the dataset creation pipeline and restore the normal search wizard
243 function disableDatasetPipeline() {
244 var r = confirm("Are you sure you want to close the dataset creation help?");
247 jQuery("#dsp-help").css('display', 'none');
248 jQuery('.wizard-panel').removeClass('wizard-panel-selected');
249 jQuery('.wizard-datasets > .panel').removeClass('wizard-panel-selected');
250 jQuery('.wizard-type-select').prop('disabled', false);
251 jQuery('.wizard-type-select option').prop('disabled', false);
261 #dsp-help-container {
264 margin: 5px 0 15px 0;
267 background-color: #ffc107;
269 vertical-align: middle;
271 #dsp-help-instructions {
286 #dsp-help-cancel:hover {
290 .wizard-panel-selected {
291 border: 5px solid #ffc107;
294 .wizard-type-select option {
298 .wizard-type-select option:disabled {