zsmj 2 years ago
parent
commit
c3dd73622f
  1. 17
      src/base/combination/searcher.js
  2. 11
      src/case/button/index.js
  3. 105
      src/case/button/treeitem/item.first.treeleaf.js
  4. 105
      src/case/button/treeitem/item.last.treeleaf.js
  5. 105
      src/case/button/treeitem/item.mid.treeleaf.js
  6. 78
      src/case/button/treeitem/item.root.treeleaf.js
  7. 76
      src/case/button/treeitem/item.treetextleaf.js
  8. 134
      src/case/button/treeitem/treeitem.js
  9. 94
      src/case/layer/pane.list.js
  10. 2
      src/case/list/list.select.js
  11. 2
      src/less/base/dom.less

17
src/base/combination/searcher.js

@ -5,7 +5,20 @@
* @class BI.Searcher
* @extends BI.Widget
*/
import { shortcut, Widget, Controller, extend, createWidget, debounce, bind, endWith, deepWithout, nextTick, isEmptyString, isNull } from "../../core";
import {
shortcut,
Widget,
Controller,
extend,
createWidget,
debounce,
bind,
endWith,
deepWithout,
nextTick,
isEmptyString,
isNull
} from "../../core";
import { ButtonGroup } from "./group.button";
import { Maskers } from "../0.base";
@ -217,7 +230,7 @@ export class Searcher extends Widget {
_getLastSearchKeyword() {
if (this.isValid()) {
const res = this.editor.getValue().split(/\u200b\s\u200b/);
let res = this.editor.getValue().split(/\u200b\s\u200b/);
if (isEmptyString(res[res.length - 1])) {
res = res.slice(0, res.length - 1);
}

11
src/case/button/index.js

@ -19,11 +19,10 @@ export { PlusGroupNode } from "./node/node.plus";
export { TreeNodeSwitcher } from "./node/siwtcher.tree.node";
export { BasicTreeNode } from "./node/treenode";
export { FirstTreeLeafItem } from "./treeitem/item.first.treeleaf";
export { IconTreeLeafItem } from "./treeitem/item.icon.treeleaf";
export { LastTreeLeafItem } from "./treeitem/item.last.treeleaf";
export { MidTreeLeafItem } from "./treeitem/item.mid.treeleaf";
export { MultiLayerIconTreeLeafItem } from "./treeitem/item.multilayer.icon.treeleaf";
export { RootTreeLeafItem } from "./treeitem/item.root.treeleaf";
export { TreeTextLeafItem } from "./treeitem/item.treetextleaf";
export { BasicTreeItem } from "./treeitem/treeitem";
export {
BasicTreeItem, FirstTreeLeafItem, MidTreeLeafItem, LastTreeLeafItem, RootTreeLeafItem
} from "./treeitem/treeitem";

105
src/case/button/treeitem/item.first.treeleaf.js

@ -1,105 +0,0 @@
import { BasicButton } from "../../../base/single/button/button.basic";
import { shortcut, extend, createWidget } from "../../../core";
@shortcut()
export class FirstTreeLeafItem extends BasicButton {
static xtype = "bi.first_tree_leaf_item";
_defaultConfig() {
return extend(super._defaultConfig(...arguments), {
extraCls: "bi-first-tree-leaf-item bi-list-item-active",
logic: {
dynamic: false,
},
id: "",
pId: "",
layer: 0,
height: 24,
});
}
_init() {
super._init(...arguments);
const o = this.options;
this.text = createWidget({
type: "bi.label",
textAlign: "left",
whiteSpace: "nowrap",
textHeight: o.height,
height: o.height,
hgap: o.hgap,
text: o.text,
value: o.value,
py: o.py,
keyword: o.keyword,
});
const type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
const items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, ((o.layer === 0) ? "" : {
width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2,
el: {
type: "bi.layout",
cls: (o.pNode && o.pNode.isLastNode) ? "" : this._getBaseLineCls(),
width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2,
height: o.height,
},
}), {
width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
el: {
type: "bi.layout",
cls: this._getFirstLineCls(),
width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
height: o.height,
},
}, {
el: this.text,
});
createWidget(extend({
element: this,
}, BI.LogicFactory.createLogic(type, extend(o.logic, {
items,
}))));
}
_getBaseLineCls() {
switch (BI.STYLE_CONSTANTS.LINK_LINE_TYPE) {
case "solid":
return "base-solid-line-conn-background";
default:
return "base-line-conn-background";
}
}
_getFirstLineCls() {
switch (BI.STYLE_CONSTANTS.LINK_LINE_TYPE) {
case "solid":
return "first-solid-line-conn-background";
default:
return "first-line-conn-background";
}
}
doRedMark() {
this.text.doRedMark(...arguments);
}
unRedMark() {
this.text.unRedMark(...arguments);
}
doHighLight() {
this.text.doHighLight(...arguments);
}
unHighLight() {
this.text.unHighLight(...arguments);
}
getId() {
return this.options.id;
}
getPId() {
return this.options.pId;
}
}

105
src/case/button/treeitem/item.last.treeleaf.js

@ -1,105 +0,0 @@
import { BasicButton } from "../../../base/single/button/button.basic";
import { shortcut, extend, createWidget } from "../../../core";
@shortcut()
export class LastTreeLeafItem extends BasicButton {
static xtype = "bi.last_tree_leaf_item";
_defaultConfig() {
return extend(super._defaultConfig(...arguments), {
extraCls: "bi-last-tree-leaf-item bi-list-item-active",
logic: {
dynamic: false,
},
id: "",
pId: "",
layer: 0,
height: 24,
});
}
_init() {
super._init(...arguments);
const o = this.options;
this.text = createWidget({
type: "bi.label",
textAlign: "left",
whiteSpace: "nowrap",
textHeight: o.height,
height: o.height,
hgap: o.hgap,
text: o.text,
value: o.value,
py: o.py,
keyword: o.keyword,
});
const type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
const items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, ((o.layer === 0) ? "" : {
width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2,
el: {
type: "bi.layout",
cls: (o.pNode && o.pNode.isLastNode) ? "" : this._getBaseLineCls(),
width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2,
height: o.height,
},
}), {
width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
el: {
type: "bi.layout",
cls: this._getLastLineCls(),
width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
height: o.height,
},
}, {
el: this.text,
});
createWidget(extend({
element: this,
}, BI.LogicFactory.createLogic(type, extend(o.logic, {
items,
}))));
}
_getBaseLineCls() {
switch (BI.STYLE_CONSTANTS.LINK_LINE_TYPE) {
case "solid":
return "base-solid-line-conn-background";
default:
return "base-line-conn-background";
}
}
_getLastLineCls() {
switch (BI.STYLE_CONSTANTS.LINK_LINE_TYPE) {
case "solid":
return "last-solid-line-conn-background";
default:
return "last-line-conn-background";
}
}
doRedMark() {
this.text.doRedMark(...arguments);
}
unRedMark() {
this.text.unRedMark(...arguments);
}
doHighLight() {
this.text.doHighLight(...arguments);
}
unHighLight() {
this.text.unHighLight(...arguments);
}
getId() {
return this.options.id;
}
getPId() {
return this.options.pId;
}
}

105
src/case/button/treeitem/item.mid.treeleaf.js

@ -1,105 +0,0 @@
import { BasicButton } from "../../../base/single/button/button.basic";
import { shortcut, extend, createWidget } from "../../../core";
@shortcut()
export class MidTreeLeafItem extends BasicButton {
static xtype = "bi.mid_tree_leaf_item";
_defaultConfig() {
return extend(super._defaultConfig(...arguments), {
extraCls: "bi-mid-tree-leaf-item bi-list-item-active",
logic: {
dynamic: false,
},
id: "",
pId: "",
layer: 0,
height: 24,
});
}
_init() {
super._init(...arguments);
const o = this.options;
this.text = createWidget({
type: "bi.label",
textAlign: "left",
whiteSpace: "nowrap",
textHeight: o.height,
height: o.height,
hgap: o.hgap,
text: o.text,
value: o.value,
py: o.py,
keyword: o.keyword,
});
const type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
const items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, ((o.layer === 0) ? "" : {
width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2,
el: {
type: "bi.layout",
cls: (o.pNode && o.pNode.isLastNode) ? "" : this._getBaseLineCls(),
width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2,
height: o.height,
},
}), {
width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
el: {
type: "bi.layout",
cls: this._getMidLineCls(),
width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
height: o.height,
},
}, {
el: this.text,
});
createWidget(extend({
element: this,
}, BI.LogicFactory.createLogic(type, extend(o.logic, {
items,
}))));
}
_getBaseLineCls() {
switch (BI.STYLE_CONSTANTS.LINK_LINE_TYPE) {
case "solid":
return "base-solid-line-conn-background";
default:
return "base-line-conn-background";
}
}
_getMidLineCls() {
switch (BI.STYLE_CONSTANTS.LINK_LINE_TYPE) {
case "solid":
return "mid-solid-line-conn-background";
default:
return "mid-line-conn-background";
}
}
doRedMark() {
this.text.doRedMark(...arguments);
}
unRedMark () {
this.text.unRedMark(...arguments);
}
doHighLight() {
this.text.doHighLight(...arguments);
}
unHighLight() {
this.text.unHighLight(...arguments);
}
getId() {
return this.options.id;
}
getPId() {
return this.options.pId;
}
}

78
src/case/button/treeitem/item.root.treeleaf.js

@ -1,78 +0,0 @@
import { BasicButton } from "../../../base/single/button/button.basic";
import { shortcut, extend } from "../../../core";
@shortcut()
export class RootTreeLeafItem extends BasicButton {
static xtype = "bi.root_tree_leaf_item";
props = {
baseCls: "bi-root-tree-leaf-item bi-list-item-active",
logic: {
dynamic: false,
},
id: "",
pId: "",
layer: 0,
height: 24,
}
render() {
const o = this.options;
const text = {
type: "bi.label",
ref: _ref => {
this.text = _ref;
},
textAlign: "left",
whiteSpace: "nowrap",
textHeight: o.height,
height: o.height,
hgap: o.hgap,
text: o.text,
value: o.value,
py: o.py,
keyword: o.keyword,
};
const type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
const items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
el: {
type: "bi.layout",
width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
height: o.height,
},
}, {
el: text,
});
return BI.LogicFactory.createLogic(type, extend(o.logic, {
items,
}));
}
doRedMark() {
this.text.doRedMark(...arguments);
}
unRedMark() {
this.text.unRedMark(...arguments);
}
doHighLight() {
this.text.doHighLight(...arguments);
}
unHighLight() {
this.text.unHighLight(...arguments);
}
getId() {
return this.options.id;
}
getPId() {
return this.options.pId;
}
}

76
src/case/button/treeitem/item.treetextleaf.js

@ -1,76 +0,0 @@
import { BasicButton } from "../../../base/single/button/button.basic";
import { shortcut, extend, createWidget } from "../../../core";
/**
* 树叶子节点
* Created by GUY on 2015/9/6.
* @class BI.TreeTextLeafItem
* @extends BI.BasicButton
*/
@shortcut()
export class TreeTextLeafItem extends BasicButton {
static xtype = "bi.tree_text_leaf_item";
_defaultConfig() {
return extend(super._defaultConfig.apply(this, arguments), {
extraCls: "bi-tree-text-leaf-item bi-list-item-active",
id: "",
pId: "",
height: 24,
hgap: 0,
lgap: 0,
rgap: 0,
});
}
_init() {
super._init(...arguments);
const o = this.options;
this.text = createWidget({
type: "bi.label",
textAlign: "left",
whiteSpace: "nowrap",
textHeight: o.height,
height: o.height,
hgap: o.hgap,
lgap: o.lgap,
rgap: o.hgap,
text: o.text,
value: o.value,
py: o.py,
keyword: o.keyword,
});
createWidget({
type: "bi.htape",
element: this,
items: [{
el: this.text,
}],
});
}
doRedMark() {
this.text.doRedMark(...arguments);
}
unRedMark() {
this.text.unRedMark(...arguments);
}
doHighLight() {
this.text.doHighLight(...arguments);
}
unHighLight() {
this.text.unHighLight(...arguments);
}
getId() {
return this.options.id;
}
getPId() {
return this.options.pId;
}
}

134
src/case/button/treeitem/treeitem.js

@ -1,5 +1,5 @@
import { shortcut, extend, VerticalAdaptLayout, Layout } from "@/core";
import { NodeButton, Label } from "@/base";
import { shortcut, extend, VerticalAdaptLayout, Layout, compact, isKey } from "@/core";
import { NodeButton, Label, IconLabel } from "@/base";
@shortcut()
export class BasicTreeItem extends NodeButton {
@ -16,25 +16,57 @@ export class BasicTreeItem extends NodeButton {
readonly: true,
isFirstNode: false,
isLastNode: false,
layer: 0,
iconWidth: 16,
iconHeight: 16,
iconCls: "",
});
}
render() {
const o = this.options;
const {
layer,
height,
hgap,
textHgap,
textVgap,
textLgap,
textRgap,
text,
value,
py,
keyword,
iconWidth,
iconHeight,
iconCls,
} = this.options;
const icon = isKey(iconCls) ? {
el: {
type: IconLabel.xtype,
iconWidth,
iconHeight,
cls: iconCls,
},
width: 24,
} : null;
const indent = layer === 0 ? null : {
el: {
type: Layout.xtype,
height,
width: height,
cls: this.getLineCls(),
},
lgap: layer * BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2, // 偏移公式为每一层的偏移量为节点高度的一半
width: "",
};
return {
type: VerticalAdaptLayout.xtype,
columnSize: ["", "fill"],
items: [
{
el: {
type: Layout.xtype,
height: o.height,
width: o.height,
cls: this.getLineCls(),
},
lgap: o.layer * BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2, // 偏移公式为每一层的偏移量为节点高度的一半
},
items: compact([
icon,
indent,
{
el: {
type: Label.xtype,
@ -43,19 +75,20 @@ export class BasicTreeItem extends NodeButton {
},
textAlign: "left",
whiteSpace: "nowrap",
textHeight: o.height,
height: o.height,
hgap: o.hgap || o.textHgap,
vgap: o.textVgap,
lgap: o.textLgap,
rgap: o.textRgap,
text: o.text,
value: o.value,
keyword: o.keyword,
py: o.py,
textHeight: height,
height,
hgap: hgap || textHgap,
vgap: textVgap,
lgap: textLgap,
rgap: textRgap,
text,
value,
keyword,
py,
},
width: "fill",
}
],
]),
};
}
@ -88,3 +121,54 @@ export class BasicTreeItem extends NodeButton {
return this.options.pId;
}
}
export class FirstTreeLeafItem extends BasicTreeItem {
static xtype = "bi.first_tree_leaf_item";
_defaultConfig() {
return extend(super._defaultConfig(...arguments), {
extraCls: "bi-first-tree-leaf-item",
isFirstNode: true,
isLastNode: false,
});
}
}
@shortcut()
export class MidTreeLeafItem extends BasicTreeItem {
static xtype = "bi.mid_tree_leaf_item";
_defaultConfig() {
return extend(super._defaultConfig(...arguments), {
extraCls: "bi-mid-tree-leaf-item",
isFirstNode: false,
isLastNode: false,
});
}
}
@shortcut()
export class LastTreeLeafItem extends BasicTreeItem {
static xtype = "bi.last_tree_leaf_item";
_defaultConfig() {
return extend(super._defaultConfig(...arguments), {
extraCls: "bi-last-tree-leaf-item",
isFirstNode: false,
isLastNode: true,
});
}
}
@shortcut()
export class RootTreeLeafItem extends BasicTreeItem {
static xtype = "bi.root_tree_leaf_item";
_defaultConfig() {
return extend(super._defaultConfig(...arguments), {
extraCls: "bi-root-tree-leaf-item",
isFirstNode: false,
isLastNode: false,
});
}
}

94
src/case/layer/pane.list.js

@ -5,13 +5,34 @@
* @class BI.ListPane
* @extends BI.Pane
*/
import { shortcut, extend, each, createWidget, emptyFn, nextTick, concat, get, Controller, Events, LogicFactory, Direction, isNull, removeAt, isFunction, isNotEmptyString, isEmptyArray } from "@/core";
import {
shortcut,
extend,
each,
createWidget,
emptyFn,
nextTick,
concat,
get,
Controller,
Events,
LogicFactory,
Direction,
isNull,
removeAt,
isFunction,
isNotEmptyString,
isEmptyArray,
VerticalLayout
} from "@/core";
import { Pane, ButtonGroup } from "@/base";
@shortcut()
export class ListPane extends Pane {
static xtype = "bi.list_pane";
static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig () {
_defaultConfig() {
const conf = super._defaultConfig(...arguments);
return extend(conf, {
@ -30,15 +51,16 @@ export class ListPane extends Pane {
hasNext: emptyFn,
onLoaded: emptyFn,
el: {
type: "bi.button_group",
type: ButtonGroup.xtype,
},
});
}
_init () {
_init() {
super._init(...arguments);
const o = this.options;
this.button_group = createWidget(o.el, {
type: "bi.button_group",
type: ButtonGroup.xtype,
chooseType: ButtonGroup.CHOOSE_TYPE_SINGLE,
behaviors: {},
items: o.items,
@ -52,9 +74,9 @@ export class ListPane extends Pane {
}
o.itemsCreator(op, (...args) => {
callback(...args);
o.items = concat(o.items, get(...args, [0], []));
o.items = concat(o.items, get(args, [0], []));
if (op.times === 1) {
o.items = get(...args, [0], []);
o.items = get(args, [0], []);
nextTick(() => {
this.loaded();
// callback可能在loading之前执行, check保证显示正确
@ -64,9 +86,11 @@ export class ListPane extends Pane {
});
},
hasNext: o.hasNext,
layouts: [{
type: "bi.vertical",
}],
layouts: [
{
type: VerticalLayout.xtype,
}
],
});
this.button_group.on(Controller.EVENT_CHANGE, (type, value, obj, ...args) => {
@ -92,42 +116,44 @@ export class ListPane extends Pane {
}))));
}
hasPrev () {
hasPrev() {
return this.button_group.hasPrev && this.button_group.hasPrev();
}
hasNext () {
hasNext() {
return this.button_group.hasNext && this.button_group.hasNext();
}
prependItems (items) {
prependItems(items) {
this.options.items = items.concat(this.options.items);
this.button_group.prependItems(...arguments);
this.check();
}
addItems (items) {
addItems(items) {
this.options.items = this.options.items.concat(items);
this.button_group.addItems(...arguments);
this.check();
}
removeItemAt (indexes) {
removeItemAt(indexes) {
indexes = isNull(indexes) ? [] : indexes;
removeAt(this.options.items, indexes);
this.button_group.removeItemAt(...arguments);
this.check();
}
populate (items) {
populate(items) {
const o = this.options;
if (arguments.length === 0 && (isFunction(this.button_group.attr("itemsCreator")))) {// 接管loader的populate方法
this.button_group.attr("itemsCreator").apply(this, [{ times: 1 }, (...args) => {
if (args.length === 0) {
throw new Error("参数不能为空");
this.button_group.attr("itemsCreator").apply(this, [
{ times: 1 }, (...args) => {
if (args.length === 0) {
throw new Error("参数不能为空");
}
this.populate(...args);
}
this.populate(...args);
}]);
]);
return;
}
@ -144,23 +170,23 @@ export class ListPane extends Pane {
}
}
empty () {
empty() {
this.button_group.empty();
}
setNotSelectedValue () {
setNotSelectedValue() {
this.button_group.setNotSelectedValue(...arguments);
}
getNotSelectedValue () {
getNotSelectedValue() {
return this.button_group.getNotSelectedValue();
}
setValue () {
setValue() {
this.button_group.setValue(...arguments);
}
setAllSelected (v) {
setAllSelected(v) {
if (this.button_group.setAllSelected) {
this.button_group.setAllSelected(v);
} else {
@ -170,35 +196,35 @@ export class ListPane extends Pane {
}
}
getValue () {
getValue() {
return this.button_group.getValue(...arguments);
}
getAllButtons () {
getAllButtons() {
return this.button_group.getAllButtons();
}
getAllLeaves () {
getAllLeaves() {
return this.button_group.getAllLeaves();
}
getSelectedButtons () {
getSelectedButtons() {
return this.button_group.getSelectedButtons();
}
getNotSelectedButtons () {
getNotSelectedButtons() {
return this.button_group.getNotSelectedButtons();
}
getIndexByValue (value) {
getIndexByValue(value) {
return this.button_group.getIndexByValue(value);
}
getNodeById (id) {
getNodeById(id) {
return this.button_group.getNodeById(id);
}
getNodeByValue (value) {
getNodeByValue(value) {
return this.button_group.getNodeByValue(value);
}
}

2
src/case/list/list.select.js

@ -67,7 +67,7 @@ export class SelectList extends Widget {
this.list = createWidget(o.el, {
type: ListPane.xtype,
items: o.items,
itemsCreator(op, callback) {
itemsCreator: (op, callback) => {
op.times === 1 && this.toolbar.setVisible(false);
o.itemsCreator(op, (items, keywords, context, ...args) => {
callback(items, keywords, context, ...args);

2
src/less/base/dom.less

@ -1,2 +0,0 @@
@import "../index.less";
@import "../lib/colors.less";
Loading…
Cancel
Save