Problem/Motivation
The delete operation for job items does not work. When you try to delete an item (/admin/tmgmt/items/7/delete, the delete operation for job items on /admin/tmgmt/jobs/7). The error is:
Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException: The "tmgmt_job_item" entity type did not specify a "delete" form class. in Drupal\Core\Entity\EntityManager->getFormObject() (line 309 of core/lib/Drupal/Core/Entity/EntityManager.php).
And when you take a look at the JobItem: "delete" = "Drupal\tmgmt\Form\JobItemDeleteForm"
That class does not exist though...
Proposed resolution
Add JobItemDeleteForm which extends from EntityDeleteForm and redirects back to the job to which the item used to belong.
Remaining tasks
Review patch, commit.
User interface changes
None.
API changes
None.
Data model changes
None.
Comments
Comment #1
joshi.rohit100Comment #2
berdirwe can't just use that. the default delete form assumes the existence of a collection route/link template and we don't have that and can't add it.
So we still need a custom class that extends from that and overrides the cancel/redirect Url methods to go back to the job this item belongs to.
Sounds like we need test coverage here.
Comment #3
joshi.rohit100working !
Comment #4
joshi.rohit100Without tests
Comment #5
joshi.rohit100With Test case.
Comment #7
LKS90 commentedComment #8
joshi.rohit100Just changes in the test case (in job creation).
Comment #9
LKS90 commentedWouldn't just clicking the link be enough? (delete the two lines at the top, leave only the clickLink)
The what? I guess copy paste? :D
Comment #10
joshi.rohit100Sorry my bad ):
Comment #13
joshi.rohit100Don't know why delete link is not there ):
Comment #14
LKS90 commentedThe delete link only appears after submitting the job to the translator. Insert a
drupalPostForm('admin/tmgmt/jobs/' . $job->id(), [], t('Submit to translator'))before you do the drupalGet to the job and it should work.Edit: You are also missing the permission to delete stuff (I think, there is a 403 in the test when you try to delete the job [you want to delete job items by the way]).
Edit-2: Yep,
$this->loginAsAdmin();in the beginning of the method and it passes :).Comment #15
berdirThere's a special delete permission, you might be missing that with your test user.
Comment #16
joshi.rohit100@berdir : I couldn't find the delete permission so I just commanded the admin user to do that.
@LKS90 : thanks for the help.
Comment #17
joshi.rohit100Finally green sigh!
Comment #18
berdirYou can write this in a single line: return $this->getEntity()->getJob()->urlInfo();
Comment #19
joshi.rohit100I will do that :)
Comment #20
joshi.rohit100Comment #21
joshi.rohit100forgot minor change.
Diff with #20.
Comment #22
berdirThanks, committed.