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
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
f8455a5
[ACS-4985] Added SearchFilterTabbedComponent and SearchDateRangeAdvan…
swapnil-verma-gl Jun 9, 2023
df1801d
[ACS-4985] Using widget-composite component now correctly updates the…
swapnil-verma-gl Jun 12, 2023
0bb2e00
[ACS-4985] Added compatibility of all search filters/facets with Sear…
swapnil-verma-gl Jun 13, 2023
839a718
[ACS-4985] Updated UI for search filters. Minor fixes
swapnil-verma-gl Jun 13, 2023
c54b4e1
[ACS-4985] Added test cases for SearchFilterTabbedComponent
swapnil-verma-gl Jun 13, 2023
9a37bd2
[ACS-4985] Added data-automation-id to search-date-range-advanced.com…
swapnil-verma-gl Jun 13, 2023
164a5a5
[ACS-4985] Added test cases for SearchFilterTabbedComponent. Added te…
swapnil-verma-gl Jun 13, 2023
ccb4b4c
[ACS-4985] Updated Labels for 'In last' date range option
swapnil-verma-gl Jun 14, 2023
9b38a8b
[ACS-4985] Added test cases for SearchDateRangeAdvancedComponent. Min…
swapnil-verma-gl Jun 14, 2023
2ae8b4b
[ACS-4985] Resolved minor issue where the reset method would still tr…
swapnil-verma-gl Jun 14, 2023
20f38a0
[ACS-4985] Added exports for SearchDateRangeAdvanced and SearchFilter…
swapnil-verma-gl Jun 14, 2023
c8e4e17
[ACS-4985] Updated imports in test cases
swapnil-verma-gl Jun 14, 2023
520c6e5
[ACS-4985] Migrated SearchDateRangeAdvancedComponent from moment.js t…
swapnil-verma-gl Jun 14, 2023
b45b133
[ACS-4985] Updated test cases for SearchDateRangeAdvancedComponent fr…
swapnil-verma-gl Jun 14, 2023
df598ea
[ACS-4985] Added license headers and re-ordered imports
swapnil-verma-gl Jun 14, 2023
406e1e6
[ACS-4985] Fixed erroneous imports
swapnil-verma-gl Jun 14, 2023
482adfb
[ACS-4985] Fixed test cases for SearchDateRangeAdvancedComponent.
swapnil-verma-gl Jun 14, 2023
f838267
[ACS-4985] Removed fdescribe test cases for SearchDateRangeAdvancedCo…
swapnil-verma-gl Jun 14, 2023
67ebf29
[ACS-4985] Updated date formats for SearchDateRangeAdvancedComponent
swapnil-verma-gl Jun 14, 2023
778809b
[ACS-4985] Updated test cases for changed date format
swapnil-verma-gl Jun 14, 2023
b59ea26
ACS-4985 Fixed issue with nx build, some clean ups, using changes in …
AleksanderSklorz Jun 21, 2023
18586bb
[ACS-4985] Updated test cases for SearchDateRangeAdvancedComponent. M…
swapnil-verma-gl Jun 26, 2023
5ca8856
[ACS-4985] Updated test cases for SearchFilterTabbedComponent. Added …
swapnil-verma-gl Jun 26, 2023
131b2bc
[ACS-4985] Added clear and apply button to SearchDateRangeAdvancedTab…
swapnil-verma-gl Jun 26, 2023
0b8a4d9
[ACS-4985] Added test cases for SearchDateRangeAdvancedTabbedComponen…
swapnil-verma-gl Jun 27, 2023
5574aef
[ACS-4985] Removed disableUpdateOnSubmit flag from search widgets
swapnil-verma-gl Jun 28, 2023
a00375a
[ACS-4985] Resolved minor issues where switching between tabs could s…
swapnil-verma-gl Jun 28, 2023
68047e4
[ACS-4985] Resolved linting and unit test issues
swapnil-verma-gl Jun 28, 2023
a75d6eb
[ACS-4985] Resolved PR review comments
swapnil-verma-gl Jun 28, 2023
05f2524
[ACS-4985] Removed unused code from base-query-builder.service.ts
swapnil-verma-gl Jul 4, 2023
b16fd58
[ACS-4985] Resolved PR review comments
swapnil-verma-gl Jul 4, 2023
884568e
[ACS-4985] Transferred business logic from SearchDateRangeAdvancedCom…
swapnil-verma-gl Jul 6, 2023
33575c5
[ACS-4985] Updated test cases for SearchDateRangeAdvancedTabbedComponent
swapnil-verma-gl Jul 6, 2023
f937cbf
[ACS-4985] Added borders to inputs
swapnil-verma-gl Jul 6, 2023
f62f74b
[ACS-4985] Fixed code smell in regex
swapnil-verma-gl Jul 10, 2023
c4aaa8f
[ACS-4985] Resolved lint issues
swapnil-verma-gl Jul 10, 2023
d4de517
[ACS-4985] Updated query generation logic. Now both 'In the last' and…
swapnil-verma-gl Jul 10, 2023
fd2ee24
[ACS-4985] Added missing null check when generating query
swapnil-verma-gl Jul 10, 2023
fb9c13a
[ACS-4985] Resolved issue where typing a special character after addi…
swapnil-verma-gl Jul 11, 2023
456b9d0
[ACS-4985] Added documentation to versionIndex.md and README.md
swapnil-verma-gl Jul 14, 2023
3a95445
[ACS-4985] Moved new components to v6.2.0 in versionIndex.md
swapnil-verma-gl Jul 14, 2023
8dd9ff5
[ACS-4985] Resolved e2e test failures
swapnil-verma-gl Jul 19, 2023
354b5a4
Testing global install of webdriver-manager for e2e webdriver fix
swapnil-verma-gl Jul 19, 2023
b08093a
[ACS-4985] Revert test fix for e2e execution. Updated search.config.t…
swapnil-verma-gl Jul 20, 2023
aa7daae
mat-datepicker component added and removed old mat-datetimepicker com…
jatin2008 Jul 11, 2023
7a66328
endof('day') addition when no time is present as we are using new dat…
jatin2008 Jul 11, 2023
14c339e
modification of test cases as per endof the day changes in new code
jatin2008 Jul 11, 2023
fa783e2
default date format setting changes as we now using new calendar
jatin2008 Jul 12, 2023
dcbe39a
date-fns implementation in card-view-datetime component and added/mod…
jatin2008 Jul 20, 2023
8f74b8a
minimized duplications for code redundancy in test cases
jatin2008 Jul 20, 2023
388b2ab
review changes addressed
jatin2008 Jul 21, 2023
5f0086c
review comments addressed
jatin2008 Jul 21, 2023
22153a1
duplicate code removed after rebasing my branch
jatin2008 Jul 24, 2023
ef0b2ae
added type MatDatepickerInputEvent for parameter $event
jatin2008 Jul 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,100 +1,113 @@
<label class="adf-property-label"
[attr.data-automation-id]="'card-dateitem-label-' + property.key"
*ngIf="showProperty() || isEditable()"
[attr.for]="'card-view-dateitem-' + property.key">
<label
class="adf-property-label"
[attr.data-automation-id]="'card-dateitem-label-' + property.key"
*ngIf="showProperty() || isEditable()"
[attr.for]="'card-view-dateitem-' + property.key">
{{ property.label | translate }}
</label>
<div class="adf-property-value adf-property-value-padding-top">
<span *ngIf="!isEditable() && !property.multivalued"
[attr.data-automation-id]="'card-' + property.type + '-value-' + property.key">
<span *ngIf="showProperty()"
[attr.data-automation-id]="'card-dateitem-' + property.key"
(dblclick)="copyToClipboard(property.displayValue)"
matTooltipShowDelay="1000"
[matTooltip]="'CORE.METADATA.ACTIONS.COPY_TO_CLIPBOARD' | translate">{{ property.displayValue}}</span>
<span
*ngIf="!isEditable() && !property.multivalued"
[attr.data-automation-id]="'card-' + property.type + '-value-' + property.key">
<span
*ngIf="showProperty()"
[attr.data-automation-id]="'card-dateitem-' + property.key"
(dblclick)="copyToClipboard(property.displayValue)"
matTooltipShowDelay="1000"
[matTooltip]="'CORE.METADATA.ACTIONS.COPY_TO_CLIPBOARD' | translate">
{{ property.displayValue}}
</span>
</span>
<div *ngIf="isEditable() && !property.multivalued"
class="adf-dateitem-editable">
<div *ngIf="isEditable() && !property.multivalued" class="adf-dateitem-editable">
<div class="adf-dateitem-editable-controls">
<span class="adf-datepicker-toggle"
[attr.data-automation-id]="'datepicker-label-toggle-' + property.key"
(click)="showDatePicker()">
<span *ngIf="showProperty(); else elseEmptyValueBlock"
[attr.data-automation-id]="'card-' + property.type + '-value-' + property.key">
{{ property.displayValue }}</span>
<span
class="adf-datepicker-toggle"
[attr.data-automation-id]="'datepicker-label-toggle-' + property.key"
(click)="showDatePicker()">
<span
*ngIf="showProperty(); else elseEmptyValueBlock"
[attr.data-automation-id]="'card-' + property.type + '-value-' + property.key">
{{ property.displayValue }}
</span>
</span>

<mat-icon *ngIf="showClearAction()"
class="adf-date-reset-icon"
(click)="onDateClear()"
[attr.title]="'CORE.METADATA.ACTIONS.CLEAR' | translate"
[attr.data-automation-id]="'datepicker-date-clear-' + property.key">
<mat-icon
*ngIf="showClearAction()"
class="adf-date-reset-icon"
(click)="onDateClear()"
[attr.title]="'CORE.METADATA.ACTIONS.CLEAR' | translate"
[attr.data-automation-id]="'datepicker-date-clear-' + property.key">
clear
</mat-icon>

<mat-datetimepicker-toggle [attr.tabindex]="-1"
[attr.title]="'CORE.METADATA.ACTIONS.EDIT' | translate"
[attr.data-automation-id]="'datepickertoggle-' + property.key"
[for]="datetimePicker">
</mat-datetimepicker-toggle>
<mat-datepicker-toggle
[attr.tabindex]="-1"
[attr.title]="'CORE.METADATA.ACTIONS.EDIT' | translate"
[attr.data-automation-id]="'datepickertoggle-' + property.key"
[for]="datePicker">
</mat-datepicker-toggle>
</div>

<input class="adf-invisible-date-input"
[attr.tabIndex]="-1"
[matDatetimepicker]="datetimePicker"
[value]="valueDate"
(dateChange)="onDateChanged($event)"
[attr.id]="'card-view-dateitem-' + property.key"
>
<input
class="adf-invisible-date-input"
[attr.tabIndex]="-1"
[matDatepicker]="datePicker"
[value]="valueDate"
(dateChange)="onDateChanged($event)"
[attr.id]="'card-view-dateitem-' + property.key">

<mat-datetimepicker #datetimePicker
[type]="$any(property).type"
[timeInterval]="5"
[attr.data-automation-id]="'datepicker-' + property.key"
[startAt]="valueDate">
</mat-datetimepicker>
<mat-datepicker
#datePicker
[attr.data-automation-id]="'datepicker-' + property.key"
[startAt]="valueDate">
</mat-datepicker>
</div>
<ng-template #elseEmptyValueBlock>
{{ property.default | translate }}
</ng-template>

<div *ngIf="property.multivalued"
class="adf-property-field adf-dateitem-chip-list-container adf-dateitem-editable">
<mat-chip-list #chipList
class="adf-textitem-chip-list">
<mat-chip *ngFor="let propertyValue of property.displayValue; let idx = index"
[removable]="isEditable()"
(removed)="removeValueFromList(idx)">
<div
*ngIf="property.multivalued"
class="adf-property-field adf-dateitem-chip-list-container adf-dateitem-editable">
<mat-chip-list #chipList class="adf-textitem-chip-list">
<mat-chip
*ngFor="let propertyValue of property.displayValue; let idx = index"
[removable]="isEditable()"
(removed)="removeValueFromList(idx)">
{{ propertyValue }}
<mat-icon *ngIf="isEditable()"
matChipRemove>cancel</mat-icon>
<mat-icon
*ngIf="isEditable()"
matChipRemove>
cancel
</mat-icon>
</mat-chip>
</mat-chip-list>

<mat-form-field *ngIf="isEditable()"
class="adf-property-field adf-dateitem-editable-controls"
[floatLabel]="'never'"
(click)="showDatePicker()">
<input matInput
class="adf-invisible-date-input"
[attr.tabIndex]="-1"
[matDatetimepicker]="datetimePicker"
(dateChange)="addDateToList($event)"
[attr.id]="'card-view-dateitem-' + property.key"
>
<mat-datetimepicker-toggle [attr.tabindex]="-1"
matSuffix
[attr.title]="'CORE.METADATA.ACTIONS.EDIT' | translate"
[attr.data-automation-id]="'datepickertoggle-' + property.key"
[for]="datetimePicker">
</mat-datetimepicker-toggle>
<mat-form-field
*ngIf="isEditable()"
class="adf-property-field adf-dateitem-editable-controls"
[floatLabel]="'never'"
(click)="showDatePicker()">
<input
matInput
class="adf-invisible-date-input"
[attr.tabIndex]="-1"
[matDatepicker]="datePicker"
(dateChange)="addDateToList($event)"
[attr.id]="'card-view-dateitem-' + property.key">
<mat-datepicker-toggle
[attr.tabindex]="-1"
matSuffix
[attr.title]="'CORE.METADATA.ACTIONS.EDIT' | translate"
[attr.data-automation-id]="'datepickertoggle-' + property.key"
[for]="datePicker">
</mat-datepicker-toggle>

<mat-datetimepicker #datetimePicker
[type]="$any(property).type"
[timeInterval]="5"
[attr.data-automation-id]="'datepicker-' + property.key"
[startAt]="valueDate">
</mat-datetimepicker>
<mat-datepicker
#datePicker
[attr.data-automation-id]="'datepicker-' + property.key"
[startAt]="valueDate">
</mat-datepicker>
</mat-form-field>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@

import { ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import moment from 'moment';
import { CardViewDateItemModel } from '../../models/card-view-dateitem.model';
import { CardViewUpdateService } from '../../services/card-view-update.service';
import { CardViewDateItemComponent } from './card-view-dateitem.component';
import { CoreTestingModule } from '../../../testing/core.testing.module';
import { ClipboardService } from '../../../clipboard/clipboard.service';
import { CardViewDatetimeItemModel } from '../../models/card-view-datetimeitem.model';
import { TranslateModule } from '@ngx-translate/core';
import { AppConfigService } from '@alfresco/adf-core';
import { endOfDay, startOfDay } from 'date-fns';
import { CardViewDatetimeItemModel } from '../../models/card-view-datetimeitem.model';

describe('CardViewDateItemComponent', () => {

Expand Down Expand Up @@ -61,7 +61,25 @@ describe('CardViewDateItemComponent', () => {

afterEach(() => fixture.destroy());

it('should pick date format from appConfigService', () => {
const updateDateTime = (key: string): Date => {
component.property.key = key;
component.dateFormat = 'M/d/yy, h:mm a';
component.property.value = new Date('Jul 10 2017 00:01:00');
const expectedDate = new Date('Jul 10 2018');
fixture.detectChanges();

const element = fixture.debugElement.nativeElement.querySelector(`span[data-automation-id="card-date-value-${key}"]`);
expect(element).toBeDefined();
expect(element.innerText).toEqual('Jul 10, 2017');
component.onDateChanged({ value: expectedDate });

fixture.detectChanges();
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.

// eslint-disable-next-line ban/ban
xit('should pick date format from appConfigService', () => {
expect(component.dateFormat).toEqual('shortDate');
});

Expand Down Expand Up @@ -192,15 +210,16 @@ describe('CardViewDateItemComponent', () => {
const itemUpdatedSpy = spyOn(cardViewUpdateService.itemUpdated$, 'next');
component.editable = true;
component.property.editable = true;
const expectedDate = moment('Jul 10 2017', 'MMM DD YYYY');
component.property.value = endOfDay(new Date('Jul 10 2017'));
const expectedDate = new Date('Jul 10 2017');
fixture.detectChanges();
const property = { ...component.property };

component.onDateChanged({ value: expectedDate });
expect(itemUpdatedSpy).toHaveBeenCalledWith({
target: property,
changed: {
dateKey: expectedDate.toDate()
dateKey: endOfDay(expectedDate)
}
});
});
Expand All @@ -209,13 +228,13 @@ describe('CardViewDateItemComponent', () => {
component.editable = true;
component.property.editable = true;
component.property.value = null;
const expectedDate = moment('Jul 10 2017', 'MMM DD YY');
const expectedDate = new Date('Jul 10 2017');
fixture.detectChanges();

component.onDateChanged({ value: expectedDate });

await fixture.whenStable();
expect(component.property.value).toEqual(expectedDate.toDate());
expect(component.property.value).toEqual(endOfDay(expectedDate));
});

it('should copy value to clipboard on double click', () => {
Expand Down Expand Up @@ -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

component.editable = true;
component.property.editable = true;
component.property.default = 'Jul 10 2017 00:01:00';
component.property.key = 'fake-key';
component.dateFormat = 'M/d/yy, h:mm a';
component.property.value = 'Jul 10 2017 00:01:00';
const expectedDate = moment('Jul 10 2018', 'MMM DD YY h:m:s');
fixture.detectChanges();

await fixture.whenStable();
fixture.detectChanges();
const element = fixture.debugElement.nativeElement.querySelector('span[data-automation-id="card-date-value-fake-key"]');
expect(element).toBeDefined();
expect(element.innerText).toEqual('Jul 10, 2017');
component.onDateChanged({ value: expectedDate });

fixture.detectChanges();
expect(component.property.value).toEqual(expectedDate.toDate());
it('should set date as end of the day when proprty is not `properties.cm:from`', async () => {
const expectedDate = updateDateTime('fake-key');
expect(component.property.value).toEqual(endOfDay(expectedDate));
});

it('should render chips for multivalue dates when chips are enabled', async () => {
Expand Down Expand Up @@ -372,4 +375,9 @@ describe('CardViewDateItemComponent', () => {
expect(valueChips[1].nativeElement.innerText.trim()).toBe('Jul 11, 2017, 0:01');
expect(valueChips[2].nativeElement.innerText.trim()).toBe('Jul 12, 2017, 0:01');
});

it('should set date as start of the day when proprty is `properties.cm:from`', async () => {
const expectedDate = updateDateTime('properties.cm:from');
expect(component.property.value).toEqual(startOfDay(expectedDate));
});
});
Loading