mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
[ACS-5645]code modification
This commit is contained in:
@@ -33,7 +33,7 @@ export class MetadataViewPage {
|
|||||||
author = $(`[data-automation-id='card-textitem-value-properties.cm:author']`);
|
author = $(`[data-automation-id='card-textitem-value-properties.cm:author']`);
|
||||||
titleProperty = $(`span[data-automation-id='card-textitem-value-properties.cm:title'] span`);
|
titleProperty = $(`span[data-automation-id='card-textitem-value-properties.cm:title'] span`);
|
||||||
editIcon = $(`button[data-automation-id='meta-data-card-toggle-edit']`);
|
editIcon = $(`button[data-automation-id='meta-data-card-toggle-edit']`);
|
||||||
editIconGeneral = $(`button[data-automation-id='meta-data-generalInfo-edit']`);
|
editIconGeneral = $(`button[data-automation-id='meta-data-general-info-edit']`);
|
||||||
informationButton = $(`button[data-automation-id='meta-data-card-toggle-expand']`);
|
informationButton = $(`button[data-automation-id='meta-data-card-toggle-expand']`);
|
||||||
informationSpan = $(`span[data-automation-id='meta-data-card-toggle-expand-label']`);
|
informationSpan = $(`span[data-automation-id='meta-data-card-toggle-expand-label']`);
|
||||||
informationIcon = $(`span[data-automation-id='meta-data-card-toggle-expand-label'] ~ mat-icon`);
|
informationIcon = $(`span[data-automation-id='meta-data-card-toggle-expand-label'] ~ mat-icon`);
|
||||||
@@ -119,7 +119,7 @@ export class MetadataViewPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async editIconGeneralClick(): Promise<void> {
|
async editIconGeneralClick(): Promise<void> {
|
||||||
await BrowserActions.clickExecuteScript('button[data-automation-id="meta-data-generalInfo-edit"]');
|
await BrowserActions.click(this.editIconGeneral);
|
||||||
}
|
}
|
||||||
|
|
||||||
async informationButtonIsDisplayed(): Promise<void> {
|
async informationButtonIsDisplayed(): Promise<void> {
|
||||||
|
|||||||
+2
-2
@@ -220,7 +220,7 @@ describe('CategoriesManagementComponent', () => {
|
|||||||
component.categoryNameControlVisible = true;
|
component.categoryNameControlVisible = true;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
it('should be hidden initially', () => {
|
it('should not hide category name control when categoryNameControlVisible is false', () => {
|
||||||
component.categoryNameControlVisible = false;
|
component.categoryNameControlVisible = false;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
const categoryControl: HTMLDivElement = fixture.debugElement.query(By.css('.adf-category-name-field')).nativeElement;
|
const categoryControl: HTMLDivElement = fixture.debugElement.query(By.css('.adf-category-name-field')).nativeElement;
|
||||||
@@ -308,7 +308,7 @@ describe('CategoriesManagementComponent', () => {
|
|||||||
it('should have no required validator set for category control', () => {
|
it('should have no required validator set for category control', () => {
|
||||||
expect(component.categoryNameControl.hasValidator(Validators.required)).toBeFalse();
|
expect(component.categoryNameControl.hasValidator(Validators.required)).toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display validation error when searching for empty category', fakeAsync(() => {
|
it('should display validation error when searching for empty category', fakeAsync(() => {
|
||||||
typeCategory(' ');
|
typeCategory(' ');
|
||||||
|
|
||||||
|
|||||||
+16
-16
@@ -21,19 +21,19 @@
|
|||||||
(click)="toggleGeneralEdit($event)"
|
(click)="toggleGeneralEdit($event)"
|
||||||
[attr.title]="'CORE.METADATA.ACTIONS.EDIT' | translate"
|
[attr.title]="'CORE.METADATA.ACTIONS.EDIT' | translate"
|
||||||
[attr.aria-label]="'CORE.METADATA.ACCESSIBILITY.EDIT' | translate"
|
[attr.aria-label]="'CORE.METADATA.ACCESSIBILITY.EDIT' | translate"
|
||||||
data-automation-id="meta-data-generalInfo-edit"
|
data-automation-id="meta-data-general-info-edit"
|
||||||
class="adf-edit-icon-buttons">
|
class="adf-edit-icon-buttons">
|
||||||
<mat-icon>mode_edit</mat-icon>
|
<mat-icon>mode_edit</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
<div *ngIf="editable"
|
<div *ngIf="editable"
|
||||||
class="adf-metadata-action-buttons">
|
class="adf-metadata-action-buttons">
|
||||||
<button mat-icon-button
|
<button mat-icon-button
|
||||||
(click)="cancelGeneralInfoChanges($event)"
|
(click)="cancelEditChanges('generalInfo', $event)"
|
||||||
data-automation-id="reset-metadata">
|
data-automation-id="reset-metadata">
|
||||||
<mat-icon>clear</mat-icon>
|
<mat-icon>clear</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
<button mat-icon-button
|
<button mat-icon-button
|
||||||
(click)="saveGeneralInfoChanges($event)"
|
(click)="saveEditChanges('generalInfo', $event)"
|
||||||
color="primary"
|
color="primary"
|
||||||
data-automation-id="save-generalInfo-metadata"
|
data-automation-id="save-generalInfo-metadata"
|
||||||
[disabled]="!hasMetadataChanged">
|
[disabled]="!hasMetadataChanged">
|
||||||
@@ -54,8 +54,8 @@
|
|||||||
</mat-expansion-panel>
|
</mat-expansion-panel>
|
||||||
<ng-container *ngIf="displayTags">
|
<ng-container *ngIf="displayTags">
|
||||||
<mat-expansion-panel
|
<mat-expansion-panel
|
||||||
(opened)="handleTagPanelOpen()"
|
(opened)="handleTagsPanelState(true)"
|
||||||
(closed)="handleTagPanelClose()"
|
(closed)="handleTagsPanelState(false)"
|
||||||
hideToggle
|
hideToggle
|
||||||
[expanded]="tagsPanelState">
|
[expanded]="tagsPanelState">
|
||||||
<mat-expansion-panel-header>
|
<mat-expansion-panel-header>
|
||||||
@@ -80,12 +80,12 @@
|
|||||||
</div>
|
</div>
|
||||||
<div *ngIf="editableTags" class="adf-metadata-action-buttons">
|
<div *ngIf="editableTags" class="adf-metadata-action-buttons">
|
||||||
<button mat-icon-button
|
<button mat-icon-button
|
||||||
(click)="CancelTagsChanges($event)"
|
(click)="cancelEditChanges('tags', $event)"
|
||||||
data-automation-id="reset-metadata">
|
data-automation-id="reset-tags-metadata">
|
||||||
<mat-icon>clear</mat-icon>
|
<mat-icon>clear</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
<button mat-icon-button
|
<button mat-icon-button
|
||||||
(click)="saveTagsChanges($event)"
|
(click)="saveEditChanges('tags', $event)"
|
||||||
color="primary"
|
color="primary"
|
||||||
data-automation-id="save-tags-metadata"
|
data-automation-id="save-tags-metadata"
|
||||||
[disabled]="!hasMetadataChanged">
|
[disabled]="!hasMetadataChanged">
|
||||||
@@ -115,8 +115,8 @@
|
|||||||
</ng-container>
|
</ng-container>
|
||||||
<ng-container *ngIf="displayCategories">
|
<ng-container *ngIf="displayCategories">
|
||||||
<mat-expansion-panel
|
<mat-expansion-panel
|
||||||
(opened)="handleCategoryPanelOpen()"
|
(opened)="handleCategoriesPanelState(true)"
|
||||||
(closed)="handleCategoryPanelClose()"
|
(closed)="handleCategoriesPanelState(false)"
|
||||||
hideToggle
|
hideToggle
|
||||||
[expanded]="categoriesPanelState">
|
[expanded]="categoriesPanelState">
|
||||||
<mat-expansion-panel-header>
|
<mat-expansion-panel-header>
|
||||||
@@ -140,12 +140,12 @@
|
|||||||
</div>
|
</div>
|
||||||
<div *ngIf="editableCategories" class="adf-metadata-action-buttons">
|
<div *ngIf="editableCategories" class="adf-metadata-action-buttons">
|
||||||
<button mat-icon-button
|
<button mat-icon-button
|
||||||
(click)="cancelCategoriesChanges($event)"
|
(click)="cancelEditChanges('categories', $event)"
|
||||||
data-automation-id="reset-metadata">
|
data-automation-id="reset-metadata">
|
||||||
<mat-icon>clear</mat-icon>
|
<mat-icon>clear</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
<button mat-icon-button
|
<button mat-icon-button
|
||||||
(click)="saveCategoriesChanges($event)"
|
(click)="saveEditChanges('categories', $event)"
|
||||||
color="primary"
|
color="primary"
|
||||||
data-automation-id="save-categories-metadata"
|
data-automation-id="save-categories-metadata"
|
||||||
[disabled]="!hasMetadataChanged">
|
[disabled]="!hasMetadataChanged">
|
||||||
@@ -185,8 +185,8 @@
|
|||||||
<mat-expansion-panel
|
<mat-expansion-panel
|
||||||
[attr.data-automation-id]="'adf-metadata-group-' + group.title"
|
[attr.data-automation-id]="'adf-metadata-group-' + group.title"
|
||||||
[expanded]="canExpandTheCard(group) || !displayDefaultProperties && first || group.expanded"
|
[expanded]="canExpandTheCard(group) || !displayDefaultProperties && first || group.expanded"
|
||||||
(opened)="group.expanded= true"
|
(opened)="group.expanded = true"
|
||||||
(closed)="group.expanded= false"
|
(closed)="group.expanded = false"
|
||||||
hideToggle>
|
hideToggle>
|
||||||
<mat-expansion-panel-header>
|
<mat-expansion-panel-header>
|
||||||
<div class="adf-metadata-properties-panel-content">
|
<div class="adf-metadata-properties-panel-content">
|
||||||
@@ -207,12 +207,12 @@
|
|||||||
</button>
|
</button>
|
||||||
<div class="adf-metadata-action-buttons" *ngIf="group.editable">
|
<div class="adf-metadata-action-buttons" *ngIf="group.editable">
|
||||||
<button mat-icon-button
|
<button mat-icon-button
|
||||||
(click)="cancelGroupChanges(group, $event)"
|
(click)="cancelEditChanges('group', $event, group)"
|
||||||
data-automation-id="reset-metadata">
|
data-automation-id="reset-metadata">
|
||||||
<mat-icon>clear</mat-icon>
|
<mat-icon>clear</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
<button mat-icon-button
|
<button mat-icon-button
|
||||||
(click)="saveGroupChanges(group, $event)"
|
(click)="saveEditChanges('group', $event, group)"
|
||||||
color="primary"
|
color="primary"
|
||||||
data-automation-id="save-metadata"
|
data-automation-id="save-metadata"
|
||||||
[disabled]="!hasMetadataChanged">
|
[disabled]="!hasMetadataChanged">
|
||||||
|
|||||||
+6
-8
@@ -123,14 +123,12 @@
|
|||||||
|
|
||||||
.acs-details-container {
|
.acs-details-container {
|
||||||
.mat-tab-body-content {
|
.mat-tab-body-content {
|
||||||
.adf-content-metadata-card {
|
.adf-metadata-properties {
|
||||||
.adf-metadata-properties {
|
.mat-expansion-panel {
|
||||||
.mat-expansion-panel {
|
width: 755px;
|
||||||
width: 755px;
|
border: 1px solid var(--adf-metadata-property-panel-border-color);
|
||||||
border: 1px solid var(--adf-metadata-property-panel-border-color);
|
margin: 24px;
|
||||||
margin: 24px;
|
border-radius: 12px !important;
|
||||||
border-radius: 12px !important;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+67
-44
@@ -76,6 +76,7 @@ describe('ContentMetadataComponent', () => {
|
|||||||
const findTagElements = (): DebugElement[] => fixture.debugElement.queryAll(By.css('.adf-metadata-properties .adf-metadata-properties-tag'));
|
const findTagElements = (): DebugElement[] => fixture.debugElement.queryAll(By.css('.adf-metadata-properties .adf-metadata-properties-tag'));
|
||||||
|
|
||||||
const findCancelButton = (): HTMLButtonElement => fixture.debugElement.query(By.css('[data-automation-id=reset-metadata]')).nativeElement;
|
const findCancelButton = (): HTMLButtonElement => fixture.debugElement.query(By.css('[data-automation-id=reset-metadata]')).nativeElement;
|
||||||
|
const findCancelTagsButton = (): HTMLButtonElement => fixture.debugElement.query(By.css('[data-automation-id=reset-tags-metadata]')).nativeElement;
|
||||||
|
|
||||||
const clickOnCancel = () => {
|
const clickOnCancel = () => {
|
||||||
findCancelButton().click();
|
findCancelButton().click();
|
||||||
@@ -302,7 +303,7 @@ describe('ContentMetadataComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
findTagsCreator().tagsChange.emit([tagName1, tagName2]);
|
findTagsCreator().tagsChange.emit([tagName1, tagName2]);
|
||||||
const mockEvent = new Event('click');
|
const mockEvent = new Event('click');
|
||||||
component.saveTagsChanges(mockEvent);
|
component.saveChanges(mockEvent);
|
||||||
|
|
||||||
const tag1 = new TagBody();
|
const tag1 = new TagBody();
|
||||||
tag1.tag = tagName1;
|
tag1.tag = tagName1;
|
||||||
@@ -312,7 +313,7 @@ describe('ContentMetadataComponent', () => {
|
|||||||
expect(tagService.assignTagsToNode).toHaveBeenCalledWith(node.id, [tag1, tag2]);
|
expect(tagService.assignTagsToNode).toHaveBeenCalledWith(node.id, [tag1, tag2]);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should call getTagsByNodeId on TagService on save click', async() => {
|
it('should call getTagsByNodeId on TagService on save click', () => {
|
||||||
component.editableTags = true;
|
component.editableTags = true;
|
||||||
component.displayTags = true;
|
component.displayTags = true;
|
||||||
const property = { key: 'properties.property-key', value: 'original-value' } as CardViewBaseItemModel;
|
const property = { key: 'properties.property-key', value: 'original-value' } as CardViewBaseItemModel;
|
||||||
@@ -330,7 +331,7 @@ describe('ContentMetadataComponent', () => {
|
|||||||
findTagsCreator().tagsChange.emit([tagPaging.list.entries[0].entry.tag, 'New tag 3']);
|
findTagsCreator().tagsChange.emit([tagPaging.list.entries[0].entry.tag, 'New tag 3']);
|
||||||
getTagsByNodeIdSpy.calls.reset();
|
getTagsByNodeIdSpy.calls.reset();
|
||||||
const mockEvent = new Event('click');
|
const mockEvent = new Event('click');
|
||||||
component.saveTagsChanges(mockEvent);
|
component.saveChanges(mockEvent);
|
||||||
|
|
||||||
expect(tagService.getTagsByNodeId).toHaveBeenCalledWith(node.id);
|
expect(tagService.getTagsByNodeId).toHaveBeenCalledWith(node.id);
|
||||||
});
|
});
|
||||||
@@ -432,81 +433,106 @@ describe('ContentMetadataComponent', () => {
|
|||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('saveChanges', () => {
|
describe('saveEditChanges', () => {
|
||||||
it('should save general info changes and toggle editable', () => {
|
it('should save general info changes and toggle editable flag', () => {
|
||||||
const event = new Event('click');
|
const event = new Event('click');
|
||||||
spyOn(component, 'saveChanges');
|
const buttonType = 'generalInfo';
|
||||||
component.editable = true;
|
component.editable = true;
|
||||||
component.saveGeneralInfoChanges(event);
|
|
||||||
|
spyOn(component, 'saveChanges');
|
||||||
|
component.saveEditChanges(buttonType, event);
|
||||||
|
|
||||||
expect(component.saveChanges).toHaveBeenCalledWith(event);
|
expect(component.saveChanges).toHaveBeenCalledWith(event);
|
||||||
expect(component.editable).toBe(false);
|
expect(component.editable).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should save tags changes and toggle editableTags', () => {
|
it('should save tags changes and toggle editableTags flag', () => {
|
||||||
const event = new Event('click');
|
const event = new Event('click');
|
||||||
spyOn(component, 'saveChanges');
|
const buttonType = 'tags';
|
||||||
component.editableTags = true;
|
component.editableTags = true;
|
||||||
component.saveTagsChanges(event);
|
|
||||||
|
spyOn(component, 'saveChanges');
|
||||||
|
component.saveEditChanges(buttonType, event);
|
||||||
|
|
||||||
expect(component.saveChanges).toHaveBeenCalledWith(event);
|
expect(component.saveChanges).toHaveBeenCalledWith(event);
|
||||||
expect(component.editableTags).toBe(false);
|
expect(component.editableTags).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should save categories changes and toggle editableCategories', () => {
|
it('should save categories changes and toggle editableCategories flag', () => {
|
||||||
const event = new Event('click');
|
const event = new Event('click');
|
||||||
spyOn(component, 'saveChanges');
|
const buttonType = 'categories';
|
||||||
component.editableCategories = true;
|
component.editableCategories = true;
|
||||||
component.saveCategoriesChanges(event);
|
|
||||||
|
spyOn(component, 'saveChanges');
|
||||||
|
component.saveEditChanges(buttonType, event);
|
||||||
|
|
||||||
expect(component.saveChanges).toHaveBeenCalledWith(event);
|
expect(component.saveChanges).toHaveBeenCalledWith(event);
|
||||||
expect(component.editableTags).toBe(false);
|
expect(component.editableCategories).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should save group changes and toggle group.editable', () => {
|
it('should save group changes and toggle editable flag', () => {
|
||||||
const group = { editable: true };
|
const group = { editable: true };
|
||||||
const event = new Event('click');
|
const event = new Event('click');
|
||||||
|
const buttonType = 'group';
|
||||||
|
|
||||||
spyOn(component, 'saveChanges');
|
spyOn(component, 'saveChanges');
|
||||||
component.saveGroupChanges(group, event);
|
component.saveEditChanges(buttonType, event, group);
|
||||||
|
|
||||||
expect(component.saveChanges).toHaveBeenCalledWith(event);
|
expect(component.saveChanges).toHaveBeenCalledWith(event);
|
||||||
expect(group.editable).toBe(false);
|
expect(group.editable).toBe(false);
|
||||||
});
|
});
|
||||||
})
|
});
|
||||||
|
|
||||||
describe('cancelChanges', () => {
|
describe('cancelChanges', () => {
|
||||||
it('should cancel group changes and set group editable to false', () => {
|
it('should cancel group changes and set group editable to false', () => {
|
||||||
const group = { editable: true };
|
const group = { editable: true };
|
||||||
const event = new Event('click');
|
const event = new Event('click');
|
||||||
|
const buttonType = 'group';
|
||||||
|
|
||||||
spyOn(component, 'cancelChanges');
|
spyOn(component, 'cancelChanges');
|
||||||
component.cancelGroupChanges(group, event);
|
component.cancelEditChanges(buttonType, event, group);
|
||||||
|
|
||||||
expect(component.cancelChanges).toHaveBeenCalledWith(event);
|
expect(component.cancelChanges).toHaveBeenCalledWith(event);
|
||||||
expect(group.editable).toBe(false);
|
expect(group.editable).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should cancel general info changes and toggle editable', () => {
|
it('should cancel general info changes and toggle editable flag', () => {
|
||||||
const event = new Event('click');
|
const event = new Event('click');
|
||||||
|
const buttonType = 'generalInfo';
|
||||||
|
component.editable = true;
|
||||||
|
|
||||||
spyOn(component, 'cancelChanges');
|
spyOn(component, 'cancelChanges');
|
||||||
component.editable= true;
|
component.cancelEditChanges(buttonType, event);
|
||||||
component.cancelGeneralInfoChanges(event);
|
|
||||||
expect(component.cancelChanges).toHaveBeenCalledWith(event);
|
expect(component.cancelChanges).toHaveBeenCalledWith(event);
|
||||||
expect(component.editable).toBe(false);
|
expect(component.editable).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should cancel tags changes and toggle editableTags', () => {
|
it('should cancel tags changes and toggle editableTags flag', () => {
|
||||||
const event = new Event('click');
|
const event = new Event('click');
|
||||||
spyOn(component, 'cancelChanges');
|
const buttonType = 'tags';
|
||||||
component.editableTags = true;
|
component.editableTags = true;
|
||||||
component.CancelTagsChanges(event);
|
|
||||||
|
spyOn(component, 'cancelChanges');
|
||||||
|
component.cancelEditChanges(buttonType, event);
|
||||||
|
|
||||||
expect(component.cancelChanges).toHaveBeenCalledWith(event);
|
expect(component.cancelChanges).toHaveBeenCalledWith(event);
|
||||||
expect(component.editableTags).toBe(false);
|
expect(component.editableTags).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should cancel categories changes and toggle editableCategories', () => {
|
it('should cancel categories changes and toggle editableCategories flag', () => {
|
||||||
const event = new Event('click');
|
const event = new Event('click');
|
||||||
spyOn(component, 'cancelChanges');
|
const buttonType = 'categories';
|
||||||
component.editableCategories = true;
|
component.editableCategories = true;
|
||||||
component.cancelCategoriesChanges(event);
|
|
||||||
|
spyOn(component, 'cancelChanges');
|
||||||
|
component.cancelEditChanges(buttonType, event);
|
||||||
|
|
||||||
expect(component.cancelChanges).toHaveBeenCalledWith(event);
|
expect(component.cancelChanges).toHaveBeenCalledWith(event);
|
||||||
expect(component.editableCategories).toBe(false);
|
expect(component.editableCategories).toBe(false);
|
||||||
});
|
});
|
||||||
})
|
});
|
||||||
|
|
||||||
|
|
||||||
describe('editing', () => {
|
describe('editing', () => {
|
||||||
it('should toggle categories edit and set categoriesPanelState accordingly', () => {
|
it('should toggle categories edit and set categoriesPanelState accordingly', () => {
|
||||||
@@ -729,7 +755,7 @@ describe('ContentMetadataComponent', () => {
|
|||||||
|
|
||||||
it('should display card views group when there is at least one property that is not empty', async () => {
|
it('should display card views group when there is at least one property that is not empty', async () => {
|
||||||
component.expanded = true;
|
component.expanded = true;
|
||||||
spyOn(contentMetadataService, 'getGroupedProperties');
|
spyOn(contentMetadataService, 'getGroupedProperties').and.stub();
|
||||||
|
|
||||||
component.ngOnChanges({ node: new SimpleChange(node, expectedNode, false) });
|
component.ngOnChanges({ node: new SimpleChange(node, expectedNode, false) });
|
||||||
|
|
||||||
@@ -1118,7 +1144,6 @@ describe('ContentMetadataComponent', () => {
|
|||||||
it('should render tags after loading tags in ngOnInit', () => {
|
it('should render tags after loading tags in ngOnInit', () => {
|
||||||
spyOn(tagService, 'getTagsByNodeId').and.returnValue(of(tagPaging));
|
spyOn(tagService, 'getTagsByNodeId').and.returnValue(of(tagPaging));
|
||||||
component.ngOnInit();
|
component.ngOnInit();
|
||||||
fixture.whenStable();
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
const tagElements = findTagElements();
|
const tagElements = findTagElements();
|
||||||
expect(tagElements).toHaveSize(2);
|
expect(tagElements).toHaveSize(2);
|
||||||
@@ -1195,9 +1220,7 @@ describe('ContentMetadataComponent', () => {
|
|||||||
tick(500);
|
tick(500);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
spyOn(tagService, 'getTagsByNodeId').and.returnValue(of(tagPaging));
|
spyOn(tagService, 'getTagsByNodeId').and.returnValue(of(tagPaging));
|
||||||
|
findCancelTagsButton().click();
|
||||||
const mockEvent = new Event('click');
|
|
||||||
component.CancelTagsChanges(mockEvent);
|
|
||||||
component.editableTags = false;
|
component.editableTags = false;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
const tagElements = findTagElements();
|
const tagElements = findTagElements();
|
||||||
@@ -1249,7 +1272,7 @@ describe('ContentMetadataComponent', () => {
|
|||||||
it('should enable cancel button after emitting tagsChange event', () => {
|
it('should enable cancel button after emitting tagsChange event', () => {
|
||||||
tagsCreator.tagsChange.emit(['New tag 1', 'New tag 2', 'New tag 3']);
|
tagsCreator.tagsChange.emit(['New tag 1', 'New tag 2', 'New tag 3']);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(findCancelButton().disabled).toBeFalse();
|
expect(findCancelTagsButton().disabled).toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should enable save button after emitting tagsChange event', () => {
|
it('should enable save button after emitting tagsChange event', () => {
|
||||||
@@ -1270,7 +1293,7 @@ describe('ContentMetadataComponent', () => {
|
|||||||
expect(tagsCreator.disabledTagsRemoving).toBeTrue();
|
expect(tagsCreator.disabledTagsRemoving).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have assigned false to disabledTagsRemoving if forkJoin fails', fakeAsync(() => {
|
it('should have assigned false to disabledTagsRemoving if forkJoin fails', () => {
|
||||||
const property = { key: 'properties.property-key', value: 'original-value' } as CardViewBaseItemModel;
|
const property = { key: 'properties.property-key', value: 'original-value' } as CardViewBaseItemModel;
|
||||||
const expectedNode = { ...node, name: 'some-modified-value' };
|
const expectedNode = { ...node, name: 'some-modified-value' };
|
||||||
spyOn(nodesApiService, 'updateNode').and.returnValue(of(expectedNode));
|
spyOn(nodesApiService, 'updateNode').and.returnValue(of(expectedNode));
|
||||||
@@ -1289,7 +1312,7 @@ describe('ContentMetadataComponent', () => {
|
|||||||
clickOnTagsSave();
|
clickOnTagsSave();
|
||||||
|
|
||||||
expect(tagsCreator.disabledTagsRemoving).toBeFalse();
|
expect(tagsCreator.disabledTagsRemoving).toBeFalse();
|
||||||
}));
|
});
|
||||||
|
|
||||||
it('should have assigned false to tagNameControlVisible after clicking on update button', () => {
|
it('should have assigned false to tagNameControlVisible after clicking on update button', () => {
|
||||||
tagsCreator.tagNameControlVisibleChange.emit(true);
|
tagsCreator.tagNameControlVisibleChange.emit(true);
|
||||||
|
|||||||
+47
-49
@@ -273,24 +273,28 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
saveGeneralInfoChanges(event:Event) {
|
saveEditChanges(buttonType: string, event: Event, group?: any) {
|
||||||
this.saveChanges(event);
|
this.saveChanges(event);
|
||||||
this.editable = !this.editable;
|
|
||||||
}
|
switch (buttonType) {
|
||||||
|
case 'generalInfo':
|
||||||
saveTagsChanges(event: Event) {
|
this.editable = !this.editable;
|
||||||
this.saveChanges(event);
|
break;
|
||||||
this.editableTags = !this.editableTags;
|
case 'tags':
|
||||||
}
|
this.editableTags = !this.editableTags;
|
||||||
|
break;
|
||||||
saveCategoriesChanges(event: Event) {
|
case 'categories':
|
||||||
this.saveChanges(event);
|
this.editableCategories = !this.editableCategories;
|
||||||
this.editableCategories = !this.editableCategories;
|
break;
|
||||||
}
|
case 'group':
|
||||||
|
if (group) {
|
||||||
saveGroupChanges(group: any, event:Event) {
|
group.editable = !group.editable;
|
||||||
this.saveChanges(event);
|
}
|
||||||
group.editable = !group.editable;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -328,24 +332,28 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
|
|||||||
this.loadProperties(this.node);
|
this.loadProperties(this.node);
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelGroupChanges(group: any, event: Event) {
|
cancelEditChanges(buttonType: string, event: Event, group?: any) {
|
||||||
this.cancelChanges(event);
|
this.cancelChanges(event);
|
||||||
group.editable = !group.editable;
|
|
||||||
}
|
switch (buttonType) {
|
||||||
|
case 'generalInfo':
|
||||||
CancelTagsChanges(event: Event) {
|
this.editable = !this.editable;
|
||||||
this.cancelChanges(event);
|
break;
|
||||||
this.editableTags = !this.editableTags;
|
case 'tags':
|
||||||
}
|
this.editableTags = !this.editableTags;
|
||||||
|
break;
|
||||||
cancelCategoriesChanges(event: Event) {
|
case 'categories':
|
||||||
this.cancelChanges(event);
|
this.editableCategories = !this.editableCategories;
|
||||||
this.editableCategories = !this.editableCategories;
|
break;
|
||||||
}
|
case 'group':
|
||||||
|
if (group) {
|
||||||
cancelGeneralInfoChanges(event: Event) {
|
group.editable = !group.editable;
|
||||||
this.cancelChanges(event);
|
}
|
||||||
this.editable = !this.editable;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleGeneralEdit(event: Event): void {
|
toggleGeneralEdit(event: Event): void {
|
||||||
@@ -386,28 +394,18 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleTagPanelOpen() {
|
|
||||||
this.tagsPanelState = true;
|
|
||||||
this.cdr.detectChanges();
|
|
||||||
}
|
|
||||||
|
|
||||||
handleTagPanelClose() {
|
|
||||||
this.tagsPanelState = false;
|
|
||||||
this.cdr.detectChanges();
|
|
||||||
}
|
|
||||||
|
|
||||||
generalTogglePanelState() {
|
generalTogglePanelState() {
|
||||||
this.generalInfoPanelState = !this.generalInfoPanelState;
|
this.generalInfoPanelState = !this.generalInfoPanelState;
|
||||||
this.cdr.detectChanges();
|
this.cdr.detectChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
handleCategoryPanelOpen() {
|
handleTagsPanelState(tagPanelState: boolean) {
|
||||||
this.categoriesPanelState = true;
|
this.tagsPanelState = tagPanelState;
|
||||||
this.cdr.detectChanges();
|
this.cdr.detectChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
handleCategoryPanelClose() {
|
handleCategoriesPanelState(categoriesPanelState: boolean) {
|
||||||
this.categoriesPanelState = false;
|
this.categoriesPanelState= categoriesPanelState;
|
||||||
this.cdr.detectChanges();
|
this.cdr.detectChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -386,13 +386,6 @@ describe('TagsCreatorComponent', () => {
|
|||||||
expect(getFirstError()).toBe('TAG.TAGS_CREATOR.ERRORS.ALREADY_ADDED_TAG');
|
expect(getFirstError()).toBe('TAG.TAGS_CREATOR.ERRORS.ALREADY_ADDED_TAG');
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should not show error for required if tags are changed', fakeAsync(() => {
|
|
||||||
typeTag('');
|
|
||||||
component.tags = ['new tag 1', 'new tag 2'];
|
|
||||||
fixture.detectChanges();
|
|
||||||
expect(getFirstError()).toBeUndefined();
|
|
||||||
}));
|
|
||||||
|
|
||||||
it('should show error when duplicated already existing tag', fakeAsync(() => {
|
it('should show error when duplicated already existing tag', fakeAsync(() => {
|
||||||
const tag = 'Some tag';
|
const tag = 'Some tag';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user