Browse Source

feat: improve scope handling

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/5332/head
mertmit 2 years ago
parent
commit
e91ea6d1df
  1. 6
      packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue
  2. 2
      packages/nc-gui/components/smartsheet/toolbar/RowHeight.vue
  3. 2
      packages/nc-gui/composables/useGridViewColumnWidth.ts
  4. 6
      packages/nc-gui/composables/useLTARStore.ts
  5. 13
      packages/nc-gui/composables/useUndoRedo.ts
  6. 6
      packages/nc-gui/composables/useViewData.ts

6
packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue

@ -117,7 +117,7 @@ const onMove = (_event: { moved: { newIndex: number; oldIndex: number } }, undo
},
args: [],
},
scope: activeView.value?.is_default ? [activeView.value.fk_model_id, activeView.value.title] : activeView.value?.title,
scope: activeView.value?.title,
})
}
@ -203,7 +203,7 @@ const toggleFieldVisibility = (e: CheckboxChangeEvent, field: any, index: number
},
args: [e.target.checked],
},
scope: activeView.value?.is_default ? [activeView.value.fk_model_id, activeView.value.title] : activeView.value?.title,
scope: activeView.value?.title,
})
saveOrUpdate(field, index)
}
@ -222,7 +222,7 @@ const toggleSystemFields = (e: CheckboxChangeEvent) => {
},
args: [e.target.checked],
},
scope: activeView.value?.is_default ? [activeView.value.fk_model_id, activeView.value.title] : activeView.value?.title,
scope: activeView.value?.title,
})
}

2
packages/nc-gui/components/smartsheet/toolbar/RowHeight.vue

@ -30,7 +30,7 @@ const updateRowHeight = async (rh: number, undo = false) => {
fn: (r: number) => updateRowHeight(r, true),
args: [(view.value.view as GridType).row_height],
},
scope: view.value?.is_default ? [view.value.fk_model_id, view.value.title] : view.value?.title,
scope: view.value?.title,
})
}

2
packages/nc-gui/composables/useGridViewColumnWidth.ts

@ -78,7 +78,7 @@ export function useGridViewColumnWidth(view: Ref<ViewType | undefined>) {
fn: (w: string) => updateWidth(id, w, true),
args: [gridViewCols.value[id].width],
},
scope: view.value?.is_default ? [view.value.fk_model_id, view.value.title] : view.value?.title,
scope: view.value?.title,
})
}

6
packages/nc-gui/composables/useLTARStore.ts

@ -43,6 +43,8 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState(
const { $api } = useNuxtApp()
const activeView = inject(ActiveViewInj, ref())
const { addUndo, clone } = useUndoRedo()
const sharedViewPassword = inject(SharedViewPasswordInj, ref(null))
@ -284,7 +286,7 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState(
fn: (row: Record<string, any>) => link(row, {}, true),
args: [clone(row)],
},
scope: metaValue.id,
scope: activeView.value?.title,
})
}
} catch (e: any) {
@ -330,7 +332,7 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState(
fn: (row: Record<string, any>) => unlink(row, {}, true),
args: [clone(row)],
},
scope: metaValue.id,
scope: activeView.value?.title,
})
}
} catch (e: any) {

13
packages/nc-gui/composables/useUndoRedo.ts

@ -10,6 +10,8 @@ export const useUndoRedo = createSharedComposable(() => {
const route = $(router.currentRoute)
const activeView = inject(ActiveViewInj, ref())
const scope = computed<string[]>(() => {
let tempScope = ['root']
for (const param of Object.values(route.params)) {
@ -19,13 +21,12 @@ export const useUndoRedo = createSharedComposable(() => {
tempScope.push(param)
}
}
if (
Object.keys(route.params).includes('viewTitle') &&
Object.keys(route.params).includes('title') &&
route.params.viewTitle.length
) {
tempScope.splice(tempScope.indexOf(route.params.title as string), 1)
// if the current view is the default view, add it to the scope (as viewTitle might be missing)
if (activeView.value?.is_default) {
tempScope.push(activeView.value.title)
}
return tempScope
})

6
packages/nc-gui/composables/useViewData.ts

@ -271,7 +271,7 @@ export function useViewData(
},
args: [id],
},
scope: viewMeta.value?.is_default ? [viewMeta.value.fk_model_id, viewMeta.value.title] : viewMeta.value?.title,
scope: viewMeta.value?.title,
})
}
@ -346,7 +346,7 @@ export function useViewData(
},
args: [clone(toUpdate), property],
},
scope: viewMeta.value?.is_default ? [viewMeta.value.fk_model_id, viewMeta.value.title] : viewMeta.value?.title,
scope: viewMeta.value?.title,
})
/** update row data(to sync formula and other related columns)
@ -463,7 +463,7 @@ export function useViewData(
},
args: [clone(row), {}],
},
scope: viewMeta.value?.is_default ? [viewMeta.value.fk_model_id, viewMeta.value.title] : viewMeta.value?.title,
scope: viewMeta.value?.title,
})
}

Loading…
Cancel
Save