template fixes
This commit is contained in:
		@@ -37,7 +37,7 @@
 | 
			
		||||
  </ng-container>
 | 
			
		||||
 | 
			
		||||
  <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
 | 
			
		||||
    </rb-icon-button>
 | 
			
		||||
    <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>
 | 
			
		||||
      </a>
 | 
			
		||||
    </ng-template>
 | 
			
		||||
    <span class="dev-label" *ngIf="devMode && false">DEVELOPMENT</span>
 | 
			
		||||
    <span class="dev-label" *ngIf="devMode">DEVELOPMENT</span>
 | 
			
		||||
    DeFinMa
 | 
			
		||||
  </div>
 | 
			
		||||
</rb-full-header>
 | 
			
		||||
 
 | 
			
		||||
@@ -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];
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,4 @@
 | 
			
		||||
<h2>{{mode === 'new' ? 'Add new sample' : 'Edit sample '}}</h2>
 | 
			
		||||
<!--TODO: title-->
 | 
			
		||||
<h2>{{mode === 'new' ? 'Add new sample' : 'Edit sample'}}</h2>
 | 
			
		||||
 | 
			
		||||
<rb-loading-spinner *ngIf="loading; else content"></rb-loading-spinner>
 | 
			
		||||
 | 
			
		||||
@@ -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">
 | 
			
		||||
          <ng-template rbFormValidationMessage="required">Cannot be empty</ng-template>
 | 
			
		||||
          <ng-template rbFormValidationMessage="failure">Unknown material, add properties for new material</ng-template>
 | 
			
		||||
        </rb-form-input>
 | 
			
		||||
        <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
 | 
			
		||||
        </rb-icon-button>
 | 
			
		||||
      </div>
 | 
			
		||||
@@ -197,8 +196,11 @@
 | 
			
		||||
            </button>
 | 
			
		||||
          </h5>
 | 
			
		||||
          <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">
 | 
			
		||||
              <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>
 | 
			
		||||
            </rb-form-select>
 | 
			
		||||
 | 
			
		||||
@@ -234,9 +236,11 @@
 | 
			
		||||
            <rb-form-select [name]="'measurementTemplateSelect-' + gIndex + '-' + mIndex" label="Template"
 | 
			
		||||
                            [(ngModel)]="measurement.measurement_template"
 | 
			
		||||
                            (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>
 | 
			
		||||
            </rb-form-select>
 | 
			
		||||
 | 
			
		||||
            <div *ngFor="let parameter of d.id.measurementTemplates[measurement.measurement_template].parameters;
 | 
			
		||||
                 index as pIndex">
 | 
			
		||||
              <ng-container [ngSwitch]="(parameter.range.type ? 1 : 0) + (parameter.range.values ? 2 : 0)">
 | 
			
		||||
 
 | 
			
		||||
@@ -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<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']));
 | 
			
		||||
            this.samples[i].material = this.d.arr.materials.find(e => e._id === this.samples[0].material_id);
 | 
			
		||||
            this.view.base = false;
 | 
			
		||||
 
 | 
			
		||||
@@ -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) {
 | 
			
		||||
 
 | 
			
		||||
@@ -56,7 +56,6 @@
 | 
			
		||||
    <th>Device</th>
 | 
			
		||||
    <th>Models</th>
 | 
			
		||||
    <th></th>
 | 
			
		||||
    <th></th>
 | 
			
		||||
  </tr>
 | 
			
		||||
 | 
			
		||||
  <tr *ngFor="let user of users">
 | 
			
		||||
@@ -71,8 +70,7 @@
 | 
			
		||||
        {{(i > 0 ? ', ' : '') + modelIds[model]}}
 | 
			
		||||
        </ng-container>
 | 
			
		||||
      </td>
 | 
			
		||||
      <td><span [class]="'rb-ic clickable ' + (user.status === 'new' ? 'rb-ic-edit': 'rb-ic-undo')"
 | 
			
		||||
                (click)="user.status === 'new' ? user.edit = true: restoreUser(user)"></span></td>
 | 
			
		||||
      <td><span class="rb-ic clickable rb-ic-edit"  (click)="user.edit = true"></span></td>
 | 
			
		||||
    </ng-container>
 | 
			
		||||
    <ng-template #editUser>
 | 
			
		||||
      <td>
 | 
			
		||||
@@ -134,6 +132,37 @@
 | 
			
		||||
  </tr>
 | 
			
		||||
</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>
 | 
			
		||||
  <option value=""></option>
 | 
			
		||||
  <ng-container *ngFor="let model of modelSelect">
 | 
			
		||||
 
 | 
			
		||||
@@ -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<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.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);
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user