diff options
-rw-r--r-- | js/functions.js | 15 | ||||
-rw-r--r-- | libraries/tbl_columns_definition_form.inc.php | 2 | ||||
-rw-r--r-- | tbl_create.php | 17 | ||||
-rw-r--r-- | templates/columns_definitions/column_definitions_form.phtml | 2 | ||||
-rw-r--r-- | templates/columns_definitions/partitions_form.phtml | 20 |
5 files changed, 33 insertions, 23 deletions
diff --git a/js/functions.js b/js/functions.js index 1a3304cdff..0ad32b0a90 100644 --- a/js/functions.js +++ b/js/functions.js @@ -2743,8 +2743,8 @@ AJAX.registerTeardown('functions.js', function () { $(document).off('click', "form.create_table_form.ajax input[name=submit_num_fields]"); $(document).off('keyup', "form.create_table_form.ajax input"); $(document).off('change', "form.create_table_form.ajax input[name=partition_count]," + - "form.create_table_form.ajax input[name=subpartition_count]"); - $(document).off('change', "form.create_table_form.ajax select[name=partition_by]"); + "form.create_table_form.ajax input[name=subpartition_count]," + + "form.create_table_form.ajax select[name=partition_by]"); $(document).off('change', "form.create_table_form.ajax select[name=subpartition_by]"); }); @@ -2915,18 +2915,11 @@ AJAX.registerOnload('functions.js', function () { * Attach event handler to manage changes in number of partitions and subpartitions */ $(document).on('change', "form.create_table_form.ajax input[name=partition_count]," + - "form.create_table_form.ajax input[name=subpartition_count]", function (event) { + "form.create_table_form.ajax input[name=subpartition_count]," + + "form.create_table_form.ajax select[name=partition_by]", function (event) { submitChangesInCreateTableForm('submit_partition_change=1'); }); - $(document).on('change', "form.create_table_form.ajax select[name=partition_by]", function (event) { - var value = $(this).val(); - $('input[name=partition_expr], input[name=partition_count]').prop('required', (value != '')); - - var listOrRange = value == 'LIST' || value == 'RANGE'; - $('.partition_value').val('').prop('disabled', ! listOrRange); - }); - $(document).on('change', "form.create_table_form.ajax select[name=subpartition_by]", function (event) { var value = $(this).val(); $('input[name=subpartition_expr], input[name=subpartition_count]').prop('required', (value != '')); diff --git a/libraries/tbl_columns_definition_form.inc.php b/libraries/tbl_columns_definition_form.inc.php index ec7d38eec7..fcd33d0987 100644 --- a/libraries/tbl_columns_definition_form.inc.php +++ b/libraries/tbl_columns_definition_form.inc.php @@ -409,7 +409,7 @@ $html = PMA\Template::get('columns_definitions/column_definitions_form')->render 'action' => $action, 'form_params' => $form_params, 'content_cells' => $content_cells, - 'partitions' => isset($partitions) ? $partitions : array() + 'partitionDetails' => isset($partitionDetails) ? $partitionDetails : array() ) ); diff --git a/tbl_create.php b/tbl_create.php index 7def879b07..6402736f82 100644 --- a/tbl_create.php +++ b/tbl_create.php @@ -100,6 +100,21 @@ if (isset($_REQUEST['do_save_data'])) { //This global variable needs to be reset for the headerclass to function properly $GLOBAL['table'] = ''; +$partitionDetails = array(); +$partitionParams = array( + 'partition_by', 'partition_expr', 'partition_count', + 'subpartition_by', 'subpartition_expr', 'subpartition_count' +); +foreach ($partitionParams as $partitionParam) { + $partitionDetails[$partitionParam] = isset($_REQUEST[$partitionParam]) + ? $_REQUEST[$partitionParam] : ''; +} + +$partitionDetails['can_have_subpartitions'] = isset($_REQUEST['partition_count']) + && $_REQUEST['partition_count'] > 1 + && isset($_REQUEST['partition_by']) + && ($_REQUEST['partition_by'] == 'RANGE' || $_REQUEST['partition_by'] == 'LIST'); + if (PMA_isValid($_REQUEST['partition_count'], 'numeric') && $_REQUEST['partition_count'] > 0 ) { @@ -131,6 +146,7 @@ if (PMA_isValid($_REQUEST['partition_count'], 'numeric') if (PMA_isValid($_REQUEST['subpartition_count'], 'numeric') && $_REQUEST['subpartition_count'] > 0 + && $partition['value_enabled'] == true ) { $partition['subpartition_count'] = $_REQUEST['subpartition_count']; @@ -164,6 +180,7 @@ if (PMA_isValid($_REQUEST['partition_count'], 'numeric') unset($partition['subpartition_count']); } } + $partitionDetails['partitions'] = $partitions; } /** diff --git a/templates/columns_definitions/column_definitions_form.phtml b/templates/columns_definitions/column_definitions_form.phtml index b325a5398a..8ee9365af7 100644 --- a/templates/columns_definitions/column_definitions_form.phtml +++ b/templates/columns_definitions/column_definitions_form.phtml @@ -142,7 +142,7 @@ <tr> <td colspan="5"> <?php echo PMA\Template::get('columns_definitions/partitions_form') - ->render(array('partitions' => $partitions)); ?> + ->render(array('partitionDetails' => $partitionDetails)); ?> </td> </tr> <?php endif; ?> diff --git a/templates/columns_definitions/partitions_form.phtml b/templates/columns_definitions/partitions_form.phtml index 07dc44e92d..cb8bfc1e9b 100644 --- a/templates/columns_definitions/partitions_form.phtml +++ b/templates/columns_definitions/partitions_form.phtml @@ -11,7 +11,7 @@ $valueTypeOptions = array('', 'LESS THAN', 'LESS THAN MAXVALUE', 'IN'); <select name="partition_by" id="partition_by"> <?php foreach ($partitionOptions as $option): ?> <option value="<?php echo $option?>" - <?php if (isset($_REQUEST['partition_by']) && $_REQUEST['partition_by'] == $option): ?> + <?php if ($partitionDetails['partition_by'] == $option): ?> selected="selected" <?php endif; ?> > @@ -23,24 +23,24 @@ $valueTypeOptions = array('', 'LESS THAN', 'LESS THAN MAXVALUE', 'IN'); <td>( <input name="partition_expr" type="text" placeholder="<?php echo __('Expression or column list'); ?>" - value="<?php echo (isset($_REQUEST['partition_expr']) ? htmlspecialchars($_REQUEST['partition_expr']) : ''); ?>"/> + value="<?php echo htmlspecialchars($partitionDetails['partition_expr']); ?>"/> )</td> </tr> <tr class="vmiddle"> <td><label for="partition_count"><?php echo __('Partitions:'); ?></label></td> <td> <input name="partition_count" type="number" min="2" - value="<?php echo (isset($_REQUEST['partition_count']) ? htmlspecialchars($_REQUEST['partition_count']) : ''); ?>" /> + value="<?php echo htmlspecialchars($partitionDetails['partition_count']); ?>" /> </td> </tr> - <?php if (isset($_REQUEST['partition_count']) && $_REQUEST['partition_count'] > 1): ?> + <?php if ($partitionDetails['can_have_subpartitions']): ?> <tr class="vmiddle"> <td><label for="subpartition_by"><?php echo __('Subpartition by:'); ?></label></td> <td> <select name="subpartition_by" id="subpartition_by"> <?php foreach ($subPartitionOptions as $option): ?> <option value="<?php echo $option?>" - <?php if (isset($_REQUEST['subpartition_by']) && $_REQUEST['subpartition_by'] == $option): ?> + <?php if ($partitionDetails['subpartition_by'] == $option): ?> selected="selected" <?php endif; ?> > @@ -52,25 +52,25 @@ $valueTypeOptions = array('', 'LESS THAN', 'LESS THAN MAXVALUE', 'IN'); <td>( <input name="subpartition_expr" type="text" placeholder="<?php echo __('Expression or column list'); ?>" - value="<?php echo (isset($_REQUEST['subpartition_expr']) ? htmlspecialchars($_REQUEST['subpartition_expr']) : ''); ?>"/> + value="<?php echo htmlspecialchars($partitionDetails['subpartition_expr']); ?>"/> )</td> </tr> <tr class="vmiddle"> <td><label for="subpartition_count"><?php echo __('Subpartitions:'); ?></label></td> <td> <input name="subpartition_count" type="number" min="2" - value="<?php echo (isset($_REQUEST['subpartition_count']) ? htmlspecialchars($_REQUEST['subpartition_count']) : ''); ?>" /> + value="<?php echo htmlspecialchars($partitionDetails['subpartition_count']); ?>" /> </td> </tr> <?php endif; ?> </table> -<?php if (isset($_REQUEST['partition_count']) && $_REQUEST['partition_count'] > 1): ?> +<?php if ($partitionDetails['partition_count'] > 1): ?> <table id="partition_definition_table"> <tr> <th><?php echo __('Partition'); ?></th> <th><?php echo __('Values'); ?></th> - <?php if (isset($_REQUEST['subpartition_count']) && $_REQUEST['subpartition_count'] > 1): ?> + <?php if ($partitionDetails['subpartition_count'] > 1): ?> <th><?php echo __('Subpartition'); ?></th> <?php endif; ?> <th><?php echo __('Engine'); ?></th> @@ -83,7 +83,7 @@ $valueTypeOptions = array('', 'LESS THAN', 'LESS THAN MAXVALUE', 'IN'); <th><?php echo __('Node group'); ?></th> </tr> <?php $odd = true; ?> - <?php foreach ($partitions as $partition): ?> + <?php foreach ($partitionDetails['partitions'] as $partition): ?> <?php $rowspan = isset($partition['subpartition_count']) ? ($partition['subpartition_count'] + 1) : 2; ?> <tr class="<?php echo ($odd ? 'odd' : 'even'); ?>"> <th rowspan="<?php echo $rowspan; ?>" class="vmiddle"> |