From d46377f4d2eb7927e6cf330da326f4eed8fb5547 Mon Sep 17 00:00:00 2001 From: luoxiao-supermap Date: Mon, 10 Oct 2022 17:08:15 +0800 Subject: [PATCH] =?UTF-8?q?[fix]isvj-5083=20=E5=B1=9E=E6=80=A7=E8=A1=A8?= =?UTF-8?q?=E6=8E=92=E5=BA=8F=E4=B8=8D=E5=AF=B9=20review=20by=20qiw?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../attributes/AttributesViewModel.ts | 2 +- .../__tests__/AttributesViewModel.spec.js | 28 +++++++++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/mapboxgl/attributes/AttributesViewModel.ts b/src/mapboxgl/attributes/AttributesViewModel.ts index 68fdf09e..363a0a60 100644 --- a/src/mapboxgl/attributes/AttributesViewModel.ts +++ b/src/mapboxgl/attributes/AttributesViewModel.ts @@ -507,7 +507,7 @@ class FeatureTableViewModel extends mapboxgl.Evented { dataIndex: propertyName, visible: true }; - if (typeof +headers[propertyName] === 'number' && !isNaN(+headers[propertyName])) { + if (!isNaN(parseFloat(headers[propertyName])) && !isNaN(+headers[propertyName])) { // @ts-ignore columnConfig.sorter = (a, b) => a[propertyName] - b[propertyName]; } diff --git a/src/mapboxgl/attributes/__tests__/AttributesViewModel.spec.js b/src/mapboxgl/attributes/__tests__/AttributesViewModel.spec.js index 57d5a091..a3d80363 100644 --- a/src/mapboxgl/attributes/__tests__/AttributesViewModel.spec.js +++ b/src/mapboxgl/attributes/__tests__/AttributesViewModel.spec.js @@ -135,7 +135,7 @@ describe('AttributesViewModel.ts', () => { { type: 'Feature', geometry: { - coordinates: [1,1], + coordinates: [1, 1], type: 'Point' }, properties: { @@ -371,7 +371,7 @@ describe('AttributesViewModel.ts', () => { getBounds: () => { return { contains: () => true - } + }; } }, featureMap: { @@ -407,7 +407,7 @@ describe('AttributesViewModel.ts', () => { getBounds: () => { return { contains: () => true - } + }; } }, featureMap: { @@ -431,4 +431,26 @@ describe('AttributesViewModel.ts', () => { viewModel.addOverlaysToMap(selectedKeys, layerStyleOptions, attributesTitle); expect(spy).toBeCalled(); }); + it('add Polygon Overlays to map', () => { + const headers = { + Layer: '中学1', + LayerOn: '1', + LineWidth: '0', + Ctype: null, + Ctype1: [], + Ctype2: undefined, + Ctype3: '', + Ctype4: {}, + key: 0 + }; + const viewModel = new AttributesViewModel(options); + const columns = viewModel.toTableColumns(headers); + columns.forEach((element, index) => { + if([1, 2, 8].includes(index)){ + expect(typeof element.sorter).toBe('function'); + }else { + expect(element.sorter).toBe(undefined); + } + }); + }); });