From 4773229b1df6184e547542b9fb3d4ac1aa9fb999 Mon Sep 17 00:00:00 2001 From: Denis Oblogin Date: Sun, 15 Dec 2019 22:04:34 +0200 Subject: [PATCH] Added `hideForSelect`, `hideForCompare` for field config (#129) --- CHANGELOG.md | 1 + CONFIG.adoc | 2 ++ modules/components/Field.jsx | 5 ++++- modules/components/ValueField.jsx | 5 ++++- modules/index.d.ts | 2 ++ 5 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27c660988..0c38ea7e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ - Added support for your custom functions as value source (args can be values/fields/funcs), see new section `funcs` in `config` - Improved Mongo format: now can compare with field & use funcs with help of `$expr` - (breaking) `mongoFormatOp` - inserted arg `useExpr` at 4th position + - Added `hideForSelect`, `hideForCompare` for field config - 1.0.7 - Fixed Babel - 1.0.6 diff --git a/CONFIG.adoc b/CONFIG.adoc index 60a57f6a4..3e9fcfc9c 100644 --- a/CONFIG.adoc +++ b/CONFIG.adoc @@ -168,6 +168,8 @@ const myConfig = { |operators, defaultOperator, widgets, valueSources | | |You can override config of corresponding type (see below at section link:#configtypes[config.types]) |mainWidgetProps | | |Shorthand for `widgets.
.widgetProps` |excludeOperators | | |Can exclude some operators, eg. `proximity` for `text` type +|hideForSelect | |false |If true, field will appear only at right side (when you compare field with another field) +|hideForCompare | |false |If true, field will appear only at left side |=== diff --git a/modules/components/Field.jsx b/modules/components/Field.jsx index ecb4db979..7dc9feab0 100644 --- a/modules/components/Field.jsx +++ b/modules/components/Field.jsx @@ -83,6 +83,9 @@ export default class Field extends PureComponent { const tooltip = field.tooltip; const subpath = (path ? path : []).concat(fieldKey); + if (field.hideForSelect) + return undefined; + if (field.type == "!struct") { return { key: fieldKey, @@ -104,7 +107,7 @@ export default class Field extends PureComponent { grouplabel: optGroupLabel }; } - }); + }).filter(o => !!o); } render() { diff --git a/modules/components/ValueField.jsx b/modules/components/ValueField.jsx index e79ad6c17..c0824f1a1 100644 --- a/modules/components/ValueField.jsx +++ b/modules/components/ValueField.jsx @@ -134,6 +134,9 @@ export default class ValueField extends PureComponent { const tooltip = field.tooltip; const subpath = (path ? path : []).concat(fieldKey); + if (field.hideForCompare) + return undefined; + if (field.type == "!struct") { return { key: fieldKey, @@ -155,7 +158,7 @@ export default class ValueField extends PureComponent { grouplabel: optGroupLabel }; } - }); + }).filter(o => !!o); } getFieldLabel(fieldOpts, fieldKey, config) { diff --git a/modules/index.d.ts b/modules/index.d.ts index 2ddacb886..2a0e9f7aa 100644 --- a/modules/index.d.ts +++ b/modules/index.d.ts @@ -303,6 +303,8 @@ interface ValueField extends BaseField { //obsolete - moved to FieldSettings listValues?: TypedMap, allowCustomValues?: Boolean, + hideForSelect?: Boolean, + hideForCompare?: Boolean, }; interface SimpleField extends ValueField { label2?: String,