Browse Source

Merge pull request #892 in VISUAL/fineui from ~DAILER/fineui:master to master

* commit 'c1ca16a5992eedddada2dde80b07979ef5133e34':
  无JIRA任务 添加一个路由,方便一些
  无jira任务 fix: multi_select_combo 和 multi_select_insert_combo 统一逻辑,只有勾选了全选才认为是全选.
es6
windy 6 years ago
parent
commit
c8f013136f
  1. 3
      Gruntfile.js
  2. 37
      demo/app.js
  3. 2
      demo/js/center.js
  4. 23
      demo/js/main.js
  5. 65
      demo/js/main.store.js
  6. 3
      demo/js/west.js
  7. 28
      src/widget/multiselect/multiselect.combo.js

3
Gruntfile.js

@ -223,7 +223,6 @@ module.exports = function (grunt) {
}, },
less: { less: {
demo: { demo: {
expand: true, expand: true,
@ -332,7 +331,7 @@ module.exports = function (grunt) {
}, },
watch: { watch: {
scripts: { 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"], tasks: ["less", "concat"],
options: { options: {
spanw: true, spanw: true,

37
demo/app.js

@ -3,21 +3,40 @@ Demo = {
}; };
$(function () { $(function () {
var ref; 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: { routes: {
"": "index" "": "index"
}, },
index: function () { index: function () {
BI.createWidget({ Demo.showIndex = "demo.face";
type: "demo.main", }
ref: function (_ref) { };
console.log(_ref);
ref = _ref; BI.Tree.traversal(tree, function (index, node) {
}, if (!node.children || BI.isEmptyArray(node.children)) {
element: "#wrapper" obj.routes[node.text] = node.text;
}); obj[node.text] = function () {
Demo.showIndex = node.value;
};
} }
}); });
var AppRouter = BI.inherit(BI.Router, obj);
new AppRouter; new AppRouter;
BI.history.start(); BI.history.start();
BI.createWidget({
type: "demo.main",
ref: function (_ref) {
console.log(_ref);
ref = _ref;
},
element: "#wrapper"
});
}); });

2
demo/js/center.js

@ -10,7 +10,7 @@ Demo.Center = BI.inherit(BI.Widget, {
self.tab = this; self.tab = this;
}, },
single: true, single: true,
showIndex: "demo.face", showIndex: Demo.showIndex,
cardCreator: function (v) { cardCreator: function (v) {
return BI.createWidget({ return BI.createWidget({
type: v type: v

23
demo/js/main.js

@ -2,8 +2,23 @@ Demo.Main = BI.inherit(BI.Widget, {
props: { props: {
baseCls: "demo-main bi-background" 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 () { render: function () {
var center; var self = this;
return { return {
type: "bi.border", type: "bi.border",
items: { items: {
@ -14,7 +29,7 @@ Demo.Main = BI.inherit(BI.Widget, {
listeners: [{ listeners: [{
eventName: Demo.North.EVENT_VALUE_CHANGE, eventName: Demo.North.EVENT_VALUE_CHANGE,
action: function (v) { action: function (v) {
center.setValue(v); self.store.handleTreeSelectChange(v);
} }
}] }]
} }
@ -26,7 +41,7 @@ Demo.Main = BI.inherit(BI.Widget, {
listeners: [{ listeners: [{
eventName: Demo.West.EVENT_VALUE_CHANGE, eventName: Demo.West.EVENT_VALUE_CHANGE,
action: function (v) { action: function (v) {
center.setValue(v); self.store.handleTreeSelectChange(v);
} }
}] }]
} }
@ -35,7 +50,7 @@ Demo.Main = BI.inherit(BI.Widget, {
el: { el: {
type: "demo.center", type: "demo.center",
ref: function (_ref) { ref: function (_ref) {
center = _ref; self.center = _ref;
} }
} }
} }

65
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);
})();

3
demo/js/west.js

@ -2,9 +2,11 @@ Demo.West = BI.inherit(BI.Widget, {
props: { props: {
baseCls: "demo-west bi-border-right bi-card" baseCls: "demo-west bi-border-right bi-card"
}, },
mounted: function () { mounted: function () {
this.searcher.setAdapter(this.tree); this.searcher.setAdapter(this.tree);
}, },
render: function () { render: function () {
var self = this; var self = this;
return { return {
@ -48,6 +50,7 @@ Demo.West = BI.inherit(BI.Widget, {
self.fireEvent(Demo.West.EVENT_VALUE_CHANGE, v); self.fireEvent(Demo.West.EVENT_VALUE_CHANGE, v);
} }
}], }],
value: Demo.showIndex,
items: Demo.CONFIG, items: Demo.CONFIG,
ref: function (ref) { ref: function (ref) {
self.tree = ref; self.tree = ref;

28
src/widget/multiselect/multiselect.combo.js

@ -299,32 +299,9 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, {
_adjust: function (callback) { _adjust: function (callback) {
var self = this, o = this.options; var self = this, o = this.options;
if (!this._count) { adjust();
o.itemsCreator({ callback();
type: BI.MultiSelectCombo.REQ_GET_DATA_LENGTH
}, function (res) {
self._count = res.count;
adjust();
callback();
});
} else {
adjust();
callback();
}
function adjust () { 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) { if (self.wants2Quit === true) {
self.fireEvent(BI.MultiSelectCombo.EVENT_CONFIRM); self.fireEvent(BI.MultiSelectCombo.EVENT_CONFIRM);
self.wants2Quit = false; self.wants2Quit = false;
@ -377,7 +354,6 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, {
}, },
populate: function () { populate: function () {
this._count = null;
this.combo.populate.apply(this.combo, arguments); this.combo.populate.apply(this.combo, arguments);
} }
}); });

Loading…
Cancel
Save