Skip to content
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

Merged
merged 15 commits into from
Nov 3, 2023

Conversation

tomgny
Copy link
Contributor

@tomgny tomgny commented Oct 27, 2023

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

What kind of change does this PR introduce? (check one with "x")

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation
  • Other... Please describe:

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")

  • Yes
  • No

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:

locale: undefined
};

constructor(private readonly appConfig: AppConfigService) {
Copy link
Contributor

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?

Comment on lines 56 to 67
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);
}
Copy link
Contributor

@wiktord2000 wiktord2000 Oct 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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);
}

Copy link
Contributor

@wiktord2000 wiktord2000 Oct 30, 2023

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

@tomgny tomgny force-pushed the AAE-16965-handle-date-column branch from f25ee9a to 44f6220 Compare October 31, 2023 15:57
Copy link

sonarcloud bot commented Nov 3, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@tomgny tomgny merged commit 9278d92 into develop Nov 3, 2023
34 checks passed
@tomgny tomgny deleted the AAE-16965-handle-date-column branch November 3, 2023 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants