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.
67 lines
1.9 KiB
67 lines
1.9 KiB
import { shortcut, store } from '@core/core'; |
|
import { CollapseModel } from './collapse.model'; |
|
import { IconLabel } from '@fui/core'; |
|
|
|
export const EVENT_CHANGE = 'EVENT_CHANGE'; |
|
@shortcut() |
|
@store(CollapseModel) |
|
export class Collapse extends BI.BasicButton { |
|
static xtype = 'dec.dcm.components.collapse'; |
|
|
|
props = { |
|
name: '', |
|
isCollapse: true, |
|
$testId: 'dec-dcm-components-collapse', |
|
} |
|
|
|
rightFont: IconLabel; |
|
downFont: IconLabel; |
|
|
|
model: CollapseModel['model']; |
|
store: CollapseModel['store']; |
|
|
|
watch = { |
|
isCollapse: (isCollapse: boolean) => { |
|
this.rightFont.setVisible(isCollapse); |
|
this.downFont.setVisible(!isCollapse); |
|
this.fireEvent(EVENT_CHANGE, isCollapse); |
|
}, |
|
} |
|
|
|
render() { |
|
this.store.setCollapse(this.options.isCollapse); |
|
|
|
return { |
|
type: BI.FloatLeftLayout.xtype, |
|
items: [ |
|
{ |
|
type: BI.IconLabel.xtype, |
|
height: 17, |
|
cls: 'dcm-triangle-collapse-font icon-size-16', |
|
ref: (_ref: IconLabel) => { |
|
this.rightFont = _ref; |
|
}, |
|
invisible: !this.model.isCollapse, |
|
}, |
|
{ |
|
type: BI.IconLabel.xtype, |
|
height: 17, |
|
cls: 'dcm-triangle-expand-font icon-size-16', |
|
ref: (_ref: IconLabel) => { |
|
this.downFont = _ref; |
|
}, |
|
invisible: this.model.isCollapse, |
|
}, |
|
{ |
|
type: BI.Label.xtype, |
|
lgap: 2, |
|
text: this.options.name, |
|
}, |
|
], |
|
}; |
|
} |
|
|
|
doClick() { |
|
this.store.setCollapse(!this.model.isCollapse); |
|
} |
|
}
|
|
|