[Monitor Dashboard | Trunk]: Change reorder method
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-monitor-portal/trunk/monitor_dashboard@60104 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
44c61ac015
commit
6d2948d87f
|
@ -23,7 +23,7 @@ import {AlertModal} from "../openaireLibrary/utils/modal/alert";
|
|||
import {StatisticsService} from "../utils/services/statistics.service";
|
||||
import {HelperFunctions} from "../openaireLibrary/utils/HelperFunctions.class";
|
||||
import {DomSanitizer, SafeResourceUrl} from "@angular/platform-browser";
|
||||
import {StakeholderService} from "../openaireLibrary/monitor/services/stakeholder.service";
|
||||
import {Reorder, StakeholderService} from "../openaireLibrary/monitor/services/stakeholder.service";
|
||||
import {EnvProperties} from "../openaireLibrary/utils/properties/env-properties";
|
||||
import {Subscriber} from "rxjs";
|
||||
import {LayoutService} from "../openaireLibrary/dashboard/sharedComponents/sidebar/layout.service";
|
||||
|
@ -200,7 +200,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|||
}
|
||||
});
|
||||
if (document !== undefined) {
|
||||
let callback = (list, type: IndicatorType): void => {
|
||||
let callback = (list, type: IndicatorType, action: 'moved' | 'added' | 'removed'): void => {
|
||||
let items: HTMLCollection = list.current.children;
|
||||
let reordered = [];
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
|
@ -208,28 +208,33 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|||
reordered.push(items.item(i).id);
|
||||
}
|
||||
}
|
||||
this.reorderIndicators(list.current.id.toString().split('-')[1], type, reordered);
|
||||
let reorder: Reorder = {
|
||||
action: action,
|
||||
target: list.detail[1].id,
|
||||
ids: reordered
|
||||
}
|
||||
this.reorderIndicators(list.current.id.toString().split('-')[1], type, reorder);
|
||||
};
|
||||
this.numbers.forEach((section) => {
|
||||
this.subscriptions.push(UIkit.util.on(document, 'moved', '#number-' + section._id, (list): void => {
|
||||
callback(list, "number");
|
||||
callback(list, "number", 'moved');
|
||||
}));
|
||||
this.subscriptions.push(UIkit.util.on(document, 'added', '#number-' + section._id, (list): void => {
|
||||
callback(list, "number");
|
||||
callback(list, "number", 'added');
|
||||
}));
|
||||
this.subscriptions.push(UIkit.util.on(document, 'removed', '#number-' + section._id, (list): void => {
|
||||
callback(list, "number");
|
||||
callback(list, "number", 'removed');
|
||||
}));
|
||||
});
|
||||
this.charts.forEach((section) => {
|
||||
this.subscriptions.push(UIkit.util.on(document, 'moved', '#chart-' + section._id, (list): void => {
|
||||
callback(list, "chart");
|
||||
callback(list, "chart", 'moved');
|
||||
}));
|
||||
this.subscriptions.push(UIkit.util.on(document, 'added', '#chart-' + section._id, (list): void => {
|
||||
callback(list, "chart");
|
||||
callback(list, "chart", 'added');
|
||||
}));
|
||||
this.subscriptions.push(UIkit.util.on(document, 'removed', '#chart-' + section._id, (list): void => {
|
||||
callback(list, "chart");
|
||||
callback(list, "chart", 'removed');
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
@ -825,7 +830,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|||
}));
|
||||
}
|
||||
|
||||
reorderIndicators(sectionId: string, type: IndicatorType, indicatorIds: string[]) {
|
||||
reorderIndicators(sectionId: string, type: IndicatorType, reorder: Reorder) {
|
||||
this.editing = true;
|
||||
let path = [
|
||||
this.stakeholder._id,
|
||||
|
@ -834,7 +839,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|||
this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.subcategoryIndex]._id,
|
||||
sectionId
|
||||
];
|
||||
this.subscriptions.push(this.stakeholderService.reorderIndicators(this.properties.monitorServiceAPIURL, path, indicatorIds, type).subscribe(indicators => {
|
||||
this.subscriptions.push(this.stakeholderService.reorderIndicators(this.properties.monitorServiceAPIURL, path, reorder, type).subscribe(indicators => {
|
||||
if (type === 'chart') {
|
||||
this.charts.find(section => section._id === sectionId).indicators = indicators;
|
||||
this.filterCharts();
|
||||
|
@ -861,9 +866,11 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|||
public get isAdministrator(): boolean {
|
||||
return Session.isPortalAdministrator(this.user);
|
||||
}
|
||||
|
||||
public get isCurator(): boolean {
|
||||
return this.isAdministrator || Session.isMonitorCurator(this.user);
|
||||
}
|
||||
|
||||
refreshIndicator() {
|
||||
this.indicator = this.indicatorUtils.generateIndicatorByForm(this.chartIndicatorFb.value, this.indicator.indicatorPaths, 'chart', true);
|
||||
this.indicator.indicatorPaths.forEach(indicatorPath => {
|
||||
|
|
Loading…
Reference in New Issue