From 5a13ef0a578d616217df2ec1f156af9985ab57ed Mon Sep 17 00:00:00 2001 From: Konstantina Galouni Date: Tue, 23 Jun 2020 08:33:13 +0000 Subject: [PATCH] [Trunk | Monitor Dashboard]: 1. stakeholder.componen & indicators.component & topic.component: Delete methods replaced from simple delete to delete default & related elements (for simple elements the result is the same). 2. topic.component.html: Commented code, to show in modal 3 different buttons according to the delete option we choose. git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-monitor-portal/trunk/monitor_dashboard@58980 d315682c-612b-4755-9ff5-7f18f6832af3 --- .../stakeholder/stakeholder.component.html | 17 +++- src/app/stakeholder/stakeholder.component.ts | 14 +++- src/app/topic/indicators.component.html | 77 ++++++++++++++++--- src/app/topic/indicators.component.ts | 72 ++++++++++++----- src/app/topic/topic.component.html | 73 ++++++++++++++++-- src/app/topic/topic.component.ts | 44 ++++++++--- 6 files changed, 242 insertions(+), 55 deletions(-) diff --git a/src/app/stakeholder/stakeholder.component.html b/src/app/stakeholder/stakeholder.component.html index 20f3881..405bed6 100644 --- a/src/app/stakeholder/stakeholder.component.html +++ b/src/app/stakeholder/stakeholder.component.html @@ -52,7 +52,12 @@ {{topic.isPublic?'Private':'Public'}}
-
  • Delete
  • +
  • Delete + + + + +
  • @@ -88,9 +93,9 @@ OR + fill="none" stroke="#000" stroke-width="1" opacity="0.2"> + fill="none" stroke="#000" stroke-width="1" opacity="0.2"> @@ -116,6 +121,12 @@ You are about to delete "{{stakeholder.topics[index].name}}" topic permanently. +
    + Topics of all profiles based on this default topic, will be deleted as well. +
    + + + Are you sure you want to proceed?
    diff --git a/src/app/stakeholder/stakeholder.component.ts b/src/app/stakeholder/stakeholder.component.ts index 3112f5e..53b1c0b 100644 --- a/src/app/stakeholder/stakeholder.component.ts +++ b/src/app/stakeholder/stakeholder.component.ts @@ -35,7 +35,8 @@ export class StakeholderComponent implements OnInit, OnDestroy, IDeactivateCompo @ViewChild('deleteModal') deleteModal: AlertModal; @ViewChild('editModal') editModal: AlertModal; - + public topicChildrenActionOnDelete: string; + constructor( private route: ActivatedRoute, private router: Router, @@ -140,7 +141,14 @@ export class StakeholderComponent implements OnInit, OnDestroy, IDeactivateCompo } } - public deleteTopicOpen(index: number) { + public deleteTopicOpen(index: number, childrenAction: string = null) { + this.topicChildrenActionOnDelete = null; + if(childrenAction == "delete") { + this.topicChildrenActionOnDelete = childrenAction; + } else if(childrenAction == "disconnect") { + this.topicChildrenActionOnDelete = childrenAction; + } + this.index = index; this.deleteModal.alertTitle = 'Delete topic'; this.deleteModal.cancelButtonText = 'No'; @@ -175,7 +183,7 @@ export class StakeholderComponent implements OnInit, OnDestroy, IDeactivateCompo this.stakeholder._id, this.stakeholder.topics[this.index]._id ]; - this.stakeholderService.deleteElement(this.properties.monitorServiceAPIURL, path).subscribe(() => { + this.stakeholderService.deleteElement(this.properties.monitorServiceAPIURL, path, this.topicChildrenActionOnDelete).subscribe(() => { this.stakeholder.topics.splice(this.index, 1); this.index = -1; UIkit.notification('Topic has been successfully deleted', { diff --git a/src/app/topic/indicators.component.html b/src/app/topic/indicators.component.html index db6b4fb..f96fec4 100644 --- a/src/app/topic/indicators.component.html +++ b/src/app/topic/indicators.component.html @@ -76,8 +76,18 @@ + + + + + + + + + +

  • Delete + (click)="deleteIndicatorOpen(number, indicator._id, 'number', 'delete');hide(element)">Delete + + + +
  • @@ -212,8 +226,18 @@ + + + + + + + + + +

    -
  • - Delete
  • +
  • + Delete + + +
  • @@ -538,13 +565,41 @@ You are about to delete "{{indicator.name ? indicator.name : indicator.indicatorPaths[0].parameters.title}}" indicator permanently. +
    + Indicators of all profiles based on this default indicator, will be deleted as well. +
    + + + Are you sure you want to proceed?
    - - You are about to delete this section and his indicators permanently. - Are you sure you want to proceed? - - - You are about to delete this section and his indicators permanently. + + + + + + + + + + + + + + You are about to delete this section and its indicators permanently. +
    + Sections of all profiles based on this default section and their contents, will be deleted as well. +
    + + + Are you sure you want to proceed?
    + + + + + + + + diff --git a/src/app/topic/indicators.component.ts b/src/app/topic/indicators.component.ts index 1f260dd..06fc307 100644 --- a/src/app/topic/indicators.component.ts +++ b/src/app/topic/indicators.component.ts @@ -82,8 +82,14 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV @ViewChild('editChartModal') editChartModal: AlertModal; @ViewChild('editNumberModal') editNumberModal: AlertModal; @ViewChild('deleteModal') deleteModal: AlertModal; - @ViewChild('deleteChartSectionModal') deleteChartSectionModal: AlertModal; - @ViewChild('deleteNumberSectionModal') deleteNumberSectionModal: AlertModal; + //@ViewChild('deleteAllModal') deleteAllModal: AlertModal; + //@ViewChild('deleteAndDisconnectModal') deleteAndDisconnectModal: AlertModal; + //@ViewChild('deleteChartSectionModal') deleteChartSectionModal: AlertModal; + //@ViewChild('deleteNumberSectionModal') deleteNumberSectionModal: AlertModal; + @ViewChild('deleteSectionModal') deleteSectionModal: AlertModal; + public sectionTypeToDelete: string; + public sectionChildrenActionOnDelete: string; + public indicatorChildrenActionOnDelete: string; urlParameterizedMessage = ""; constructor(private layoutService: LayoutService, @@ -691,7 +697,14 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV }); } - deleteIndicatorOpen(section: Section, indicatorId: string, type: string = 'chart') { + deleteIndicatorOpen(section: Section, indicatorId: string, type: string, childrenAction: string = null) { + this.indicatorChildrenActionOnDelete = null; + if(childrenAction == "delete") { + this.indicatorChildrenActionOnDelete = childrenAction; + } else if(childrenAction == "disconnect") { + this.indicatorChildrenActionOnDelete = childrenAction; + } + this.section = section; if (type === 'chart') { this.index = this.charts.find(value => value._id == section._id).indicators.findIndex(value => value._id == indicatorId); @@ -715,7 +728,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV this.section._id, this.indicator._id ]; - this.stakeholderService.deleteElement(this.properties.monitorServiceAPIURL, path).subscribe(() => { + this.stakeholderService.deleteElement(this.properties.monitorServiceAPIURL, path, this.indicatorChildrenActionOnDelete).subscribe(() => { if (this.indicator.type === 'chart') { this.charts.find(section => section._id === this.section._id).indicators.splice(this.index, 1); this.filterCharts(); @@ -870,25 +883,42 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV }); } - deleteNumberSectionOpen(section: Section, index: number) { + // deleteNumberSectionOpen(section: Section, index: number) { + // this.section = section; + // this.index = index; + // this.deleteNumberSectionModal.alertTitle = 'Delete Section'; + // this.deleteNumberSectionModal.cancelButtonText = 'No'; + // this.deleteNumberSectionModal.okButtonText = 'Yes'; + // this.deleteNumberSectionModal.open(); + // } + // + // deleteChartSectionOpen(section: Section, index: number) { + // this.section = section; + // this.index = index; + // this.deleteChartSectionModal.alertTitle = 'Delete Section'; + // this.deleteChartSectionModal.cancelButtonText = 'No'; + // this.deleteChartSectionModal.okButtonText = 'Yes'; + // this.deleteChartSectionModal.open(); + // } + + deleteSectionOpen(section: Section, index: number, type: IndicatorType, childrenAction: string = null) { + this.sectionTypeToDelete = type; + this.sectionChildrenActionOnDelete = null; + if(childrenAction == "delete") { + this.sectionChildrenActionOnDelete = childrenAction; + } else if(childrenAction == "disconnect") { + this.sectionChildrenActionOnDelete = childrenAction; + } + this.section = section; this.index = index; - this.deleteNumberSectionModal.alertTitle = 'Delete Section'; - this.deleteNumberSectionModal.cancelButtonText = 'No'; - this.deleteNumberSectionModal.okButtonText = 'Yes'; - this.deleteNumberSectionModal.open(); + this.deleteSectionModal.alertTitle = 'Delete Section'; + this.deleteSectionModal.cancelButtonText = 'No'; + this.deleteSectionModal.okButtonText = 'Yes'; + this.deleteSectionModal.open(); } - deleteChartSectionOpen(section: Section, index: number) { - this.section = section; - this.index = index; - this.deleteChartSectionModal.alertTitle = 'Delete Section'; - this.deleteChartSectionModal.cancelButtonText = 'No'; - this.deleteChartSectionModal.okButtonText = 'Yes'; - this.deleteChartSectionModal.open(); - } - - deleteSection(type: IndicatorType = 'chart') { + deleteSection() { this.editing = true; let path = [ this.stakeholder._id, @@ -897,8 +927,8 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.subcategoryIndex]._id, this.section._id ]; - this.stakeholderService.deleteElement(this.properties.monitorServiceAPIURL, path).subscribe(() => { - if (type === "chart") { + this.stakeholderService.deleteElement(this.properties.monitorServiceAPIURL, path, this.sectionChildrenActionOnDelete).subscribe(() => { + if (this.sectionTypeToDelete === "chart") { this.charts.splice(this.index, 1); this.filterCharts(); } else { diff --git a/src/app/topic/topic.component.html b/src/app/topic/topic.component.html index 1276a9f..f76d353 100644 --- a/src/app/topic/topic.component.html +++ b/src/app/topic/topic.component.html @@ -30,9 +30,14 @@ {{stakeholder.topics[topicIndex].isPublic ? 'Private' : 'Public'}}
    -
  • Delete -
  • +
  • Delete + + + + + +
  • @@ -66,9 +71,13 @@ {{category.isPublic ? 'Private' : 'Public'}}
    -
  • Delete
  • +
  • Delete + + + + +
  • @@ -102,8 +111,13 @@
    -
  • Delete
  • +
  • Delete + + + + +
  • @@ -135,8 +149,51 @@ [subcategoryIndex]="subCategoryIndex"> You are about to delete "{{element.name}}" {{type}} permanently. +
    + {{getPluralTypeName()}} of all profiles based on this default {{type}}, will be deleted as well. +
    Are you sure you want to proceed?
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    diff --git a/src/app/topic/topic.component.ts b/src/app/topic/topic.component.ts index 1f4c66b..dc6e819 100644 --- a/src/app/topic/topic.component.ts +++ b/src/app/topic/topic.component.ts @@ -51,7 +51,8 @@ export class TopicComponent implements OnInit, OnDestroy, IDeactivateComponent { @ViewChild('deleteModal') deleteModal: AlertModal; @ViewChild('editModal') editModal: AlertModal; - + public elementChildrenActionOnDelete: string; + constructor( private route: ActivatedRoute, private router: Router, @@ -112,6 +113,10 @@ export class TopicComponent implements OnInit, OnDestroy, IDeactivateComponent { this.saveSubCategory(); } } + + // public closeDeleteModal() { + // this.deleteModal.cancel(); + // } public deleteElement() { if (this.type === "topic") { @@ -188,11 +193,11 @@ export class TopicComponent implements OnInit, OnDestroy, IDeactivateComponent { this.toggleAccess(this.stakeholder.topics[this.topicIndex], path); } - public deleteTopicOpen() { + public deleteTopicOpen(childrenAction: string = null) { this.type = 'topic'; this.index = this.topicIndex; this.element = this.stakeholder.topics[this.index]; - this.deleteOpen(); + this.deleteOpen(childrenAction); } public deleteTopic() { @@ -293,11 +298,11 @@ export class TopicComponent implements OnInit, OnDestroy, IDeactivateComponent { this.toggleAccess(this.stakeholder.topics[this.topicIndex].categories[this.index], path); } - public deleteCategoryOpen(index: number) { + public deleteCategoryOpen(index: number, childrenAction: string = null) { this.type = 'category'; this.index = index; this.element = this.stakeholder.topics[this.topicIndex].categories[this.index]; - this.deleteOpen(); + this.deleteOpen(childrenAction); } public deleteCategory() { @@ -397,11 +402,11 @@ export class TopicComponent implements OnInit, OnDestroy, IDeactivateComponent { this.toggleAccess(this.stakeholder.topics[this.topicIndex].categories[this.selectedCategoryIndex].subCategories[this.index], path); } - public deleteSubcategoryOpen(index) { + public deleteSubcategoryOpen(index, childrenAction: string = null) { this.type = 'subcategory'; this.index = index; this.element = this.stakeholder.topics[this.topicIndex].categories[this.selectedCategoryIndex].subCategories[this.index]; - this.deleteOpen(); + this.deleteOpen(childrenAction); } public deleteSubcategory() { @@ -435,10 +440,19 @@ export class TopicComponent implements OnInit, OnDestroy, IDeactivateComponent { this.editModal.open(); } - private deleteOpen() { + private deleteOpen(childrenAction: string = null) { + this.elementChildrenActionOnDelete = null; + if(childrenAction == "delete") { + this.elementChildrenActionOnDelete = childrenAction; + } else if(childrenAction == "disconnect") { + this.elementChildrenActionOnDelete = childrenAction; + } + this.deleteModal.alertTitle = 'Delete ' + this.type; this.deleteModal.cancelButtonText = 'No'; this.deleteModal.okButtonText = 'Yes'; + // this.deleteModal.cancelButton = false; + // this.deleteModal.okButton = false; this.deleteModal.open(); } @@ -465,7 +479,7 @@ export class TopicComponent implements OnInit, OnDestroy, IDeactivateComponent { } private delete(message: string, path: string[], callback: Function, redirect = false) { - this.stakeholderService.deleteElement(this.properties.monitorServiceAPIURL, path).subscribe(() => { + this.stakeholderService.deleteElement(this.properties.monitorServiceAPIURL, path, this.elementChildrenActionOnDelete).subscribe(() => { callback(); UIkit.notification(message, { status: 'success', @@ -528,4 +542,16 @@ export class TopicComponent implements OnInit, OnDestroy, IDeactivateComponent { this.categoryIndex = categoryIndex; this.subCategoryIndex = subcategoryIndex; } + + public getPluralTypeName(): string { + if(this.type == "topic") { + return "Topics"; + } else if(this.type == "category") { + return "Categories"; + } else if(this.type == "subcategory") { + return "Subcategories"; + } else { + return this.type; + } + } }