is_empty flag

This commit is contained in:
muerwre 2019-02-18 15:44:06 +07:00
parent a180e00ffb
commit 9b6ed74300
8 changed files with 43 additions and 19 deletions

View file

@ -13,7 +13,7 @@ import {
setActiveSticker,
setAddress,
setChanged,
setDistance,
setDistance, setIsEmpty,
setLogo, setMarkersShown,
setMode,
setPublic,
@ -123,6 +123,7 @@ export class Editor {
getChanged = () => this.getState().changed;
getRouterPoints = () => this.getState().routerPoints;
getDistance = () => this.getState().distance;
getIsEmpty = () => this.getState().is_empty;
setLogo: typeof setLogo = logo => store.dispatch(setLogo(logo));
setMode: typeof setMode = value => store.dispatch(setMode(value));
@ -131,6 +132,7 @@ export class Editor {
setTitle: typeof setTitle = value => store.dispatch(setTitle(value));
setAddress: typeof setAddress = value => store.dispatch(setAddress(value));
setPublic: typeof setPublic = value => store.dispatch(setPublic(value));
setIsEmpty: typeof setIsEmpty = value => store.dispatch(setIsEmpty(value));
setMarkersShown = value => {
if (this.getState().markers_shown !== value) store.dispatch(setMarkersShown(value));
@ -156,9 +158,8 @@ export class Editor {
};
triggerOnChange = () => {
if (!this.getEditing() || this.getChanged()) return;
this.setChanged(true);
if (this.isEmpty !== this.getIsEmpty()) this.setIsEmpty(this.isEmpty);
if (this.getEditing() && this.getChanged()) this.setChanged(true);
};
createStickerOnClick = (e) => {
@ -246,6 +247,8 @@ export class Editor {
this.poly.clearAll();
this.router.clearAll();
this.stickers.clearAll();
this.setIsEmpty(true);
};
setData = ({
@ -360,3 +363,7 @@ export class Editor {
}
export const editor = new Editor();
declare let window:any;
window.editor = editor;

View file

@ -81,7 +81,6 @@ export class Sticker {
this.marker.addEventListener('dragend', this.triggerOnChange);
this.setAngle(this.angle);
this.triggerOnChange();
}
setText = text => {
@ -89,7 +88,6 @@ export class Sticker {
};
onDelete = () => {
this.triggerOnChange();
if (!this.isDragging) this.deleteSticker(this);
};

View file

@ -25,9 +25,12 @@ export class Stickers {
triggerOnChange: this.triggerOnChange,
text,
});
this.stickers.push(marker);
marker.marker.addTo(this.map);
this.triggerOnChange();
// marker.marker.enableEdit();
};
@ -38,6 +41,8 @@ export class Stickers {
this.map.removeLayer(ref.marker);
this.stickers.splice(index, 1);
this.triggerOnChange();
};
clearAll = () => {