-
Notifications
You must be signed in to change notification settings - Fork 263
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
[AAE-16965] Improve data table date column #9038
Conversation
lib/core/src/lib/datatable/components/date-cell/date-cell.component.ts
Outdated
Show resolved
Hide resolved
lib/core/src/lib/datatable/components/date-cell/date-cell.component.ts
Outdated
Show resolved
Hide resolved
locale: undefined | ||
}; | ||
|
||
constructor(private readonly appConfig: AppConfigService) { |
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.
Can we use inject() feature over here?
private setDefaultConfig(): void { | ||
if (this.dateConfig) { | ||
this.config.format = this.dateConfig?.format ?? (this.column?.format || this.getAppConfigPropertyValue('dateValues.defaultDateFormat', this.defaultDateConfig.format)); | ||
this.config.tooltipFormat = this.dateConfig?.tooltipFormat || this.getAppConfigPropertyValue('dateValues.defaultTooltipDateFormat', this.defaultDateConfig.tooltipFormat); | ||
this.config.locale = this.dateConfig?.locale || this.getAppConfigPropertyValue('dateValues.defaultLocale', this.defaultDateConfig.locale); | ||
} else { | ||
this.config = this.defaultDateConfig; | ||
} | ||
} | ||
|
||
private getAppConfigPropertyValue(key: string, defaultValue: string): string { | ||
return this.appConfig.get(key, defaultValue); | ||
} |
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.
private setDefaultConfig(): void { | |
if (this.dateConfig) { | |
this.config.format = this.dateConfig?.format ?? (this.column?.format || this.getAppConfigPropertyValue('dateValues.defaultDateFormat', this.defaultDateConfig.format)); | |
this.config.tooltipFormat = this.dateConfig?.tooltipFormat || this.getAppConfigPropertyValue('dateValues.defaultTooltipDateFormat', this.defaultDateConfig.tooltipFormat); | |
this.config.locale = this.dateConfig?.locale || this.getAppConfigPropertyValue('dateValues.defaultLocale', this.defaultDateConfig.locale); | |
} else { | |
this.config = this.defaultDateConfig; | |
} | |
} | |
private getAppConfigPropertyValue(key: string, defaultValue: string): string { | |
return this.appConfig.get(key, defaultValue); | |
} | |
private setDefaultConfig(): void { | |
if(!this.dateConfig){ | |
this.config = this.defaultDateConfig; | |
return; | |
} | |
this.config.format = this.dateConfig?.format ?? (this.column?.format || this.getAppConfigPropertyValue('dateValues.defaultDateFormat', this.defaultDateConfig.format)); | |
this.config.tooltipFormat = this.dateConfig?.tooltipFormat || this.getAppConfigPropertyValue('dateValues.defaultTooltipDateFormat', this.defaultDateConfig.tooltipFormat); | |
this.config.locale = this.dateConfig?.locale || this.getAppConfigPropertyValue('dateValues.defaultLocale', this.defaultDateConfig.locale); | |
} | |
private getAppConfigPropertyValue(key: string, defaultValue: string): string { | |
return this.appConfig.get(key, defaultValue); | |
} |
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.
In this case is nice to avoid the else{} block and just handle 'smaller' stuff at the beginning and get use of return;
I think
f25ee9a
to
44f6220
Compare
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Please check if the PR fulfills these requirements
What kind of change does this PR introduce? (check one with "x")
What is the current behaviour? (You can also link to an open issue here)
https://alfresco.atlassian.net/browse/AAE-16965
What is the new behaviour?
New
dateConfig
params to better configure displayed date values, with backward compatibility (handle column.format)Does this PR introduce a breaking change? (check one with "x")
If this PR contains a breaking change, please describe the impact and migration path for existing applications: ...
It might have impact for components/modules that imports Pipes (adfLocalizedDate, adfTimeAgo) that are changed to standalone
Other information: