Functions to determine column visibility and requiredness.
npm install @particles/configurable-field-setFunctions to determine column visibility and requiredness.
isVisible(Object)(Object)(String) => Booleantrue if the item cannot be found.``js`
isVisible = (
// defines frontend names to match to the corresponding
// backend configurable_field_set field names
nameMapObj: { someName: 'field_set_name' },
) => (
// the object of configurable_field_set field names
sourceOfValuesObj: { field_set_name: { visible: Boolean } },
) => (
'someName'
) =>
returns Boolean
if the item cannot be found.`js
isRequired = (
// defines frontend names to match to the corresponding
// backend configurable_field_set field names
nameMapObj: { someName: 'field_set_name' },
) => (
// the object of configurable_field_set field names
sourceOfValuesObj: { field_set_name: { required: Boolean } },
) => (
'someName'
) =>
returns Boolean
`filterVisibleColumns(Object)(Object)(Array, String) => Array
A function for filtering an array of columns to only visible columns.`js
filterVisibleColumns = (
// defines frontend names to match the corresponding
// backend configurable_field_set field names
nameMapObj: { someName: 'field_set_name' },
) => (
// the object of configurable_field_set field names
sourceOfValuesObj: { field_set_name: { visible: Boolean } },
) => (
// some arbitrary array of columns
columnsArr = [{ [colKey]: 'someName' }],
colKey: 'key' // defaults to 'key'
) =>
returns []
`aggregateVisibility(Array) => Object
A function that takes in an array of CFS fields objects and returns a new set of fields where the
visibility of each field is set to true if ANY of the input fieldsets have that field set to
"visible: true", otherwise set to false.`js
aggregateVisibility = (
[
{ name: { visible: true }, status: { visible: true }, contact: { visible: false }},
{ name: { visible: true }, status: { visible: false }, contact: { visible: false }},
],
) =>
returns {} // { name: { visible: true }, status: { visible: true }, contact: { visible: false } }
`Change Log
$3
- Added aggregateVisibility() method$3
- _Breaking_ The second argument to the second function, 'visible', has been removed from isVisible()(undefined, 'visible')(). This is in order to determine keys sooner
- _Breaking_ The second argument to the first function, true, has been removed from isVisible(undefined, true)()(). This is in order to determine defaults for different keys sooner
- _Breaking_ The second argument to the second function, true, has been removed from filterVisibleColumns()(undefined, true)(). This is in order to determine defaults for different keys sooner
- added isRequired$3
- _Breaking_ The names of functions switched. visibleColumns is now filterVisibleColumns, already knowing it's filter func. And filterVisibleColumns is now visibleColumns`, needing a filter func