[ACS-5645] Lint fixes

This commit is contained in:
Yasa-Nataliya
2023-10-09 20:27:32 +05:30
parent 5fd37e4e2a
commit ac1b820ddc
3 changed files with 69 additions and 36 deletions
@@ -496,7 +496,6 @@ describe('ContentMetadataComponent', () => {
component.toggleEdit(mockEvent, mockGroup, ButtonType.GeneralInfo); component.toggleEdit(mockEvent, mockGroup, ButtonType.GeneralInfo);
expect(component.isEditingPanel).toHaveBeenCalled(); expect(component.isEditingPanel).toHaveBeenCalled();
expect(showErrorSpy).toHaveBeenCalledWith('METADATA.BASIC.SAVE_OR_DISCARD_CHANGES'); expect(showErrorSpy).toHaveBeenCalledWith('METADATA.BASIC.SAVE_OR_DISCARD_CHANGES');
}); });
}); });
@@ -129,18 +129,26 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
@Input() @Input()
customPanels: ContentMetadataCustomPanel[] = []; customPanels: ContentMetadataCustomPanel[] = [];
/** (optional) This flag sets the metadata in read only mode /**
/** (optional) This flag sets the metadata in read only mode * (optional) This flag sets the metadata in read-only mode,
* preventing changes. * preventing changes.
*/ */
@Input() @Input()
readOnly = false; readOnly = false;
/** Emitted when content's editable state is changed. **/ /**
* Emitted when content's editable state is changed.
*
* @Output
*/
@Output() @Output()
editableChange = new EventEmitter<boolean>(); editableChange = new EventEmitter<boolean>();
/** Emitted when content's editableTags state is changed. **/ /**
* Emitted when content's editableTags state is changed.
*
* @Output
*/
@Output() @Output()
editableTagsChange = new EventEmitter<boolean>(); editableTagsChange = new EventEmitter<boolean>();
@@ -148,19 +156,35 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
@Output() @Output()
editableCategoriesChange = new EventEmitter<boolean>(); editableCategoriesChange = new EventEmitter<boolean>();
/** Emitted when content's group state is changed. **/ /**
* Emitted when content's group state is changed.
*
* @Output
*/
@Output() @Output()
groupChange = new EventEmitter<CardViewGroup>(); groupChange = new EventEmitter<CardViewGroup>();
/** (optional) This flag toggles editable of categories content. **/ /**
* (optional) This flag toggles editable of categories content.
*
* @Input
*/
@Input() @Input()
editableCategories = false; editableCategories = false;
/** (optional) This flag toggles editable of tags content. **/ /**
* (optional) This flag toggles editable of tags content.
*
* @Input
*/
@Input() @Input()
editableTags = false; editableTags = false;
/** group content state **/ /**
* group content state
* @Input()
* group: CardViewGroup;
*/
@Input() @Input()
group: CardViewGroup; group: CardViewGroup;
@@ -290,7 +314,8 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
/** /**
* Called after clicking save button. It confirms all changes done for metadata and hides both category and tag name controls. * Called after clicking save button. It confirms all changes done for metadata and hides both category and tag name controls.
* Before clicking on that button they are not saved. *
* @param Before clicking on that button they are not saved.
*/ */
saveChanges(buttonType: ButtonType, event: MouseEvent, group?: CardViewGroup) { saveChanges(buttonType: ButtonType, event: MouseEvent, group?: CardViewGroup) {
event.stopPropagation(); event.stopPropagation();
@@ -390,21 +415,21 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
this.editable = !this.editable; this.editable = !this.editable;
this.editableChange.emit(this.editable); this.editableChange.emit(this.editable);
this.panel.open(); this.panel.open();
group.editable =false; group.editable = false;
break; break;
case ButtonType.Tags: case ButtonType.Tags:
this.editableTags = !this.editableTags; this.editableTags = !this.editableTags;
this.editableTagsChange.emit(this.editableTags); this.editableTagsChange.emit(this.editableTags);
this.isTagPanelVisible = this.editableTags; this.isTagPanelVisible = this.editableTags;
this.tagNameControlVisible = true; this.tagNameControlVisible = true;
group.editable =false; group.editable = false;
break; break;
case ButtonType.Categories: case ButtonType.Categories:
this.editableCategories = !this.editableCategories; this.editableCategories = !this.editableCategories;
this.editableCategoriesChange.emit(this.editableCategories); this.editableCategoriesChange.emit(this.editableCategories);
this.isCategoriesPanelVisible = this.editableCategories; this.isCategoriesPanelVisible = this.editableCategories;
this.categoryControlVisible = true; this.categoryControlVisible = true;
group.editable =false; group.editable = false;
break; break;
case ButtonType.Group: case ButtonType.Group:
group.editable = !group.editable; group.editable = !group.editable;
@@ -447,11 +472,11 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
} }
hasTags(): boolean { hasTags(): boolean {
return (this.tags?.length === 0) && !this.editableTags; return this.tags?.length === 0 && !this.editableTags;
} }
hasCategories(): boolean { hasCategories(): boolean {
return (this.categories?.length === 0) && !this.editableCategories; return this.categories?.length === 0 && !this.editableCategories;
} }
get hasToggleEdit(): boolean { get hasToggleEdit(): boolean {
@@ -485,7 +510,8 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
} }
keyDown(event: KeyboardEvent) { keyDown(event: KeyboardEvent) {
if (event.keyCode === 37 || event.keyCode === 39) { // ArrowLeft && ArrowRight if (event.keyCode === 37 || event.keyCode === 39) {
// ArrowLeft && ArrowRight
event.stopPropagation(); event.stopPropagation();
} }
} }
@@ -495,13 +521,15 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
updatedNode: this.nodesApiService.updateNode(this.node.id, this.changedProperties), updatedNode: this.nodesApiService.updateNode(this.node.id, this.changedProperties),
...(this.displayTags ? this.saveTags() : {}), ...(this.displayTags ? this.saveTags() : {}),
...(this.displayCategories ? this.saveCategories() : {}) ...(this.displayCategories ? this.saveCategories() : {})
}).pipe( })
.pipe(
catchError((err) => { catchError((err) => {
this.cardViewContentUpdateService.updateElement(this.targetProperty); this.cardViewContentUpdateService.updateElement(this.targetProperty);
this.handleUpdateError(err); this.handleUpdateError(err);
this._saving = false; this._saving = false;
return of(null); return of(null);
})) })
)
.subscribe((result: any) => { .subscribe((result: any) => {
if (result) { if (result) {
this.updateUndefinedNodeProperties(result.updatedNode); this.updateUndefinedNodeProperties(result.updatedNode);
@@ -515,9 +543,9 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
this.loadTagsForNode(this.node.id); this.loadTagsForNode(this.node.id);
} }
if (this.displayCategories && !!result.LinkingCategories) { if (this.displayCategories && !!result.LinkingCategories) {
this.assignedCategories = result.LinkingCategories.list ? this.assignedCategories = result.LinkingCategories.list
result.LinkingCategories.list.entries.map((entry: CategoryEntry) => entry.entry) : ? result.LinkingCategories.list.entries.map((entry: CategoryEntry) => entry.entry)
[result.LinkingCategories.entry]; : [result.LinkingCategories.entry];
} }
} }
this._saving = false; this._saving = false;
@@ -554,11 +582,14 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
private getProperties(node: Node) { private getProperties(node: Node) {
const properties$ = this.contentMetadataService.getBasicProperties(node); const properties$ = this.contentMetadataService.getBasicProperties(node);
const contentTypeProperty$ = this.contentMetadataService.getContentTypeProperty(node); const contentTypeProperty$ = this.contentMetadataService.getContentTypeProperty(node);
return zip(properties$, contentTypeProperty$) return zip(properties$, contentTypeProperty$).pipe(
.pipe(map(([properties, contentTypeProperty]) => { map(([properties, contentTypeProperty]) => {
const filteredProperties = contentTypeProperty.filter((property) => properties.findIndex((baseProperty) => baseProperty.key === property.key) === -1); const filteredProperties = contentTypeProperty.filter(
(property) => properties.findIndex((baseProperty) => baseProperty.key === property.key) === -1
);
return [...properties, ...filteredProperties]; return [...properties, ...filteredProperties];
})); })
);
} }
private isEmpty(value: any): boolean { private isEmpty(value: any): boolean {
@@ -614,11 +645,14 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
} }
}); });
if (this.tags.length) { if (this.tags.length) {
observables.tagsAssigning = this.tagService.assignTagsToNode(this.node.id, this.tags.map((tag) => { observables.tagsAssigning = this.tagService.assignTagsToNode(
this.node.id,
this.tags.map((tag) => {
const tagBody = new TagBody(); const tagBody = new TagBody();
tagBody.tag = tag; tagBody.tag = tag;
return tagBody; return tagBody;
})); })
);
} }
} }
return observables; return observables;