From 0a3860bb4c79110c3b82556c668df0ef0f2c7ecf Mon Sep 17 00:00:00 2001 From: Alex Martzios Date: Wed, 14 Sep 2022 16:32:52 +0300 Subject: [PATCH 1/3] improve status of topics, categories, subcategories and indicators with new modal message and clickable options --- src/app/openaireLibrary | 2 +- src/app/topic/topic.component.html | 31 +++++++++++-- src/app/topic/topic.component.ts | 70 +++++++++++++++++++++++------- 3 files changed, 83 insertions(+), 20 deletions(-) diff --git a/src/app/openaireLibrary b/src/app/openaireLibrary index 945cee4..b8ac412 160000 --- a/src/app/openaireLibrary +++ b/src/app/openaireLibrary @@ -1 +1 @@ -Subproject commit 945cee4519a4f5b2c5e53dd5c069d4f038f987e6 +Subproject commit b8ac4121379c5294d1201932af1ed76be34bdb84 diff --git a/src/app/topic/topic.component.html b/src/app/topic/topic.component.html index 6e1aee2..3ee8dd6 100644 --- a/src/app/topic/topic.component.html +++ b/src/app/topic/topic.component.html @@ -64,7 +64,7 @@
  • - +
    {{v.label}} @@ -195,7 +195,7 @@
  • - +
    {{v.label}} @@ -293,7 +293,7 @@
  • - +
    {{v.label}} @@ -363,3 +363,28 @@
    + +
    + You have the option to change the visibility status of your {{type}}, with or without affecting the visibility of its contents. +
    +
    + +
    +
    + +
    +
    +

    Note:

    +
    + The status of the {{type}} prevails the status of its contents. For example, if a {{type}}'s status is private, while it has + a category, subcategory or an indicator + a subcategory or an indicator + an indicator + that is public, the private status of the {{type}} dominates. +
    +
    +
    diff --git a/src/app/topic/topic.component.ts b/src/app/topic/topic.component.ts index 72fb8ca..f093c77 100644 --- a/src/app/topic/topic.component.ts +++ b/src/app/topic/topic.component.ts @@ -59,9 +59,11 @@ export class TopicComponent implements OnInit, OnDestroy, IDeactivateComponent { public element: Topic | Category | SubCategory; public type: 'topic' | 'category' | 'subcategory' = "topic"; public index: number = -1; - + public visibility: Visibility; + @ViewChild('deleteModal', {static: true}) deleteModal: AlertModal; @ViewChild('editModal', {static: true}) editModal: AlertModal; + @ViewChild('visibilityModal', {static: true}) visibilityModal: AlertModal; @ViewChild("topics") topics: TransitionGroupComponent; @ViewChild("categories") categories: TransitionGroupComponent; @@ -184,6 +186,16 @@ export class TopicComponent implements OnInit, OnDestroy, IDeactivateComponent { this.deleteSubcategory(); } } + + public changeElementStatus(propagate: boolean = false) { + if (this.type === "topic") { + this.changeTopicStatus(propagate); + } else if (this.type === "category") { + this.changeCategoryStatus(propagate); + } else { + this.changeSubcategoryStatus(propagate); + } + } public chooseTopic(topicIndex: number) { this.topicIndexSubject.next(topicIndex); @@ -276,13 +288,18 @@ export class TopicComponent implements OnInit, OnDestroy, IDeactivateComponent { } } - public changeTopicStatus(index: number, visibility: Visibility) { - this.type = 'topic'; + public changeTopicStatus(propagate: boolean = false) { let path = [ this.stakeholder._id, - this.stakeholder.topics[index]._id + this.stakeholder.topics[this.index]._id ]; - this.changeStatus(this.stakeholder.topics[index], path, visibility); + let callback = (topic: Topic): void => { + this.topicChanged(() => { + this.stakeholder.topics[this.index] = HelperFunctions.copy(topic); + }, true); + } + this.changeStatus(this.stakeholder.topics[this.index], path, this.visibility, callback, propagate); + this.visibilityModal.cancel(); } public deleteTopicOpen(index = this.topicIndex, childrenAction: string = null) { @@ -407,15 +424,19 @@ export class TopicComponent implements OnInit, OnDestroy, IDeactivateComponent { } } - public changeCategoryStatus(index: number, visibility: Visibility) { - this.index = index; - this.type = 'category'; + public changeCategoryStatus(propagate: boolean = false) { let path = [ this.stakeholder._id, this.stakeholder.topics[this.topicIndex]._id, this.stakeholder.topics[this.topicIndex].categories[this.index]._id ]; - this.changeStatus(this.stakeholder.topics[this.topicIndex].categories[this.index], path, visibility); + let callback = (category: Category): void => { + this.categoryChanged(() => { + this.stakeholder.topics[this.topicIndex].categories[this.index] = HelperFunctions.copy(category); + }, true); + } + this.changeStatus(this.stakeholder.topics[this.topicIndex].categories[this.index], path, this.visibility, callback, propagate); + this.visibilityModal.cancel(); } public deleteCategoryOpen(index: number, childrenAction: string = null) { @@ -537,16 +558,20 @@ export class TopicComponent implements OnInit, OnDestroy, IDeactivateComponent { } } - public changeSubcategoryStatus(index: number, visibility: Visibility) { - this.index = index; - this.type = 'subcategory'; + public changeSubcategoryStatus(propagate: boolean = false) { let path = [ this.stakeholder._id, this.stakeholder.topics[this.topicIndex]._id, this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex]._id, this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.index]._id ]; - this.changeStatus(this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.index], path, visibility); + let callback = (subcategory: SubCategory): void => { + this.subCategoryChanged(() => { + this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.index] = HelperFunctions.copy(subcategory); + }); + } + this.changeStatus(this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.index], path, this.visibility, callback, propagate); + this.visibilityModal.cancel(); } @@ -666,9 +691,13 @@ export class TopicComponent implements OnInit, OnDestroy, IDeactivateComponent { })); } - private changeStatus(element: Topic | Category | SubCategory, path: string[], visibility: Visibility) { - this.topicSubscriptions.push(this.stakeholderService.changeVisibility(this.properties.monitorServiceAPIURL, path, visibility).subscribe(visibility => { - element.visibility = visibility; + private changeStatus(element: Topic | Category | SubCategory, path: string[], visibility: Visibility, callback: Function = null, propagate: boolean = false) { + this.topicSubscriptions.push(this.stakeholderService.changeVisibility(this.properties.monitorServiceAPIURL, path, visibility, propagate).subscribe(returnedElement => { + if(propagate) { + callback(returnedElement); + } else { + element.visibility = returnedElement.visibility; + } NotificationHandler.rise(StringUtils.capitalize(this.type) + ' has been successfully changed to ' + element.visibility.toLowerCase()); }, error => { NotificationHandler.rise(error.error.message, 'danger'); @@ -705,4 +734,13 @@ export class TopicComponent implements OnInit, OnDestroy, IDeactivateComponent { event.preventDefault(); this.layoutService.setOpen(!this.open); } + + public openVisibilityModal(index: number, visibility: Visibility, type: any) { + this.index = index; + this.visibility = visibility; + this.type = type; + this.visibilityModal.alertTitle = 'Visibility Status'; + this.visibilityModal.alertFooter = false; + this.visibilityModal.open(); + } } From 3bfd648ee8619be38abef03cb2bbb9b961246469 Mon Sep 17 00:00:00 2001 From: Alex Martzios Date: Thu, 15 Sep 2022 11:50:24 +0300 Subject: [PATCH 2/3] text changes for topics' visibility modal content --- src/app/topic/topic.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/topic/topic.component.html b/src/app/topic/topic.component.html index 3ee8dd6..24e0c93 100644 --- a/src/app/topic/topic.component.html +++ b/src/app/topic/topic.component.html @@ -365,7 +365,7 @@
    - You have the option to change the visibility status of your {{type}}, with or without affecting the visibility of its contents. + You have the option to change the visibility status of your {{type}}, with or without applying the changed status to its contents.
    @@ -210,7 +210,7 @@ (click)="toggleDescriptionOverlay($event, j)"> - Description + Note diff --git a/src/app/openaireLibrary b/src/app/openaireLibrary index 9939c27..5ba1d27 160000 --- a/src/app/openaireLibrary +++ b/src/app/openaireLibrary @@ -1 +1 @@ -Subproject commit 9939c2707cffbb8f2f15cfa79e80992cd58d6bdf +Subproject commit 5ba1d27aaae2719f79f782f907089d52a2550aae