Repository navigation
Keep the name of a message template out of the edit form - #1087
Merged
Merged
Conversation
The name is read-only on the edit form, but it was posted back through a hidden input and mapped onto the template. The name is the key a template is sent by, so a changed name stopped the notification it belonged to. The edit now keeps the stored name; it is set on create only.
After a failed validation the create and edit actions set HasAttachedDownload from the posted AttachedDownloadId, so a switch the user had just turned off came back on and a resubmit kept the attachment. The form now shows the switch as it was posted.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type: bugfix
Issue
On the message template edit form the name is shown as read-only text, but it was posted back through a hidden input and
model.ToEntity(messageTemplate)copied it onto the stored template.The name is the key messages are sent by (
GetMessageTemplateByName). A changed name made the notification it belonged to stop being sent, or made the template stand in for another one. Applies to Admin and to the Store panel (on a store's own templates), which shareBaseMessageTemplateController.To reproduce: edit any template, change the hidden
Nameinput in the browser dev tools and save — the list shows the new name.Solution
BaseMessageTemplateController.Edit(POST)keeps the stored name after mapping; the name is set on create only.Nameinput is removed from the edit form; when the form is shown again after a validation error the name comes from the stored template.AttachedDownloadId, so a resubmit kept an attachment the user had turned off.Breaking changes
None. The name was never editable on the edit form.
Testing
<input name="Name" value="Other.Name">to the form in the dev tools: the name still stays.dotnet test src/Tests/Grand.Web.Admin.Tests --filter BaseMessageTemplateControllerTestspasses.