diff options
author | Madhura Jayaratne <madhura.cj@gmail.com> | 2011-05-27 08:50:27 +0400 |
---|---|---|
committer | Madhura Jayaratne <madhura.cj@gmail.com> | 2011-05-25 22:22:28 +0400 |
commit | f08f9bce7e208361f67f6ef284d45bea0a4cad0b (patch) | |
tree | 3fa4f0bb508606f33382bba0fd73b2038bf9425a /js/indexes.js | |
parent | f2569ac9914b11d41a4b427272ef75e1c950929c (diff) |
On creation or alteration spatial indexes do not allow 1. Multiple columns 2. Specifying prefix
Diffstat (limited to 'js/indexes.js')
-rw-r--r-- | js/indexes.js | 95 |
1 files changed, 94 insertions, 1 deletions
diff --git a/js/indexes.js b/js/indexes.js index a15b249150..9b64d92048 100644 --- a/js/indexes.js +++ b/js/indexes.js @@ -41,5 +41,98 @@ function checkIndexName() return true; } // end of the 'checkIndexName()' function - onload = checkIndexName; + +/** + * Hides/shows the inputs and submits appropriately depending + * on whether the index type chosen is 'SPATIAL' or not. + */ +function checkIndexType() +{ + /** + * @var Object Dropdown to select the index type. + */ + $select_index_type = $('#select_index_type'); + /** + * @var Object Table header for the size column. + */ + $size_header = $('thead tr th:nth-child(2)'); + /** + * @var Object Inputs to specify the columns for the index. + */ + $column_inputs = $('select[name="index[columns][names][]"]'); + /** + * @var Object Inputs to specify sizes for columns of the index. + */ + $size_inputs = $('input[name="index[columns][sub_parts][]"]'); + /** + * @var Object Span containg the controllers to add more columns + */ + $add_more = $('#addMoreColumns'); + + if ($select_index_type.val() == 'SPATIAL') { + // Disable and hide the size column + $size_header.hide(); + $size_inputs.each(function(){ + $(this) + .attr('disabled', true) + .parent('td').hide(); + }); + + // Disable and hide the columns of the index other than the first one + var initial = true; + $column_inputs.each(function() { + $column_input = $(this); + if (! initial) { + $column_input + .attr('disabled', true) + .parent('td').hide(); + } else { + initial = false; + } + }); + + // Hide controllers to add more columns + $add_more.hide(); + } else { + // Enable and show the size column + $size_header.show(); + $size_inputs.each(function() { + $(this) + .attr('disabled', false) + .parent('td').show(); + }); + + // Enable and show the columns of the index + $column_inputs.each(function() { + $(this) + .attr('disabled', false) + .parent('td').show(); + }); + + // Show controllers to add more columns + $add_more.show(); + } +} + +/**#@+ + * @namespace jQuery + */ + +/** + * @description <p>Ajax scripts for table index page</p> + * + * Actions ajaxified here: + * <ul> + * <li>Showing/hiding inputs depending on the index type chosen</li> + * </ul> + * + * @name document.ready + * @memberOf jQuery + */ +$(document).ready(function() { + checkIndexType(); + $('#select_index_type').bind('change', checkIndexType); +}); + +/**#@- */ |