Skip to content

Commit

Permalink
[fix]isvj-5083 属性表排序不对 review by qiw
Browse files Browse the repository at this point in the history
  • Loading branch information
luoxiao-supermap committed Oct 10, 2022
1 parent 7e29896 commit d46377f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/mapboxgl/attributes/AttributesViewModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down
28 changes: 25 additions & 3 deletions src/mapboxgl/attributes/__tests__/AttributesViewModel.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ describe('AttributesViewModel.ts', () => {
{
type: 'Feature',
geometry: {
coordinates: [1,1],
coordinates: [1, 1],
type: 'Point'
},
properties: {
Expand Down Expand Up @@ -371,7 +371,7 @@ describe('AttributesViewModel.ts', () => {
getBounds: () => {
return {
contains: () => true
}
};
}
},
featureMap: {
Expand Down Expand Up @@ -407,7 +407,7 @@ describe('AttributesViewModel.ts', () => {
getBounds: () => {
return {
contains: () => true
}
};
}
},
featureMap: {
Expand All @@ -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);
}
});
});
});

0 comments on commit d46377f

Please sign in to comment.