Skip to content

Commit 5200725

Browse files
fix: removed inline onclick javascript events (#18687)
* fix: Removed inline onclick javascript events Signed-off-by: Dipesh Gangwani <dagangwani101@gmail.com> * fix: solved syntax errors Signed-off-by: Dipesh Gangwani <dagangwani101@gmail.com> * fix: Update tests for Normalization onclick event issues Signed-off-by: Dipesh Gangwani <dagangwani101@gmail.com> --------- Signed-off-by: Dipesh Gangwani <dagangwani101@gmail.com>
1 parent 1179692 commit 5200725

4 files changed

Lines changed: 17 additions & 5 deletions

File tree

js/src/normalization.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,8 @@ AJAX.registerTeardown('normalization.js', function () {
536536
$('#mainContent').off('click', '#backEditPd');
537537
$('#mainContent').off('click', '#showPossiblePd');
538538
$('#mainContent').off('click', '.pickPd');
539+
$('#extra').off('click', '#noRepeatingGroup');
540+
$('#extra').off('click', '#noRedundantColumn');
539541
});
540542

541543
AJAX.registerOnload('normalization.js', function () {
@@ -847,4 +849,14 @@ AJAX.registerOnload('normalization.js', function () {
847849
}
848850
}
849851
});
852+
853+
$('#extra').on('click', '#noRepeatingGroup', function (evt) {
854+
evt.preventDefault();
855+
goToStep4();
856+
});
857+
858+
$('#extra').on('click', '#noRedundantColumn', function (evt) {
859+
evt.preventDefault();
860+
goToFinish1NF();
861+
});
850862
});

src/Normalization.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,8 @@ public function getHtmlContentsFor1NFStep4(string $db, string $table): array
302302
$extra = $this->getHtmlForColumnsList($db, $table, 'all', 'checkbox') . '<br>'
303303
. '<input class="btn btn-secondary" type="submit" id="removeRedundant" value="'
304304
. __('Remove selected') . '">'
305-
. '<input class="btn btn-secondary" type="submit" value="' . __('No redundant column')
306-
. '" onclick="goToFinish1NF();">';
305+
. '<input class="btn btn-secondary" type="submit" id="noRedundantColumn" value="'
306+
. __('No redundant column') . '">';
307307

308308
return ['legendText' => $legendText, 'headText' => $headText, 'subText' => $subText, 'extra' => $extra];
309309
}
@@ -336,7 +336,7 @@ public function getHtmlContentsFor1NFStep3(string $db, string $table): array
336336
. '<input class="btn btn-secondary" type="submit" id="moveRepeatingGroup" value="'
337337
. __('Done') . '">'
338338
. '<input class="btn btn-secondary" type="submit" value="' . __('No repeating group')
339-
. '" onclick="goToStep4();">';
339+
. '" id="noRepeatingGroup">';
340340
$primary = Index::getPrimary($this->dbi, $table, $db);
341341
$primarycols = $primary === null ? [] : $primary->getColumns();
342342
$pk = [];

test/classes/Controllers/Normalization/FirstNormalForm/FourthStepControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function testDefault(): void
4343
'legendText' => 'Step 1.4 Remove redundant columns',
4444
'headText' => 'Do you have a group of columns which on combining gives an existing column? For example, if you have first_name, last_name and full_name then combining first_name and last_name gives full_name which is redundant.',
4545
'subText' => 'Check the columns which are redundant and click on remove. If no redundant column, click on \'No redundant column\'',
46-
'extra' => '<input type="checkbox" value="id">id [ int(11) ]<br><input type="checkbox" value="name">name [ varchar(20) ]<br><input type="checkbox" value="datetimefield">datetimefield [ datetime ]<br><br><input class="btn btn-secondary" type="submit" id="removeRedundant" value="Remove selected"><input class="btn btn-secondary" type="submit" value="No redundant column" onclick="goToFinish1NF();">',
46+
'extra' => '<input type="checkbox" value="id">id [ int(11) ]<br><input type="checkbox" value="name">name [ varchar(20) ]<br><input type="checkbox" value="datetimefield">datetimefield [ datetime ]<br><br><input class="btn btn-secondary" type="submit" id="removeRedundant" value="Remove selected"><input class="btn btn-secondary" type="submit" id="noRedundantColumn" value="No redundant column">',
4747
], $response->getJSONResult());
4848
// phpcs:enable
4949
}

test/classes/Controllers/Normalization/FirstNormalForm/ThirdStepControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function testDefault(): void
4343
'legendText' => 'Step 1.3 Move repeating groups',
4444
'headText' => 'Do you have a group of two or more columns that are closely related and are all repeating the same attribute? For example, a table that holds data on books might have columns such as book_id, author1, author2, author3 and so on which form a repeating group. In this case a new table (book_id, author) should be created.',
4545
'subText' => 'Check the columns which form a repeating group. If no such group, click on \'No repeating group\'',
46-
'extra' => '<input type="checkbox" value="id">id [ int(11) ]<br><input type="checkbox" value="name">name [ varchar(20) ]<br><input type="checkbox" value="datetimefield">datetimefield [ datetime ]<br><br><input class="btn btn-secondary" type="submit" id="moveRepeatingGroup" value="Done"><input class="btn btn-secondary" type="submit" value="No repeating group" onclick="goToStep4();">',
46+
'extra' => '<input type="checkbox" value="id">id [ int(11) ]<br><input type="checkbox" value="name">name [ varchar(20) ]<br><input type="checkbox" value="datetimefield">datetimefield [ datetime ]<br><br><input class="btn btn-secondary" type="submit" id="moveRepeatingGroup" value="Done"><input class="btn btn-secondary" type="submit" value="No repeating group" id="noRepeatingGroup">',
4747
'primary_key' => '["id"]',
4848
], $response->getJSONResult());
4949
// phpcs:enable

0 commit comments

Comments
 (0)