Skip to content

Commit ca7b888

Browse files
committed
config-ip-filter: Add separate key label filter parameters. (template keys have a human friendly label).
1 parent b6ec3fd commit ca7b888

File tree

2 files changed

+46
-22
lines changed

2 files changed

+46
-22
lines changed

build/app/view/netcreate/components/filter/FiltersPanel.jsx

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import FilterGroup from './FilterGroup';
21
import FILTER from './FilterEnums';
2+
import FilterGroup from './FilterGroup';
33
import React from 'react';
44
import StringFilter from './StringFilter';
55
const ReactStrap = require('reactstrap');
66

77
const { Button, Input, Label } = ReactStrap;
88

9+
910
const UNISYS = require('unisys/client');
1011
var UDATA = null;
1112

@@ -27,15 +28,24 @@ const filtersDefs = [
2728
filters: [
2829
{
2930
id: '1',
30-
name: 'Label',
31-
type: 'contains',
31+
key: 'label',
32+
keylabel: 'Label',
33+
operator: 'contains',
3234
value: 'tacitus'
3335
},
3436
{
3537
id: '2',
36-
name: 'Type',
37-
type: 'not-contains',
38+
key: 'type',
39+
keylabel: 'Type',
40+
operator: 'contains',
3841
value: 'person'
42+
},
43+
{
44+
id: '3',
45+
key: 'notes',
46+
keylabel: 'Significance',
47+
operator: 'contains',
48+
value: 'xxx'
3949
}
4050
]
4151
},
@@ -44,20 +54,23 @@ const filtersDefs = [
4454
filters: [
4555
{
4656
id: '1',
47-
name: 'Source',
48-
type: 'contains',
57+
key: 'source',
58+
keylabel: 'Source',
59+
operator: 'contains',
4960
value: 'tacitus'
5061
},
5162
{
5263
id: '2',
53-
name: 'Type',
54-
type: 'not-contains',
64+
key: 'type',
65+
keylabel: 'Type',
66+
operator: 'not-contains',
5567
value: 'is related to'
5668
},
5769
{
5870
id: '3',
59-
name: 'Target',
60-
type: 'contains',
71+
key: 'target',
72+
keylabel: 'Target',
73+
operator: 'contains',
6174
value: 'Rome'
6275
}
6376
]

build/app/view/netcreate/components/filter/StringFilter.jsx

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,22 @@ import React from 'react';
33
const ReactStrap = require('reactstrap');
44
const { Form, FormGroup, Input, Label } = ReactStrap;
55

6-
export default function StringFilter({ filter: { id, name, type, value }, onChangeHandler }) {
6+
export default function StringFilter({
7+
filter: {
8+
id,
9+
key,
10+
keylabel, // human friendly display name for the key. This can be customized in the template.
11+
operator,
12+
value
13+
},
14+
onChangeHandler
15+
}) {
16+
17+
const OPERATORS = [
18+
{ value: FILTER.STRING_OPERATORS.EMPTY, label: "--"},
19+
{ value: FILTER.STRING_OPERATORS.CONTAINS, label: "contains"},
20+
{ value: FILTER.STRING_OPERATORS.NOT_CONTAINS, label: "does not contain"},
21+
]
722

823
console.log('StringFilter: id is', id);
924

@@ -13,22 +28,18 @@ export default function StringFilter({ filter: { id, name, type, value }, onChan
1328
// Construct search string
1429
// let result = name;
1530
// result +=':' + filterType + ':' + filterValue;
16-
let result = { name, type: filterType, value: filterValue };
31+
let result = { key, operator: filterType, value: filterValue };
1732
onChangeHandler(result);
1833
}
1934

20-
const OPERATORS = [
21-
{ value: FILTER.STRING_OPERATORS.EMPTY, label: "--"},
22-
{ value: FILTER.STRING_OPERATORS.CONTAINS, label: "contains"},
23-
{ value: FILTER.STRING_OPERATORS.NOT_CONTAINS, label: "does not contain"},
24-
]
25-
2635
return (
2736
<Form inline className="filter-item" id={id}>
2837
<FormGroup>
29-
<Label size="sm" style={{width:`5em`,justifyContent:'flex-end'}}>{name}&nbsp;</Label>
30-
<Input id={`filterType-${id}`} type="select" value={type} onChange={HandleChangeLocal} bsSize="sm">
31-
{OPERATORS.map(op => <option value={op.value} key={`${id}${op.value}`} size="sm">{op.label}</option>)}
38+
<Label size="sm" style={{width:`5em`,justifyContent:'flex-end'}}>{keylabel}&nbsp;</Label>
39+
<Input id={`filterType-${id}`} type="select" value={operator} onChange={HandleChangeLocal} bsSize="sm">
40+
{OPERATORS.map(op =>
41+
<option value={op.value} key={`${id}${op.value}`} size="sm">{op.label}</option>
42+
)}
3243
</Input>
3344
<Input id={`filterValue-${id}`} type="text" value={value} onChange={HandleChangeLocal} bsSize="sm"/>
3445
</FormGroup>

0 commit comments

Comments
 (0)