Merge pull request #30 in ~VLE2FE/definma-ui from development to master
* commit '819666c3444181dbe6e08ab155b4b027149217e2': condition fix template fixes
This commit is contained in:
commit
2d1b1a83aa
@ -37,7 +37,7 @@
|
|||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<div *rbSubBrandHeader>
|
<div *rbSubBrandHeader>
|
||||||
<rb-icon-button icon="bug" mode="secondary" class="space-right" [rbModal]="bugModal" *ngIf="false">
|
<rb-icon-button icon="bug" mode="secondary" class="space-right" [rbModal]="bugModal">
|
||||||
Bug
|
Bug
|
||||||
</rb-icon-button>
|
</rb-icon-button>
|
||||||
<ng-template let-close="close" #bugModal>
|
<ng-template let-close="close" #bugModal>
|
||||||
@ -48,7 +48,7 @@
|
|||||||
<rb-icon-button icon="mail" mode="primary" (mouseup)="closeBugReport(close)">Send report</rb-icon-button>
|
<rb-icon-button icon="mail" mode="primary" (mouseup)="closeBugReport(close)">Send report</rb-icon-button>
|
||||||
</a>
|
</a>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
<span class="dev-label" *ngIf="devMode && false">DEVELOPMENT</span>
|
<span class="dev-label" *ngIf="devMode">DEVELOPMENT</span>
|
||||||
DeFinMa
|
DeFinMa
|
||||||
</div>
|
</div>
|
||||||
</rb-full-header>
|
</rb-full-header>
|
||||||
|
@ -41,8 +41,12 @@ export class SampleModel extends BaseModel {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
sendFormat() {
|
sendFormat(pickCondition = true) {
|
||||||
const tmp = pick(this.conditionTemplateCheck(), ['color', 'type', 'batch', 'condition', 'material_id', 'notes']);
|
const pickFields = ['color', 'type', 'batch', 'material_id', 'notes'];
|
||||||
|
if (pickCondition) {
|
||||||
|
pickFields.push('condition');
|
||||||
|
}
|
||||||
|
const tmp = pick(this.conditionTemplateCheck(), pickFields);
|
||||||
Object.keys(tmp).forEach(key => {
|
Object.keys(tmp).forEach(key => {
|
||||||
if (tmp[key] === undefined) {
|
if (tmp[key] === undefined) {
|
||||||
delete tmp[key];
|
delete tmp[key];
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
<h2>{{mode === 'new' ? 'Add new sample' : 'Edit sample '}}</h2>
|
<h2>{{mode === 'new' ? 'Add new sample' : 'Edit sample'}}</h2>
|
||||||
<!--TODO: title-->
|
|
||||||
|
|
||||||
<rb-loading-spinner *ngIf="loading; else content"></rb-loading-spinner>
|
<rb-loading-spinner *ngIf="loading; else content"></rb-loading-spinner>
|
||||||
|
|
||||||
@ -14,13 +13,13 @@
|
|||||||
[rbFormInputAutocomplete]="autocomplete.bind(this, materialNames)" appValidate="stringOf"
|
[rbFormInputAutocomplete]="autocomplete.bind(this, materialNames)" appValidate="stringOf"
|
||||||
(keydown)="preventDefault($event)" (ngModelChange)="findMaterial($event)" ngModel
|
(keydown)="preventDefault($event)" (ngModelChange)="findMaterial($event)" ngModel
|
||||||
[appValidateArgs]="[materialNames]" required [(ngModel)]="material.name" [autofocus]="true"
|
[appValidateArgs]="[materialNames]" required [(ngModel)]="material.name" [autofocus]="true"
|
||||||
*ngIf="baseSample.material !== undefined || mode === 'new'"
|
*ngIf="baseSample.material.name !== undefined || mode === 'new'"
|
||||||
title="trade name of the material, eg. Ultradur B4300 G6">
|
title="trade name of the material, eg. Ultradur B4300 G6">
|
||||||
<ng-template rbFormValidationMessage="required">Cannot be empty</ng-template>
|
<ng-template rbFormValidationMessage="required">Cannot be empty</ng-template>
|
||||||
<ng-template rbFormValidationMessage="failure">Unknown material, add properties for new material</ng-template>
|
<ng-template rbFormValidationMessage="failure">Unknown material, add properties for new material</ng-template>
|
||||||
</rb-form-input>
|
</rb-form-input>
|
||||||
<rb-icon-button class="set-new-material space-below" icon="add" mode="secondary"
|
<rb-icon-button class="set-new-material space-below" icon="add" mode="secondary"
|
||||||
(click)="setNewMaterial(!newMaterial)" *ngIf="baseSample.material !== undefined">
|
(click)="setNewMaterial(!newMaterial)" *ngIf="baseSample.material.name !== undefined">
|
||||||
New material
|
New material
|
||||||
</rb-icon-button>
|
</rb-icon-button>
|
||||||
</div>
|
</div>
|
||||||
@ -197,8 +196,12 @@
|
|||||||
</button>
|
</button>
|
||||||
</h5>
|
</h5>
|
||||||
<div *ngIf="sample.condition.condition_template" [@inOut]>
|
<div *ngIf="sample.condition.condition_template" [@inOut]>
|
||||||
<rb-form-select name="conditionSelect" label="Condition"
|
<rb-form-select [name]="'conditionSelect-' + gIndex" label="Condition"
|
||||||
[(ngModel)]="sample.condition.condition_template">
|
[(ngModel)]="sample.condition.condition_template"
|
||||||
|
(ngModelChange)="reValidate()">
|
||||||
|
<option [value]="sample.condition.condition_template">
|
||||||
|
{{d.id.conditionTemplates[sample.condition.condition_template].name}} - current
|
||||||
|
</option>
|
||||||
<option *ngFor="let c of d.latest.conditionTemplates" [value]="c._id">{{c.name}}</option>
|
<option *ngFor="let c of d.latest.conditionTemplates" [value]="c._id">{{c.name}}</option>
|
||||||
</rb-form-select>
|
</rb-form-select>
|
||||||
|
|
||||||
@ -211,7 +214,7 @@
|
|||||||
<option *ngFor="let value of parameter.range.values" [value]="value">{{value}}</option>
|
<option *ngFor="let value of parameter.range.values" [value]="value">{{value}}</option>
|
||||||
<ng-template rbFormValidationMessage="required">Cannot be empty</ng-template>
|
<ng-template rbFormValidationMessage="required">Cannot be empty</ng-template>
|
||||||
</rb-form-select>
|
</rb-form-select>
|
||||||
<rb-form-input *ngSwitchDefault
|
<rb-form-input *ngSwitchDefault (focus)="checkFormAfterInit = true"
|
||||||
[name]="'conditionParameter-' + gIndex + '-' + i"
|
[name]="'conditionParameter-' + gIndex + '-' + i"
|
||||||
[label]="parameter.name" appValidate="string" required
|
[label]="parameter.name" appValidate="string" required
|
||||||
[(ngModel)]="sample.condition[parameter.name]" #parameterInput="ngModel">
|
[(ngModel)]="sample.condition[parameter.name]" #parameterInput="ngModel">
|
||||||
@ -234,9 +237,11 @@
|
|||||||
<rb-form-select [name]="'measurementTemplateSelect-' + gIndex + '-' + mIndex" label="Template"
|
<rb-form-select [name]="'measurementTemplateSelect-' + gIndex + '-' + mIndex" label="Template"
|
||||||
[(ngModel)]="measurement.measurement_template"
|
[(ngModel)]="measurement.measurement_template"
|
||||||
(ngModelChange)="clearMeasurement(gIndex, mIndex)">
|
(ngModelChange)="clearMeasurement(gIndex, mIndex)">
|
||||||
|
<option [value]="sample.condition.condition_template">
|
||||||
|
{{d.id.measurementTemplates[measurement.measurement_template].name}} - current
|
||||||
|
</option>
|
||||||
<option *ngFor="let m of d.latest.measurementTemplates" [value]="m._id">{{m.name}}</option>
|
<option *ngFor="let m of d.latest.measurementTemplates" [value]="m._id">{{m.name}}</option>
|
||||||
</rb-form-select>
|
</rb-form-select>
|
||||||
|
|
||||||
<div *ngFor="let parameter of d.id.measurementTemplates[measurement.measurement_template].parameters;
|
<div *ngFor="let parameter of d.id.measurementTemplates[measurement.measurement_template].parameters;
|
||||||
index as pIndex">
|
index as pIndex">
|
||||||
<ng-container [ngSwitch]="(parameter.range.type ? 1 : 0) + (parameter.range.values ? 2 : 0)">
|
<ng-container [ngSwitch]="(parameter.range.type ? 1 : 0) + (parameter.range.values ? 2 : 0)">
|
||||||
@ -328,3 +333,4 @@
|
|||||||
Do you really want to delete {{samples.length > 1 ? 'these samples' : 'this sample'}}?
|
Do you really want to delete {{samples.length > 1 ? 'these samples' : 'this sample'}}?
|
||||||
</rb-alert>
|
</rb-alert>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import cloneDeep from 'lodash/cloneDeep';
|
import cloneDeep from 'lodash/cloneDeep';
|
||||||
import merge from 'lodash/merge';
|
import merge from 'lodash/merge';
|
||||||
import omit from 'lodash/omit';
|
import omit from 'lodash/omit';
|
||||||
|
import pick from 'lodash/pick';
|
||||||
import isEqual from 'lodash/isEqual';
|
import isEqual from 'lodash/isEqual';
|
||||||
import strCompare from 'str-compare';
|
import strCompare from 'str-compare';
|
||||||
import {
|
import {
|
||||||
@ -210,6 +211,7 @@ export class SampleComponent implements OnInit, AfterContentChecked {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
this.checkFormAfterInit = true;
|
||||||
this.loading--;
|
this.loading--;
|
||||||
sampleIds.slice(1).forEach(sampleId => {
|
sampleIds.slice(1).forEach(sampleId => {
|
||||||
this.api.get<SampleModel>('/sample/' + sampleId, data => {
|
this.api.get<SampleModel>('/sample/' + sampleId, data => {
|
||||||
@ -225,6 +227,7 @@ export class SampleComponent implements OnInit, AfterContentChecked {
|
|||||||
}
|
}
|
||||||
this.loading--;
|
this.loading--;
|
||||||
this.checkFormAfterInit = true;
|
this.checkFormAfterInit = true;
|
||||||
|
console.log(this.baseSample.material.name);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -279,6 +282,7 @@ export class SampleComponent implements OnInit, AfterContentChecked {
|
|||||||
}
|
}
|
||||||
if (formReady) { // fields are ready, do validation
|
if (formReady) { // fields are ready, do validation
|
||||||
this.checkFormAfterInit = false;
|
this.checkFormAfterInit = false;
|
||||||
|
console.log('init');
|
||||||
Object.keys(this.cmForm.form.controls).forEach(field => {
|
Object.keys(this.cmForm.form.controls).forEach(field => {
|
||||||
this.cmForm.form.get(field).updateValueAndValidity();
|
this.cmForm.form.get(field).updateValueAndValidity();
|
||||||
});
|
});
|
||||||
@ -310,6 +314,10 @@ export class SampleComponent implements OnInit, AfterContentChecked {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reValidate() {
|
||||||
|
setTimeout(() => this.checkFormAfterInit = true, 0);
|
||||||
|
}
|
||||||
|
|
||||||
// save base sample
|
// save base sample
|
||||||
saveSample() {
|
saveSample() {
|
||||||
if (this.samples.length === 0) {
|
if (this.samples.length === 0) {
|
||||||
@ -355,7 +363,7 @@ export class SampleComponent implements OnInit, AfterContentChecked {
|
|||||||
else {
|
else {
|
||||||
this.samples.forEach((sample, i) => {
|
this.samples.forEach((sample, i) => {
|
||||||
console.log(sample._id);
|
console.log(sample._id);
|
||||||
this.api.put<SampleModel>('/sample/' + sample._id, this.baseSample.sendFormat(), data => {
|
this.api.put<SampleModel>('/sample/' + sample._id, this.baseSample.sendFormat(false), data => {
|
||||||
merge(this.samples[i], omit(data, ['condition']));
|
merge(this.samples[i], omit(data, ['condition']));
|
||||||
this.samples[i].material = this.d.arr.materials.find(e => e._id === this.samples[0].material_id);
|
this.samples[i].material = this.d.arr.materials.find(e => e._id === this.samples[0].material_id);
|
||||||
this.view.base = false;
|
this.view.base = false;
|
||||||
@ -370,7 +378,13 @@ export class SampleComponent implements OnInit, AfterContentChecked {
|
|||||||
cmSave() { // save measurements and conditions
|
cmSave() { // save measurements and conditions
|
||||||
this.samples.forEach(sample => {
|
this.samples.forEach(sample => {
|
||||||
if (sample.condition.condition_template) { // condition was set
|
if (sample.condition.condition_template) { // condition was set
|
||||||
this.api.put('/sample/' + sample._id, {condition: sample.condition});
|
console.log(sample.condition);
|
||||||
|
console.log(this.d.id.conditionTemplates[sample.condition.condition_template]);
|
||||||
|
this.api.put('/sample/' + sample._id,
|
||||||
|
{condition: pick(sample.condition,
|
||||||
|
['condition_template', ...this.d.id.conditionTemplates[sample.condition.condition_template].parameters.map(e => e.name)]
|
||||||
|
)}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
sample.measurements.forEach(measurement => { // save measurements
|
sample.measurements.forEach(measurement => { // save measurements
|
||||||
if (Object.keys(measurement.values).map(e => measurement.values[e]).join('') !== '') {
|
if (Object.keys(measurement.values).map(e => measurement.values[e]).join('') !== '') {
|
||||||
|
@ -340,7 +340,7 @@ export class SamplesComponent implements OnInit {
|
|||||||
|
|
||||||
updateFilterFields(field) {
|
updateFilterFields(field) {
|
||||||
const filter = this.filters.filters.find(e => e.field === field);
|
const filter = this.filters.filters.find(e => e.field === field);
|
||||||
filter.active = true;
|
filter.active = !(filter.values.length === 1 && filter.values[0] === '');
|
||||||
}
|
}
|
||||||
|
|
||||||
setSort(string) {
|
setSort(string) {
|
||||||
|
@ -56,7 +56,6 @@
|
|||||||
<th>Device</th>
|
<th>Device</th>
|
||||||
<th>Models</th>
|
<th>Models</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
<th></th>
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr *ngFor="let user of users">
|
<tr *ngFor="let user of users">
|
||||||
@ -71,8 +70,7 @@
|
|||||||
{{(i > 0 ? ', ' : '') + modelIds[model]}}
|
{{(i > 0 ? ', ' : '') + modelIds[model]}}
|
||||||
</ng-container>
|
</ng-container>
|
||||||
</td>
|
</td>
|
||||||
<td><span [class]="'rb-ic clickable ' + (user.status === 'new' ? 'rb-ic-edit': 'rb-ic-undo')"
|
<td><span class="rb-ic clickable rb-ic-edit" (click)="user.edit = true"></span></td>
|
||||||
(click)="user.status === 'new' ? user.edit = true: restoreUser(user)"></span></td>
|
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<ng-template #editUser>
|
<ng-template #editUser>
|
||||||
<td>
|
<td>
|
||||||
@ -134,6 +132,37 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</rb-table>
|
</rb-table>
|
||||||
|
|
||||||
|
<rb-accordion>
|
||||||
|
<rb-accordion-title [open]="false"><span class="rb-ic rb-ic-delete"></span> Deleted users</rb-accordion-title>
|
||||||
|
<rb-accordion-body>
|
||||||
|
<rb-table scrollTop>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Email</th>
|
||||||
|
<th>Level</th>
|
||||||
|
<th>Location</th>
|
||||||
|
<th>Device</th>
|
||||||
|
<th>Models</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr *ngFor="let user of deletedUsers">
|
||||||
|
<td>{{user.name}}</td>
|
||||||
|
<td>{{user.email}}</td>
|
||||||
|
<td>{{user.level}}</td>
|
||||||
|
<td>{{user.location}}</td>
|
||||||
|
<td>{{user.devices}}</td>
|
||||||
|
<td>
|
||||||
|
<ng-container *ngFor="let model of user.models; index as i">
|
||||||
|
{{(i > 0 ? ', ' : '') + modelIds[model]}}
|
||||||
|
</ng-container>
|
||||||
|
</td>
|
||||||
|
<td><span class="rb-ic clickable rb-ic-undo" (click)="restoreUser(user)"></span></td>
|
||||||
|
</tr>
|
||||||
|
</rb-table>
|
||||||
|
</rb-accordion-body>
|
||||||
|
</rb-accordion>
|
||||||
|
|
||||||
<ng-template #modelOptions>
|
<ng-template #modelOptions>
|
||||||
<option value=""></option>
|
<option value=""></option>
|
||||||
<ng-container *ngFor="let model of modelSelect">
|
<ng-container *ngFor="let model of modelSelect">
|
||||||
|
@ -14,6 +14,7 @@ import {DataService} from '../services/data.service';
|
|||||||
export class UsersComponent implements OnInit {
|
export class UsersComponent implements OnInit {
|
||||||
|
|
||||||
users: UserModel[] = [];
|
users: UserModel[] = [];
|
||||||
|
deletedUsers: UserModel[] = [];
|
||||||
newUser: UserModel | null = null;
|
newUser: UserModel | null = null;
|
||||||
newUserPass = '';
|
newUserPass = '';
|
||||||
modelSelect: {id: string, name: string}[] = [];
|
modelSelect: {id: string, name: string}[] = [];
|
||||||
@ -28,7 +29,8 @@ export class UsersComponent implements OnInit {
|
|||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.api.get<UserModel[]>('/users', data => {
|
this.api.get<UserModel[]>('/users', data => {
|
||||||
this.users = data.map(e => new UserModel().deserialize(e));
|
this.users = data.map(e => new UserModel().deserialize(e)).filter(e => e.status !== 'deleted');
|
||||||
|
this.deletedUsers = data.map(e => new UserModel().deserialize(e)).filter(e => e.status === 'deleted');
|
||||||
});
|
});
|
||||||
this.d.load('modelGroups', () => {
|
this.d.load('modelGroups', () => {
|
||||||
this.d.arr.modelGroups.forEach(group => {
|
this.d.arr.modelGroups.forEach(group => {
|
||||||
@ -63,6 +65,8 @@ export class UsersComponent implements OnInit {
|
|||||||
this.api.delete('/user/' + user.name, () => {
|
this.api.delete('/user/' + user.name, () => {
|
||||||
user.status = 'deleted';
|
user.status = 'deleted';
|
||||||
user.edit = false;
|
user.edit = false;
|
||||||
|
this.deletedUsers.push(user);
|
||||||
|
this.users.splice(this.users.findIndex(e => e.name === user.name), 1);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -71,6 +75,8 @@ export class UsersComponent implements OnInit {
|
|||||||
restoreUser(user) {
|
restoreUser(user) {
|
||||||
this.api.put('/user/restore/' + user.name, {}, () => {
|
this.api.put('/user/restore/' + user.name, {}, () => {
|
||||||
user.status = 'new';
|
user.status = 'new';
|
||||||
|
this.users.push(user);
|
||||||
|
this.deletedUsers.splice(this.deletedUsers.findIndex(e => e.name === user.name), 1);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user