From 75644559d41011b289048c11f8a8b7ded471914e Mon Sep 17 00:00:00 2001 From: zsmj Date: Tue, 1 Nov 2022 11:36:32 +0800 Subject: [PATCH 1/3] =?UTF-8?q?DESIGN-4355=20feat:=20tooltip=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E5=BC=82=E6=AD=A5=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/base/single/0.single.js | 55 +++++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 18 deletions(-) diff --git a/src/base/single/0.single.js b/src/base/single/0.single.js index 93705ca91..0d42ec143 100644 --- a/src/base/single/0.single.js +++ b/src/base/single/0.single.js @@ -19,35 +19,35 @@ BI.Single = BI.inherit(BI.Widget, { return BI.extend(conf, { readonly: false, title: null, - warningTitle: null, - tipType: null, // success或warning - belowMouse: false, // title是否跟随鼠标 + warningTitle: null, // deprecated + tipType: null, // deprecated success或warning + belowMouse: false, // title是否跟随鼠标 enableHover: false, }); }, _showToolTip: function (e, opt) { opt || (opt = {}); + var self = this; var o = this.options; - var tooltipOpt = {}; var title = this.getTitle(); - if (BI.isPlainObject(title)) { - tooltipOpt = title; + + if (title instanceof Promise) { + title.then(resolvedTitle => { + this.mouseOver && showToolTip(this._getTooltipOptions(resolvedTitle)); + }); } else { - tooltipOpt.level = this.getTipType() || "success"; - // 由于以前的用法,存在大量disabled:true搭配warningTitle的情况,所以这里做一个兼容,disabled:true的情况下,依然优先显示warningTitle,避免只设置了warningTitle而没有设置title的情况 - if (BI.isNull(o.tipType) && !this.isEnabled()) { - tooltipOpt.text = (this.getWarningTitle() || title); - } else { - tooltipOpt.text = tooltipOpt.level === "success" ? title : (this.getWarningTitle() || title); - } + showToolTip(this._getTooltipOptions(title)); } - if (BI.isKey(tooltipOpt.text)) { - BI.Tooltips.show(e, this.getName(), tooltipOpt, this, opt); - if (o.action) { - BI.Actions.runAction(o.action, "hover", o, this); + + function showToolTip(tooltipOpt) { + if (BI.isKey(tooltipOpt.text) && !BI.Tooltips.has(self.getName())) { + BI.Tooltips.show(e, self.getName(), tooltipOpt, self, opt); + if (o.action) { + BI.Actions.runAction(o.action, "hover", o, self); + } + BI.Actions.runGlobalAction("hover", o, self); } - BI.Actions.runGlobalAction("hover", o, this); } }, @@ -91,12 +91,30 @@ BI.Single = BI.inherit(BI.Widget, { } }, + _getTooltipOptions: function (title) { + var o = this.options; + var tooltipOpt = {}; + if (BI.isPlainObject(title)) { + tooltipOpt = title; + } else { + tooltipOpt.level = this.getTipType() || "success"; + // 由于以前的用法,存在大量disabled:true搭配warningTitle的情况,所以这里做一个兼容,disabled:true的情况下,依然优先显示warningTitle,避免只设置了warningTitle而没有设置title的情况 + if (BI.isNull(o.tipType) && !this.isEnabled()) { + tooltipOpt.text = (this.getWarningTitle() || title); + } else { + tooltipOpt.text = tooltipOpt.level === "success" ? title : (this.getWarningTitle() || title); + } + } + return tooltipOpt; + }, + enableHover: function (opt) { opt || (opt = {}); var self = this; if (!this._hoverBinded) { this.element.unbind("mouseenter.title").on("mouseenter.title", function (e) { self._e = e; + self.mouseOver = true; if (self.getTipType() === "warning" || (BI.isKey(self.getWarningTitle()) && !self.isEnabled())) { delayingTooltips = self.getName(); self.showTimeout = BI.delay(function () { @@ -144,6 +162,7 @@ BI.Single = BI.inherit(BI.Widget, { }); this.element.unbind("mouseleave.title").on("mouseleave.title", function (e) { self._e = null; + self.mouseOver = false; self._clearTimeOut(); self._hideTooltip(); }); From 4889554cfd5c41c01032712a47a18fc3b61bb2f9 Mon Sep 17 00:00:00 2001 From: zsmj Date: Tue, 1 Nov 2022 17:07:12 +0800 Subject: [PATCH 2/3] =?UTF-8?q?DESIGN-4355=20feat:=20tooltip=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E5=BC=82=E6=AD=A5=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/base/single/0.single.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/base/single/0.single.js b/src/base/single/0.single.js index 0d42ec143..c13e02e81 100644 --- a/src/base/single/0.single.js +++ b/src/base/single/0.single.js @@ -33,8 +33,10 @@ BI.Single = BI.inherit(BI.Widget, { var title = this.getTitle(); if (title instanceof Promise) { + this.requestingTitle = title; title.then(resolvedTitle => { - this.mouseOver && showToolTip(this._getTooltipOptions(resolvedTitle)); + // 由于是异步的,所以无法避免Promise resolve时机问题,所以设计为:鼠标移出了则不显示,并且只显示最后一次发起的查询结果 + this.mouseOver && this.requestingTitle === title && showToolTip(this._getTooltipOptions(resolvedTitle)); }); } else { showToolTip(this._getTooltipOptions(title)); From 3390d8ed24de2a97c15c06a51a1fa795df822943 Mon Sep 17 00:00:00 2001 From: zsmj Date: Tue, 1 Nov 2022 17:07:46 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=97=A0JIRA=20fix:=20=E5=9B=BE=E6=A0=87?= =?UTF-8?q?=E5=86=99=E5=8F=8D=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/case/button/node/siwtcher.tree.node.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/case/button/node/siwtcher.tree.node.js b/src/case/button/node/siwtcher.tree.node.js index 89d055c51..8669f697b 100644 --- a/src/case/button/node/siwtcher.tree.node.js +++ b/src/case/button/node/siwtcher.tree.node.js @@ -32,10 +32,10 @@ BI.TreeNodeSwitcher = BI.inherit(BI.NodeButton, { return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? ["tree-solid-collapse-icon-type1", "tree-solid-expand-icon-type1"] : ["tree-collapse-icon-type2", "tree-expand-icon-type2"]; } else if (options.isLastNode) { // 最后一个节点 - return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? ["tree-solid-collapse-icon-type1", "tree-solid-expand-icon-type1"] : ["tree-collapse-icon-type3", "tree-expand-icon-type3"]; + return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? ["tree-solid-collapse-icon-type1", "tree-solid-expand-icon-type1"] : ["tree-collapse-icon-type4", "tree-expand-icon-type4"]; } else { // 其他情况 - return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? ["tree-solid-collapse-icon-type1", "tree-solid-expand-icon-type1"] : ["tree-collapse-icon-type4", "tree-expand-icon-type4"]; + return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? ["tree-solid-collapse-icon-type1", "tree-solid-expand-icon-type1"] : ["tree-collapse-icon-type3", "tree-expand-icon-type3"]; } },