small fixes

This commit is contained in:
VLE2FE
2020-08-12 11:06:46 +02:00
parent 638868875b
commit 737ba40817
19 changed files with 137 additions and 63 deletions

View File

@ -127,7 +127,7 @@
</a>
</div>
<rb-table class="samples-table">
<rb-table class="samples-table" scrollTop ellipsis>
<tr>
<th *ngIf="validation">
<rb-form-checkbox name="validate-all" (change)="selectAll($event)">all</rb-form-checkbox>
@ -213,7 +213,7 @@
<tr><th>Comment</th><td>{{sampleDetailsSample.notes.comment | exists}}</td></tr>
<tr *ngFor="let customField of sampleDetailsSample.notes.custom_fields_entries">
<th>{{customField[0]}}</th>
<td>{{customField[0]}}</td>
<td>{{customField[1]}}</td>
</tr>
<tr *ngFor="let reference of sampleDetailsSample.notes.sample_references">
<th>{{reference.relation}}</th>
@ -223,6 +223,10 @@
</button>
</td>
</tr>
<tr *ngFor="let conditionField of sampleDetailsSample.condition_entries">
<th>{{conditionField[0]}}</th>
<td>{{conditionField[1]}}</td>
</tr>
<tr *ngFor="let measurement of sampleDetailsSample.measurement_entries">
<th>{{measurement.name}}</th>
<td>{{measurement.value}}</td>

View File

@ -3,6 +3,7 @@ import {ApiService} from '../services/api.service';
import {AutocompleteService} from '../services/autocomplete.service';
import cloneDeep from 'lodash/cloneDeep';
import pick from 'lodash/pick';
import omit from 'lodash/omit';
import {SampleModel} from '../models/sample.model';
import {LoginService} from '../services/login.service';
import {ModalService} from '@inst-iot/bosch-angular-ui-components';
@ -27,7 +28,7 @@ interface KeyInterface {
styleUrls: ['./samples.component.scss']
})
// TODO: save last settings
export class SamplesComponent implements OnInit {
@ -65,7 +66,7 @@ export class SamplesComponent implements OnInit {
loadSamplesQueue = []; // arguments of queued up loadSamples() calls
keys: KeyInterface[] = [
{id: 'number', label: 'Number', active: true, sortable: true},
{id: 'material.numbers', label: 'Material numbers', active: true, sortable: false},
{id: 'material.numbers', label: 'Material numbers', active: false, sortable: false},
{id: 'material.name', label: 'Material name', active: true, sortable: true},
{id: 'material.supplier', label: 'Supplier', active: true, sortable: true},
{id: 'material.group', label: 'Material', active: false, sortable: true},
@ -105,6 +106,7 @@ export class SamplesComponent implements OnInit {
this.filters.filters.find(e => e.field === 'material.group').autocomplete = this.d.arr.materialGroups;
});
this.d.load('userKey');
this.d.load('conditionTemplates');
this.loadTemplateKeys('material', 'type');
this.loadTemplateKeys('measurement', 'status');
}
@ -284,7 +286,6 @@ export class SamplesComponent implements OnInit {
});
}
// TODO: add measurements when ressource service is done
sampleDetails(id: string, modal: TemplateRef<any>) {
this.sampleDetailsSample = null;
this.api.get<SampleModel>('/sample/' + id, data => {
@ -295,11 +296,21 @@ export class SamplesComponent implements OnInit {
else {
this.sampleDetailsSample.custom_fields_entries = [];
}
if (Object.keys(data.condition).length) {
this.sampleDetailsSample.condition_entries = Object.entries(omit(this.sampleDetailsSample.condition, ['condition_template']))
.map(e => {
e[0] = `${this.ucFirst(this.d.id.conditionTemplates[this.sampleDetailsSample.condition.condition_template].name)} ${e[0]}`;
return e;
});
}
else {
this.sampleDetailsSample.condition_entries = [];
}
this.sampleDetailsSample.measurement_entries = [];
this.sampleDetailsSample.measurements.forEach(measurement => { // convert measurements for more optimized display without dpt
const name = this.d.id.measurementTemplates[measurement.measurement_template].name;
this.sampleDetailsSample.measurement_entries.push(...Object.entries(measurement.values).filter(e => e[0] !== 'dpt')
.map(e => ({name: this.ucFirst(name) + ' ' + this.ucFirst(e[0]), value: e[1]})));
.map(e => ({name: this.ucFirst(name) + ' ' + e[0], value: e[1]})));
});
new Promise(resolve => {
if (data.notes.sample_references.length) { // load referenced samples if available