From 98b81c0b863d5ad87640bca880b469fb9880b36e Mon Sep 17 00:00:00 2001 From: dailer Date: Tue, 9 Apr 2019 15:45:50 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=97=A0jira=E4=BB=BB=E5=8A=A1=20fix:=20mu?= =?UTF-8?q?lti=5Fselect=5Fcombo=20=E5=92=8C=20multi=5Fselect=5Finsert=5Fco?= =?UTF-8?q?mbo=20=E7=BB=9F=E4=B8=80=E9=80=BB=E8=BE=91,=E5=8F=AA=E6=9C=89?= =?UTF-8?q?=E5=8B=BE=E9=80=89=E4=BA=86=E5=85=A8=E9=80=89=E6=89=8D=E8=AE=A4?= =?UTF-8?q?=E4=B8=BA=E6=98=AF=E5=85=A8=E9=80=89.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/widget/multiselect/multiselect.combo.js | 28 ++------------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/src/widget/multiselect/multiselect.combo.js b/src/widget/multiselect/multiselect.combo.js index d4c7b8223..de914f337 100644 --- a/src/widget/multiselect/multiselect.combo.js +++ b/src/widget/multiselect/multiselect.combo.js @@ -299,32 +299,9 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, { _adjust: function (callback) { var self = this, o = this.options; - if (!this._count) { - o.itemsCreator({ - type: BI.MultiSelectCombo.REQ_GET_DATA_LENGTH - }, function (res) { - self._count = res.count; - adjust(); - callback(); - }); - } else { - adjust(); - callback(); - - } - + adjust(); + callback(); function adjust () { - if (self.storeValue.type === BI.Selection.All && self.storeValue.value.length >= self._count) { - self.storeValue = { - type: BI.Selection.Multi, - value: [] - }; - } else if (self.storeValue.type === BI.Selection.Multi && self.storeValue.value.length >= self._count) { - self.storeValue = { - type: BI.Selection.All, - value: [] - }; - } if (self.wants2Quit === true) { self.fireEvent(BI.MultiSelectCombo.EVENT_CONFIRM); self.wants2Quit = false; @@ -377,7 +354,6 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, { }, populate: function () { - this._count = null; this.combo.populate.apply(this.combo, arguments); } }); From 536b939b08020599498db69ff8bd450ed6862f79 Mon Sep 17 00:00:00 2001 From: dailer Date: Tue, 9 Apr 2019 21:59:07 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=97=A0JIRA=E4=BB=BB=E5=8A=A1=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E4=B8=80=E4=B8=AA=E8=B7=AF=E7=94=B1,=E6=96=B9?= =?UTF-8?q?=E4=BE=BF=E4=B8=80=E4=BA=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gruntfile.js | 3 +- demo/app.js | 37 ++++++++++++++++++------ demo/js/center.js | 2 +- demo/js/main.js | 23 ++++++++++++--- demo/js/main.store.js | 65 +++++++++++++++++++++++++++++++++++++++++++ demo/js/west.js | 3 ++ 6 files changed, 117 insertions(+), 16 deletions(-) create mode 100644 demo/js/main.store.js diff --git a/Gruntfile.js b/Gruntfile.js index 8a50c3f89..e81af8caa 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -223,7 +223,6 @@ module.exports = function (grunt) { }, - less: { demo: { expand: true, @@ -332,7 +331,7 @@ module.exports = function (grunt) { }, watch: { scripts: { - files: ["src/**/*.js", "src/**/*.less", "demo/js/**/*.js", "demo/version.js", "demo/config.js", "demo/less/**/*.less"], + files: ["src/**/*.js", "src/**/*.less", "demo/js/**/*.js", "demo/app.js", "demo/version.js", "demo/config.js", "demo/less/**/*.less"], tasks: ["less", "concat"], options: { spanw: true, diff --git a/demo/app.js b/demo/app.js index c393f10e6..c2ccef448 100644 --- a/demo/app.js +++ b/demo/app.js @@ -3,21 +3,40 @@ Demo = { }; $(function () { var ref; - var AppRouter = BI.inherit(BI.Router, { + + BI.each(Demo.CONFIG, function (index, item) { + !item.id && (item.id = item.value || item.text); + }); + var tree = BI.Tree.transformToTreeFormat(Demo.CONFIG); + + var obj = { routes: { "": "index" }, index: function () { - BI.createWidget({ - type: "demo.main", - ref: function (_ref) { - console.log(_ref); - ref = _ref; - }, - element: "#wrapper" - }); + Demo.showIndex = "demo.face"; + } + }; + + BI.Tree.traversal(tree, function (index, node) { + if (!node.children || BI.isEmptyArray(node.children)) { + obj.routes[node.text] = node.text; + obj[node.text] = function () { + Demo.showIndex = node.value; + }; } }); + + var AppRouter = BI.inherit(BI.Router, obj); new AppRouter; BI.history.start(); + + BI.createWidget({ + type: "demo.main", + ref: function (_ref) { + console.log(_ref); + ref = _ref; + }, + element: "#wrapper" + }); }); \ No newline at end of file diff --git a/demo/js/center.js b/demo/js/center.js index c51f314d1..11bae6177 100644 --- a/demo/js/center.js +++ b/demo/js/center.js @@ -10,7 +10,7 @@ Demo.Center = BI.inherit(BI.Widget, { self.tab = this; }, single: true, - showIndex: "demo.face", + showIndex: Demo.showIndex, cardCreator: function (v) { return BI.createWidget({ type: v diff --git a/demo/js/main.js b/demo/js/main.js index 4062ecc69..0fa50a657 100644 --- a/demo/js/main.js +++ b/demo/js/main.js @@ -2,8 +2,23 @@ Demo.Main = BI.inherit(BI.Widget, { props: { baseCls: "demo-main bi-background" }, + + _store: function () { + return BI.Stores.getStore("demo.store.main"); + }, + + watch: { + activeCard: function (v) { + this.center.setValue(v); + } + }, + + beforeInit: function (cb) { + this.store.init(cb); + }, + render: function () { - var center; + var self = this; return { type: "bi.border", items: { @@ -14,7 +29,7 @@ Demo.Main = BI.inherit(BI.Widget, { listeners: [{ eventName: Demo.North.EVENT_VALUE_CHANGE, action: function (v) { - center.setValue(v); + self.store.handleTreeSelectChange(v); } }] } @@ -26,7 +41,7 @@ Demo.Main = BI.inherit(BI.Widget, { listeners: [{ eventName: Demo.West.EVENT_VALUE_CHANGE, action: function (v) { - center.setValue(v); + self.store.handleTreeSelectChange(v); } }] } @@ -35,7 +50,7 @@ Demo.Main = BI.inherit(BI.Widget, { el: { type: "demo.center", ref: function (_ref) { - center = _ref; + self.center = _ref; } } } diff --git a/demo/js/main.store.js b/demo/js/main.store.js new file mode 100644 index 000000000..34f3d3fc6 --- /dev/null +++ b/demo/js/main.store.js @@ -0,0 +1,65 @@ +!(function () { + var Store = BI.inherit(Fix.Model, { + _init: function () { + + }, + + state: function () { + return { + activeCard: Demo.showIndex + }; + }, + + computed: {}, + + watch: {}, + + actions: { + init: function (cb) { + var tree = BI.Tree.transformToTreeFormat(Demo.CONFIG); + var traversal = function (array, callback) { + var t = []; + BI.some(array, function (i, item) { + var match = callback(i, item); + if (match) { + t.push(item.id); + } + var b = traversal(item.children, callback); + if (BI.isNotEmptyArray(b)) { + t = BI.concat([item.id], b); + } + }); + return t; + }; + var paths = traversal(tree, function (index, node) { + if (!node.children || BI.isEmptyArray(node.children)) { + if (node.value === Demo.showIndex) { + return true; + } + } + }); + BI.each(Demo.CONFIG, function (index, item) { + if (BI.contains(paths, item.id)) { + item.open = true; + } + }); + + cb(); + }, + + handleTreeSelectChange: function (v) { + this.model.activeCard = v; + var matched = BI.some(Demo.CONFIG, function (index, item) { + if (item.value === v) { + BI.history.navigate(item.text, {trigger: true}); + return true; + } + }); + if (!matched) { + BI.history.navigate("", {trigger: true}); + } + } + } + }); + BI.store("demo.store.main", Store); +})(); \ No newline at end of file diff --git a/demo/js/west.js b/demo/js/west.js index e8c711190..2c68f3795 100644 --- a/demo/js/west.js +++ b/demo/js/west.js @@ -2,9 +2,11 @@ Demo.West = BI.inherit(BI.Widget, { props: { baseCls: "demo-west bi-border-right bi-card" }, + mounted: function () { this.searcher.setAdapter(this.tree); }, + render: function () { var self = this; return { @@ -48,6 +50,7 @@ Demo.West = BI.inherit(BI.Widget, { self.fireEvent(Demo.West.EVENT_VALUE_CHANGE, v); } }], + value: Demo.showIndex, items: Demo.CONFIG, ref: function (ref) { self.tree = ref;