import indicators: use this.index to get the index of the category to import the indicators - used to import them always in the active subcategory

This commit is contained in:
argirok 2021-12-13 11:37:06 +02:00
parent e902ebaed5
commit 0403ca6dee
2 changed files with 10 additions and 9 deletions

View File

@ -814,16 +814,16 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
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.subcategoryIndex]._id
this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.index]._id
];
this.subscriptions.push(this.stakeholderService.saveBulkElements(this.properties.monitorServiceAPIURL, indicators, path).subscribe(stakeholder => {
this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.subcategoryIndex].charts = stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.subcategoryIndex].charts;
this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.subcategoryIndex].numbers = stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.subcategoryIndex].numbers;
this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.index].charts = stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.index].charts;
this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.index].numbers = stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.index].numbers;
this.setCharts();
this.setNumbers();
this.initReorder();
this.notification = NotificationUtils.importIndicators(this.user.fullname, this.stakeholder.alias);
this.notification.entity = this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.subcategoryIndex]._id;
this.notification.entity = this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.index]._id;
this.notification.name = this.user.firstname;
this.notification.surname = this.user.lastname;
this.notification.stakeholder = this.stakeholder.alias;
@ -1216,7 +1216,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
if (chart.type == "chart") {
indicatorPath = this.indicatorUtils.generateIndicatorByChartUrl(this.statisticsService.getChartSource(chart.url), chart.url, chart.type, this.stakeholder);
for (let section of this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.subcategoryIndex].charts) {
for (let section of this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.index].charts) {
for (let chart of section.indicators) {
if (JSON.stringify(chart.indicatorPaths[0].chartObject) == JSON.stringify(indicatorPath.chartObject)) {
duplicates++;
@ -1228,7 +1228,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
} else if (chart.type == "number") {
indicatorPath = this.indicatorUtils.generateIndicatorByNumberUrl(this.statisticsService.getNumberSource(chart.url), chart.url, this.stakeholder,
chart.jsonPath, this.statisticsService.numberSources.get(this.statisticsService.getNumberSource(chart.url)));
for (let section of this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.subcategoryIndex].numbers) {
for (let section of this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.index].numbers) {
for (let chart of section.indicators) {
if (JSON.stringify(chart.indicatorPaths[0].chartObject) == JSON.stringify(indicatorPath.chartObject)) {
duplicates++;
@ -1334,7 +1334,8 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
this.exportLoading = false;
}
fileChangeEvent(fileInput: any) {
fileChangeEvent(fileInput: any, index) {
this.index = index;
this.editing = true;
this.importLoading = true;
this.filesToUpload = <Array<File>>fileInput.target.files;

View File

@ -181,7 +181,7 @@
<li *ngIf="indicators && indicators.isCurator"><a (click)=" indicators.exportIndicators();
hide(element)">Export
indicators</a></li>
<li *ngIf="indicators && indicators.isCurator"><a (click)="file.value = ''; file.click(); hide(element)">Import indicators</a></li>
<li *ngIf="indicators && indicators.isCurator"><a (click)="file.value = ''; this.index=i; file.click(); hide(element)">Import indicators</a></li>
<hr *ngIf="!stakeholder.topics[topicIndex].categories[categoryIndex].subCategories[i].defaultId"
class="uk-nav-divider">
<li *ngIf="!stakeholder.topics[topicIndex].categories[categoryIndex].subCategories[i].defaultId"><a
@ -226,7 +226,7 @@
</div>-->
</div>
<div inner>
<input #file id="import-file" type="file" class="uk-hidden" (change)="indicators.fileChangeEvent($event)"/>
<input #file id="import-file" type="file" class="uk-hidden" (change)="indicators.fileChangeEvent($event, this.index)"/>
<indicators #indicators [topicIndex]="topicIndex" [categoryIndex]="categoryIndex"
[subcategoryIndex]="subCategoryIndex"
[stakeholder]="stakeholder" [changed]="change.asObservable()"></indicators>