-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support views share #WIK-16187 #22
Conversation
src/app/app.component.ts
Outdated
sort(){ | ||
const direction = this.activeView().sortCondition?.conditions[0].direction | ||
const sortCondition = { keepSort:true , conditions:[{sortBy: 'column-4', direction: direction=== Direction.ascending ? Direction.descending: Direction.ascending}]} | ||
this.activeView().sortCondition = sortCondition |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不需要给 sortCondition 赋值,通过 computed 会自动计算
src/app/app.component.ts
Outdated
const direction = this.activeView().sortCondition?.conditions[0].direction | ||
const sortCondition = { keepSort:true , conditions:[{sortBy: 'column-4', direction: direction=== Direction.ascending ? Direction.descending: Direction.ascending}]} | ||
this.activeView().sortCondition = sortCondition | ||
CustomActions.setView(this.aiTable as any, this.activeView(), [0]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里只需要传 { sortCondition } 就可以, set_view 的实现和定义也可以参考下 set_field
@@ -10,20 +11,25 @@ export function translateYjsEvent(aiTable: AITable, event: Y.YEvent<any>): AITab | |||
return []; | |||
} | |||
|
|||
export function applyEvents(aiTable: AITable, events: Y.YEvent<any>[]){ | |||
events.forEach((event) => | |||
translateYjsEvent(aiTable, event).forEach((item: AIViewAction| AITableAction) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的 event 类型应该是 Y.YMapEvent 了,不能在 translateArrayEvent 中处理了,关于 map 的处理可以参考下 https://github.com/worktile/y-slate/blob/main/src/apply-to-slate/map-event.ts
const views = sharedType.get('views'); | ||
if (views) { | ||
const index = action.path[0]; | ||
views.delete(index); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的修改应该是针对 views 中具体某个属性的修改,
- 通过 path 从 views 中取到对应 view
- 遍历 action.newView ,执行 set 方法修改对应 key 的数据
修改整个数组理论上虽然可行,但是开销会变大,转换为 action 操作时也无法准确的知道修改的属性都有哪些了,fieldValue 的修改是因为每个值都转换为数组存储了,而这里 view 中的每一项都是对象而非数组。
具体的实现可以参考下 https://github.com/worktile/y-slate/blob/main/src/apply-to-yjs/node/set-node.ts
No description provided.