- 🇫🇮Finland sokru
Needs at least reroll. Also this would greatly benefit from tests. The validation doesn't seem to take into account that some vocabulary might be translatable and other not and moving translated term to non-translatable vocabulary probably causes errors.
- First commit to issue fork.
- 🇺🇸United States jsutta United States
I rebased the issue's merge request against the current 2.0.x branch and readded the changes from #27. A patch generated from the merge request applies cleanly against the latest release in my environment.
- 🇺🇸United States torfj Seattle, WA
Patch also applied cleanly for me and moving terms within a taxonomy seems to be working well. However, when I tried enable the option to 'Keep old parents and add new ones' I get this error:
Error: Call to undefined method Drupal\taxonomy\Entity\Vocabulary::setHierarchy() in Drupal\taxonomy_manager\Form\MoveTermsForm->submitForm() (line 188 of /opt/drupal/web/modules/contrib/taxonomy_manager/src/Form/MoveTermsForm.php).
- 🇺🇸United States torfj Seattle, WA
Linted the code and added a validation check to ensure only one vocabulary is selected.
I think it might also be necessary to add an access check before moving terms across vocabularies to confirm that the user has both delete term permissions in source and create term permissions in destination.
- 🇺🇸United States jsutta United States
The latest commits apply cleanly and work on my end. Thank you @torfj!
- 🇭🇷Croatia devad
The latest merge patch
https://git.drupalcode.org/project/taxonomy_manager/-/merge_requests/5.d...
works nicely for me. Thank's a lot! You made my day!
The only thing I noticed is that after moving the term from one vocabulary to another the automatic URL alias is not updated.
For example... if the old URL alias was /tag/old-vocabulary/term-name, after move I would expect the URL to be tag/new-vocabulary/term-name but it remains the same.
After I made all the term moves I needed the bulk regeneration of URL aliases did the job for me of course.
Maybe this is an intentional behavior of course. Just posting the note here in case that it is not. :)
- Assigned to torfj
- 🇺🇸United States torfj Seattle, WA
I merged the working branch with the changes from the latests release and did some more testing. Moving terms seems to be working well.
One thing I noticed is that the move button should be disabled when no term is selected. I will be working on that.
Also, I think it would be good to show some warning message that moving a term to a different vocabulary could results in data loss if the two vocabulary doesn't have the same fields. - 🇺🇸United States torfj Seattle, WA
I have added the following checks to the MoveTermsForm and TaxonomyManagerForm since there were no permissions checks before.
- Added a check to ensure the user has permission to create terms in the target vocabulary.
- Added a check to ensure the user has permission to delete terms in the source vocabulary if the keep_old_parents checkbox is not checked. If the user does not have the required permission, an error message is displayed.
- Added an access check to the move button to ensure it is only displayed if the user has permission to edit terms in the vocabulary. - 🇺🇸United States torfj Seattle, WA
I can confirm what @devad mention that the term URL alias doesn't get updated when moving a term to a new vocabulary.
I tried do that on the D7 version of the taxonomy manager and the URL does automatically get updated there.I think it would be beneficial to have the same behavior here. However, since the Pathauto module is a contrib module rather than part of Drupal core, it might not be strictly necessary.
Re #41 - maybe the user can be advised to do the batch alias update of taxonomy paths using pathauto? Or could it be called from this module at the end of the process of moving the terms?
- 🇺🇸United States torfj Seattle, WA
@leeksoup Thanks for the input!
I’ve created an issue in the Pathauto module’s issue queue to see what they recommend regarding updating URL aliases when moving taxonomy terms.
Once I get feedback from the Pathauto maintainers, I’ll update this thread with their suggestions. Let me know if you have any thoughts in the meantime!Issue: https://www.drupal.org/project/pathauto/issues/3513096 💬 Best approach for updating URL Alias when moving a taxonomy term Active
- 🇺🇸United States torfj Seattle, WA
I added some logic to preserve child terms when moving taxonomy terms across vocabularies since before that when moving a term to a new vocabulary children were deleted. But if you're just moving to a new parent within the same vocabulary the children are not deleted.
@torfj #43 - Thanks!
Re #44 - So to clarify, with your new logic, child terms are preserved regardless of whether a term is moved within the same vocabulary or to another?