Generate the type dropdown for Routine editor in PHP, not JavaScript.
This commit is contained in:
parent
889cce8583
commit
e2834cd49d
@ -285,31 +285,6 @@ $(document).ready(function() {
|
||||
// Cache the template for a parameter table row
|
||||
param_template = data.param_template;
|
||||
// Make adjustments in the dialog to make it AJAX compatible
|
||||
/**
|
||||
* @var is_procedure Used to make the PROCEDURE dropdown option selected
|
||||
* if a procedure is being edited or created.
|
||||
*/
|
||||
var is_procedure = '';
|
||||
/**
|
||||
* @var is_function Used to make the FUNCTION dropdown option selected
|
||||
* if a function is being edited or created.
|
||||
*/
|
||||
var is_function = '';
|
||||
if (data.type == 'PROCEDURE') {
|
||||
is_procedure = ' selected="selected"';
|
||||
} else if (data.type == 'FUNCTION') {
|
||||
is_function = ' selected="selected"';
|
||||
}
|
||||
/**
|
||||
* @var new_type_cell Contains HTML code that replaces the non-JS functionality
|
||||
* used to switch the routine editor from procedure to function
|
||||
* editing modes and back with a JS-aware dropdown.
|
||||
*/
|
||||
var new_type_cell = '<select name="routine_type">'
|
||||
+ '<option value="PROCEDURE"' + is_procedure + '>PROCEDURE</option>'
|
||||
+ '<option value="FUNCTION"' + is_function + '>FUNCTION</option>'
|
||||
+ '</select>';
|
||||
$('.routine_changetype_cell').html(new_type_cell);
|
||||
$('.routine_param_remove').show();
|
||||
$('input[name=routine_removeparameter]').remove();
|
||||
$('input[name=routine_addparameter]').css('width', '100%');
|
||||
|
||||
@ -623,12 +623,16 @@ function displayRoutineEditor($mode, $operation, $routine, $errors, $is_ajax) {
|
||||
. "<input name='routine_original_type' "
|
||||
. "type='hidden' value='{$routine['original_type']}'/>\n";
|
||||
}
|
||||
$isfunction_class = '';
|
||||
$isprocedure_class = '';
|
||||
$isfunction_class = '';
|
||||
$isprocedure_class = '';
|
||||
$isfunction_select = '';
|
||||
$isprocedure_select = '';
|
||||
if ($routine['type'] == 'PROCEDURE') {
|
||||
$isfunction_class = ' hide';
|
||||
$isfunction_class = ' hide';
|
||||
$isprocedure_select = " selected='selected'";
|
||||
} else {
|
||||
$isprocedure_class = ' hide';
|
||||
$isfunction_select = " selected='selected'";
|
||||
}
|
||||
|
||||
// Create the output
|
||||
@ -647,14 +651,20 @@ function displayRoutineEditor($mode, $operation, $routine, $errors, $is_ajax) {
|
||||
$retval .= "</tr>\n";
|
||||
$retval .= "<tr>\n";
|
||||
$retval .= " <td>" . __('Type') . "</td>\n";
|
||||
// TODO: generate ajax dropdown here, not by js
|
||||
$retval .= " <td class='routine_changetype_cell'>\n";
|
||||
$retval .= " <input name='routine_type' type='hidden' value='{$routine['type']}' />\n";
|
||||
$retval .= " <div style='width: 49%; float: left; text-align: center; font-weight: bold;'>\n";
|
||||
$retval .= " {$routine['type']}\n";
|
||||
$retval .= " </div>\n";
|
||||
$retval .= " <input style='width: 49%;' type='submit' name='routine_changetype'\n";
|
||||
$retval .= " value='".sprintf(__('Change to %s'), $routine['type_toggle'])."' />\n";
|
||||
$retval .= " <td>\n";
|
||||
if ($is_ajax) {
|
||||
$retval .= " <select name='routine_type'>\n";
|
||||
$retval .= " <option value='PROCEDURE'$isprocedure_select>PROCEDURE</option>\n";
|
||||
$retval .= " <option value='FUNCTION'$isfunction_select>FUNCTION</option>\n";
|
||||
$retval .= " </select>\n";
|
||||
} else {
|
||||
$retval .= " <input name='routine_type' type='hidden' value='{$routine['type']}' />\n";
|
||||
$retval .= " <div style='width: 49%; float: left; text-align: center; font-weight: bold;'>\n";
|
||||
$retval .= " {$routine['type']}\n";
|
||||
$retval .= " </div>\n";
|
||||
$retval .= " <input style='width: 49%;' type='submit' name='routine_changetype'\n";
|
||||
$retval .= " value='".sprintf(__('Change to %s'), $routine['type_toggle'])."' />\n";
|
||||
}
|
||||
$retval .= " </td>\n";
|
||||
$retval .= "</tr>\n";
|
||||
$retval .= "<tr>\n";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user