diff --git a/src/app/app.component.html b/src/app/app.component.html index dd81ca9..d026c27 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -37,7 +37,7 @@
- + Bug @@ -48,7 +48,7 @@ Send report - DEVELOPMENT + DEVELOPMENT DeFinMa
diff --git a/src/app/models/sample.model.ts b/src/app/models/sample.model.ts index e1d3c86..966d2b7 100644 --- a/src/app/models/sample.model.ts +++ b/src/app/models/sample.model.ts @@ -41,8 +41,12 @@ export class SampleModel extends BaseModel { return this; } - sendFormat() { - const tmp = pick(this.conditionTemplateCheck(), ['color', 'type', 'batch', 'condition', 'material_id', 'notes']); + sendFormat(pickCondition = true) { + const pickFields = ['color', 'type', 'batch', 'material_id', 'notes']; + if (pickCondition) { + pickFields.push('condition'); + } + const tmp = pick(this.conditionTemplateCheck(), pickFields); Object.keys(tmp).forEach(key => { if (tmp[key] === undefined) { delete tmp[key]; diff --git a/src/app/sample/sample.component.html b/src/app/sample/sample.component.html index ad1f03c..17c94f6 100644 --- a/src/app/sample/sample.component.html +++ b/src/app/sample/sample.component.html @@ -1,5 +1,4 @@ -

{{mode === 'new' ? 'Add new sample' : 'Edit sample '}}

- +

{{mode === 'new' ? 'Add new sample' : 'Edit sample'}}

@@ -14,13 +13,13 @@ [rbFormInputAutocomplete]="autocomplete.bind(this, materialNames)" appValidate="stringOf" (keydown)="preventDefault($event)" (ngModelChange)="findMaterial($event)" ngModel [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"> Cannot be empty Unknown material, add properties for new material + (click)="setNewMaterial(!newMaterial)" *ngIf="baseSample.material.name !== undefined"> New material @@ -197,8 +196,11 @@
- + @@ -234,9 +236,11 @@ + -
diff --git a/src/app/sample/sample.component.ts b/src/app/sample/sample.component.ts index dadcfc1..18046cf 100644 --- a/src/app/sample/sample.component.ts +++ b/src/app/sample/sample.component.ts @@ -225,6 +225,7 @@ export class SampleComponent implements OnInit, AfterContentChecked { } this.loading--; this.checkFormAfterInit = true; + console.log(this.baseSample.material.name); }); }); }); @@ -355,7 +356,7 @@ export class SampleComponent implements OnInit, AfterContentChecked { else { this.samples.forEach((sample, i) => { console.log(sample._id); - this.api.put('/sample/' + sample._id, this.baseSample.sendFormat(), data => { + this.api.put('/sample/' + sample._id, this.baseSample.sendFormat(false), data => { 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.view.base = false; diff --git a/src/app/samples/samples.component.ts b/src/app/samples/samples.component.ts index 33ce4fd..4cdf0f3 100644 --- a/src/app/samples/samples.component.ts +++ b/src/app/samples/samples.component.ts @@ -340,7 +340,7 @@ export class SamplesComponent implements OnInit { updateFilterFields(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) { diff --git a/src/app/users/users.component.html b/src/app/users/users.component.html index 2b7a457..16c5fb9 100644 --- a/src/app/users/users.component.html +++ b/src/app/users/users.component.html @@ -56,7 +56,6 @@ Device Models - @@ -71,8 +70,7 @@ {{(i > 0 ? ', ' : '') + modelIds[model]}} - + @@ -134,6 +132,37 @@ + +   Deleted users + + + + Name + Email + Level + Location + Device + Models + + + + + {{user.name}} + {{user.email}} + {{user.level}} + {{user.location}} + {{user.devices}} + + + {{(i > 0 ? ', ' : '') + modelIds[model]}} + + + + + + + + diff --git a/src/app/users/users.component.ts b/src/app/users/users.component.ts index 27c587f..fad50dd 100644 --- a/src/app/users/users.component.ts +++ b/src/app/users/users.component.ts @@ -14,6 +14,7 @@ import {DataService} from '../services/data.service'; export class UsersComponent implements OnInit { users: UserModel[] = []; + deletedUsers: UserModel[] = []; newUser: UserModel | null = null; newUserPass = ''; modelSelect: {id: string, name: string}[] = []; @@ -28,7 +29,8 @@ export class UsersComponent implements OnInit { ngOnInit(): void { this.api.get('/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.arr.modelGroups.forEach(group => { @@ -63,6 +65,8 @@ export class UsersComponent implements OnInit { this.api.delete('/user/' + user.name, () => { user.status = 'deleted'; 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) { this.api.put('/user/restore/' + user.name, {}, () => { user.status = 'new'; + this.users.push(user); + this.deletedUsers.splice(this.deletedUsers.findIndex(e => e.name === user.name), 1); }); } }