-
Notifications
You must be signed in to change notification settings - Fork 373
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 先去掉 bk-PaaS 中的其他内容,只保留 paas-ce/lesscode 目录 * init lesscode * add .pre-commit-config.yaml * test * test * add pre-commit & update dev_install doc & add bk-PaaS doc * typo * up dev_install doc * up dev_install doc * up dev_install doc * up dev_install doc * up .pre-commit-config.yaml * up comment info * add .pre-commit-config.yaml to ignore * feature: 组件属性配置类型提示首字母大写 * 可视化布局 => 可视化开发 * 可视化布局 => 可视化开发 * 可视化布局 => 可视化开发 * Lesscode update doc (#199) * ignore .idea * update bk-magic-vue version (for bk-color-picker select '') * 组件属性提示增加 tips 配置字段 * button 按钮组件使用说明 * text 按钮组件使用说明 * image 图片组件使用说明 * input 输入框组件使用说明 * events 配置数据结构优化 ['change'] ==> [{ name: 'change', tips: ''}] * 组件使用帮助 tips * 帮助文档页面移除单个组件导航 * 帮助文档:栅格布局 * merge manually from #201 (#202) * merge #201 * merge manually from #201 * 添加快捷操作功能 (#205) * 增加chart图表 (#206) * 增加chart图表 * fix冲突 * 删除consolelog * 更新图标库 * merge manually from #203 (#212) * 拖拽快捷操作支持Mac Command键 (#213) * 添加快捷操作功能 * 拖拽快捷键支持Mac Command键 * 修改快捷操作说明 * 修复 charts-line options.tips 小问题 (#215) * 【lesscode】修复刷新页面时,没有选中组件但右侧面板会显示 grid 属性的问题 (#216) * merge #201 * merge manually from #201 * merge manually from #203 * fix some bug * 修复 charts-line options.tips 小问题 * 修复刷新页面时,没有选中组件但右侧面板会显示 grid 属性的问题 * 【lesscode】修复 chart 组件样式被覆盖的问题 (#217) * merge #201 * merge manually from #201 * merge manually from #203 * fix some bug * 修复 charts-line options.tips 小问题 * 修复刷新页面时,没有选中组件但右侧面板会显示 grid 属性的问题 * 修复 chart 组件样式被覆盖的问题 * fix图表问题 (#218) * 增加chart图表 * fix冲突 * 删除consolelog * 更新图标库 * 同步新的lesscode-develop,fix图表bug * 修改快捷操作 (#219) * 添加快捷操作功能 * 拖拽快捷键支持Mac Command键 * 修改快捷操作说明 * 修复剪切快捷操作,修改快捷操作说明 * 修改快捷操作 (#220) * 添加快捷操作功能 * 拖拽快捷键支持Mac Command键 * 修改快捷操作说明 * 修复剪切快捷操作,修改快捷操作说明 * 兼容数据为空的情况 * 兼容数据为空的情况 Co-authored-by: ielgnaw <wuji0223@gmail.com> * 【lesscode】体验 bug 修复 (#221) * merge #201 * merge manually from #201 * merge manually from #203 * fix some bug * 修复 charts-line options.tips 小问题 * 修复刷新页面时,没有选中组件但右侧面板会显示 grid 属性的问题 * 修复 chart 组件样式被覆盖的问题 * 体验 bug 修复 * 修改快捷操作判断 (#222) * 添加快捷操作功能 * 拖拽快捷键支持Mac Command键 * 修改快捷操作说明 * 修复剪切快捷操作,修改快捷操作说明 * 兼容数据为空的情况 * 兼容数据为空的情况 * 仅在选中拖拽区域触发快捷操作 * 修改判断是否在拖拽区域 * 修复体验问题 (#223) * 增加backspace快捷删除 (#224) * 添加快捷操作功能 * 拖拽快捷键支持Mac Command键 * 修改快捷操作说明 * 修复剪切快捷操作,修改快捷操作说明 * 兼容数据为空的情况 * 兼容数据为空的情况 * 仅在选中拖拽区域触发快捷操作 * 修改判断是否在拖拽区域 * 增加backspace快速删除 修改快捷面版样式 * 画布仅剩一个 grid 时,不允许删除;增加清空 grid 操作 (#225) * 修复 clone grid 时,右侧面板没有默认选中的问题;更新日志 (#226) * 文案 (#227) Co-authored-by: hLinx <327159425@qq.com> Co-authored-by: sundytt <30256396+sundytt@users.noreply.github.com> Co-authored-by: Arman19941113 <35905177+Arman19941113@users.noreply.github.com> Co-authored-by: xuzhan <xuzhan@tencent.com> Co-authored-by: terlinhe <312592676@qq.com>
- Loading branch information
1 parent
22145fc
commit ae6425f
Showing
112 changed files
with
2,374 additions
and
2,673 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,220 @@ | ||
import store from '@/store' | ||
import { uuid, walkGrid, findComponentParentGrid } from '@/common/util' | ||
import cloneDeep from 'lodash.clonedeep' | ||
|
||
class TargetData { | ||
constructor () { | ||
this.targetData = store.getters['drag/targetData'] | ||
} | ||
|
||
value () { | ||
return this.targetData | ||
} | ||
|
||
setTargetData (targetData) { | ||
store.state.drag.targetData = targetData | ||
this.targetData = store.state.drag.targetData | ||
return this | ||
} | ||
|
||
find (id) { | ||
if (typeof id !== 'undefined') { | ||
const targetData = store.getters['drag/targetData'] || [] | ||
targetData.forEach((grid, index) => { | ||
const callBack = (data) => { | ||
if (data.componentId === id) this.targetData = data | ||
} | ||
walkGrid(targetData, grid, callBack, callBack, index) | ||
}) | ||
} | ||
return this | ||
} | ||
|
||
parent () { | ||
const id = this.targetData.componentId | ||
if (typeof id !== 'undefined') { | ||
this.targetData = findComponentParentGrid(store.getters['drag/targetData'], id) | ||
} | ||
return this | ||
} | ||
|
||
remove (id) { | ||
const targetData = store.getters['drag/targetData'] || [] | ||
targetData.forEach((grid, index) => { | ||
const callBack = (data, parent, index, parentGrid) => { | ||
if (data.componentId === id) { | ||
if (parentGrid) parentGrid.renderKey = uuid() | ||
parent.splice(index, 1) | ||
if (id === this.targetData.componentId) this.targetData = parentGrid | ||
const curSelectedComponentData = store.getters['drag/curSelectedComponentData'] || {} | ||
if (id === curSelectedComponentData.componentId) store.state.drag.curSelectedComponentData = {} | ||
} | ||
} | ||
walkGrid(targetData, grid, callBack, callBack, index) | ||
}) | ||
return this | ||
} | ||
|
||
move (sourceParentNodeId, sourceColumnIndex, sourceChildrenIndex, targetParentNodeId, targetColumnIndex, targetChildrenIndex) { | ||
let node | ||
const sourceGrid = this.find(sourceParentNodeId).value() | ||
if (typeof sourceColumnIndex === 'undefined') { | ||
node = sourceGrid.splice(sourceChildrenIndex, 1)[0] | ||
} else { | ||
sourceGrid.renderKey = uuid() | ||
const renderProps = sourceGrid.renderProps || {} | ||
const slots = renderProps.slots || {} | ||
const columns = slots.val || [] | ||
const column = columns[sourceColumnIndex] | ||
node = column.children.splice(sourceChildrenIndex, 1)[0] | ||
} | ||
node = this.cloneNode(node) | ||
|
||
const targetGrid = this.find(targetParentNodeId).value() | ||
if (typeof targetColumnIndex === 'undefined') { | ||
targetGrid.splice(targetChildrenIndex, 0, node) | ||
} else { | ||
targetGrid.renderKey = uuid() | ||
const renderProps = targetGrid.renderProps || {} | ||
const slots = renderProps.slots || {} | ||
const columns = slots.val || [] | ||
const column = columns[targetColumnIndex] | ||
column.children.splice(targetChildrenIndex, 0, node) | ||
} | ||
return this | ||
} | ||
|
||
update (newNode) { | ||
const node = this.find(newNode.componentId) | ||
const oldNode = node.value() | ||
const parent = node.parent().value() || {} | ||
parent.renderKey = uuid() | ||
newNode.renderKey = uuid() | ||
const curNode = Object.assign(oldNode, newNode) | ||
const curSelectedComponentData = store.getters['drag/curSelectedComponentData'] || {} | ||
if (oldNode.componentId === curSelectedComponentData.componentId) { | ||
store.state.drag.curSelectedComponentData = curNode | ||
} | ||
return this | ||
} | ||
|
||
appendChild (node, shouldChangeId) { | ||
node = this.cloneNode(node, shouldChangeId) | ||
if (Array.isArray(this.targetData) && node.type === 'render-grid') { | ||
this.targetData.push(node) | ||
} else if (this.targetData.type === 'render-grid') { | ||
this.targetData.renderKey = uuid() | ||
const renderProps = this.targetData.renderProps || {} | ||
const slots = renderProps.slots || {} | ||
const columns = slots.val || [] | ||
for (let index = 0; index < columns.length; index++) { | ||
const nextColumn = columns[index + 1] || { children: [] } | ||
if (nextColumn.children.length <= 0) { | ||
columns[index].children.push(node) | ||
break | ||
} | ||
} | ||
} else { | ||
const targetData = store.getters['drag/targetData'] || [] | ||
targetData.forEach((grid, index) => { | ||
const callBack = (data, parent, index, parentGrid) => { | ||
if (data.componentId === this.targetData.componentId) { | ||
parentGrid.renderKey = uuid() | ||
parent.splice(index + 1, 0, node) | ||
} | ||
} | ||
walkGrid(targetData, grid, callBack, callBack, index) | ||
}) | ||
} | ||
return this.find(node.componentId) | ||
} | ||
|
||
appendChildByIndex (node, parentId, columnIndex, childrenIndex, shouldChangeId) { | ||
node = this.cloneNode(node, shouldChangeId) | ||
const parent = this.find(parentId).value() | ||
if (typeof columnIndex === 'undefined') { | ||
parent.splice(childrenIndex, 0, node) | ||
} else { | ||
parent.renderKey = uuid() | ||
const renderProps = parent.renderProps || {} | ||
const slots = renderProps.slots || {} | ||
const columns = slots.val || [] | ||
const column = columns[columnIndex] | ||
const children = column.children | ||
children.splice(childrenIndex, 0, node) | ||
} | ||
return this | ||
} | ||
|
||
getNodePosition (id) { | ||
id = id || this.targetData.componentId | ||
let res | ||
const targetData = store.getters['drag/targetData'] || [] | ||
targetData.forEach((grid, index) => { | ||
const callBack = (data, parent, childrenIndex, parentGrid, columnIndex) => { | ||
if (data.componentId === id) { | ||
res = { | ||
parent: parentGrid, | ||
columnIndex, | ||
childrenIndex | ||
} | ||
} | ||
} | ||
walkGrid(targetData, grid, callBack, callBack, index) | ||
}) | ||
return res | ||
} | ||
|
||
appendBefore (id, node, shouldChangeId) { | ||
node = this.cloneNode(node, shouldChangeId) | ||
const targetData = store.getters['drag/targetData'] || [] | ||
targetData.forEach((grid, index) => { | ||
const callBack = (data, parent, index, parentGrid) => { | ||
if (data.componentId === id) { | ||
parentGrid.renderKey = uuid() | ||
parent.splice(index, 0, node) | ||
} | ||
} | ||
walkGrid(targetData, grid, callBack, callBack, index) | ||
}) | ||
return this | ||
} | ||
|
||
appendAfter (id, node, shouldChangeId) { | ||
node = this.cloneNode(node, shouldChangeId) | ||
const targetData = store.getters['drag/targetData'] || [] | ||
targetData.forEach((grid, index) => { | ||
const callBack = (data, parent, index, parentGrid) => { | ||
if (data.componentId === id) { | ||
parentGrid.renderKey = uuid() | ||
parent.splice(index + 1, 0, node) | ||
} | ||
} | ||
walkGrid(targetData, grid, callBack, callBack, index) | ||
}) | ||
return this | ||
} | ||
|
||
cloneNode (node, shouldChangeId) { | ||
node = cloneDeep(node) | ||
const callBack = (data) => { | ||
if (shouldChangeId) data.componentId = data.componentId.replace(/.{8}$/, uuid()) | ||
data.renderKey = uuid() | ||
} | ||
if (Array.isArray(node)) { | ||
node.forEach((grid, index) => { | ||
walkGrid(node, grid, callBack, callBack, index) | ||
}) | ||
} else if (node.type === 'render-grid') { | ||
walkGrid({}, node, callBack, callBack, 0) | ||
} else { | ||
callBack(node) | ||
} | ||
return node | ||
} | ||
} | ||
|
||
export default (id) => { | ||
const targetData = new TargetData() | ||
return targetData.find(id) | ||
} |
Oops, something went wrong.