Skip to content

Commit

Permalink
Improve spatial input actions
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasstein committed Oct 30, 2024
1 parent a6b034f commit 022356a
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,38 @@ export default class AreaSelectSpatialInputAction {
this.#highlighter?.destroy();
}

enable() {
const model = this._areaSelectSpatialInputWidgetModel;
const vm = new Vue(AreaSelectSpatialInputWidget);
vm.buffer = model.buffer;
vm.minBuffer = model.minBuffer;
vm.maxBuffer = model.maxBuffer;
vm.stepSize = model.stepSize;
vm.unit = model.unit;
vm.i18n = this.i18n;

this.#binding = Binding.for(vm, model)
.syncAllToLeft("storeData")
.syncAll("selectedStoreId")
.syncAllToRight("buffer")
.enable()
.syncToLeftNow();

const widget = new VueDijit(vm);
const serviceProperties = {
"widgetRole": "areaSelectSpatialInputWidget"
};
const interfaces = ["dijit.Widget"];
if (!this.#serviceRegistration) {
this.#serviceRegistration = this.#bundleContext.registerService(interfaces, widget, serviceProperties);
}
}

disable() {
this.closeWidget();
this.removeGraphicFromView();
}

trigger(args) {
return new CancelablePromise((resolve, reject, oncancel) => {
if (!this._mapWidgetModel) {
Expand All @@ -61,31 +93,8 @@ export default class AreaSelectSpatialInputAction {
}

const model = this._areaSelectSpatialInputWidgetModel;
const vm = new Vue(AreaSelectSpatialInputWidget);
vm.buffer = model.buffer;
vm.minBuffer = model.minBuffer;
vm.maxBuffer = model.maxBuffer;
vm.stepSize = model.stepSize;
vm.unit = model.unit;
vm.i18n = this.i18n;

this.#binding = Binding.for(vm, model)
.syncAllToLeft("storeData")
.syncAll("selectedStoreId")
.syncAllToRight("buffer")
.enable()
.syncToLeftNow();

const widget = new VueDijit(vm);
const serviceProperties = {
"widgetRole": "areaSelectSpatialInputWidget"
};
const interfaces = ["dijit.Widget"];
if (!this.#serviceRegistration) {
this.#serviceRegistration = this.#bundleContext.registerService(interfaces, widget, serviceProperties);
}

const view = this._mapWidgetModel.get("view");

const clickHandle = view.on("click", (evt) => {
this.removeGraphicFromView();
clickHandle.remove();
Expand All @@ -112,7 +121,6 @@ export default class AreaSelectSpatialInputAction {
oncancel(() => {
clickHandle.remove();
this.removeGraphicFromView();
this.closeWidget();
console.debug("AreaSelectSpatialInputAction was canceled...");
});
});
Expand All @@ -134,7 +142,7 @@ export default class AreaSelectSpatialInputAction {
const model = this._areaSelectSpatialInputWidgetModel;
const storeId = model.selectedStoreId;
const store = this.getStore(storeId);
return new Promise((resolve, reject) => {
return new Promise((resolve) => {
if (!store) {
resolve(null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export default class CircleSpatialInputAction {

disable() {
this.closeWidget();
this.removeGraphicFromView();
}

trigger(args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,58 @@ export default class {
}
}

enable() {
const view = this._mapWidgetModel.get("view");
const model = this._graphicSpatialInputWidgetModel;

const vm = new Vue(GraphicSpatialInputWidget);
vm.i18n = this.i18n;
vm.buffer = model.buffer;
vm.minBuffer = model.minBuffer;
vm.maxBuffer = model.maxBuffer;
vm.stepSize = model.stepSize;
vm.unit = model.unit;

this.#binding = Binding.for(vm, model)
.syncAllToRight("buffer")
.enable()
.syncToLeftNow();

const widget = new VueDijit(vm);
const serviceProperties = {
"widgetRole": "graphicSpatialInputWidget"
};
const interfaces = ["dijit.Widget"];
if (!this.#serviceRegistration) {
this.#serviceRegistration = this.#bundleContext.registerService(interfaces, widget, serviceProperties);
}

this.#moveHandle = view.on("pointer-move", (evt) => {
// prevent popup
evt.stopPropagation();
clearTimeout(this.moveTimeout);
view.hitTest(evt).then((response) => {
const results = response.results;
if (results.length) {
const graphic = results[0].graphic;
const geometry = graphic.geometry;
if (geometry) {
const geometry = graphic.geometry;
this.addMoveGraphicToView(geometry);
}
}
});
});
}

disable() {
this.#moveHandle.remove();
this.#moveHandle = null;
this.closeWidget();
this.removeClickGraphicFromView();
this.removeMoveGraphicFromView();
}

trigger() {
return new CancelablePromise((resolve, reject, oncancel) => {
if (!this._mapWidgetModel) {
Expand All @@ -65,47 +117,8 @@ export default class {
this.addClickGraphicToView(this.#geometry);
}

const model = this._graphicSpatialInputWidgetModel;
const view = this._mapWidgetModel.get("view");

const vm = new Vue(GraphicSpatialInputWidget);
vm.i18n = this.i18n;
vm.buffer = model.buffer;
vm.minBuffer = model.minBuffer;
vm.maxBuffer = model.maxBuffer;
vm.stepSize = model.stepSize;
vm.unit = model.unit;

this.#binding = Binding.for(vm, model)
.syncAllToRight("buffer")
.enable()
.syncToLeftNow();

const widget = new VueDijit(vm);
const serviceProperties = {
"widgetRole": "graphicSpatialInputWidget"
};
const interfaces = ["dijit.Widget"];
if (!this.#serviceRegistration) {
this.#serviceRegistration = this.#bundleContext.registerService(interfaces, widget, serviceProperties);
}

this.#moveHandle = view.on("pointer-move", (evt) => {
// prevent popup
evt.stopPropagation();
clearTimeout(this.moveTimeout);
view.hitTest(evt).then((response) => {
const results = response.results;
if (results.length) {
const graphic = results[0].graphic;
const geometry = graphic.geometry;
if (geometry) {
const geometry = graphic.geometry;
this.addMoveGraphicToView(geometry);
}
}
});
});
const model = this._graphicSpatialInputWidgetModel;

const clickHandle = view.on("click", (evt) => {
this.removeClickGraphicFromView();
Expand All @@ -131,10 +144,7 @@ export default class {
});

oncancel(() => {
this.#moveHandle.remove();
this.#moveHandle = null;
clickHandle.remove();
this.closeWidget();
console.debug("GraphicSpatialInputAction was canceled...");
async(() => {
this.removeClickGraphicFromView();
Expand Down

0 comments on commit 022356a

Please sign in to comment.