Skip to content

Commit

Permalink
Merge pull request #22 from conterra/4.18
Browse files Browse the repository at this point in the history
Add new 4.18 support for Non-interactive SpatialInputActions
  • Loading branch information
sholtkamp authored Nov 8, 2024
2 parents 9da2518 + 022356a commit cc002cb
Show file tree
Hide file tree
Showing 5 changed files with 157 additions and 173 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 @@ -51,6 +51,58 @@ export default class CircleSpatialInputAction {
this.#highlighter?.destroy();
}

enable() {
const view = this._mapWidgetModel.get("view");
const model = this._circleSpatialInputWidgetModel;
if (!model.enableDonut) {
model.innerRadius = 0;
}

const vm = this.vm = new Vue(CircleSpatialInputWidget);
vm.i18n = this.i18n;
vm.enableDonut = model.enableDonut;
vm.minRadius = model.minRadius;
vm.maxRadius = model.maxRadius;
vm.innerRadius = model.innerRadius;
vm.outerRadius = model.outerRadius;
vm.stepSize = model.stepSize;
vm.adjustStepSize = model.adjustStepSize;
vm.unit = model.unit;

vm.$on("adjustStepSize-changed", adjustStepSize => {
if (adjustStepSize) {
this.#scaleWatcher = this._getScaleWatcher(view, model, vm);
} else {
this.#scaleWatcher.remove();
this.#scaleWatcher = undefined;
vm.stepSize = model.stepSize;
}
});

// handle inital activation adjustStepSize via config
if (model.adjustStepSize) {
this.#scaleWatcher = this._getScaleWatcher(view, model, vm);
}

this.#binding = Binding.for(vm, model)
.syncAllToRight("innerRadius", "outerRadius", "adjustStepSize")
.enable();

const widget = new VueDijit(vm);
const serviceProperties = {
"widgetRole": "circleSpatialInputWidget"
};
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 @@ -60,52 +112,8 @@ export default class CircleSpatialInputAction {
this.addGraphicToView(this.#geometry);
}

const model = this._circleSpatialInputWidgetModel;
if (!model.enableDonut) {
model.innerRadius = 0;
}

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

const vm = new Vue(CircleSpatialInputWidget);
vm.i18n = this.i18n;
vm.enableDonut = model.enableDonut;
vm.minRadius = model.minRadius;
vm.maxRadius = model.maxRadius;
vm.innerRadius = model.innerRadius;
vm.outerRadius = model.outerRadius;
vm.stepSize = model.stepSize;
vm.adjustStepSize = model.adjustStepSize;
vm.unit = model.unit;

vm.$on("adjustStepSize-changed", adjustStepSize => {
if (adjustStepSize) {
this.#scaleWatcher = this._getScaleWatcher(view, model, vm);
} else {
this.#scaleWatcher.remove();
this.#scaleWatcher = undefined;
vm.stepSize = model.stepSize;
}
});

// handle inital activation adjustStepSize via config
if (model.adjustStepSize) {
this.#scaleWatcher = this._getScaleWatcher(view, model, vm);
}

this.#binding = Binding.for(vm, model)
.syncAllToRight("innerRadius", "outerRadius", "adjustStepSize")
.enable();

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

const clickHandle = view.on("click", (evt) => {
this.removeGraphicFromView();
clickHandle.remove();
Expand All @@ -123,7 +131,6 @@ export default class CircleSpatialInputAction {

oncancel(() => {
clickHandle.remove();
this.closeWidget();
console.debug("CircleSpatialInputAction was canceled...");
this.removeGraphicFromView();
async(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
*/
import CancelablePromise from "apprt-core/CancelablePromise";
import Observers from "apprt-core/Observers";
import when from "apprt-core/when";
import Extent from "esri/geometry/Extent";

Expand All @@ -26,55 +25,36 @@ export default class {
this.title = i18n.title;
this.description = i18n.description;
this.iconClass = "icon-globe";
this.interactive = true;
this.interactive = false;
}

trigger() {
return new CancelablePromise((resolve, reject, oncancel) => {
const that = this;
const model = that._mapWidgetModel;
const model = this._mapWidgetModel;
if (!model) {
reject("MapWidgetModel not available!");
}

const observers = Observers();

function connectToView(view) {
const group = observers.group("view");
group.clean();
if (!view) {
return;
const fullExtent = new Extent({
"xmin": -20037507.067161843,
"ymin": -19971868.880408604,
"xmax": 20037507.067161843,
"ymax": 19971868.8804085,
"spatialReference": {
"wkid": 102100,
"latestWkid": 3857
}
group.add(view.on("click", (evt) => {
// prevent popup
evt.stopPropagation();

observers.destroy();
const fullExtent = new Extent({
"xmin": -20037507.067161843,
"ymin": -19971868.880408604,
"xmax": 20037507.067161843,
"ymax": 19971868.8804085,
"spatialReference": {
"wkid": 102100,
"latestWkid": 3857
}
});
return when(that._coordinateTransformer.transform(fullExtent, view.spatialReference.wkid),
(transformedExtent) => {
resolve(transformedExtent);
});
}));
}
});

connectToView(model.view);
observers.add(model.watch("view", ({value}) => {
connectToView(value);
}));
oncancel(() => {
console.debug("FullExtentSpatialInputAction was canceled...");
observers.destroy();
});

when(that._coordinateTransformer.transform(fullExtent, model.view.spatialReference.wkid),
(transformedExtent) => {
resolve(transformedExtent);
});
});
}
}
Loading

0 comments on commit cc002cb

Please sign in to comment.