implemented no measurements or condition filter

This commit is contained in:
VLE2FE 2020-09-02 16:31:59 +02:00
parent 1460b5c1e6
commit bda6331c59
4 changed files with 21 additions and 3 deletions

View File

@ -104,6 +104,12 @@
</div>
</ng-container>
</div>
<rb-form-checkbox name="no-condition" [(ngModel)]="filters.no.condition" class="space-right">
has no condition
</rb-form-checkbox>
<rb-form-checkbox name="no-measurements" [(ngModel)]="filters.no.measurements" class="space-right">
has no measurements
</rb-form-checkbox>
</div>
</form>

View File

@ -178,6 +178,10 @@ rb-table {
float: left;
margin-right: 30px;
}
& > rb-form-checkbox {
float: left;
}
}
.filtermode {

View File

@ -52,6 +52,7 @@ export class SamplesComponent implements OnInit {
pageSize: 25,
toPage: 0,
sort: 'added-asc',
no: {condition: false, measurements: false},
filters: [
{field: 'number', label: 'Number', active: false, autocomplete: [], mode: 'eq', values: ['']},
{field: 'material.name', label: 'Product name', active: false, autocomplete: [], mode: 'eq', values: ['']},
@ -265,6 +266,12 @@ export class SamplesComponent implements OnInit {
.filter(e => e.active && e.values.length > 0)
.map(e => 'filters[]=' + encodeURIComponent(JSON.stringify(pick(e, ['mode', 'field', 'values']))))
);
if (this.filters.no.condition) {
query.push('filters[]=' + encodeURIComponent( JSON.stringify({mode: 'eq', field: 'condition', values: [{}]})));
}
if (this.filters.no.measurements) {
query.push('filters[]=' + encodeURIComponent( JSON.stringify( {mode: 'eq', field: 'measurements', values: [null]})));
}
if (!options.export) {
additionalTableKeys.forEach(key => {
if (query.indexOf('fields[]=' + key) < 0) { // add key if not already added

View File

@ -15,7 +15,8 @@
<option *ngFor="let level of login.levels" [value]="level">{{level}}</option>
<ng-template rbFormValidationMessage="required">Cannot be empty</ng-template>
</rb-form-select>
<rb-form-input name="location" label="location" appValidate="string" required [appValidateArgs]="['alphanum']"
<rb-form-input name="location" label="location (Abbreviation, eg. Rng, for sample number)" appValidate="string"
[appValidateArgs]="['alphanum']" required
[(ngModel)]="newUser.location" #locationInput="ngModel">
<ng-template rbFormValidationMessage="failure">{{locationInput.errors.failure}}</ng-template>
<ng-template rbFormValidationMessage="required">Cannot be empty</ng-template>
@ -100,13 +101,13 @@
<td>
<rb-array-input [(ngModel)]="user.devices" name="devices" [pushTemplate]="''">
<rb-form-input *rbArrayInputItem="let item" rbArrayInputListener="devices" [index]="item.i"
label="device" appValidate="string" [name]="'device-' + item.i" [ngModel]="item.value">
appValidate="string" [name]="'device-' + item.i" [ngModel]="item.value">
</rb-form-input>
</rb-array-input>
</td>
<td>
<rb-array-input [(ngModel)]="user.models" name="devices" [pushTemplate]="''">
<rb-form-select *rbArrayInputItem="let item" rbArrayInputListener="models" [index]="item.i" label="model"
<rb-form-select *rbArrayInputItem="let item" rbArrayInputListener="models" [index]="item.i"
[name]="'model-' + item.i" [ngModel]="item.value">
<ng-container *ngTemplateOutlet="modelOptions"></ng-container>
</rb-form-select>