@esri/solutions-components 0.8.29 → 0.8.30

Sign up to get free protection for your applications and to get access to all the features.
@@ -136,23 +136,22 @@ const FloorFilter = class {
136
136
  // Watch handlers
137
137
  //
138
138
  //--------------------------------------------------------------------------
139
+ /**
140
+ * Watch for changes to the mapView and re-init the floor filter
141
+ */
139
142
  async mapViewWatchHandler() {
140
- console.log("mapViewWatchHandler FF");
141
- const webMap = this.mapView.map;
142
- await webMap.when(() => {
143
- console.log("webMap.when FF");
144
- if (this.floorFilterWidget) {
145
- this.floorFilterWidget.destroy();
146
- this.floorFilterWidget = undefined;
147
- console.log("floorFilterWidget destroyed");
148
- }
149
- if (this._floorFilterElement) {
150
- this._floorFilterElement.remove();
151
- this._floorFilterElement = document.createElement("div");
152
- console.log("this._floorFilterElement created");
153
- }
154
- this._initFloorFilter(this.mapView, webMap);
155
- });
143
+ await this._initFloorFilter(this.mapView);
144
+ }
145
+ /**
146
+ * Watch for changes to the enabled property and re-init or destroy the floor filter
147
+ */
148
+ async enabledWatchHandler() {
149
+ if (this.enabled) {
150
+ await this._initFloorFilter(this.mapView);
151
+ }
152
+ else if (!this.enabled) {
153
+ this._destroyWidget();
154
+ }
156
155
  }
157
156
  //--------------------------------------------------------------------------
158
157
  //
@@ -165,8 +164,11 @@ const FloorFilter = class {
165
164
  async componentWillLoad() {
166
165
  return this._initModules();
167
166
  }
167
+ /**
168
+ * Renders the component.
169
+ */
168
170
  render() {
169
- return (index.h(index.Host, { key: 'df3c419f3eaf30590c44c4919f0eeddfc333b81d' }, index.h("div", { key: '8496099f3bc35f34db6e47f73870ead9144df0a4', ref: (el) => { this._floorFilterElement = el; } })));
171
+ return (index.h(index.Host, { key: 'c80a8d46fb48f3789d9fa09c2400faad49e2e236' }, index.h("div", { key: '82919a3ba061a17c8aeaa0d2f6f4f13bc428b519', ref: (el) => { this._floorFilterElement = el; } })));
170
172
  }
171
173
  //--------------------------------------------------------------------------
172
174
  //
@@ -188,38 +190,61 @@ const FloorFilter = class {
188
190
  this.FloorFilter = FloorFilter;
189
191
  this.reactiveUtils = reactiveUtils;
190
192
  }
193
+ /**
194
+ * Destroy the widget and remove the containing element if it exists
195
+ *
196
+ * @protected
197
+ */
198
+ _destroyWidget() {
199
+ if (this.floorFilterWidget) {
200
+ this.floorFilterWidget.destroy();
201
+ this.floorFilterWidget = undefined;
202
+ }
203
+ if (this._floorFilterElement) {
204
+ this._floorFilterElement.remove();
205
+ }
206
+ }
207
+ /**
208
+ * Destroy the widget and remove the containing element then re-create the container element
209
+ *
210
+ * @protected
211
+ */
212
+ _initContainer() {
213
+ this._destroyWidget();
214
+ this._floorFilterElement = document.createElement("div");
215
+ }
191
216
  /**
192
217
  * Initialize the floor filter or reset the current view if it already exists
193
218
  */
194
- _initFloorFilter(view, webMap) {
195
- var _a, _b, _c;
196
- console.log("_initFloorFilter");
197
- console.log(`view: ${view}`);
198
- console.log(`this.enabled: ${this.enabled}`);
199
- console.log(`this.FloorFilter: ${this.FloorFilter}`);
200
- console.log(`webMap?.floorInfo: ${webMap === null || webMap === void 0 ? void 0 : webMap.floorInfo}`);
219
+ async _initFloorFilter(view) {
220
+ const webMap = view === null || view === void 0 ? void 0 : view.map;
201
221
  if (view && this.enabled && this.FloorFilter && (webMap === null || webMap === void 0 ? void 0 : webMap.floorInfo)) {
202
- this.floorFilterWidget = new this.FloorFilter({
203
- container: this._floorFilterElement,
204
- view
205
- });
206
- (_a = this._facilityHandle) === null || _a === void 0 ? void 0 : _a.remove();
207
- this._facilityHandle = this.reactiveUtils.watch(() => this.floorFilterWidget.facility, (facility) => {
208
- this.facilityChanged.emit(facility);
209
- });
210
- (_b = this._levelHandle) === null || _b === void 0 ? void 0 : _b.remove();
211
- this._levelHandle = this.reactiveUtils.watch(() => this.floorFilterWidget.level, (level) => {
212
- this.levelChanged.emit(level);
213
- });
214
- (_c = this._siteHandle) === null || _c === void 0 ? void 0 : _c.remove();
215
- this._siteHandle = this.reactiveUtils.watch(() => this.floorFilterWidget.site, (site) => {
216
- this.siteChanged.emit(site);
222
+ this._initContainer();
223
+ await webMap.when(() => {
224
+ var _a, _b, _c;
225
+ this.floorFilterWidget = new this.FloorFilter({
226
+ container: this._floorFilterElement,
227
+ view
228
+ });
229
+ (_a = this._facilityHandle) === null || _a === void 0 ? void 0 : _a.remove();
230
+ this._facilityHandle = this.reactiveUtils.watch(() => this.floorFilterWidget.facility, (facility) => {
231
+ this.facilityChanged.emit(facility);
232
+ });
233
+ (_b = this._levelHandle) === null || _b === void 0 ? void 0 : _b.remove();
234
+ this._levelHandle = this.reactiveUtils.watch(() => this.floorFilterWidget.level, (level) => {
235
+ this.levelChanged.emit(level);
236
+ });
237
+ (_c = this._siteHandle) === null || _c === void 0 ? void 0 : _c.remove();
238
+ this._siteHandle = this.reactiveUtils.watch(() => this.floorFilterWidget.site, (site) => {
239
+ this.siteChanged.emit(site);
240
+ });
217
241
  });
218
242
  }
219
243
  }
220
244
  get el() { return index.getElement(this); }
221
245
  static get watchers() { return {
222
- "mapView": ["mapViewWatchHandler"]
246
+ "mapView": ["mapViewWatchHandler"],
247
+ "enabled": ["enabledWatchHandler"]
223
248
  }; }
224
249
  };
225
250
  FloorFilter.style = FloorFilterStyle0;