mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
[ACS-5645] Lint fixes
This commit is contained in:
-1
@@ -496,7 +496,6 @@ describe('ContentMetadataComponent', () => {
|
||||
component.toggleEdit(mockEvent, mockGroup, ButtonType.GeneralInfo);
|
||||
expect(component.isEditingPanel).toHaveBeenCalled();
|
||||
expect(showErrorSpy).toHaveBeenCalledWith('METADATA.BASIC.SAVE_OR_DISCARD_CHANGES');
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
+68
-34
@@ -129,18 +129,26 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
|
||||
@Input()
|
||||
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.
|
||||
*/
|
||||
@Input()
|
||||
readOnly = false;
|
||||
|
||||
/** Emitted when content's editable state is changed. **/
|
||||
/**
|
||||
* Emitted when content's editable state is changed.
|
||||
*
|
||||
* @Output
|
||||
*/
|
||||
@Output()
|
||||
editableChange = new EventEmitter<boolean>();
|
||||
|
||||
/** Emitted when content's editableTags state is changed. **/
|
||||
/**
|
||||
* Emitted when content's editableTags state is changed.
|
||||
*
|
||||
* @Output
|
||||
*/
|
||||
@Output()
|
||||
editableTagsChange = new EventEmitter<boolean>();
|
||||
|
||||
@@ -148,19 +156,35 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
|
||||
@Output()
|
||||
editableCategoriesChange = new EventEmitter<boolean>();
|
||||
|
||||
/** Emitted when content's group state is changed. **/
|
||||
/**
|
||||
* Emitted when content's group state is changed.
|
||||
*
|
||||
* @Output
|
||||
*/
|
||||
@Output()
|
||||
groupChange = new EventEmitter<CardViewGroup>();
|
||||
|
||||
/** (optional) This flag toggles editable of categories content. **/
|
||||
/**
|
||||
* (optional) This flag toggles editable of categories content.
|
||||
*
|
||||
* @Input
|
||||
*/
|
||||
@Input()
|
||||
editableCategories = false;
|
||||
|
||||
/** (optional) This flag toggles editable of tags content. **/
|
||||
/**
|
||||
* (optional) This flag toggles editable of tags content.
|
||||
*
|
||||
* @Input
|
||||
*/
|
||||
@Input()
|
||||
editableTags = false;
|
||||
|
||||
/** group content state **/
|
||||
/**
|
||||
* group content state
|
||||
* @Input()
|
||||
* group: CardViewGroup;
|
||||
*/
|
||||
@Input()
|
||||
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.
|
||||
* 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) {
|
||||
event.stopPropagation();
|
||||
@@ -390,21 +415,21 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
|
||||
this.editable = !this.editable;
|
||||
this.editableChange.emit(this.editable);
|
||||
this.panel.open();
|
||||
group.editable =false;
|
||||
group.editable = false;
|
||||
break;
|
||||
case ButtonType.Tags:
|
||||
this.editableTags = !this.editableTags;
|
||||
this.editableTagsChange.emit(this.editableTags);
|
||||
this.isTagPanelVisible = this.editableTags;
|
||||
this.tagNameControlVisible = true;
|
||||
group.editable =false;
|
||||
group.editable = false;
|
||||
break;
|
||||
case ButtonType.Categories:
|
||||
this.editableCategories = !this.editableCategories;
|
||||
this.editableCategoriesChange.emit(this.editableCategories);
|
||||
this.isCategoriesPanelVisible = this.editableCategories;
|
||||
this.categoryControlVisible = true;
|
||||
group.editable =false;
|
||||
group.editable = false;
|
||||
break;
|
||||
case ButtonType.Group:
|
||||
group.editable = !group.editable;
|
||||
@@ -447,11 +472,11 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
hasTags(): boolean {
|
||||
return (this.tags?.length === 0) && !this.editableTags;
|
||||
return this.tags?.length === 0 && !this.editableTags;
|
||||
}
|
||||
|
||||
hasCategories(): boolean {
|
||||
return (this.categories?.length === 0) && !this.editableCategories;
|
||||
return this.categories?.length === 0 && !this.editableCategories;
|
||||
}
|
||||
|
||||
get hasToggleEdit(): boolean {
|
||||
@@ -485,7 +510,8 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
keyDown(event: KeyboardEvent) {
|
||||
if (event.keyCode === 37 || event.keyCode === 39) { // ArrowLeft && ArrowRight
|
||||
if (event.keyCode === 37 || event.keyCode === 39) {
|
||||
// ArrowLeft && ArrowRight
|
||||
event.stopPropagation();
|
||||
}
|
||||
}
|
||||
@@ -495,13 +521,15 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
|
||||
updatedNode: this.nodesApiService.updateNode(this.node.id, this.changedProperties),
|
||||
...(this.displayTags ? this.saveTags() : {}),
|
||||
...(this.displayCategories ? this.saveCategories() : {})
|
||||
}).pipe(
|
||||
catchError((err) => {
|
||||
this.cardViewContentUpdateService.updateElement(this.targetProperty);
|
||||
this.handleUpdateError(err);
|
||||
this._saving = false;
|
||||
return of(null);
|
||||
}))
|
||||
})
|
||||
.pipe(
|
||||
catchError((err) => {
|
||||
this.cardViewContentUpdateService.updateElement(this.targetProperty);
|
||||
this.handleUpdateError(err);
|
||||
this._saving = false;
|
||||
return of(null);
|
||||
})
|
||||
)
|
||||
.subscribe((result: any) => {
|
||||
if (result) {
|
||||
this.updateUndefinedNodeProperties(result.updatedNode);
|
||||
@@ -515,9 +543,9 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
|
||||
this.loadTagsForNode(this.node.id);
|
||||
}
|
||||
if (this.displayCategories && !!result.LinkingCategories) {
|
||||
this.assignedCategories = result.LinkingCategories.list ?
|
||||
result.LinkingCategories.list.entries.map((entry: CategoryEntry) => entry.entry) :
|
||||
[result.LinkingCategories.entry];
|
||||
this.assignedCategories = result.LinkingCategories.list
|
||||
? result.LinkingCategories.list.entries.map((entry: CategoryEntry) => entry.entry)
|
||||
: [result.LinkingCategories.entry];
|
||||
}
|
||||
}
|
||||
this._saving = false;
|
||||
@@ -554,11 +582,14 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
|
||||
private getProperties(node: Node) {
|
||||
const properties$ = this.contentMetadataService.getBasicProperties(node);
|
||||
const contentTypeProperty$ = this.contentMetadataService.getContentTypeProperty(node);
|
||||
return zip(properties$, contentTypeProperty$)
|
||||
.pipe(map(([properties, contentTypeProperty]) => {
|
||||
const filteredProperties = contentTypeProperty.filter((property) => properties.findIndex((baseProperty) => baseProperty.key === property.key) === -1);
|
||||
return zip(properties$, contentTypeProperty$).pipe(
|
||||
map(([properties, contentTypeProperty]) => {
|
||||
const filteredProperties = contentTypeProperty.filter(
|
||||
(property) => properties.findIndex((baseProperty) => baseProperty.key === property.key) === -1
|
||||
);
|
||||
return [...properties, ...filteredProperties];
|
||||
}));
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
private isEmpty(value: any): boolean {
|
||||
@@ -614,11 +645,14 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
|
||||
}
|
||||
});
|
||||
if (this.tags.length) {
|
||||
observables.tagsAssigning = this.tagService.assignTagsToNode(this.node.id, this.tags.map((tag) => {
|
||||
const tagBody = new TagBody();
|
||||
tagBody.tag = tag;
|
||||
return tagBody;
|
||||
}));
|
||||
observables.tagsAssigning = this.tagService.assignTagsToNode(
|
||||
this.node.id,
|
||||
this.tags.map((tag) => {
|
||||
const tagBody = new TagBody();
|
||||
tagBody.tag = tag;
|
||||
return tagBody;
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
return observables;
|
||||
|
||||
@@ -340,7 +340,7 @@ describe('TagsCreatorComponent', () => {
|
||||
describe('isTagsEmpty', () => {
|
||||
it('should return true when tags empty', () => {
|
||||
component.tags = [];
|
||||
component.tagNameControlVisible = false;
|
||||
component.tagNameControlVisible = false;
|
||||
const result = component.isTagsEmpty;
|
||||
expect(result).toBeTrue();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user