Skip to content
Open
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
16 changes: 9 additions & 7 deletions src/GeolocationEditor/mb-editor/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useCallback, useMemo } from 'react';
import PropTypes from 'prop-types';
import { GEOLOCATION_FORMAT, DEFAULT_GEOLOCATION_FORMAT } from 'dtable-utils';
import { GEOLOCATION_FORMAT, DEFAULT_GEOLOCATION_FORMAT, HIDDEN_DISTRICTS } from 'dtable-utils';
import CountryEditor from './country-editor';
import ProvinceEditor from './province-editor';
import ProvinceCityEditor from './province-city-editor';
Expand All @@ -17,6 +17,8 @@ const transLocationData = (data) => {
data.value = name;
data.name = null;
if (data.children) {
// Filter out hidden districts at the district level (children of city nodes)
data.children = data.children.filter((child) => !HIDDEN_DISTRICTS.includes(child.name));
data.children.map(child => {
return transLocationData(child);
});
Expand Down Expand Up @@ -71,25 +73,25 @@ const MBGeolocationEditor = ({

switch (format) {
case GEOLOCATION_FORMAT.LNG_LAT: {
return (<MapEditor { ...props } config={config} column={column} />);
return (<MapEditor {...props} config={config} column={column} />);
}
case GEOLOCATION_FORMAT.MAP_SELECTION: {
return (<MapSelectionEditor {...props} config={config} column={column} />);
}
case GEOLOCATION_FORMAT.COUNTRY_REGION: {
return (<CountryEditor { ...props } getData={_getCountryData} column={column} />);
return (<CountryEditor {...props} getData={_getCountryData} column={column} />);
}
case GEOLOCATION_FORMAT.PROVINCE: {
return (<ProvinceEditor { ...props } getData={getData} column={column} />);
return (<ProvinceEditor {...props} getData={getData} column={column} />);
}
case GEOLOCATION_FORMAT.PROVINCE_CITY: {
return (<ProvinceCityEditor { ...props } getData={getData} column={column} />);
return (<ProvinceCityEditor {...props} getData={getData} column={column} />);
}
case GEOLOCATION_FORMAT.PROVINCE_CITY_DISTRICT: {
return (<LocationEditor { ...props } getData={getData} column={column} />);
return (<LocationEditor {...props} getData={getData} column={column} />);
}
default: {
return (<LocationEditor { ...props } isShowDetails={true} getData={getData} column={column} />);
return (<LocationEditor {...props} isShowDetails={true} getData={getData} column={column} />);
}
}
};
Expand Down
15 changes: 10 additions & 5 deletions src/GeolocationEditor/pc-editor/selector-list.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import { HIDDEN_DISTRICTS } from 'dtable-utils';

const SelectorListPropTypes = {
type: PropTypes.string,
Expand All @@ -9,13 +10,19 @@ const SelectorListPropTypes = {
doubleClickHandler: PropTypes.oneOfType([PropTypes.func])
};


class SelectorList extends React.Component {

getVisibleChildren = (parent) => {
if (!Array.isArray(parent.children)) return [];
return parent.children.filter((item) => !HIDDEN_DISTRICTS.includes(item.name));
};

render() {
const { clickHandler, type, selectedItem, parent, doubleClickHandler } = this.props;
const visibleChildren = this.getVisibleChildren(parent);
return (
<ul className='dtable-ui-geolocation-selector-list'>
{parent.children.map((item, index) => {
{visibleChildren.map((item, index) => {
const isSelected = selectedItem && (item.name === selectedItem.name);
return (
<li
Expand All @@ -24,9 +31,7 @@ class SelectorList extends React.Component {
doubleClickHandler && doubleClickHandler(item);
}}
key={type + '-item-' + index}
className={`dtable-ui-geolocation-selector-list-item ${type === 'province' ? 'province-item' : ''} ${
isSelected ? 'selected-list-item' : ''
}`}
className={`dtable-ui-geolocation-selector-list-item ${type === 'province' ? 'province-item' : ''} ${isSelected ? 'selected-list-item' : ''}`}
>
{item.name}
</li>
Expand Down
Loading