@nextgis/ngw-map 1.12.0 → 1.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- /** Bundle of @nextgis/ngw-map; version: 1.12.0; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-map; version: 1.12.1; author: NextGIS */
2
2
  import { EventEmitter } from 'events';
3
3
  import CancelablePromise from '@nextgis/cancelable-promise';
4
4
  import { deepmerge, isObject, defined, deprecatedWarn } from '@nextgis/utils';
@@ -1,4 +1,4 @@
1
- /** Bundle of @nextgis/ngw-map; version: 1.12.0; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-map; version: 1.12.1; author: NextGIS */
2
2
  var NgwMap = (function (exports) {
3
3
  'use strict';
4
4
 
@@ -1308,6 +1308,9 @@ var NgwMap = (function (exports) {
1308
1308
 
1309
1309
  function isObject$1(val) {
1310
1310
  return Object.prototype.toString.call(val) === '[object Object]';
1311
+ }
1312
+ function isArray(val) {
1313
+ return Object.prototype.toString.call(val) === '[object Array]';
1311
1314
  }
1312
1315
 
1313
1316
  function fixUrlStr(url) {
@@ -2371,6 +2374,9 @@ var NgwMap = (function (exports) {
2371
2374
  'movestart',
2372
2375
  'move',
2373
2376
  'moveend',
2377
+ 'mousemove',
2378
+ 'mouseout',
2379
+ 'mouseover',
2374
2380
  ];
2375
2381
  if (opt && opt.include) {
2376
2382
  events = events.filter(function (x) { return opt.include.includes(x); });
@@ -4178,6 +4184,11 @@ var NgwMap = (function (exports) {
4178
4184
  xhr.abort();
4179
4185
  });
4180
4186
  }
4187
+ if (options.signal) {
4188
+ options.signal.addEventListener('abort', function () {
4189
+ xhr.abort();
4190
+ });
4191
+ }
4181
4192
  xhr.send(data);
4182
4193
  };
4183
4194
  }
@@ -4319,7 +4330,12 @@ var NgwMap = (function (exports) {
4319
4330
  forCache.id = resource;
4320
4331
  }
4321
4332
  else if (isObject(resource)) {
4322
- forCache.id = resource.id;
4333
+ if (resource.id !== undefined) {
4334
+ forCache.id = resource.id;
4335
+ }
4336
+ else if (resource.keyname) {
4337
+ forCache.keyname = resource.keyname;
4338
+ }
4323
4339
  }
4324
4340
  var makeRequest = function () {
4325
4341
  if (typeof resource === 'string') {
@@ -4421,20 +4437,35 @@ var NgwMap = (function (exports) {
4421
4437
  };
4422
4438
  ResourcesControl.prototype.getChildrenOf = function (resource, requestOptions) {
4423
4439
  var _this = this;
4424
- return this.getId(resource).then(function (parent) {
4425
- return _this.connector
4426
- .get('resource.collection', __assign({ cache: true }, requestOptions), {
4427
- parent: parent,
4428
- })
4429
- .then(function (items) {
4430
- for (var _i = 0, items_1 = items; _i < items_1.length; _i++) {
4431
- var i = items_1[_i];
4432
- _this.cache.add('resource.item', CancelablePromise.resolve(i), {
4433
- id: i.resource.id,
4434
- });
4440
+ return this.getIdOrFail(resource).then(function (parent) {
4441
+ return _this._getChildrenOf(parent, requestOptions);
4442
+ });
4443
+ };
4444
+ ResourcesControl.prototype._getChildrenOf = function (parent, requestOptions, _items) {
4445
+ var _this = this;
4446
+ if (_items === void 0) { _items = []; }
4447
+ return this.connector
4448
+ .get('resource.collection', __assign({ cache: true }, requestOptions), {
4449
+ parent: parent,
4450
+ })
4451
+ .then(function (items) {
4452
+ var recursivePromises = [];
4453
+ for (var _i = 0, items_1 = items; _i < items_1.length; _i++) {
4454
+ var item = items_1[_i];
4455
+ _this.cache.add('resource.item', CancelablePromise.resolve(item), {
4456
+ id: item.resource.id,
4457
+ });
4458
+ _items.push(item);
4459
+ if ((requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.recursive) && item.resource.children) {
4460
+ recursivePromises.push(_this._getChildrenOf(item.resource.id, requestOptions, _items));
4435
4461
  }
4436
- return items;
4437
- });
4462
+ }
4463
+ if (recursivePromises.length) {
4464
+ return CancelablePromise.all(recursivePromises).then(function () {
4465
+ return _items;
4466
+ });
4467
+ }
4468
+ return _items;
4438
4469
  });
4439
4470
  };
4440
4471
  ResourcesControl.prototype.update = function (resource, data) {
@@ -5327,6 +5358,7 @@ var NgwMap = (function (exports) {
5327
5358
  }
5328
5359
 
5329
5360
  function prepareNgwFieldsToPropertiesFilter(fields) {
5361
+ console.log(fields);
5330
5362
  var f;
5331
5363
  var _loop_1 = function () {
5332
5364
  var field = fields[f];
@@ -5346,6 +5378,9 @@ var NgwMap = (function (exports) {
5346
5378
  fields[f] = new (Date.bind.apply(Date, __spreadArray([void 0], dt_1, false)))().toISOString();
5347
5379
  }
5348
5380
  }
5381
+ else if (f === 'id' && typeof field === 'string') {
5382
+ fields[f] = field.split(',').map(Number);
5383
+ }
5349
5384
  };
5350
5385
  for (f in fields) {
5351
5386
  _loop_1();
@@ -5358,7 +5393,7 @@ var NgwMap = (function (exports) {
5358
5393
  if (filters) {
5359
5394
  return createFeatureFieldFilterQueries(__assign(__assign({}, options), { filters: filters })).then(function (data) {
5360
5395
  var _a;
5361
- var clientFilterValidate = (_a = options.clientFilterValidate) !== null && _a !== void 0 ? _a : true;
5396
+ var clientFilterValidate = (_a = options.clientFilterValidate) !== null && _a !== void 0 ? _a : isFilterWithAnyCase(filters);
5362
5397
  // Additional client-side filter check
5363
5398
  if (clientFilterValidate) {
5364
5399
  data = data.filter(function (y) {
@@ -5373,6 +5408,21 @@ var NgwMap = (function (exports) {
5373
5408
  else {
5374
5409
  return fetchNgwLayerItemsRequest(options);
5375
5410
  }
5411
+ }
5412
+ function isFilterWithAnyCase(filters) {
5413
+ if (filters[0] === 'any') {
5414
+ return true;
5415
+ }
5416
+ for (var i = 1; i < filters.length; i++) {
5417
+ var p = filters[i];
5418
+ if (isArray(p)) {
5419
+ var deep = isFilterWithAnyCase(p);
5420
+ if (deep) {
5421
+ return true;
5422
+ }
5423
+ }
5424
+ }
5425
+ return false;
5376
5426
  }
5377
5427
 
5378
5428
  function fetchNgwLayerFeatures(options) {
@@ -7922,7 +7972,6 @@ var NgwMap = (function (exports) {
7922
7972
 
7923
7973
  function getIdentifyItems(identify, multiple) {
7924
7974
  if (multiple === void 0) { multiple = false; }
7925
- var params;
7926
7975
  var resources = [];
7927
7976
  var paramsList = [];
7928
7977
  for (var l in identify) {
@@ -7943,14 +7992,9 @@ var NgwMap = (function (exports) {
7943
7992
  if ('features' in identifyItem) {
7944
7993
  var layerFeatures = identifyItem.features;
7945
7994
  var resourceId = Number(l);
7946
- var feature = layerFeatures[0];
7947
- if (feature) {
7948
- params = {
7949
- featureId: feature.id,
7950
- resourceId: resourceId,
7951
- feature: feature,
7952
- };
7953
- paramsList.push(params);
7995
+ var featureParams = createParamsFromFeatures(layerFeatures, resourceId, multiple);
7996
+ if (featureParams.length) {
7997
+ paramsList.push.apply(paramsList, featureParams);
7954
7998
  if (!multiple) {
7955
7999
  break;
7956
8000
  }
@@ -7959,6 +8003,22 @@ var NgwMap = (function (exports) {
7959
8003
  }
7960
8004
  return paramsList;
7961
8005
  }
8006
+ function createParamsFromFeatures(features, resourceId, multiple) {
8007
+ var featureParams = [];
8008
+ for (var _i = 0, features_1 = features; _i < features_1.length; _i++) {
8009
+ var feature = features_1[_i];
8010
+ var params = {
8011
+ featureId: feature.id,
8012
+ resourceId: resourceId,
8013
+ feature: feature,
8014
+ };
8015
+ featureParams.push(params);
8016
+ if (!multiple) {
8017
+ break;
8018
+ }
8019
+ }
8020
+ return featureParams;
8021
+ }
7962
8022
  function fetchIdentifyGeoJson(options) {
7963
8023
  var connector = options.connector, identify = options.identify;
7964
8024
  for (var l in identify) {