Skip to content

Commit

Permalink
Merge pull request #18032 from MauricioFauth/fix-add-routine-param-bu…
Browse files Browse the repository at this point in the history
…tton

Fix broken button that adds routine params

- Fixes #17833
- Fixes #17929
- Fixes #17971
  • Loading branch information
MauricioFauth committed Jan 24, 2023
2 parents 725e067 + 5a267d0 commit 6c9f5d7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
6 changes: 2 additions & 4 deletions js/src/database/routines.js
Expand Up @@ -9,7 +9,7 @@ AJAX.registerTeardown('database/routines.js', function () {
$(document).off('change', 'select[name=item_type]');
$(document).off('change', 'select[name^=item_param_type]');
$(document).off('change', 'select[name=item_returntype]');
$(document).off('click', 'input[name=routine_addparameter]');
$(document).off('click', '#addRoutineParameterButton');
$(document).off('click', 'a.routine_param_remove_anchor');
});

Expand Down Expand Up @@ -526,8 +526,6 @@ const DatabaseRoutines = {
var that = this;
// Make adjustments in the dialog to make it AJAX compatible
$('td.routine_param_remove').show();
$('input[name=routine_removeparameter]').remove();
$('input[name=routine_addparameter]').css('width', '100%');
// Enable/disable the 'options' dropdowns for parameters as necessary
$('table.routine_params_table').last().find('th[colspan=2]').attr('colspan', '1');
$('table.routine_params_table').last().find('tr').has('td').each(function () {
Expand Down Expand Up @@ -923,7 +921,7 @@ AJAX.registerOnload('database/routines.js', function () {
);
});

$(document).on('click', 'input[name=routine_addparameter]', function (event) {
$(document).on('click', '#addRoutineParameterButton', function (event) {
event.preventDefault();
/**
* @var routine_params_table jQuery object containing the reference
Expand Down
10 changes: 7 additions & 3 deletions templates/database/routines/editor_form.twig
@@ -1,4 +1,4 @@
<form class="rte_form" action="{{ url('/database/routines') }}" method="post">
<form class="rte_form{{ not is_ajax ? ' disableAjax' }}" action="{{ url('/database/routines') }}" method="post">
<input name="{{ is_edit_mode ? 'edit_item' : 'add_item' }}" type="hidden" value="1">
{% if is_edit_mode %}
<input name="item_original_name" type="hidden" value="{{ routine.item_original_name }}">
Expand Down Expand Up @@ -63,8 +63,12 @@
<tr>
<td></td>
<td>
<input type="button" class="btn btn-primary" name="routine_addparameter" value="{% trans 'Add parameter' %}">
<input type="submit" class="btn btn-secondary" name="routine_removeparameter" value="{% trans 'Remove last parameter' %}"{{ not routine.item_num_params ? ' disabled' }}>
{% if is_ajax %}
<button type="button" class="btn btn-primary" id="addRoutineParameterButton">{% trans 'Add parameter' %}</button>
{% else %}
<input type="submit" class="btn btn-primary" name="routine_addparameter" value="{% trans 'Add parameter' %}">
<input type="submit" class="btn btn-secondary" name="routine_removeparameter" value="{% trans 'Remove last parameter' %}"{{ not routine.item_num_params ? ' disabled' }}>
{% endif %}
</td>
</tr>
<tr class="routine_return_row{{ routine.item_type == 'PROCEDURE' ? ' hide' }}">
Expand Down
6 changes: 1 addition & 5 deletions test/classes/Database/RoutinesTest.php
Expand Up @@ -760,11 +760,7 @@ public function providerGetEditorForm3(): array
],
[
$data,
'name="routine_addparameter"',
],
[
$data,
'name="routine_removeparameter"',
'id="addRoutineParameterButton"',
],
[
$data,
Expand Down

0 comments on commit 6c9f5d7

Please sign in to comment.