dataset-data-details.component.ts 1.25 KB
Newer Older
FORESTIER Fabien's avatar
FORESTIER Fabien committed
1
2
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { DatasetDetailService } from '../../services';
3
4
5
6
7
8
9

@Component({
  selector: 'app-dataset-data-details',
  templateUrl: './dataset-data-details.component.html',
  styleUrls: ['./dataset-data-details.component.scss'],
})
export class DatasetDataDetailsComponent implements OnInit {
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

  private _properties;
  @Input()
  set properties(properties) {
    // Making sure the complex properties values are under objects or array form and not string
    // When properties comme from the map MVT the types are lost and they are always represented as string
    for (const key in properties) {
      if (properties.hasOwnProperty(key)) {
        if (!this._datasetDetailService.dataset.fields.types[key] && typeof properties[key] === 'string') {
          try {
            const parsed = JSON.parse(properties[key]);
            properties[key] = parsed;
          } catch (err) { }
        }
      }
    }
    this._properties = properties;
  }

29
30
  @Output() close = new EventEmitter<boolean>();

31
32
33
  constructor(
    private _datasetDetailService: DatasetDetailService,
  ) { }
34
35
36
37

  ngOnInit() {
  }

38
39
  get properties() {
    return this._properties;
40
41
42
43
44
45
46
  }

  closeSelf() {
    this.close.emit(true);
  }

}