mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 19:16:41 +07:00
possibly fixed editor initialData
This commit is contained in:
parent
fce88cac29
commit
25d9b1d2df
3 changed files with 32 additions and 17 deletions
|
@ -60,6 +60,12 @@ export class SaveDialog extends React.Component {
|
||||||
setSuccess = ({ address, description }) => {
|
setSuccess = ({ address, description }) => {
|
||||||
pushPath(`/${address}/edit`);
|
pushPath(`/${address}/edit`);
|
||||||
|
|
||||||
|
console.log('addr?', address);
|
||||||
|
this.props.editor.setAddress(address);
|
||||||
|
this.props.editor.owner = this.props.user.id;
|
||||||
|
|
||||||
|
this.props.editor.setInitialData();
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
error: description, finished: true, sending: true, overwriting: false
|
error: description, finished: true, sending: true, overwriting: false
|
||||||
});
|
});
|
||||||
|
|
|
@ -67,7 +67,10 @@ export class App extends React.Component {
|
||||||
};
|
};
|
||||||
|
|
||||||
setTitle = title => this.setState({ title });
|
setTitle = title => this.setState({ title });
|
||||||
setAddress = address => this.setState({ address });
|
setAddress = address => {
|
||||||
|
console.log('SAT', address);
|
||||||
|
this.setState({ address });
|
||||||
|
};
|
||||||
|
|
||||||
getTitle = () => this.state.title;
|
getTitle = () => this.state.title;
|
||||||
|
|
||||||
|
|
|
@ -190,7 +190,9 @@ export class Editor {
|
||||||
|
|
||||||
setData = ({ route, stickers, version = 1, owner, title, address }) => {
|
setData = ({ route, stickers, version = 1, owner, title, address }) => {
|
||||||
this.setTitle(title || '');
|
this.setTitle(title || '');
|
||||||
this.setAddress(address || '');
|
const { id } = this.getUser();
|
||||||
|
|
||||||
|
if (address && id && owner && id === owner) this.setAddress(address);
|
||||||
|
|
||||||
if (route) {
|
if (route) {
|
||||||
this.poly.setPoints(route);
|
this.poly.setPoints(route);
|
||||||
|
@ -215,21 +217,9 @@ export class Editor {
|
||||||
if (Object.values(bounds)) this.map.map.fitBounds(bounds);
|
if (Object.values(bounds)) this.map.map.fitBounds(bounds);
|
||||||
};
|
};
|
||||||
|
|
||||||
startEditing = () => {
|
setInitialData = () => {
|
||||||
const { path } = getUrlData();
|
const { path } = getUrlData();
|
||||||
const { random_url, id } = this.getUser();
|
const { id } = this.getUser();
|
||||||
|
|
||||||
// console.log('ID', id, this.owner);
|
|
||||||
|
|
||||||
const url = (this.owner && this.owner === id) ? path : random_url;
|
|
||||||
|
|
||||||
pushPath(`/${url}/edit`);
|
|
||||||
|
|
||||||
if (this.poly.latlngs && this.poly.latlngs.length > 1) this.poly.poly.enableEdit();
|
|
||||||
|
|
||||||
this.stickers.startEditing();
|
|
||||||
this.setEditing(true);
|
|
||||||
|
|
||||||
const { route, stickers } = this.dumpData();
|
const { route, stickers } = this.dumpData();
|
||||||
|
|
||||||
this.initialData = {
|
this.initialData = {
|
||||||
|
@ -241,6 +231,22 @@ export class Editor {
|
||||||
route,
|
route,
|
||||||
stickers,
|
stickers,
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
startEditing = () => {
|
||||||
|
const { path } = getUrlData();
|
||||||
|
const { random_url, id } = this.getUser();
|
||||||
|
|
||||||
|
this.setInitialData();
|
||||||
|
|
||||||
|
const url = (this.owner && this.owner === id) ? path : random_url;
|
||||||
|
|
||||||
|
pushPath(`/${url}/edit`);
|
||||||
|
|
||||||
|
if (this.poly.latlngs && this.poly.latlngs.length > 1) this.poly.poly.enableEdit();
|
||||||
|
|
||||||
|
this.stickers.startEditing();
|
||||||
|
this.setEditing(true);
|
||||||
|
|
||||||
console.log(this.initialData);
|
console.log(this.initialData);
|
||||||
};
|
};
|
||||||
|
@ -284,6 +290,6 @@ export class Editor {
|
||||||
hasEmptyHistory = () => {
|
hasEmptyHistory = () => {
|
||||||
const { route, stickers } = this.initialData;
|
const { route, stickers } = this.initialData;
|
||||||
|
|
||||||
return !(route && route.length >= 1 && stickers && stickers.length > 0);
|
return (!route || route.length < 1) && (!stickers || stickers.length <= 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue