Browse Source

chore(nc-gui): fix types and cleanup unused vars

pull/3931/head
braks 2 years ago
parent
commit
fcfab01995
  1. 10
      packages/nc-gui/components/cell/MultiSelect.vue
  2. 2
      packages/nc-gui/components/cell/TextArea.vue
  3. 2
      packages/nc-gui/components/general/ShareBaseButton.vue
  4. 2
      packages/nc-gui/components/shared-view/Grid.vue
  5. 6
      packages/nc-gui/components/smartsheet/sidebar/toolbar/DebugMeta.vue
  6. 4
      packages/nc-gui/components/smartsheet/sidebar/toolbar/DeleteTable.vue
  7. 7
      packages/nc-gui/components/smartsheet/toolbar/ColumnFilter.vue
  8. 7
      packages/nc-gui/lib/types.ts
  9. 2
      packages/nc-gui/utils/viewUtils.ts

10
packages/nc-gui/components/cell/MultiSelect.vue

@ -56,8 +56,14 @@ const options = computed<SelectOptionType[]>(() => {
return []
})
const vModel = computed({
get: () => selectedIds.value.map((el) => options.value.find((op) => op.id === el)?.title) as string[],
const vModel = computed<string[]>({
get: () => selectedIds.value.flatMap((el) => {
const title = options.value.find((op) => op.id === el)?.title
if (title) return [title]
return [] as string[]
}) || [] as string[],
set: (val) => emit('update:modelValue', val.length === 0 ? null : val.join(',')),
})

2
packages/nc-gui/components/cell/TextArea.vue

@ -3,7 +3,7 @@ import type { VNodeRef } from '@vue/runtime-core'
import { EditModeInj, inject, useVModel } from '#imports'
const props = defineProps<{
modelValue?: string | null
modelValue?: string
}>()
const emits = defineEmits(['update:modelValue'])

2
packages/nc-gui/components/general/ShareBaseButton.vue

@ -26,6 +26,6 @@ const { isUIAllowed } = useUIPermission()
</div>
</div>
<LazyTabsAuthUserManagementUsersModal :key="showUserModal" :show="showUserModal" @closed="showUserModal = false" />
<LazyTabsAuthUserManagementUsersModal :show="showUserModal" @closed="showUserModal = false" />
</div>
</template>

2
packages/nc-gui/components/shared-view/Grid.vue

@ -21,7 +21,7 @@ const { sharedView, meta, sorts, nestedFilters } = useSharedView()
const { signedIn } = useGlobal()
const { loadProject } = useProject(meta.value?.project_id)
const { loadProject } = useProject()
useProvideSmartsheetStore(sharedView, meta, true, sorts, nestedFilters)

6
packages/nc-gui/components/smartsheet/sidebar/toolbar/DebugMeta.vue

@ -1,4 +1,6 @@
<script setup lang="ts">
import { computed, ref, useMetas, useTable } from '#imports'
const editorOpen = ref(false)
const tabKey = ref()
@ -7,7 +9,9 @@ const { metas } = $(useMetas())
const { tables } = useTable()
const localTables = tables.value.filter((t) => metas[t.id as string])
const localTables = computed(
() => tables.value.filter((t) => metas[t.id as string]) as (typeof tables.value[number] & { id: string })[],
)
</script>
<template>

4
packages/nc-gui/components/smartsheet/sidebar/toolbar/DeleteTable.vue

@ -1,7 +1,7 @@
<script setup lang="ts">
import { MetaInj, inject, ref, useSidebar, useTable } from '#imports'
import { MetaInj, inject, useSidebar, useTable } from '#imports'
const meta = inject(MetaInj, ref())
const meta = inject(MetaInj)!
const { deleteTable } = useTable()

7
packages/nc-gui/components/smartsheet/toolbar/ColumnFilter.vue

@ -215,10 +215,13 @@ defineExpose({
</a-select-option>
</a-select>
<span v-if="['null', 'notnull', 'empty', 'notempty'].includes(filter.comparison_op)" :key="`span${i}`" />
<span
v-if="filter.comparison_op && ['null', 'notnull', 'empty', 'notempty'].includes(filter.comparison_op)"
:key="`span${i}`"
/>
<a-checkbox
v-else-if="types[filter.field] === 'boolean'"
v-else-if="filter.field && types[filter.field] === 'boolean'"
v-model:checked="filter.value"
dense
:disabled="filter.readOnly"

7
packages/nc-gui/lib/types.ts

@ -35,7 +35,12 @@ export interface Field {
export type Roles<T extends Role | ProjectRole = Role | ProjectRole> = Record<T | string, boolean>
export type Filter = FilterType & { status?: 'update' | 'delete' | 'create'; parentId?: string; readOnly?: boolean }
export type Filter = FilterType & {
field?: string
status?: 'update' | 'delete' | 'create'
parentId?: string
readOnly?: boolean
}
export type NocoI18n = I18n<{}, unknown, unknown, string, false>

2
packages/nc-gui/utils/viewUtils.ts

@ -8,7 +8,7 @@ import MdiGalleryIcon from '~icons/mdi/camera-image'
import MdiKanbanIcon from '~icons/mdi/tablet-dashboard'
import MdiEyeIcon from '~icons/mdi/eye-circle-outline'
export const viewIcons = {
export const viewIcons: Record<number | string, { icon: any; color: string }> = {
[ViewTypes.GRID]: { icon: MdiGridIcon, color: '#8f96f2' },
[ViewTypes.FORM]: { icon: MdiFormIcon, color: themeV2Colors.pink['500'] },
calendar: { icon: MdiCalendarIcon, color: 'purple' },

Loading…
Cancel
Save