How to add delete button

Problem Add Delete button in AdminFile/update under New Attribute Create actionDeleteAttr Pass Behat tests How Add Delete button in /protected/adminFile/_form.php <tbody> <?php foreach($model->fileAttributes as $fa) { ?> <tr class="row-edit-<?= $fa->id ?>"> <td> <?= $fa->attribute->attribute_name ?> </td> <td> <?= $fa->value ?> </td> <td> <?= $fa->unit ? $fa->unit->name : '' ?> </td> <td><a role="button" class="btn btn-edit js-edit" data="<?= $fa->id ?>">Edit</a></td> <td><a role="button" class="btn js-delete" name="delete_attr" data="<?= $fa->id ?>">Delete</a></td> </tr> <?php } ?> </tbody> <script> $('.js-delete').click(function (e) { e.preventDefault(); id = $(this).attr('data'); console.log(id); row = $('.row-edit-' + id); console.log(row); if (id) { $.post('/adminFile/deleteAttr', { 'id': id }, function(result) { if (result) { // console.log(result); } }, 'json'); } window.location.reload(); }) </script> Create actionDeleteAttr in /controller/AdminFileController.php public function actionDeleteAttr() { if (!Yii::app()->request->isPostRequest) throw new CHttpException(404, "The requested page does not exist."); if (isset($_POST['id'])) { $attribute = FileAttributes::model()->findByPk($_POST['id']); if ($attribute) { $attribute->delete(); Yii::app()->end(); } } } Create admin-file.feature @admin-file @issue-457 Feature: An admin user can edit and delete attribute in admin file page As an admin user I can edit/delete attribute So that I can associate various attributes to files Background: Given Gigadb web site is loaded with production-like data @ok @issue-457 @javascript Scenario: Guest user cannot visit admin file update page Given I am not logged in to Gigadb web site When I go to "/adminFile/update/" Then I should see "Login" @ok @issue-457 @javascript Scenario: Sign in as admin and visit admin file update page and see New Attribute, Edit, Delete buttons Given I sign in as an admin When I am on "/adminFile/update/id/13973" Then I should see a button "New Attribute" And I should see a button input "Edit" And I should see a button input "Delete" @ok @issue-457 @javascript Scenario: Sign in as admin to delete attribute Given I sign in as an admin And I am on "/adminFile/update/id/13973" And I should see a button input "Delete" When I press "Delete" And I wait "3" seconds Then I should not see a button "Delete" Run behat test with Database set up 4.1 only accptance test #!/usr/bin/env bash set -e -u ./tests/acceptance #./tests/unit_functional #./tests/coverage 4.2 change tag to @wip ...

September 23, 2020 · 3 min · 508 words · Ken Cho

Learn, todo and done 21-24/9/20

Learn Yii2 JavaScript, FCC CSS, FCC Clean Code, YouTube Todo To start a new project, user story Done Merged PR Delete button #503 Closed and merged PR Pagination #495 Reference

September 21, 2020 · 1 min · 30 words · Ken Cho

Learn, todo and done 14-18/9/20

Learn JavaScript, FCC CSS, FCC Clean Code, YouTube Learning progress Finished 80% of Java Algorithm and Data Structure Certification. Todo Finish no ability to remove file attributes #457 Done Follow up PR Pagination #495 Update the pressEnterKey to detectEnterKeyPress Clean up the dataset-view.feature For PR Delete button #503 Create actionDeleteAttr in the controller class for the delete function Create a Delete button in the _form file of view class that calls js-delete function Create a js-delete function that calls action deleteAttr and add window.location.reload() to refresh the page after delete Try to finish the behat test Update browser to chrome in behat.yml and docker-compose.yml Problem Behat test configuration Cannot pass the step I sign in as an admin, but it could be passed in Peter’s branch. Reference ...

September 14, 2020 · 1 min · 127 words · Ken Cho

Learn, todo and done 7-11/9/20

Learn JavaScript, FCC CSS, FCC Clean Code, YouTube Learning progress Finished 75% of Responsive Web Design Certification Finished 70% of Java Algorithm and Data Structure Certification. Todo Done Follow up PR View files from large db #437 Create a more generic I hit return behat scenario. Remove commented codes. Delete PhantomJS dependence and update chrome browser window size to window-size=1024,768 Follow up no ability to remove file attributes #457 Update actionUpdate, but get Error 500 Trying to get property of non-object error. Reference ...

September 6, 2020 · 1 min · 83 words · Ken Cho

Learn, todo and done 31/8-4/9-20

Learn JavaScript, FCC API, FCC CSS, FCC Clean Code, YouTube Todo Done Cleanup PR View files from large db #437 Asked review for PR no ability to remove file attributes #457 Reference

August 31, 2020 · 1 min · 32 words · Ken Cho