Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions web/client/components/widgets/builder/wizard/FilterWizard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const isFilterConfigValid = (editorData = {}) => {
const FilterWizard = ({
filterData = {},
editorData = {},
selectableItems = [],
onChange = () => {},
onOpenLayerSelector = () => {},
openFilterEditor = () => {},
Expand All @@ -74,7 +75,8 @@ const FilterWizard = ({
onAddFilter = () => {},
onDeleteFilter = () => {},
onRenameFilter = () => {},
onSelectionChange = () => {}
onSelectionChange = () => {},
onSelectableItemsChange = () => {}
}) => {
const [activeTab, setActiveTab] = useState('data');

Expand All @@ -94,7 +96,7 @@ const FilterWizard = ({

const tabContents = {
data: <FilterDataTab data={filterData} onChange={onChange} onOpenLayerSelector={onOpenLayerSelector} openFilterEditor={openFilterEditor} onEditorChange={onEditorChange} dashBoardEditing={dashBoardEditing} selections={selections} />,
layout: <FilterLayoutTab data={filterData} onChange={onChange} selections={selections} onEditorChange={onEditorChange} />,
layout: <FilterLayoutTab data={filterData} onChange={onChange} selections={selections} onEditorChange={onEditorChange} selectableItems={selectableItems} />,
actions: <FilterActionsTab data={filterData} onChange={onChange} onEditorChange={onEditorChange} />
};

Expand All @@ -108,6 +110,7 @@ const FilterWizard = ({
selections={selections}
getSelectionHandler={onSelectionChange}
selectedFilterId={selectedFilterId}
onSelectableItemsChange={onSelectableItemsChange}
/>
</div>
<FilterSelector
Expand Down Expand Up @@ -176,4 +179,3 @@ const FilterWizard = ({
};

export default FilterWizard;

Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ const FilterCheckboxList = ({
return (
<FormGroup className="ms-filter-checkbox-list">
<div className={containerClassName} style={containerStyle}>
{items.map(({ id, label, description, disabled }) => (
{items.map(({ id, label, description, disabled }, index) => (
<ControlComponent
key={`${id}-${index}`}
inline={isInline}
checked={selectedValues.includes(id)}
onChange={() => handleToggle(id)}
Expand Down Expand Up @@ -85,4 +86,3 @@ FilterCheckboxList.propTypes = {

export default FilterCheckboxList;


Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ const FilterChipList = ({
className="ms-filter-chip-list-items"
style={listStyle}
>
{items.map(({ id, label, disabled }) => {
{items.map(({ id, label, disabled }, index) => {
const active = selectedValues.includes(id);
return (
<Text
key={id}
key={`${id}-${index}`}
component="li"
fontSize="sm"
role={isSingle ? 'radio' : 'checkbox'}
Expand Down Expand Up @@ -110,4 +110,3 @@ FilterChipList.propTypes = {

export default FilterChipList;


Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ AttributeSelector.propTypes = {
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
options: PropTypes.arrayOf(PropTypes.shape({
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
label: PropTypes.string
label: PropTypes.string,
type: PropTypes.string
})),
onChange: PropTypes.func,
placeholder: PropTypes.string,
Expand All @@ -77,4 +78,3 @@ AttributeSelector.propTypes = {
};

export default AttributeSelector;

Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ const FilterAttributesSection = ({
const isAttributeDisabled = !attributeOptions.length && !isLoading;

const handleValueAttributeChange = (option) => {
onValueAttributeChange(option?.value);
onValueAttributeChange(option);
};

const handleLabelAttributeChange = (option) => {
onLabelAttributeChange(option?.value);
onLabelAttributeChange(option);
};

const handleSortByAttributeChange = (option) => {
Expand Down Expand Up @@ -153,4 +153,3 @@ FilterAttributesSection.propTypes = {
};

export default FilterAttributesSection;

Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ export const useFilterData = (data = {}) => {

// Attributes
const valueAttribute = filterData.valueAttribute ?? null;
const valueAttributeType = filterData.valueAttributeType ?? null;
const labelAttribute = filterData.labelAttribute ?? null;
const labelAttributeType = filterData.labelAttributeType ?? null;
const sortByAttribute = filterData.sortByAttribute ?? null;
const sortOrder = filterData.sortOrder;

Expand Down Expand Up @@ -111,7 +113,9 @@ export const useFilterData = (data = {}) => {

// Attributes
valueAttribute,
valueAttributeType,
labelAttribute,
labelAttributeType,
sortByAttribute,
sortOrder,

Expand All @@ -128,4 +132,3 @@ export const useFilterData = (data = {}) => {
};
}, [data]);
};

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ const getLayerKey = (layer, layerId = null) => {
const mapAttributesToOptions = (attributes = []) => {
return attributes.map(attribute => ({
value: attribute.value || attribute.attribute || attribute.name,
label: attribute.label || attribute.alias || attribute.value || attribute.attribute || attribute.name
label: attribute.label || attribute.alias || attribute.value || attribute.attribute || attribute.name,
type: attribute.type
}));
};

Expand Down Expand Up @@ -110,4 +111,3 @@ export const useLayerAttributes = (selectedLayer, hasLayerSelection = false) =>
error: attributesError
};
};

Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,17 @@ const FilterDataTab = ({
}, [onEditorChange]);

// Generic handlers using the factory function
const handleValueAttributeChange = createChangeHandler('data.valueAttribute');
const handleLabelAttributeChange = createChangeHandler('data.labelAttribute');
const handleValueAttributeChange = useCallback((option) => {
onChange('data.valueAttribute', option?.value);
onChange('data.valueAttributeType', option?.type);
if (!filterDataState.labelAttribute) {
onChange('data.labelAttributeType', option?.type);
}
}, [onChange, filterDataState.labelAttribute]);
const handleLabelAttributeChange = useCallback((option) => {
onChange('data.labelAttribute', option?.value);
onChange('data.labelAttributeType', option?.type);
}, [onChange]);
const handleSortByAttributeChange = createChangeHandler('data.sortByAttribute');
const handleSortOrderChange = createChangeHandler('data.sortOrder');
const handleMaxFeaturesChange = createChangeHandler('data.maxFeatures');
Expand Down Expand Up @@ -207,4 +216,3 @@ FilterDataTab.propTypes = {
};

export default FilterDataTab;

Loading
Loading