Project

General

Profile

« Previous | Next » 

Revision 57719

[Monitor Dashboard]: Add home page. Fix a bug when edit indicator and filter is on

View differences:

indicators.component.ts
97 97

  
98 98
  ngOnChanges(changes: SimpleChanges): void {
99 99
    if (this.canEdit) {
100
      this.buildFilters();
100
      if(changes.topicIndex || changes.categoryIndex || changes.subcategoryIndex) {
101
        this.buildFilters();
102
      }
101 103
      this.filterCharts();
102 104
      this.filterNumbers();
103 105
    }
......
157 159
  }
158 160

  
159 161
  onPrivacyChange(value) {
160
    console.log(value);
161 162
    this.displayCharts = this.filterPrivacy(this.charts, value);
162 163
    this.displayNumbers = this.filterPrivacy(this.numbers, value);
163 164
  }
......
308 309
    this.editIndicatorOpen();
309 310
  }
310 311

  
311
  public editIndicatorOpen(index: number = -1) {
312
    this.index = index;
312
  public editIndicatorOpen(id = null) {
313
    this.index = this.charts.findIndex(value => value._id === id);
313 314
    if (this.index !== -1) {
314
      this.indicator = HelperFunctions.copy(this.charts[index]);
315
      this.indicator = HelperFunctions.copy(this.charts[this.index]);
315 316
    }
316 317
    let indicatorPaths = this.fb.array([]);
317 318
    this.indicator.indicatorPaths.forEach(indicatorPath => {
......
346 347
      indicatorPaths: indicatorPaths,
347 348
      width: this.fb.control(this.indicator.width, Validators.required),
348 349
    });
349
    if(index === -1) {
350
    if(this.index === -1) {
350 351
      this.editIndicatorModal.okButtonText = 'Save';
351 352
      this.editIndicatorModal.stayOpen = false;
352 353
    } else {
......
414 415
    this.indicatorPaths.at(index).markAsPristine({onlySelf: true});
415 416
  }
416 417

  
417
  deleteIndicatorOpen(index: number, type: string = 'chart') {
418
    this.index = index;
418
  deleteIndicatorOpen(id: string, type: string = 'chart') {
419 419
    if(type === 'chart') {
420
      this.indicator = this.charts[index];
420
      this.indicator = this.charts.find(value => value._id == id);
421 421
    } else {
422
      this.indicator = this.numbers[index];
422
      this.indicator = this.numbers.find(value => value._id == id);
423 423
    }
424 424
    this.deleteIndicatorModal.alertTitle = 'Delete ' + this.indicator.name;
425 425
    this.deleteIndicatorModal.cancelButtonText = 'No';

Also available in: Unified diff