added batch edit
This commit is contained in:
@ -4,14 +4,16 @@
|
||||
<a routerLink="/samples/new" *ngIf="login.isLevel.write">
|
||||
<rb-icon-button icon="add" mode="primary" class="space-left">New sample</rb-icon-button>
|
||||
</a>
|
||||
<rb-icon-button *ngIf="validation" mode="secondary" icon="close" (click)="validation = false" class="validation-close"
|
||||
iconOnly></rb-icon-button>
|
||||
<rb-icon-button *ngIf="login.isLevel.dev" [icon]="validation ? 'checkmark' : 'clear-all'"
|
||||
<rb-icon-button *ngIf="sampleSelect === 2" mode="secondary" icon="close" (click)="sampleSelect = 0"
|
||||
class="validation-close" iconOnly></rb-icon-button>
|
||||
<rb-icon-button *ngIf="login.isLevel.dev" [icon]="sampleSelect === 2 ? 'checkmark' : 'clear-all'"
|
||||
mode="secondary" (click)="validate()">
|
||||
{{validation ? 'Validate' : 'Validation'}}
|
||||
{{sampleSelect === 2 ? 'Validate' : 'Validation'}}
|
||||
</rb-icon-button>
|
||||
</div>
|
||||
|
||||
<!--FILTERS-->
|
||||
|
||||
<rb-accordion>
|
||||
<rb-accordion-title [open]="false"><span class="rb-ic rb-ic-filter"></span> Filter</rb-accordion-title>
|
||||
<rb-accordion-body>
|
||||
@ -121,6 +123,8 @@
|
||||
<div>Loading...</div>
|
||||
</div>
|
||||
|
||||
<!--DOWNLOAD BUTTONS-->
|
||||
|
||||
<div class="download space-below" *ngIf="login.isLevel.dev">
|
||||
<rb-icon-button class="space-right" icon="download" mode="secondary" [rbModal]="linkModal">
|
||||
JSON download link
|
||||
@ -149,10 +153,12 @@
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!--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>
|
||||
<th *ngIf="sampleSelect">
|
||||
<rb-form-checkbox name="select-all" (change)="selectAll($event)">all</rb-form-checkbox>
|
||||
</th>
|
||||
<th *ngFor="let key of activeKeys" [title]="key.label">
|
||||
<div class="sort-header">
|
||||
@ -167,13 +173,16 @@
|
||||
</div>
|
||||
</div>
|
||||
</th>
|
||||
<th *ngIf="login.isLevel.write"></th>
|
||||
<th *ngIf="login.isLevel.write">
|
||||
<span class="rb-ic rb-ic-edit clickable" *ngIf="login.isLevel.dev" (click)="batchEdit()"></span>
|
||||
<span class="rb-ic rb-ic-close clickable" *ngIf="sampleSelect === 1" (click)="sampleSelect = 0"></span>
|
||||
</th>
|
||||
</tr>
|
||||
|
||||
<tr *ngFor="let sample of samples; index as i" class="clickable" (click)="sampleDetails(sample._id, sampleModal)">
|
||||
<td *ngIf="validation">
|
||||
<td *ngIf="sampleSelect">
|
||||
<rb-form-checkbox *ngIf="sample.status !== 'deleted'" [name]="'validate-' + i" (click)="stopPropagation($event)"
|
||||
[(ngModel)]="sample.validate">
|
||||
[(ngModel)]="sample.selected">
|
||||
</rb-form-checkbox>
|
||||
</td>
|
||||
<td *ngIf="isActiveKey['number']">{{sample.number}}</td>
|
||||
@ -224,6 +233,8 @@
|
||||
</div>
|
||||
</ng-template>
|
||||
|
||||
<!--SAMPLE DETAILS-->
|
||||
|
||||
<ng-template #sampleModal>
|
||||
<rb-loading-spinner *ngIf="sampleDetailsSample === null; else sampleDetailsTemplate"></rb-loading-spinner>
|
||||
<ng-template #sampleDetailsTemplate>
|
||||
|
@ -9,6 +9,7 @@ import {LoginService} from '../services/login.service';
|
||||
import {ModalService} from '@inst-iot/bosch-angular-ui-components';
|
||||
import {DataService} from '../services/data.service';
|
||||
import {LocalStorageService} from 'angular-2-local-storage';
|
||||
import {Router} from '@angular/router';
|
||||
|
||||
// TODO: turn off sort field
|
||||
// TODO reset sort when field is excluded
|
||||
@ -63,6 +64,7 @@ export class SamplesComponent implements OnInit {
|
||||
{field: 'type', label: 'Type', active: false, autocomplete: [], mode: 'eq', values: ['']},
|
||||
{field: 'color', label: 'Color', active: false, autocomplete: [], mode: 'eq', values: ['']},
|
||||
{field: 'batch', label: 'Batch', active: false, autocomplete: [], mode: 'eq', values: ['']},
|
||||
// {field: 'notes.comment', label: 'Comment', active: false, autocomplete: [], mode: 'eq', values: ['']},
|
||||
{field: 'added', label: 'Added', active: false, autocomplete: [], mode: 'eq', values: ['']}
|
||||
]
|
||||
};
|
||||
@ -78,6 +80,7 @@ export class SamplesComponent implements OnInit {
|
||||
{id: 'type', label: 'Type', active: true, sortable: true},
|
||||
{id: 'color', label: 'Color', active: false, sortable: true},
|
||||
{id: 'batch', label: 'Batch', active: true, sortable: true},
|
||||
// {id: 'notes.comment', label: 'Comment', active: false, sortable: false},
|
||||
{id: 'notes', label: 'Notes', active: false, sortable: false},
|
||||
{id: 'status', label: 'Status', active: false, sortable: true},
|
||||
{id: 'added', label: 'Added', active: true, sortable: true}
|
||||
@ -86,7 +89,7 @@ export class SamplesComponent implements OnInit {
|
||||
activeKeys: KeyInterface[] = [];
|
||||
activeTemplateKeys = {material: [], condition: [], measurements: []};
|
||||
sampleDetailsSample: any = null;
|
||||
validation = false; // true to activate validation mode
|
||||
sampleSelect = 0; // modes: 0 - no selection, 1 - sample edit selection, 2 - validation selection
|
||||
loading = 0;
|
||||
|
||||
|
||||
@ -97,7 +100,8 @@ export class SamplesComponent implements OnInit {
|
||||
private modalService: ModalService,
|
||||
public d: DataService,
|
||||
private storage: LocalStorageService,
|
||||
private window: Window
|
||||
private window: Window,
|
||||
private router: Router
|
||||
) {
|
||||
}
|
||||
|
||||
@ -285,7 +289,7 @@ export class SamplesComponent implements OnInit {
|
||||
}
|
||||
|
||||
loadPage(delta) {
|
||||
if (!/[0-9]+/.test(delta) || (this.page <= 1 && delta < 0)) { // invalid delta
|
||||
if (!/[0-9]+/.test(delta) || this.page + delta < 1 || this.page + delta > this.pages) { // invalid delta
|
||||
return;
|
||||
}
|
||||
this.page += delta;
|
||||
@ -414,17 +418,27 @@ export class SamplesComponent implements OnInit {
|
||||
}
|
||||
|
||||
validate() {
|
||||
if (this.validation) {
|
||||
if (this.sampleSelect) {
|
||||
this.samples.forEach(sample => {
|
||||
if (sample.validate) {
|
||||
if (sample.selected) {
|
||||
this.api.put('/sample/validate/' + sample._id);
|
||||
}
|
||||
});
|
||||
this.loadSamples();
|
||||
this.validation = false;
|
||||
this.sampleSelect = 0;
|
||||
}
|
||||
else {
|
||||
this.validation = true;
|
||||
this.sampleSelect = 2;
|
||||
}
|
||||
}
|
||||
|
||||
batchEdit() {
|
||||
if (this.sampleSelect) {
|
||||
this.router.navigate(['/samples/edit/' + this.samples.filter(e => e.selected).map(e => e._id).join(',')]);
|
||||
this.sampleSelect = 0;
|
||||
}
|
||||
else {
|
||||
this.sampleSelect = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -442,10 +456,10 @@ export class SamplesComponent implements OnInit {
|
||||
selectAll(event) {
|
||||
this.samples.forEach(sample => {
|
||||
if (sample.status !== 'deleted') {
|
||||
sample.validate = event.target.checked;
|
||||
sample.selected = event.target.checked;
|
||||
}
|
||||
else {
|
||||
sample.validate = false;
|
||||
sample.selected = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user