Closed (fixed)
Project:
Contact Emails
Version:
8.x-1.x-dev
Component:
User interface
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
3 Feb 2017 at 10:42 UTC
Updated:
25 Apr 2017 at 08:14 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
scott_euser commentedAt the moment they can't be, but I don't think it would be too difficult to make each email a translatable entity. I will add this to my to-do list (may be a few weeks) but would be happy if anyone is willing to contribute a patch to help.
Comment #3
replicaobscuraThis is important functionality for us on a site I'm building. I'm not positive when I'll have time to get to this, but I'll create a patch in the near future if there is not one already by then.
Comment #4
scott_euser commentedThanks! I have given this a start, I will try to get my progress more complete and upload it here as a patch and outline the remaining tasks.
Comment #5
scott_euser commentedHere is my progress thus far. What is completed:
What is left to do:
And finally:
Comment #6
replicaobscuraAwesome! Migrating the existing data is the part I have the least experience with, so I could definitely help with at least some of those other remaining tasks very soon if they're still open. Thanks for posting your progress on that so far!
Comment #7
replicaobscuraJust to let you know, I'm almost finished with this.
The changes are pretty far-reaching, definitely affecting more than just adding translations, however I think they are all positive.
There may be a couple of regressions given that things work a bit differently in some cases. For example, I don't know the best way to have the message at the top of the contact email listing page indicating whether or not the default email settings are still in effect.
I need to finish a little bit more testing and will post a full patch for further review / discussion tomorrow.
Comment #8
scott_euser commentedSounds good, thanks for the update and your efforts!
Comment #9
replicaobscuraHere's my first try. I began with your patch, and ended up modifying just about every file in the module in some pretty large ways to try and do things the "entity" way. The end result is that the two services are much lighter, and some functionality has been moved out of those into other entity-related classes.
I'm hoping I haven't removed any functionality that existed before, other than the aforementioned message that I haven't figured out how to make work the same using a list builder class, though I'm sure there's an easy way to do it. After abstracting things out to the entity classes, it turned out the controller wasn't even needed anymore--though it could be added back if I've missed anything there.
I've tested fully using the new entity system, I think. There are a couple of quirks with the UX that can be enhanced, such as making sure to redirect to the proper list page (currently if you add a contact email from the main list, it'll redirect you to that contact form's list afterward).
I have not yet tested the update hook. I made a couple minor changes to it as I modified the "disabled" field to be a "status" field. I also changed the "contact_form" field to be an entity reference instead of a plain string, but I don't think that requires any changes to the update hook. I'm going to attempt some testing of the update process tonight yet.
I'll update this if I find any further issues. I'd appreciate if you could check it over and provide any feedback, as well. Thanks!
Comment #10
replicaobscuraBTW, accessing the lists is slightly different with this patch as well. I figure I should clarify how to access the various pages.
1. Full list at Structure > Contact forms > Manage emails
2. Individual lists when you're editing any contact form using the "Manage emails" tab
3. Through the action button on the Structure > Contact forms listing page, like before
Sorry if I overstepped at all with those updates. I started with different routes entirely using the entity system so they didn't collide with the existing ones, but ended up liking where they are and leaving them. Feel free to move these things around as you see fit!
Comment #11
replicaobscuraJust noticed an issue, currently when deleting it redirects to the homepage. Maybe it's necessary to override the entity delete form to specify a redirect, or perhaps there's a cleaner way to do it while still using the default entity delete form, I'm not positive yet.
Comment #12
replicaobscuraI tested the update hook, and the good news is it works! Here's a new patch with a couple minor changes:
1. Added a "Contact form" column to the list page which solves a couple of issues. First, on the main list page it differentiates the rows so you know which form is for which email. Second, on the specific list pages, it makes it abundantly clear which form you're editing the emails for.
2. Added a line to the update hook to call entity updates first. Previously, you had to be sure to run
drush entity-updatesbefore the update hook or the new entity type schema wouldn't have been installed. I think that should solve that issue.Comment #13
replicaobscuraI should also mention, I've been so caught up just getting the whole entity system fully baked, I neglected to test that translations actually work properly.
I'm noticing that there currently isn't a Translate tab visible when editing a contact email, which I would guess to be a requirement?
Comment #14
replicaobscuraI'm working on a new patch version now that completes the translation aspect of this patch. Running into a couple issues, but should have a new patch shortly, or in the morning.
Comment #15
scott_euser commentedSounds good, looks like you've put a lot of work into it. Just uploading an interdiff to help me see what's changed and review easier. In general the approach of using the built in entity handlers should be fine; I'll review the UX and flow from core contact email to contact emails provided by this module in the process. Also makes sense to move the getBody, etc to the entity class as you've done. Will try to review in more detail once you feel it's ready for review (sounds like you are still working on it).
Comment #16
scott_euser commentedProbably the biggest understatement :)
Comment #17
replicaobscuraThanks for the initial feedback!
I've resolved an issue with one route title, and finished making the ContactEmail entity type translatable. New patch attached.
Testing needs to be done to see how well the translations work now that they're in place, and if the proper email gets selected depending on the user's preference when submitting a contact form, etc.
I think this is ready for further review / discussion. Thanks again for taking a look!
Comment #18
replicaobscuraIt'd be nice if there were a "Translate" tab at the top of the page when editing a contact email. Normally I think that happens automatically when enabling translations, however it seems like there should be other actions showing up there as well (at least Edit). Perhaps there's something more that needs to be done to make local actions show up as tabs at the top?
Comment #19
scott_euser commentedFrom the hook_update_N manual page:
This should do the trick to instead just install it for the contact_email entity:
I'm happy to of course carry on from where you leave off and implement stuff like that, not necessary to take the whole rework on your shoulders.
Comment #20
scott_euser commentedGreat thanks for the new patch! Shall I take it from here for a bit? I don't want to start on it while you're in progress.
Comment #21
replicaobscuraThanks for the tip about that update hook issue! Also, that'd be great if you'd like to take it from here for now. I'd be happy to come back later to put in some additional effort on changes or fixes, but now's probably a good time for me to step back for a bit while you go over things and make some changes or provide some additional feedback about what else should be completed.
I appreciate your timely comments, and willingness to take on this beast of a patch!
Comment #22
replicaobscuraI ran DB updates with Drush again to test this, but this time I didn't have as good of results.
Last time I tested, the upgrades were successful. It's possible there was some unrelated issue with my data that was being upgraded which caused the other fields to be missing. But, figured I would report this in case you or anyone else sees this as well.
Comment #23
scott_euser commentedThanks for the info. It will take me a bit to get through this but I am making some progress (just don't it in my free time so time is a bit sparse) and I am trying to get tests in to ensure such a major change is non-breaking.
Comment #24
scott_euser commentedI haven't been getting through this as quick as hoped, but anyways uploading my progress here. Will keep assigned to me as I've only gone through a portion of the work and would like to build in more tests before actually moving ahead with this (but an upgrade test is there at least now).
Comment #25
scott_euser commentedJust an update on this. I am almost there with it - I still need to add test coverage for the reply-to and recipient's to ensure those continue to work, but otherwise I would consider this quite usable already. You can find the progress on the 8.x-1.x-translatable-entities branch found here.
Comment #26
replicaobscuraCool, thanks a lot for your continued efforts on this!
I'm a bit scared to switch over from my patch that something unexpected might break, but I'll give it a try in the near future.
Even if I need to uninstall it and re-create my emails afterward it wouldn't be a big deal, but I suppose I should wait on THAT aspect until it's in the official dev branch at least.
Comment #28
scott_euser commentedHappy to say this is now on the dev branch with a fair amount of test coverage including for the upgrade path. Thanks again for all the effort on your end as well getting this end - definitely a useful step!
Comment #29
replicaobscuraWoohoo! Thanks for getting this functionality in! I've been using your other branch for a couple of days successfully now, so I anticipate it'll be a smooth transition to come back to the dev branch now.
Comment #30
scott_euser commentedYep, should be smooth - only a few php warning/notice bug fixes - primarily just adding test coverage over the past few days. Glad to hear you've been using it successfully already!