From a05e92892b9a06d1bec135bcd769578d88bdfed7 Mon Sep 17 00:00:00 2001 From: xiongjj Date: Wed, 30 Oct 2024 14:44:37 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90feature=E3=80=91=E9=AB=98=E4=BA=AE?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E5=BC=B9=E7=AA=97=E6=A0=B7=E5=BC=8F=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E8=B0=83=E6=95=B4;=20review=20by=20qiw?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/attribute-panel/AttributePanel.vue | 2 +- .../layer-highlight/LayerHighlight.vue | 41 ++++++++++--------- .../__tests__/LayersHighlight.spec.js | 19 +-------- src/mapboxgl/map-popup/MapPopup.vue | 1 + src/mapboxgl/query/Query.vue | 2 +- 5 files changed, 26 insertions(+), 39 deletions(-) diff --git a/src/common/attribute-panel/AttributePanel.vue b/src/common/attribute-panel/AttributePanel.vue index d8dc036c..9535be23 100644 --- a/src/common/attribute-panel/AttributePanel.vue +++ b/src/common/attribute-panel/AttributePanel.vue @@ -80,7 +80,7 @@ class SmAttributePanel extends Mixins(Theme) { columns: this.columns, showHeader: this.showHeader, background: 'transparent', - textColor: 'inherit' + textColor: this.textColor }; } diff --git a/src/mapboxgl/layer-highlight/LayerHighlight.vue b/src/mapboxgl/layer-highlight/LayerHighlight.vue index 729d48fc..b09ec5b0 100644 --- a/src/mapboxgl/layer-highlight/LayerHighlight.vue +++ b/src/mapboxgl/layer-highlight/LayerHighlight.vue @@ -94,33 +94,34 @@ export default { return this.allPopupDatas[this.currentIndex] || []; }, columnStyle() { - const { autoResize, keyWidth, valueWidth, keyMaxWidth, valueMaxWidth, keyWordStyle, valueWordStyle} = this.popupStyle; - let style = { keyStyle: {}, valueStyle: {} }; + const { autoResize, keyWidth, valueWidth, keyMaxWidth, valueMaxWidth, keyWordStyle, valueWordStyle } = this.popupStyle; + const style = { keyStyle: {}, valueStyle: {} }; + if (keyWidth) { + style.keyStyle.minWidth = keyWidth + 'px'; + } + if (valueWidth) { + style.valueStyle.minWidth = valueWidth + 'px'; + } + if (keyMaxWidth) { + style.keyStyle.maxWidth = keyMaxWidth + 'px'; + } + if (valueMaxWidth) { + style.valueStyle.maxWidth = valueMaxWidth + 'px'; + } if (!autoResize) { - if (keyWidth) { - style.keyStyle.width = keyWidth + 'px'; - } - if (valueWidth) { - style.valueStyle.width = valueWidth + 'px'; - } - } else { - if (keyMaxWidth) { - style.keyStyle.maxWidth = keyMaxWidth + 'px'; - } - if (valueMaxWidth) { - style.valueStyle.maxWidth = valueMaxWidth + 'px'; - } + style.keyStyle.maxWidth = style.keyStyle.minWidth; + style.valueStyle.maxWidth = style.valueStyle.minWidth; } const ellipsisStyle = { overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' + }; + if (keyWordStyle === 'ellipsis') { + style.keyStyle = { ...style.keyStyle, ...ellipsisStyle }; } - if (keyWordStyle === 'ellipsis'){ - style.keyStyle = {...style.keyStyle, ...ellipsisStyle} - } - if (valueWordStyle === 'ellipsis'){ - style.valueStyle = {...style.valueStyle, ...ellipsisStyle} + if (valueWordStyle === 'ellipsis') { + style.valueStyle = { ...style.valueStyle, ...ellipsisStyle }; } return style; }, diff --git a/src/mapboxgl/layer-highlight/__tests__/LayersHighlight.spec.js b/src/mapboxgl/layer-highlight/__tests__/LayersHighlight.spec.js index 315d978d..272e7550 100644 --- a/src/mapboxgl/layer-highlight/__tests__/LayersHighlight.spec.js +++ b/src/mapboxgl/layer-highlight/__tests__/LayersHighlight.spec.js @@ -71,8 +71,8 @@ describe('LayerHighlight.vue', () => { expect(wrapper.find(SmMapPopup).exists()).toBe(true); expect(wrapper.vm.tableColumns.length).toBe(2); const style = { overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }; - expect(wrapper.vm.columnStyle.keyStyle).toEqual({ ...style, maxWidth: '160px' }); - expect(wrapper.vm.columnStyle.valueStyle).toEqual({ ...style, maxWidth: '300px' }); + expect(wrapper.vm.columnStyle.keyStyle).toEqual({ ...style, maxWidth: '160px', minWidth: '80px' }); + expect(wrapper.vm.columnStyle.valueStyle).toEqual({ ...style, maxWidth: '300px', minWidth: '150px' }); done(); }); @@ -139,21 +139,6 @@ describe('LayerHighlight.vue', () => { done(); }); - it('set featureFieldsMap', done => { - wrapper = mount(SmLayerHighlight, { - propsData: { - mapTarget: 'map', - uniqueName: 'Test', - highlightStyle: {} - } - }); - const setSpy = jest.spyOn(wrapper.vm.viewModel, 'setDisplayFieldsMap'); - wrapper.setProps({ displayFieldsMap: {} }); - wrapper.vm.$nextTick(); - expect(setSpy).toBeCalled(); - done(); - }); - it('set clickTolerance', done => { wrapper = mount(SmLayerHighlight, { propsData: { diff --git a/src/mapboxgl/map-popup/MapPopup.vue b/src/mapboxgl/map-popup/MapPopup.vue index c5e07d0d..6135aa6a 100644 --- a/src/mapboxgl/map-popup/MapPopup.vue +++ b/src/mapboxgl/map-popup/MapPopup.vue @@ -9,6 +9,7 @@ :textColor="textColor" :attributes="data[defaultIndex]" :columns="columns" + :showHeader="showHeader" @change="changeIndex" > diff --git a/src/mapboxgl/query/Query.vue b/src/mapboxgl/query/Query.vue index 5a069e25..2c2440f3 100644 --- a/src/mapboxgl/query/Query.vue +++ b/src/mapboxgl/query/Query.vue @@ -142,7 +142,7 @@ :clickTolerance="clickTolerance" :popupStyle="popupStyle" :background="popupStyle.background || background" - :textColor="popupStyle.background || textColor" + :textColor="popupStyle.textColor || textColor" :mapTarget="mapTarget" :customColumnRenders="$scopedSlots" :showPopup="showPopup"