-
Notifications
You must be signed in to change notification settings - Fork 0
feat(app): add dynamic translation to agent detail form #311
feat(app): add dynamic translation to agent detail form #311
Conversation
ff36faa
to
b0ef512
Compare
…y `setTranslation` under the dynamicForm.action & adds translation for its value in all of the JSON files. Uses this new property to set the form submit button text when setting translation on an agent
…get()` if the fieldConfig is not for dynamicContent translation fields. Otherwise uses `group.control` to get the value of fields that requires translation
… is nested inside dynamicContent
@@ -31,7 +31,9 @@ export class FormInputComponent implements OnInit { | |||
} | |||
|
|||
public get formControl(): AbstractControl { | |||
return this.group.get(this.config.name); | |||
return this.config.name.split('.').length > 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a better way to implement this? I wasn't able to get the formControl
using group.get
when the config.name
was a nested property type string like "dynamicContent.description"
signUp: string = 'dynamicForm.title.signUp'; | ||
updateAgency: string = 'dynamicForm.title.updateAgency'; | ||
updateAgent: string = 'dynamicForm.title.updateAgent'; | ||
updateProfile: string = 'dynamicForm.title.updateProfile'; | ||
updateUser: string = 'dynamicForm.title.activateAccount'; | ||
updateUser: string = 'dynamicForm.title.updateUser'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
@@ -54,19 +69,24 @@ export class AgentDetailSmartComponent implements OnInit { | |||
} | |||
|
|||
public updateOrCreateAgent(): void { | |||
return this.agent.id ? this.updateAgent() : this.createAgent(); | |||
if (this.isSetTranslation) { | |||
this.setTranslation(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function seems to just call this.buildPayload()
, could we just call that here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That functionality isn't in yet. The method is essentially noop right now. We decided to handle the mapping of the data into the payload in a separate branch so we could merge this while the API catches up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Karvel Got it, thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good to me, I think @pratimasakinala has better implementation context
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything's working great! NIce job!
Changes
set-translate
route using event emitters instead of state.AgentDetailComponent
to handle theset-translation
route:isSetTranslation
boolean.isSetTranslation
to disable form controls.isSetTranslation
to update form title and submit method.set-translation/:id/:languageCode
route.CreateAgentResolver
with default language dynamic content.Purpose
The webapp should be able to load a form where a user can set translations for records with dynamic content. This form should disable the non-dynamic fields. It should load the selected language values when available. It should state the selected language in the form title to improve the UX.
setTranslation()
does not yet send a request payload to theAgentService
.Approach
This branch puts the responsibility of setting up the dynamic content in the component that creates the form, in this case,
AgentDetailComponent
, rather thanDynamicFormComponent
. The only change toDynamicFormComponent
was to translateformTitleParams
when it is available.Pre-Testing TODOs
Testing Steps
If you are not a member of this project, skip this step
required
error message under the input wherever applicable (if the value is blank).http://localhost:4200/content/set-translation/1/es-ES
& that changing the language code to one that isn't supported by the application returns the user to the Agent list view.Closes #310.