Browse Source

feat(nc-gui): kanban grouping column id in copy view

#3840
pull/3563/head
Wing-Kam Wong 2 years ago
parent
commit
9ef76504c5
  1. 17
      packages/nc-gui/components/dlg/ViewCreate.vue
  2. 2
      packages/nc-gui/components/smartsheet/sidebar/MenuTop.vue
  3. 11
      packages/nc-gui/components/smartsheet/sidebar/RenameableMenuItem.vue
  4. 17
      packages/nc-gui/components/smartsheet/sidebar/index.vue

17
packages/nc-gui/components/dlg/ViewCreate.vue

@ -25,6 +25,7 @@ interface Props {
type: ViewTypes type: ViewTypes
title?: string title?: string
selectedViewId?: string selectedViewId?: string
groupingFieldColumnId?: string
} }
interface Emits { interface Emits {
@ -123,7 +124,13 @@ function init() {
label: field.title, label: field.title,
} }
}) })
form.grp_column_id = singleSelectFieldOptions.value?.[0]?.value as string if (props.groupingFieldColumnId) {
// take from the one from copy view
form.grp_column_id = props.groupingFieldColumnId
} else {
// take the first option
form.grp_column_id = singleSelectFieldOptions.value?.[0]?.value as string
}
} }
nextTick(() => { nextTick(() => {
@ -186,11 +193,17 @@ async function onSubmit() {
<a-form-item :label="$t('labels.viewName')" name="title" :rules="viewNameRules"> <a-form-item :label="$t('labels.viewName')" name="title" :rules="viewNameRules">
<a-input ref="inputEl" v-model:value="form.title" autofocus @keydown.enter="onSubmit" /> <a-input ref="inputEl" v-model:value="form.title" autofocus @keydown.enter="onSubmit" />
</a-form-item> </a-form-item>
<a-form-item v-if="form.type === ViewTypes.KANBAN" name="grp_column_id" :rules="groupingFieldColumnRules"> <a-form-item
v-if="form.type === ViewTypes.KANBAN"
:label="$t('general.groupingField')"
name="grp_column_id"
:rules="groupingFieldColumnRules"
>
<a-select <a-select
v-model:value="form.grp_column_id" v-model:value="form.grp_column_id"
class="w-full nc-kanban-grouping-field-select" class="w-full nc-kanban-grouping-field-select"
:options="singleSelectFieldOptions" :options="singleSelectFieldOptions"
:disabled="props.groupingFieldColumnId"
placeholder="Select a Grouping Field" placeholder="Select a Grouping Field"
not-found-content="No Single Select Field can be found. Please create one first." not-found-content="No Single Select Field can be found. Please create one first."
/> />

2
packages/nc-gui/components/smartsheet/sidebar/MenuTop.vue

@ -28,7 +28,7 @@ const emits = defineEmits<Emits>()
const { t } = useI18n() const { t } = useI18n()
interface Emits { interface Emits {
(event: 'openModal', data: { type: ViewTypes; title?: string; copyViewId?: string }): void (event: 'openModal', data: { type: ViewTypes; title?: string; copyViewId?: string; groupingFieldColumnId?: string }): void
(event: 'deleted'): void (event: 'deleted'): void
} }

11
packages/nc-gui/components/smartsheet/sidebar/RenameableMenuItem.vue

@ -1,5 +1,5 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { ViewType, ViewTypes } from 'nocodb-sdk' import type { KanbanType, ViewType, ViewTypes } from 'nocodb-sdk'
import type { WritableComputedRef } from '@vue/reactivity' import type { WritableComputedRef } from '@vue/reactivity'
import { import {
IsLockedInj, IsLockedInj,
@ -23,7 +23,7 @@ interface Emits {
(event: 'changeView', view: Record<string, any>): void (event: 'changeView', view: Record<string, any>): void
(event: 'rename', view: ViewType): void (event: 'rename', view: ViewType): void
(event: 'delete', view: ViewType): void (event: 'delete', view: ViewType): void
(event: 'openModal', data: { type: ViewTypes; title?: string; copyViewId?: string }): void (event: 'openModal', data: { type: ViewTypes; title?: string; copyViewId?: string; groupingFieldColumnId?: string }): void
} }
const props = defineProps<Props>() const props = defineProps<Props>()
@ -101,7 +101,12 @@ function focusInput(el: HTMLInputElement) {
/** Duplicate a view */ /** Duplicate a view */
// todo: This is not really a duplication, maybe we need to implement a true duplication? // todo: This is not really a duplication, maybe we need to implement a true duplication?
function onDuplicate() { function onDuplicate() {
emits('openModal', { type: vModel.value.type!, title: vModel.value.title, copyViewId: vModel.value.id }) emits('openModal', {
type: vModel.value.type!,
title: vModel.value.title,
copyViewId: vModel.value.id,
groupingFieldColumnId: (vModel.value.view as KanbanType).grp_column_id!,
})
$e('c:view:copy', { view: vModel.value.type }) $e('c:view:copy', { view: vModel.value.type })
} }

17
packages/nc-gui/components/smartsheet/sidebar/index.vue

@ -50,6 +50,9 @@ let viewCreateTitle = $ref('')
/** selected view id for copying view meta */ /** selected view id for copying view meta */
let selectedViewId = $ref('') let selectedViewId = $ref('')
/** Kanban Grouping Column Id for copying view meta */
let kanbanGrpColumnId = $ref('')
/** is view creation modal open */ /** is view creation modal open */
let modalOpen = $ref(false) let modalOpen = $ref(false)
@ -82,11 +85,22 @@ watch(
) )
/** Open view creation modal */ /** Open view creation modal */
function openModal({ type, title = '', copyViewId }: { type: ViewTypes; title: string; copyViewId: string }) { function openModal({
type,
title = '',
copyViewId,
groupingFieldColumnId,
}: {
type: ViewTypes
title: string
copyViewId: string
groupingFieldColumnId: string
}) {
modalOpen = true modalOpen = true
viewCreateType = type viewCreateType = type
viewCreateTitle = title viewCreateTitle = title
selectedViewId = copyViewId selectedViewId = copyViewId
kanbanGrpColumnId = groupingFieldColumnId
} }
/** Handle view creation */ /** Handle view creation */
@ -126,6 +140,7 @@ function onCreate(view: ViewType) {
:title="viewCreateTitle" :title="viewCreateTitle"
:type="viewCreateType" :type="viewCreateType"
:selected-view-id="selectedViewId" :selected-view-id="selectedViewId"
:grouping-field-column-id="kanbanGrpColumnId"
@created="onCreate" @created="onCreate"
/> />
</a-layout-sider> </a-layout-sider>

Loading…
Cancel
Save