SMS-53622【数据模型-项目需求】数据模型工具栏添加前端扩展接口
JIRA: http://jira.smartbi.com.cn:28080/browse/SMS-53622
需求文档:无
需求概述:
在数据模型的工具栏上添加前端扩展接口,允许通过定制扩展包在数据模型工具栏添加自定义的按钮等。
概要设计
扩展点:
AUGMENTEDDATASET_ON_TOOLBAR_INIT(已存在)
修改生成工具栏项的item数组:
工具栏由 DatasetToolbar.buttons 控制生成,改变数组的项即可对工具栏进行增加/删除/修改
回调:
通过接口提供的菜单可通过 handler属性提供一个回调函数,该函数将会在该项被点击时触发
详细设计
工具栏扩展接口类:
class ToolbarImpl {
constructor (toolbar) {
this.__toolbar = toolbar
}
// 新增如下方法
getDataSetId () {
return this.__toolbar.dataSet.id
}
getAction () {
return this.__toolbar.dataSet.action
}
addItem (item) {
this.__toolbar.addItem(item)
}
removeItem (index) {
this.__toolbar.removeItem(index)
}
insertItem (index, item) {
this.__toolbar.insertItem(index, item)
}
/**
* 根据属性获取配置节点
* @param {*} val 属性值
* @param {*} props 属性名
* @return {
* node: 节点
* index: 找到的节点Index
* parent: 该节点的父节点
* }
*/
getItemNodesByProps (val, props) {
return this.__toolbar.getItemNodesByProps(val, props)
}
setDirty (isDirty = true) {
return this.__toolbar.setDirty(isDirty)
}
}
菜单项示例
// 单项 + 下拉 (参考:设置)
{
type: 'operate',
name: lang.$t('common.save'),
icon: 'sx-icon-save',
click: true,
action: 'SAVE',
customClass: 'augment-operate-btn-bar',
qtp: 'AugmentedToolbar-save',
expendQtp: 'AugmentedToolbar-save-more',
handler: () => {},
children: [{
maskId: 'save',
id: 'SAVE',
icon: 'sx-icon-save',
title: lang.$t('common.save'),
type: 'button',
qtp: 'AugmentedToolbar-save-save',
handler: () => {}
}]
}
// 单个图标(参考:检测)
{
name: lang.$t('common.check'),
action: 'VALIDATE',
icon: 'sx-icon-check',
type: 'icon',
handler: () => {},
children: []
}
// TODO 下拉面板 (参考设置)
{
type: 'multDrop',
name: lang.$t('common.setting'),
icon: 'sx-icon-setting',
action: 'setting',
qtp: 'AugmentedToolbar-setting',
children: [{
maskId: 'autoDetectedRelationships',
action: 'relationCheck',
name: lang.$t('augmenteddataset.autoDetectedRelationships'),
leftWidth: '108px',
activeAction: 'SYSTEMCHECK',
comLabel: 'sx-item-select',
type: 'button',
qtp: 'AugmentedToolbar-setting-autoDetectedRelationships',
children: [{
value: true,
action: 'AUTOCHECK',
icon: 'sx-icon-auto-check',
title: lang.$t('augmenteddataset.detect'),
qtp: 'AugmentedToolbar-setting-autoDetectedRelationships-autoCheck',
handler: () => {}
}, {
value: false,
icon: 'sx-icon-uncheck',
action: 'FORBIDCHECK',
title: lang.$t('augmenteddataset.doNotDetect'),
qtp: 'AugmentedToolbar-setting-autoDetectedRelationships-unCheck',
handler: () => {}
}, {
value: false,
action: 'SYSTEMCHECK',
icon: 'sx-icon-system-cache',
title: lang.$t('dataset.systemCache'),
qtp: 'AugmentedToolbar-setting-autoDetectedRelationships-systemCache',
handler: () => {}
}]
}]
}
// TODO 伸缩菜单 (参考新建分析)
{
maskId: 'createResource',
name: lang.$t('augmenteddataset.createAnalysis'),
icon: 'sx-icon-add-smartbix-page',
type: 'cascaderMenus',
qtp: 'AugmentedToolbar-createResource',
children: [{
name: lang.$t('dashboard.interactiveDashboard'),
icon: 'sx-icon-smartbix-page',
action: 'CREATE_LARGESCREEN_DASHBOARD',
qtp: 'AugmentedToolbar-createResource-interactiveDashboard',
license: 'XDashboard',
handler: () => {}
}]
}