Added value converter to correctly display values
This commit is contained in:
parent
fa164b424c
commit
84ccb4df91
@ -103,6 +103,11 @@ export class SamplesComponent implements OnInit {
|
||||
sampleSelect = 0; // modes: 0 - no selection, 1 - sample edit selection, 2 - validation selection
|
||||
loading = 0; // number of loading instances
|
||||
|
||||
valueConverters = {
|
||||
added: (v: string, _sample) => new Date(v).toLocaleDateString(),
|
||||
notes: v => v.sample_references.length > 0 ? Object.keys(v.sample_references).map(r => v.sample_references[r].relation).join(", ") : "",
|
||||
'notes.comment': (v: any, sample: any) => sample['notes']['comment']
|
||||
}
|
||||
|
||||
constructor(
|
||||
private api: ApiService,
|
||||
@ -114,6 +119,7 @@ export class SamplesComponent implements OnInit {
|
||||
private window: Window,
|
||||
private router: Router
|
||||
) {
|
||||
//this.valueConverters['notes.comment'] = v => console.log(v['comment']);
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
@ -440,7 +446,7 @@ export class SamplesComponent implements OnInit {
|
||||
.push(...Object.entries(measurement.values).filter(e => e[0] !== 'dpt')
|
||||
.map(e => ({ name: this.ucFirst(name) + ' ' + e[0], value: e[1] })));
|
||||
});
|
||||
new Promise(resolve => {
|
||||
new Promise<void>(resolve => {
|
||||
if (data.notes.sample_references.length) { // load referenced samples if available
|
||||
let loadingCounter = data.notes.sample_references.length;
|
||||
this.sampleDetailsSample.notes.sample_references.forEach(reference => {
|
||||
@ -532,7 +538,6 @@ export class SamplesComponent implements OnInit {
|
||||
refreshMultiSelect() {
|
||||
for (let collection in this.categories) {
|
||||
this.categories[collection] = [...this.categories[collection]];
|
||||
console.log(this.categories[collection]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -543,11 +548,8 @@ export class SamplesComponent implements OnInit {
|
||||
let value = [];
|
||||
this.activeKeys.forEach(key => {
|
||||
let id = key.id.split('material.')[1];
|
||||
if(id){
|
||||
value.push(this.d.id.materials[sample.material_id][id]);
|
||||
}else{
|
||||
value.push(sample[key.id]);
|
||||
}
|
||||
let tmpValue = id ? this.d.id.materials[sample.material_id][id] : sample[key.id];
|
||||
value.push(this.valueConverters[key.id] ? this.valueConverters[key.id](tmpValue, sample) : tmpValue);
|
||||
});
|
||||
this.data.push({ id: sample._id, data: value });
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user