Skip to content

Commit

Permalink
Added hideForSelect, hideForCompare for field config (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
ukrbublik authored Dec 15, 2019
1 parent 9759490 commit 4773229
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions CONFIG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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.<main>.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
|===


Expand Down
5 changes: 4 additions & 1 deletion modules/components/Field.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -104,7 +107,7 @@ export default class Field extends PureComponent {
grouplabel: optGroupLabel
};
}
});
}).filter(o => !!o);
}

render() {
Expand Down
5 changes: 4 additions & 1 deletion modules/components/ValueField.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -155,7 +158,7 @@ export default class ValueField extends PureComponent {
grouplabel: optGroupLabel
};
}
});
}).filter(o => !!o);
}

getFieldLabel(fieldOpts, fieldKey, config) {
Expand Down
2 changes: 2 additions & 0 deletions modules/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ interface ValueField extends BaseField {
//obsolete - moved to FieldSettings
listValues?: TypedMap<String>,
allowCustomValues?: Boolean,
hideForSelect?: Boolean,
hideForCompare?: Boolean,
};
interface SimpleField extends ValueField {
label2?: String,
Expand Down

0 comments on commit 4773229

Please sign in to comment.