-
Notifications
You must be signed in to change notification settings - Fork 444
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prepared emails should display the value of variables like author name #2180
Comments
I have found that to be true at the reviewer forms. That is not the case with the NAME placeholder at the "select a reviewer" form (when the user selects a reviewer for a submission). Even though the email template displayed form (after the Select Reviewer button is pushed) should know the reviewer name, the email editor displays the NAME placeholder. If we need to have some javascript functionality for that (for example if the user selects a "review due date" the editor should change too), I suggest to add an Editor callback that takes as parameter the editor id or name and an array of parameters/values and apply it on form events ('click' or 'change' or other) I am looking for other instances of the above, but couldn't yet find any. |
@defstat I think you've diagnosed the problem correctly. For this to work properly, we're going to want a general way to process the variable data in the browser (JS), not the server, so that we can update it on-the-fly. But we will run into issues after we have processed the variables. If we replace the placeholder with the name, and then the user edits the form, and then changes the recipient, we won't have the placeholder to safely insert the name again. One possibility would be to write a TinyMCE integration which rendered the value of the placeholder in the WYSIWYG view, but kept the placeholder in the actual submitted code. Another approach could be to wrap the values in a This is a challenging problem, but if a good system was in place, it could be used widely in our system to supply relevant data inserts for emails and messages of all kinds. |
@NateWr, we already have a TinyMCE integration: it displays |
Cool, so it sounds like all we need is a method we can call on the TinyMCE and pass a hash of variables to, and have the existing content updated, eg: editor.setPlaceholders({
variableName: value,
}); |
@NateWr @asmecher I think that there could be a mechanism that would do something like the following:
That way we can add more tags to the already existing email templates, and the user can see the value of the tags (not their symbolic name), as he changes the form's input values. I have not found a general way/mechanism to do the same with already existing email template placeholders, mainly because the emailTemplates seem to have a very tight connection with the already existing placeholder-replacing mechanism which is depending on server-side code. For example, let's consider the "Email to be sent to reviewer" email template, upon the creation of a new reviewer. There, the TinyMCE editor has a Another approach could involve a different display of the emailTemplate's placeholders. We could change the display of a tag in the TinyMCE editor (let's say to display it in red) if there is no server-side assignment to it during the loading of the form, or if there is no form element that can assign value to it on-the-fly, upon a form element change event. That way the user can be notified regarding the placeholders that will be assigned later by the server-side code. (not sure if that is more confusing for the user, it could help me as a user I think). Any thoughts on these? |
That sounds good. One hiccup you'll probably run into is when form data is changed but the tag data needs to be fetched from the server. For instance, I may select a user ID, but the TinyMCE needs to update the user's first name. To get around this, I'd encourage you to build it with callbacks in mind. So in I'd encourage you to abandon the server-side replacement in the template altogether. Instead, I'd handle the replacement entirely in the client. That way you don't need to worry about syncing the original template with the data. Just pass the initial data into TinyMCE when it's loaded, and repeat the procedure any time the data is updated. Then accept whatever is sent to the server as the final rendered version. |
@NateWr I think that the tag data could be manipulated at client side. The problem I wanted to point out is actually what happens if the server couldn't have a "valid" response for a requested placeholder name. For example what if the reviewer email is displayed before the server knows about the reviewer object (because we are at the form for creating a reviewer). In that case the Ajax approach will not work. |
@defstat I'd set it up so that I can pass an empty data object into the prepared email (in the client) and it shouldn't be destructive. Instead, it should show the placeholders when no data is available. |
@asmecher It's my fault that I haven't look into that for so long. I will go through the requirements and start developing next week, if that's ok. |
Not a problem, thanks! Just raising it because we've had a few recent issues filed about variables in emails, and there's likely further work that'll follow this one getting closed off. |
Just a note that I think the biggest source of confusion is on the reviewer assignment message compose window. That's the only case where we're presenting variable names in the default template rather than just replacing them before showing them. |
@defstat, if you're not sure where to start with this, the most frequent point of confusion is why we see the label "Name" rather than an actual name in the reviewer assign email compose box. But before you make any changes there, check quickly with @NateWr whether that aspect will be affected by his current reviewer assignment work. |
Nope, it shouldn't be effected. |
…play-value-variables-2##
PRs pkp-lib: #3402 |
…play-value-variables-2##
…play-value-variables-2##
…play-value-variables-2##
Just our opinion for this: we think that just display name and not other variables like URL or DATE is ambiguous. Ps: I have tried the PR, see my comments. |
This looks really nice @defstat! I think we do need to extend it to the other forms. So right now it's working when you create a new reviewer. There's also email fields associated with selecting an existing reviewer and selecting an existing user (who isn't a reviewer). It should work for those too. Other comments:
|
@defstat, this is not a priority for 3.3, but please don't forget this issue! |
This has been addressed as part of the new email composer UI introduced in #5717. It is not available for every prepared email but it will become available once we convert each email to the new composer UI. |
Prepared emails show placeholders like
NAME
for variables that will be injected to the email when it's sent. Users reported confusion about this and would prefer to see the actual name that will be used displayed.From UI/UX testing outcomes: https://docs.google.com/spreadsheets/d/1RkZ0avL3UIUU-hUScbM77lLCsGtk-T2_dL-FEx_vKcM/
The text was updated successfully, but these errors were encountered: