You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
123 lines
3.2 KiB
123 lines
3.2 KiB
import { ArrowTreeGroupNodeCheckbox } from "../../checkbox"; |
|
import { IconLabel, Label, NodeButton } from "@/base"; |
|
import { shortcut, extend, createWidget, Controller, isNotNull, Events, LogicFactory, Direction } from "@/core"; |
|
|
|
/** |
|
* Created by User on 2016/3/31. |
|
* |
|
* > + icon + 文本 |
|
* @class IconArrowNode |
|
* @extends NodeButton |
|
*/ |
|
@shortcut() |
|
export class IconArrowNode extends NodeButton { |
|
static xtype = "bi.icon_arrow_node"; |
|
|
|
_defaultConfig() { |
|
const conf = super._defaultConfig(...arguments); |
|
|
|
return extend(conf, { |
|
baseCls: `${conf.baseCls || ""} bi-icon-arrow-node bi-list-item`, |
|
logic: { |
|
dynamic: false, |
|
}, |
|
id: "", |
|
pId: "", |
|
open: false, |
|
height: 24, |
|
iconHeight: 12, |
|
iconWidth: 12, |
|
iconCls: "", |
|
iconWrapperWidth: 16, |
|
}); |
|
} |
|
|
|
_init() { |
|
super._init.apply(this, arguments); |
|
const o = this.options; |
|
this.checkbox = createWidget({ |
|
type: ArrowTreeGroupNodeCheckbox.xtype, |
|
expandIcon: o.expandIcon, |
|
collapseIcon: o.collapseIcon, |
|
width: 24, |
|
stopPropagation: true, |
|
}); |
|
|
|
const icon = createWidget({ |
|
type: IconLabel.xtype, |
|
width: 24, |
|
cls: o.iconCls, |
|
iconWidth: o.iconWidth, |
|
iconHeight: o.iconHeight, |
|
}); |
|
|
|
createWidget({ |
|
type: Label.xtype, |
|
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, |
|
}); |
|
this.checkbox.on(Controller.EVENT_CHANGE, type => { |
|
if (type === Events.CLICK) { |
|
if (this.checkbox.isSelected()) { |
|
this.triggerExpand(); |
|
} else { |
|
this.triggerCollapse(); |
|
} |
|
} |
|
}); |
|
const type = LogicFactory.createLogicTypeByDirection(Direction.Left); |
|
const items = LogicFactory.createLogicItemsByDirection( |
|
Direction.Left, |
|
{ |
|
width: o.iconWrapperWidth, |
|
el: this.checkbox, |
|
}, |
|
{ |
|
width: 16, |
|
el: icon, |
|
}, |
|
this.text |
|
); |
|
createWidget( |
|
extend( |
|
{ |
|
element: this, |
|
}, |
|
LogicFactory.createLogic( |
|
type, |
|
extend(o.logic, { |
|
items, |
|
rgap: 5, |
|
}) |
|
) |
|
) |
|
); |
|
} |
|
|
|
doRedMark() { |
|
this.text.doRedMark(...arguments); |
|
} |
|
|
|
unRedMark() { |
|
this.text.unRedMark(...arguments); |
|
} |
|
|
|
doClick() { |
|
super.doClick(...arguments); |
|
this.checkbox.setSelected(this.isSelected()); |
|
} |
|
|
|
setOpened(v) { |
|
super.setOpened(...arguments); |
|
if (isNotNull(this.checkbox)) { |
|
this.checkbox.setSelected(v); |
|
} |
|
} |
|
}
|
|
|