11import { query } from '@dineug/erd-editor-schema' ;
2- import { createAction } from '@dineug/r-html' ;
2+ import { createAction , Reducer } from '@dineug/r-html' ;
33import { arrayHas } from '@dineug/shared' ;
44import { round } from 'lodash-es' ;
55
@@ -147,6 +147,23 @@ const changeTableColor: ReducerType<typeof ActionType.changeTableColor> = (
147147 } ) ;
148148} ;
149149
150+ export const toggleGhostAction = createAction <
151+ ActionMap [ typeof ActionType . toggleGhost ]
152+ > ( ActionType . toggleGhost ) ;
153+
154+ const toggleGhost : ReducerType < typeof ActionType . toggleGhost > = (
155+ { collections, lww } ,
156+ { payload : { id } , version } ,
157+ { clock }
158+ ) => {
159+ const collection = query ( collections ) . collection ( 'tableEntities' ) ;
160+ collection . getOrCreate ( id , id => createTable ( { id } ) ) ;
161+
162+ collection . updateOne ( id , table => {
163+ table . ghost = ! table . ghost ;
164+ } ) ;
165+ } ;
166+
150167export const changeZIndexAction = createAction <
151168 ActionMap [ typeof ActionType . changeZIndex ]
152169> ( ActionType . changeZIndex ) ;
@@ -211,6 +228,7 @@ export const tableReducers = {
211228 [ ActionType . changeTableColor ] : changeTableColor ,
212229 [ ActionType . changeZIndex ] : changeZIndex ,
213230 [ ActionType . sortTable ] : sortTable ,
231+ [ ActionType . toggleGhost ] : toggleGhost ,
214232} ;
215233
216234export const actions = {
@@ -223,4 +241,5 @@ export const actions = {
223241 changeTableColorAction,
224242 changeZIndexAction,
225243 sortTableAction,
244+ toggleGhostAction,
226245} ;
0 commit comments