[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
This commit is contained in:
Konstantina Galouni 2020-06-23 08:33:13 +00:00
parent cdcf946958
commit 5a13ef0a57
6 changed files with 242 additions and 55 deletions

View File

@ -52,7 +52,12 @@
{{topic.isPublic?'Private':'Public'}}</a>
</li>
<hr *ngIf="!topic.defaultId" class="uk-nav-divider">
<li><a *ngIf="!topic.defaultId" (click)="deleteTopicOpen(i); hide(element)">Delete</a></li>
<li *ngIf="!topic.defaultId"><a (click)="deleteTopicOpen(i, 'delete'); hide(element)">Delete</a>
<!-- <ng-container *ngIf="!stakeholder.defaultId">-->
<!-- <a (click)="deleteTopicOpen(i, 'delete'); hide(element)">Delete from all profiles</a>-->
<!-- <a (click)="deleteTopicOpen(i, 'disconnect'); hide(element)">Delete and disconnect from all profiles</a>-->
<!-- </ng-container>-->
</li>
</ul>
</div>
</div>
@ -88,9 +93,9 @@
<tspan x="0" y="0">OR</tspan>
</text>
<line class="stroke_line" id="Line_225" data-name="Line 225" y2="30" transform="translate(885.5 490.5)"
fill="none" stroke="#000" stroke-width="1" opacity="0.2"/>
fill="none" stroke="#000" stroke-width="1" opacity="0.2"></line>
<line class="stroke_line" id="Line_226" data-name="Line 226" y2="30" transform="translate(885.5 548.5)"
fill="none" stroke="#000" stroke-width="1" opacity="0.2"/>
fill="none" stroke="#000" stroke-width="1" opacity="0.2"></line>
</g>
</svg>
</div>
@ -116,6 +121,12 @@
</div>
<modal-alert #deleteModal (alertOutput)="deleteTopic()">
You are about to delete <span class="uk-text-bold" *ngIf="index !== -1">"{{stakeholder.topics[index].name}}"</span> topic permanently.
<div *ngIf="topicChildrenActionOnDelete == 'delete'" class="uk-text-bold">
Topics of all profiles based on this default topic, will be deleted as well.
</div>
<!-- <span *ngIf="topicChildrenActionOnDelete == 'disconnect'" class="uk-text-bold">-->
<!-- Topics of all profiles based on this default topic, will not be marked as copied from default anymore.-->
<!-- </span>-->
Are you sure you want to proceed?
</modal-alert>
<modal-alert #editModal (alertOutput)="saveTopic(index)">

View File

@ -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', {

View File

@ -76,8 +76,18 @@
<!--<button class="md-btn md-btn-mini"><i class="material-icons rotate-90">drag_indicator</i></button>-->
<button [disabled]="editing || number.defaultId " class="md-btn md-btn-mini"
[title]="(number.defaultId?'Default sections cannot be deleted':'Delete section')"
(click)="deleteNumberSectionOpen(number, i)"><i class="material-icons">clear</i>
(click)="deleteSectionOpen(number, i, 'number', 'delete')"><i class="material-icons">clear</i>
</button>
<!-- <ng-container *ngIf="!stakeholder.defaultId">-->
<!-- <button [disabled]="editing || number.defaultId " class="md-btn md-btn-mini"-->
<!-- [title]="(number.defaultId?'Default sections cannot be deleted':'Delete all related sections')"-->
<!-- (click)="deleteSectionOpen(number, i, 'number', 'delete')"><i class="material-icons">highlight_off</i>-->
<!-- </button>-->
<!-- <button [disabled]="editing || number.defaultId " class="md-btn md-btn-mini"-->
<!-- [title]="(number.defaultId?'Default sections cannot be deleted':'Delete section and disconnect related')"-->
<!-- (click)="deleteSectionOpen(number, i, 'number', 'disconnect')"><i class="material-icons">link_off</i>-->
<!-- </button>-->
<!-- </ng-container>-->
</div>
</div>
<div *ngIf="grid && numberSections.at(i)"
@ -131,7 +141,11 @@
</li>
<hr *ngIf="isAdministrator && !indicator.defaultId" class="uk-nav-divider">
<li *ngIf="isAdministrator && !indicator.defaultId && !editing"><a
(click)="deleteIndicatorOpen(number, indicator._id, 'number');hide(element)">Delete</a>
(click)="deleteIndicatorOpen(number, indicator._id, 'number', 'delete');hide(element)">Delete</a>
<!-- <ng-container *ngIf="!stakeholder.defaultId">-->
<!-- <a (click)="deleteIndicatorOpen(number, indicator._id, 'number', 'delete');hide(element)">Delete from all profiles</a>-->
<!-- <a (click)="deleteIndicatorOpen(number, indicator._id, 'number', 'disconnect');hide(element)">Delete and disconnect from all profiles</a>-->
<!-- </ng-container>-->
</li>
</ul>
</div>
@ -212,8 +226,18 @@
<!--<button class="md-btn md-btn-mini"><i class="material-icons rotate-90">drag_indicator</i></button>-->
<button [disabled]="editing || chart.defaultId "
[title]="(chart.defaultId?'Default sections cannot be deleted':'Delete section')"
class="md-btn md-btn-mini" (click)="deleteChartSectionOpen(chart, i)"><i class="material-icons">clear</i>
class="md-btn md-btn-mini" (click)="deleteSectionOpen(chart, i, 'chart', 'delete')"><i class="material-icons">clear</i>
</button>
<!-- <ng-container *ngIf="!stakeholder.defaultId">-->
<!-- <button [disabled]="editing || chart.defaultId " class="md-btn md-btn-mini"-->
<!-- [title]="(chart.defaultId?'Default sections cannot be deleted':'Delete all related sections')"-->
<!-- (click)="deleteSectionOpen(chart, i, 'chart', 'delete')"><i class="material-icons">highlight_off</i>-->
<!-- </button>-->
<!-- <button [disabled]="editing || chart.defaultId " class="md-btn md-btn-mini"-->
<!-- [title]="(chart.defaultId?'Default sections cannot be deleted':'Delete section and disconnect related')"-->
<!-- (click)="deleteSectionOpen(chart, i, 'chart', 'disconnect')"><i class="material-icons">link_off</i>-->
<!-- </button>-->
<!-- </ng-container>-->
</div>
</div>
<div *ngIf="grid && chartSections.at(i)"
@ -278,8 +302,11 @@
{{indicator.isPublic ? 'Private' : 'Public'}}</a>
</li>
<hr *ngIf="!indicator.defaultId " class="uk-nav-divider">
<li *ngIf="!editing && !indicator.defaultId "><a (click)="deleteIndicatorOpen(chart, indicator._id);hide(element)">
Delete</a></li>
<li *ngIf="!editing && !indicator.defaultId "><a (click)="deleteIndicatorOpen(chart, indicator._id, 'chart', 'delete');hide(element)">
Delete</a>
<!-- <a (click)="deleteIndicatorOpen(chart, indicator._id, 'chart', 'delete');hide(element)">Delete from all profiles</a>-->
<!-- <a (click)="deleteIndicatorOpen(chart, indicator._id, 'chart', 'disconnect');hide(element)">Delete and disconnect from all profiles</a>-->
</li>
</ul>
</div>
</div>
@ -538,13 +565,41 @@
<modal-alert #deleteModal (alertOutput)="deleteIndicator()">
You are about to delete <span class="uk-text-bold" *ngIf="indicator && index !== -1">
"{{indicator.name ? indicator.name : indicator.indicatorPaths[0].parameters.title}}"</span> indicator permanently.
<div *ngIf="indicatorChildrenActionOnDelete == 'delete'" class="uk-text-bold">
Indicators of all profiles based on this default indicator, will be deleted as well.
</div>
<!-- <span *ngIf="indicatorChildrenActionOnDelete == 'disconnect'" class="uk-text-bold">-->
<!-- Indicators of all profiles based on this default indicator, will not be marked as copied from default anymore.-->
<!-- </span>-->
Are you sure you want to proceed?
</modal-alert>
<modal-alert #deleteNumberSectionModal (alertOutput)="deleteSection('number')">
You are about to delete this section and his indicators permanently.
Are you sure you want to proceed?
</modal-alert>
<modal-alert #deleteChartSectionModal (alertOutput)="deleteSection()">
You are about to delete this section and his indicators permanently.
<!--<modal-alert #deleteAllModal (alertOutput)="deleteIndicator('delete')">-->
<!-- You are about to delete <span class="uk-text-bold" *ngIf="indicator && index !== -1">-->
<!-- "{{indicator.name ? indicator.name : indicator.indicatorPaths[0].parameters.title}}"</span> indicator permanently.-->
<!-- <span class="uk-text-bold">Indicators of all profiles based on this default indicator, will be deleted as well.</span>-->
<!-- Are you sure you want to proceed?-->
<!--</modal-alert>-->
<!--<modal-alert #deleteAndDisconnectModal (alertOutput)="deleteIndicator('disconnect')">-->
<!-- You are about to delete <span class="uk-text-bold" *ngIf="indicator && index !== -1">-->
<!-- "{{indicator.name ? indicator.name : indicator.indicatorPaths[0].parameters.title}}"</span> indicator permanently.-->
<!-- <span class="uk-text-bold">Indicators of all profiles based on this default indicator, will not be marked as copied from default anymore.</span>-->
<!-- Are you sure you want to proceed?-->
<!--</modal-alert>-->
<modal-alert #deleteSectionModal (alertOutput)="deleteSection()">
You are about to delete this section and its indicators permanently.
<div *ngIf="sectionChildrenActionOnDelete == 'delete'" class="uk-text-bold">
Sections of all profiles based on this default section and their contents, will be deleted as well.
</div>
<!-- <span *ngIf="sectionChildrenActionOnDelete == 'disconnect'" class="uk-text-bold">-->
<!-- Sections of all profiles based on this default section and their contents, will not be marked as copied from default anymore.-->
<!-- </span>-->
Are you sure you want to proceed?
</modal-alert>
<!--<modal-alert #deleteNumberSectionModal (alertOutput)="deleteSection('number')">-->
<!-- You are about to delete this section and its indicators permanently.-->
<!-- Are you sure you want to proceed?-->
<!--</modal-alert>-->
<!--<modal-alert #deleteChartSectionModal (alertOutput)="deleteSection()">-->
<!-- You are about to delete this section and its indicators permanently.-->
<!-- Are you sure you want to proceed?-->
<!--</modal-alert>-->

View File

@ -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 {

View File

@ -30,9 +30,14 @@
{{stakeholder.topics[topicIndex].isPublic ? 'Private' : 'Public'}}</a>
</li>
<hr *ngIf="!stakeholder.topics[topicIndex].defaultId" class="uk-nav-divider">
<li><a *ngIf="!stakeholder.topics[topicIndex].defaultId"
(click)="deleteTopicOpen(); hide(element)">Delete
</a></li>
<li *ngIf="!stakeholder.topics[topicIndex].defaultId"><a
(click)="deleteTopicOpen('delete'); hide(element)">Delete
</a>
<!-- <ng-container *ngIf="!stakeholder.defaultId">-->
<!-- <a (click)="deleteTopicOpen('delete'); hide(element)">Delete from all profiles</a>-->
<!-- <a (click)="deleteTopicOpen('disconnect'); hide(element)">Delete and disconnect from all profiles</a>-->
<!-- </ng-container>-->
</li>
</ul>
</div>
</div>
@ -66,9 +71,13 @@
{{category.isPublic ? 'Private' : 'Public'}}</a>
</li>
<hr *ngIf="!stakeholder.topics[topicIndex].categories[i].defaultId" class="uk-nav-divider">
<li><a *ngIf="!stakeholder.topics[topicIndex].categories[i].defaultId"
(click)="deleteCategoryOpen(i);
hide(element)">Delete</a></li>
<li *ngIf="!stakeholder.topics[topicIndex].categories[i].defaultId"><a
(click)="deleteCategoryOpen(i, 'delete'); hide(element)">Delete</a>
<!-- <ng-container *ngIf="!stakeholder.defaultId">-->
<!-- <a (click)="deleteCategoryOpen(i, 'delete'); hide(element)">Delete from all profiles</a>-->
<!-- <a (click)="deleteCategoryOpen(i, 'disconnect'); hide(element)">Delete and disconnect from all profiles</a>-->
<!-- </ng-container>-->
</li>
</ul>
</div>
</div>
@ -102,8 +111,13 @@
</li>
<hr *ngIf="!stakeholder.topics[topicIndex].categories[i].subCategories[j].defaultId"
class="uk-nav-divider">
<li><a *ngIf="!stakeholder.topics[topicIndex].categories[i].subCategories[j].defaultId"
(click)="deleteSubcategoryOpen(j); hide(element)">Delete</a></li>
<li *ngIf="!stakeholder.topics[topicIndex].categories[i].subCategories[j].defaultId"><a
(click)="deleteSubcategoryOpen(j, 'delete'); hide(element)">Delete</a>
<!-- <ng-container *ngIf="!stakeholder.defaultId">-->
<!-- <a (click)="deleteSubcategoryOpen(j, 'delete'); hide(element)">Delete from all profiles</a>-->
<!-- <a (click)="deleteSubcategoryOpen(j, 'disconnect'); hide(element)">Delete and disconnect from all profiles</a>-->
<!-- </ng-container>-->
</li>
</ul>
</div>
</div>
@ -135,8 +149,51 @@
[subcategoryIndex]="subCategoryIndex"></indicators>
<modal-alert #deleteModal (alertOutput)="deleteElement()">
You are about to delete <span class="uk-text-bold" *ngIf="element">"{{element.name}}"</span> {{type}} permanently.
<div *ngIf="elementChildrenActionOnDelete == 'delete'" class="uk-text-bold">
{{getPluralTypeName()}} of all profiles based on this default {{type}}, will be deleted as well.
</div>
Are you sure you want to proceed?
</modal-alert>
<!--<modal-alert #deleteModal>-->
<!-- You are about to delete <span class="uk-text-bold" *ngIf="element">"{{element.name}}"</span> {{type}} permanently.-->
<!-- <div *ngIf="!stakeholder.topics[topicIndex].defaultId">-->
<!-- <div class="uk-margin-top uk-margin-bottom">-->
<!-- <div>Delete this {{type}} only.</div>-->
<!-- <div class="uk-text-center">-->
<!-- <a *ngIf="type == 'topic'" class="md-btn md-btn-primary waves-button waves-effect uk-width-1-2"-->
<!-- (click)="deleteElement(); closeDeleteModal()">Delete</a>-->
<!-- <a *ngIf="type == 'category'" class="md-btn md-btn-primary waves-button waves-effect uk-width-1-2"-->
<!-- (click)="deleteElement(); closeDeleteModal()">Delete</a>-->
<!-- <a *ngIf="type == 'subcategory'" class="md-btn md-btn-primary waves-button waves-effect uk-width-1-2"-->
<!-- (click)="deleteElement(); closeDeleteModal()">Delete</a>-->
<!-- </div>-->
<!-- </div>-->
<!-- <ng-container *ngIf="!stakeholder.defaultId">-->
<!-- <div class="uk-margin-top uk-margin-bottom">-->
<!-- <div>Delete this {{type}} and {{getPluralTypeName()}} of all profiles based on this default {{type}}.</div>-->
<!-- <div class="uk-text-center">-->
<!-- <a *ngIf="type == 'topic'" class="md-btn md-btn-primary waves-button waves-effect uk-width-1-2"-->
<!-- (click)="deleteElement('delete'); closeDeleteModal()">Delete all</a>-->
<!-- <a *ngIf="type == 'category'" class="md-btn md-btn-primary waves-button waves-effect uk-width-1-2"-->
<!-- (click)="deleteElement('delete'); closeDeleteModal()">Delete all</a>-->
<!-- <a *ngIf="type == 'subcategory'" class="md-btn md-btn-primary waves-button waves-effect uk-width-1-2"-->
<!-- (click)="deleteElement('delete'); closeDeleteModal()">Delete all</a>-->
<!-- </div>-->
<!-- </div>-->
<!-- <div class="uk-margin-top uk-margin-bottom">-->
<!-- <div>Delete this {{type}} and {{getPluralTypeName()}} of all profiles based on this default {{type}}, will not be marked as copied from default anymore.</div>-->
<!-- <div class="uk-text-center">-->
<!-- <a *ngIf="type == 'topic'" class="md-btn md-btn-primary waves-button waves-effect uk-width-1-2"-->
<!-- (click)="deleteElement('disconnect'); closeDeleteModal()">Delete and disconnect</a>-->
<!-- <a *ngIf="type == 'category'" class="md-btn md-btn-primary waves-button waves-effect uk-width-1-2"-->
<!-- (click)="deleteElement('disconnect'); closeDeleteModal()">Delete and disconnect</a>-->
<!-- <a *ngIf="type == 'subcategory'" class="md-btn md-btn-primary waves-button waves-effect uk-width-1-2"-->
<!-- (click)="deleteElement('disconnect'); closeDeleteModal()">Delete and disconnect</a>-->
<!-- </div>-->
<!-- </div>-->
<!-- </ng-container>-->
<!-- </div>-->
<!--</modal-alert>-->
<modal-alert #editModal (alertOutput)="saveElement()">
<div *ngIf="form" class="uk-padding-small" [formGroup]="form">
<div dashboard-input class="uk-form-row" [formInput]="form.get('name')" label="Title"></div>

View File

@ -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;
}
}
}