Merge pull request #15 in ~VLE2FE/definma-ui from development to master
* commit 'c0b410c4830179c6f5dcc41901da4b234134ee8e': fixed material numbers in new dialog fixed new sample material group/supplier autocomplete, template refresh after changes, template array input
This commit is contained in:
@ -19,16 +19,17 @@
|
||||
<div class="material shaded-container" *ngIf="newMaterial" [@inOut]>
|
||||
<h4>Material properties</h4>
|
||||
<rb-form-input name="supplier" label="supplier"
|
||||
[rbFormInputAutocomplete]="autocomplete.bind(this, d.arr.materialSupplier)"
|
||||
[rbFormInputAutocomplete]="autocomplete.bind(this, d.arr.materialSuppliers)"
|
||||
[rbDebounceTime]="0" [rbInitialOpen]="true" appValidate="string" required
|
||||
[(ngModel)]="material.supplier" #supplierInput="ngModel"
|
||||
(focusout)="checkTypo('materialSuppliers', 'supplier', modalWarning)">
|
||||
(focusout)="checkTypo($event, 'materialSuppliers', 'supplier', modalWarning)">
|
||||
<ng-template rbFormValidationMessage="failure">{{supplierInput.errors.failure}}</ng-template>
|
||||
</rb-form-input>
|
||||
<rb-form-input name="group" label="group" [rbFormInputAutocomplete]="autocomplete.bind(this, d.arr.materialGroup)"
|
||||
<rb-form-input name="group" label="group"
|
||||
[rbFormInputAutocomplete]="autocomplete.bind(this, d.arr.materialGroups)"
|
||||
[rbDebounceTime]="0" [rbInitialOpen]="true" appValidate="string" required
|
||||
[(ngModel)]="material.group" #groupInput="ngModel"
|
||||
(focusout)="checkTypo('materialGroups', 'group', modalWarning)">
|
||||
(focusout)="checkTypo($event, 'materialGroups', 'group', modalWarning)">
|
||||
<ng-template rbFormValidationMessage="failure">{{groupInput.errors.failure}}</ng-template>
|
||||
</rb-form-input>
|
||||
<ng-template #modalWarning>
|
||||
@ -44,7 +45,7 @@
|
||||
</rb-array-input>
|
||||
<rb-form-select name="conditionSelect" label="Type"
|
||||
[(ngModel)]="material.properties.material_template">
|
||||
<option *ngFor="let m of d.arr.materialTemplates" [value]="m._id">{{m.name}}</option>
|
||||
<option *ngFor="let m of d.latest.materialTemplates" [value]="m._id">{{m.name}}</option>
|
||||
</rb-form-select>
|
||||
<rb-form-input *ngFor="let parameter of d.id.materialTemplates[material.properties.material_template].parameters;
|
||||
index as i" [name]="'materialParameter' + i"
|
||||
@ -157,7 +158,7 @@
|
||||
<div *ngIf="gSample.condition.condition_template" [@inOut]>
|
||||
<rb-form-select name="conditionSelect" label="Condition"
|
||||
[(ngModel)]="gSample.condition.condition_template">
|
||||
<option *ngFor="let c of d.arr.conditionTemplates" [value]="c._id">{{c.name}}</option>
|
||||
<option *ngFor="let c of d.latest.conditionTemplates" [value]="c._id">{{c.name}}</option>
|
||||
</rb-form-select>
|
||||
|
||||
<ng-container *ngFor="let parameter of
|
||||
@ -186,7 +187,7 @@
|
||||
<rb-form-select [name]="'measurementTemplateSelect-' + gIndex + '-' + mIndex" label="Template"
|
||||
[(ngModel)]="measurement.measurement_template"
|
||||
(ngModelChange)="clearMeasurement(gIndex, mIndex)">
|
||||
<option *ngFor="let m of d.arr.measurementTemplates" [value]="m._id">{{m.name}}</option>
|
||||
<option *ngFor="let m of d.latest.measurementTemplates" [value]="m._id">{{m.name}}</option>
|
||||
</rb-form-select>
|
||||
|
||||
<div *ngFor="let parameter of d.id.measurementTemplates[measurement.measurement_template].parameters;
|
||||
|
@ -139,7 +139,7 @@ export class SampleComponent implements OnInit, AfterContentChecked {
|
||||
});
|
||||
this.d.load('materialTemplates', () => {
|
||||
if (!this.material.properties.material_template) {
|
||||
this.material.properties.material_template = this.d.arr.materialTemplates.filter(e => e.name === 'plastic').reverse()[0]._id;
|
||||
this.material.properties.material_template = this.d.latest.materialTemplates.find(e => e.name === 'plastic')._id;
|
||||
}
|
||||
this.loading--;
|
||||
});
|
||||
@ -270,6 +270,8 @@ export class SampleComponent implements OnInit, AfterContentChecked {
|
||||
}
|
||||
new Promise<void>(resolve => {
|
||||
if (this.newMaterial) { // save material first if new one exists
|
||||
console.log(this.material);
|
||||
this.material.numbers = this.material.numbers.filter(e => e !== '');
|
||||
this.api.post<MaterialModel>('/material/new', this.material.sendFormat(), data => {
|
||||
this.d.arr.materials.push(data); // add material to data
|
||||
this.material = data;
|
||||
@ -348,7 +350,7 @@ export class SampleComponent implements OnInit, AfterContentChecked {
|
||||
else { // no matching material found
|
||||
if (this.sample.material_id !== null) { // reset previous match
|
||||
this.material = new MaterialModel();
|
||||
this.material.properties.material_template = this.d.arr.materialTemplates.filter(e => e.name === 'plastic').reverse()[0]._id;
|
||||
this.material.properties.material_template = this.d.latest.materialTemplates.find(e => e.name === 'plastic')._id;
|
||||
}
|
||||
this.sample.material_id = null;
|
||||
}
|
||||
@ -376,9 +378,9 @@ export class SampleComponent implements OnInit, AfterContentChecked {
|
||||
// add a new measurement for generated sample at index
|
||||
addMeasurement(gIndex) {
|
||||
this.generatedSamples[gIndex].measurements.push(
|
||||
new MeasurementModel(this.d.arr.measurementTemplates.filter(e => e.name === 'spectrum').reverse()[0]._id)
|
||||
new MeasurementModel(this.d.latest.measurementTemplates.find(e => e.name === 'spectrum')._id)
|
||||
);
|
||||
this.generatedSamples[gIndex].measurements[this.generatedSamples[gIndex].measurements.length - 1].values.device = this.defaultDevice;
|
||||
console.log(this.d.latest.measurementTemplates.find(e => e.name === 'spectrum'));
|
||||
if (!this.charts[gIndex]) { // add array if there are no charts yet
|
||||
this.charts[gIndex] = [];
|
||||
}
|
||||
@ -411,6 +413,8 @@ export class SampleComponent implements OnInit, AfterContentChecked {
|
||||
this.addMeasurement(gIndex);
|
||||
index = this.generatedSamples[gIndex].measurements.length - 1;
|
||||
}
|
||||
this.generatedSamples[gIndex].measurements[index].values.device =
|
||||
this.generatedSamples[gIndex].measurements[mIndex].values.device;
|
||||
this.generatedSamples[gIndex].measurements[index].values.filename = files[i].name;
|
||||
this.generatedSamples[gIndex].measurements[index].values[parameter] =
|
||||
fileReader.result.toString().split('\r\n').map(e => e.split(','));
|
||||
@ -430,12 +434,15 @@ export class SampleComponent implements OnInit, AfterContentChecked {
|
||||
sample.condition.condition_template = null;
|
||||
}
|
||||
else {
|
||||
sample.condition.condition_template = this.d.arr.conditionTemplates[0]._id;
|
||||
sample.condition.condition_template = this.d.latest.conditionTemplates[0]._id;
|
||||
}
|
||||
}
|
||||
|
||||
checkTypo(list, mKey, modal: TemplateRef<any>) {
|
||||
if (this.d.arr[list].indexOf(this.material[list]) < 0) { // entry is not in list
|
||||
checkTypo(event, list, mKey, modal: TemplateRef<any>) {
|
||||
// user did not click on suggestion and entry is not in list
|
||||
if (!(event.relatedTarget && (event.relatedTarget.className.indexOf('rb-dropdown-item') >= 0 ||
|
||||
event.relatedTarget.className.indexOf('close-btn rb-btn rb-passive-link') >= 0)) &&
|
||||
this.d.arr[list].indexOf(this.material[mKey]) < 0) {
|
||||
this.modalText.list = mKey;
|
||||
this.modalText.suggestion = this.d.arr[list] // find possible entry from list
|
||||
.map(e => ({v: e, s: strCompare.sorensenDice(e, this.material[mKey])}))
|
||||
|
Reference in New Issue
Block a user