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

[ACS-5556] [ACS-5557] [ACS-5558] [ACS-5559] [ACS-5602] [ACS-5603] mat-datepicker component added and removed old mat-datetimepicker component from UI #8749

Closed
wants to merge 54 commits into from

Conversation

jatin2008
Copy link
Contributor

@jatin2008 jatin2008 commented Jul 11, 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)
old mat-datetimePicker component is being used in the UI

What is the new behaviour?
Added new date-timepicker component and removed old mat-datetimePicker component

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: ...

Other information:
Jira id - https://alfresco.atlassian.net/browse/ACS-5557

Images for new datetime-picker

Screenshot from 2023-07-11 13-30-14

Screenshot from 2023-07-11 13-31-19

@jatin2008 jatin2008 requested a review from rbahirsheth July 11, 2023 08:37
@jatin2008 jatin2008 changed the title [ACS-5557] mat-datepicker component added and removed old mat-datetimepicker component from UI [ACS-5556] [ACS-5557] mat-datepicker component added and removed old mat-datetimepicker component from UI Jul 11, 2023
@jatin2008 jatin2008 changed the title [ACS-5556] [ACS-5557] mat-datepicker component added and removed old mat-datetimepicker component from UI [ACS-5556] [ACS-5557] [ACS-5558] [ACS-5559] [ACS-5602] [ACS-5603] mat-datepicker component added and removed old mat-datetimepicker component from UI Jul 12, 2023
@@ -194,6 +193,7 @@ describe('CardViewDateItemComponent', () => {
const itemUpdatedSpy = spyOn(cardViewUpdateService.itemUpdated$, 'next');
component.editable = true;
component.property.editable = true;
component.property.value = moment('Jul 10 2017', 'MMM DD YYYY').endOf('day').toDate();
Copy link
Contributor

Choose a reason for hiding this comment

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

can this be date-fns ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yess converted to date-fns

@@ -355,23 +355,4 @@ describe('CardViewDateItemComponent', () => {
expect(valueChips[1].nativeElement.innerText.trim()).toBe('Jul 11, 2017');
expect(valueChips[2].nativeElement.innerText.trim()).toBe('Jul 12, 2017');
});

it('should render chips for multivalue datetimes when chips are enabled', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

why this test is removed? do you plan adding a replacement?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hi @DenysVuika I added this test case back again, earlier it was removed as I changed the datetime format to 'MMM d, y' so two test cases might went duplicate that was the reason of removing this.

@@ -22,7 +22,7 @@ import { CardViewDateItemProperties } from '../interfaces/card-view.interfaces';

export class CardViewDatetimeItemModel extends CardViewDateItemModel implements CardViewItem, DynamicComponentModel {
type: string = 'datetime';
format: string = 'MMM d, y, H:mm';
format: string = 'MMM d, y';
Copy link
Contributor

Choose a reason for hiding this comment

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

the model file is called "datetime" model, and the "type" is called "datetime", so you can't drop the time from here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i have again implemented tim here

@jatin2008 jatin2008 force-pushed the dev-jatin-ACS-5557 branch 3 times, most recently from ae00544 to 53a4d32 Compare July 21, 2023 10:50
@jatin2008 jatin2008 marked this pull request as ready for review July 21, 2023 11:41
@jatin2008 jatin2008 requested a review from DenysVuika July 21, 2023 11:41
@@ -314,25 +333,9 @@ describe('CardViewDateItemComponent', () => {
});
});

it('should be possible update a date-time', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you delete this test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hi @nikita-web-ua i have not deleted this test, just modified it's name and added it's functionality in updateDateTIme() function to avoid duplication of code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because we have 2 cases here now one with properties.cm:from and other without properties.cm:from

@jatin2008 jatin2008 force-pushed the dev-jatin-ACS-5557 branch from 82d3488 to 0df3e02 Compare July 24, 2023 09:08
@jatin2008 jatin2008 requested a review from nikita-web-ua July 24, 2023 09:24
return expectedDate;
};

//we will enable this test when will change from moment to date-fns throughout the application
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering if we should raise jira for that or maybe correct it for now based on actual functionality instead of disabling that so then when functionality will be corrected then test can be corrected too. @MichalKinas what do you think?

Copy link
Contributor Author

@jatin2008 jatin2008 Jul 26, 2023

Choose a reason for hiding this comment

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

We can keep this test case with xit as of now. We will create a new Jira ticket to address this test case. Once we replace moment.js in whole application with date-fns we will adress the jira ticket. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be best not to create a partial PR for such a change. I believe the best approach would be to go through the whole ADF and replace it everywhere and then adjust all affected tests at once instead of disabling some of them. This approach makes it easier to miss something during testing phase, during unit test and e2e fixes and most importantly such a change shouldn't be merged partially as it may be released without being complete. cc @AleksanderSklorz @MateuszHY

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with you @MichalKinas

Choose a reason for hiding this comment

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

Agreed with @MichalKinas
@jatin2008 @rbahirsheth what do you think ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi, @MichalKinas I do agree with you. We found some occurrences in the codebase but we could not find out the UI. We will analyze it. But, This PR is also part of the calendar replacement.

super();
this.dateFormat = this.appConfig.get('dateValues.defaultDateFormat');
// need to change this to app.config when will change from moment to date-fns throughout the application
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have jira for this comment? We can forget about that without jira

@MateuszHY
Copy link

@jatin2008 @rbahirsheth did you check accessibility after changes introduced here?
Plus ... any additional tests needed here?

@@ -154,4 +152,8 @@ export class CardViewDateItemComponent extends BaseCardView<CardViewDateItemMode
update() {
this.cardViewUpdateService.update({ ...this.property } as CardViewDateItemModel, this.property.value);
}

getDateValue(newDateValue): Date {
Copy link
Contributor

Choose a reason for hiding this comment

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

missing type for newDateValue

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we are calling our method from onDateChanged() & this method is triggering on the date change from UI. This method accepts the $event object & does not use type in this method too. We can use MatDatepickerInputEvent<any, any> type here. Is it fine?

Copy link
Contributor

Choose a reason for hiding this comment

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

If function takes $event as parameter then type of parameter should be type of $event. You can check $event type very easily. For example:
image

here you have dateChange event so you can check what it emits:
image

You see that it emits MatDatepickerInputEvent<D, S> so please use that type in every function.

Also please check if we really need to use <any, any> or maybe we can use better types in <>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hi @AleksanderSklorz added type here as MatDatepickerInputEvent<any, any> for $event, also checked and found any as the best supported type here.

Copy link
Contributor

Choose a reason for hiding this comment

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

@jatin2008 based on what information you think that any is the best supported type? That's not true, please go through the documentation https://material.angular.io/components/datepicker/overview especially the section with change event to check what type should be used here

Copy link
Contributor

Choose a reason for hiding this comment

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

Btw any is against strongly typed TypeScript code, it's basically antipattern that we should avoid as much as we can, so please update your knowledge about best practices for TS

@jatin2008
Copy link
Contributor Author

@jatin2008 @rbahirsheth did you check accessibility after changes introduced here? Plus ... any additional tests needed here?

hi @MateuszHY we have checked and not found any accessibility issue in the new datepicker component added and also added a new test case for the changes we made.

…cedComponent. Added config for using the new components
… search query on submit. Added optional property to disable update on submit button click for widget-composite.
swapnil-verma-gl and others added 25 commits July 27, 2023 11:14
…ponent and SearchFilterTabbedComponent to SearchDateRangeAdvancedTabbedComponent. Updated test cases accordingly
… 'Between' options use the start date to end date query format
…ng some numbers in the 'In the last' input field would clear out the field
@jatin2008 jatin2008 force-pushed the dev-jatin-ACS-5557 branch from 75429b2 to ef0b2ae Compare July 27, 2023 05:47
@sonarqubecloud
Copy link

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
1.7% 1.7% Duplication

private clipboardService: ClipboardService,
private translateService: TranslationService) {
private translateService: TranslationService,
@Inject(MAT_DATE_FORMATS) private dateFormatConfig: MatDateFormats) {
Copy link
Contributor

Choose a reason for hiding this comment

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

never ever do this, this is a singleton access to all the date time formats, changing it will change all components

@DenysVuika
Copy link
Contributor

closing as abandoned and of poor quality

@DenysVuika DenysVuika closed this Oct 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants