Skip to content

feat: map editor #336

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
7 changes: 5 additions & 2 deletions src/GeolocationEditor/mb-editor/map-editor/index.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
.dtable-ui-mobile-geolocation-map-editor .dtable-ui-mobile-geolocation-map-editor-input-container {
height: 60px;
padding-top: 16px;
height: auto;
width: 100%;
}

.dtable-ui-mobile-geolocation-map-editor .dtable-ui-mobile-geolocation-map-editor-input-container .view-subtitle:first-child {
border-top: 0;
}

.dtable-ui-mobile-geolocation-map-editor .dtable-ui-mobile-geolocation-map-editor-map {
flex: 1;
overflow: hidden;
Expand Down
31 changes: 22 additions & 9 deletions src/GeolocationEditor/mb-editor/map-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,15 @@ class MapEditor extends React.Component {

constructor(props) {
super(props);
const value = props.value || {};
const value = props.value || { lng: '', lat: '' };
const { mapType, mapKey } = getMapInfo(props.config);
this.mapType = mapType;
this.mapKey = mapKey;
const { lng, lat } = value;
this.map = null;
this.state = {
mode: 'preview',
isLoading: true,
value: value,
inputValue: isValidPosition(lng, lat) ? (DOMESTIC_MAP_TYPE.includes(this.mapType) ? `${lng}, ${lat}` : `${lat}, ${lng}`) : '',
};
}

Expand Down Expand Up @@ -203,8 +201,7 @@ class MapEditor extends React.Component {
value: {
lng: point.lng,
lat: point.lat
},
inputValue: DOMESTIC_MAP_TYPE.includes(this.mapType) ? `${point.lng}, ${point.lat}` : `${point.lat}, ${point.lng}`
}
});
};

Expand Down Expand Up @@ -326,7 +323,7 @@ class MapEditor extends React.Component {
};

renderMap = () => {
const { isLoading, inputValue, mode } = this.state;
const { isLoading, mode, value } = this.state;
if (isLoading) return (<div className="w-100 h-100 d-flex align-items-center justify-content-center"><Loading /></div>);
if (!this.mapType) {
return (
Expand All @@ -336,17 +333,33 @@ class MapEditor extends React.Component {
);
}
const isEdit = mode === 'edit';
const { lat, lng } = value;
return (
<>
<div className="dtable-ui-mobile-geolocation-map-editor-input-container">
<div className="view-subtitle">
<span>{getLocale('Latitude_abbr')}</span>
</div>
<InputItem
type="text"
className="dtable-ui-mobile-geolocation-map-editor-input"
style={{ marginTop: 0 }}
value={lat}
editable={isEdit}
onChange={this.handleLatitudeChange}
placeholder={getLocale('Enter_latitude')}
/>
<div className="view-subtitle">
<span>{getLocale('Longitude_abbr')}</span>
</div>
<InputItem
type="text"
className="dtable-ui-mobile-geolocation-map-editor-input"
style={{ marginTop: 0 }}
value={inputValue}
value={lng}
editable={isEdit}
onChange={this.onChange}
placeholder={DOMESTIC_MAP_TYPE.includes(this.mapType) ? getLocale('Enter_longitude_and_latitude') : getLocale('Enter_latitude_and_longitude')}
onChange={this.handleLongitudeChange}
placeholder={getLocale('Enter_longitude')}
/>
</div>
<div className="dtable-ui-mobile-geolocation-map-editor-map">
Expand Down
21 changes: 6 additions & 15 deletions src/GeolocationEditor/pc-editor/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -204,22 +204,22 @@
width: 92%;
}

.dtable-ui-geolocation-map-editor .search-tables-input {
.dtable-ui-geolocation-map-editor .selection-input {
padding-right: 30px;
border-bottom: 0;
background: #fff;
border-radius: 3px;
border: 1px solid #dedede;
box-shadow: 0 -0 12px rgb(0 0 0 / 30%);
}

.dtable-ui-geolocation-map-editor .search-tables-input.selection-input {
width: 88%;
box-shadow: 0 -0 2px rgb(0 0 0 / 30%);
border-radius: 3px 0px 0px 3px;
border-right: none;
}

.dtable-ui-geolocation-map-editor .selection-input:focus {
border-color: #bdbdbd;
box-shadow: 0 -0 3px rgb(0 0 0 / 30%);
}

.dtable-ui-geolocation-submit-map-editor {
display: inline-block;
height: 38px;
Expand Down Expand Up @@ -425,15 +425,6 @@
text-align: center;
}

.dtable-ui-geolocation-map-editor .search-tables-input:focus {
border-color: #bdbdbd;
box-shadow: 0 -0 12px rgb(0 0 0 / 30%);
}

.dtable-ui-geolocation-map-editor .selection-input:focus {
box-shadow: 0 -0 3px rgb(0 0 0 / 30%);
}

.dtable-ui-geolocation-map-editor-error-message {
word-break: break-all;
padding: 10px;
Expand Down
6 changes: 3 additions & 3 deletions src/GeolocationEditor/pc-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class PCGeolocationEditor extends React.Component {

createEditor = () => {
const geoFormat = this.getGeoFormat();
const { config, column, getCountryData, getLocationData } = this.props;
const { config, column, getCountryData, getLocationData, toggleLargeMap } = this.props;
const props = {
column,
config,
Expand All @@ -157,10 +157,10 @@ class PCGeolocationEditor extends React.Component {

switch (geoFormat) {
case GEOLOCATION_FORMAT.LNG_LAT: {
return (<MapEditor {...props} ref={ref => this.editor = ref} />);
return (<MapEditor {...props} toggleLargeMap={toggleLargeMap} ref={ref => this.editor = ref} />);
}
case GEOLOCATION_FORMAT.MAP_SELECTION: {
return (<MapSelectionEditor {...props} ref={ref => this.editor = ref} />);
return (<MapSelectionEditor {...props} toggleLargeMap={toggleLargeMap} ref={ref => this.editor = ref} />);
}
case GEOLOCATION_FORMAT.COUNTRY_REGION: {
return (<CountryEditor {...props} getData={getCountryData} ref={ref => this.editor = ref} />);
Expand Down
33 changes: 33 additions & 0 deletions src/GeolocationEditor/pc-editor/map-editor/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.dtable-ui-geolocation-map-lng-lat-editor-header {
display: flex;
flex-direction: row;
gap: 8px;
padding: 1rem;
flex-shrink: 0;
}

.dtable-ui-geolocation-map-lng-lat-editor-header .dtable-ui-geolocation-map-lng-lat-input-container {
display: flex;
flex: 1 1;
}

.dtable-ui-geolocation-map-lng-lat-input-label {
align-items: center;
background-color: #f8f9fa;
border: 1px solid #0028641f;
border-bottom-left-radius: 3px;
border-right: none;
border-top-left-radius: 3px;
display: flex;
justify-content: center;
padding: .375rem .75rem;
}

.dtable-ui-geolocation-map-lng-lat-input-container input {
border-bottom-left-radius: 0;
border-top-left-radius: 0;
flex: 1 1;
position: relative;
z-index: 0;
}

Loading