Browse Source

fix(nc-gui): new record from sidemenu

pull/7611/head
DarkPhoenix2704 9 months ago
parent
commit
b1cccb8fa1
  1. 4
      packages/nc-gui/components/smartsheet/calendar/SideMenu.vue
  2. 36
      packages/nc-gui/components/smartsheet/calendar/index.vue

4
packages/nc-gui/components/smartsheet/calendar/SideMenu.vue

@ -7,7 +7,7 @@ const props = defineProps<{
visible: boolean visible: boolean
}>() }>()
const emit = defineEmits(['expand-record']) const emit = defineEmits(['expand-record', 'new-record'])
const INFINITY_SCROLL_THRESHOLD = 100 const INFINITY_SCROLL_THRESHOLD = 100
@ -136,7 +136,7 @@ const sideBarListScrollHandle = useDebounceFn(async (e: Event) => {
<component :is="iconMap.search" class="h-4 w-4 mr-1 text-gray-500" /> <component :is="iconMap.search" class="h-4 w-4 mr-1 text-gray-500" />
</template> </template>
</a-input> </a-input>
<NcButton type="secondary"> <NcButton type="secondary" @click="emit('new-record')">
<div class="px-4 flex items-center gap-2 justify-center"> <div class="px-4 flex items-center gap-2 justify-center">
<component :is="iconMap.plus" class="h-4 w-4 text-gray-700" /> <component :is="iconMap.plus" class="h-4 w-4 text-gray-700" />
{{ t('activity.newRecord') }} {{ t('activity.newRecord') }}

36
packages/nc-gui/components/smartsheet/calendar/index.vue

@ -16,6 +16,7 @@ import {
inject, inject,
provide, provide,
ref, ref,
rowDefaultData,
useI18n, useI18n,
} from '#imports' } from '#imports'
@ -72,8 +73,9 @@ const expandedFormOnRowIdDlg = computed({
const expandedFormDlg = ref(false) const expandedFormDlg = ref(false)
const expandedFormRow = ref<RowType>() const expandedFormRow = ref<RowType>()
const expandedFormRowState = ref<Record<string, any>>()
const expandRecord = (row: RowType, isNew = false) => { const expandRecord = (row: RowType) => {
const rowId = extractPkFromRow(row.row, meta.value!.columns!) const rowId = extractPkFromRow(row.row, meta.value!.columns!)
if (rowId) { if (rowId) {
@ -89,6 +91,20 @@ const expandRecord = (row: RowType, isNew = false) => {
} }
} }
const newRecord = () => {
// TODO: The default values has to be filled based on the active calendar view
// and selected sidebar filter option
expandRecord({
row: {
...rowDefaultData(meta.value?.columns),
},
oldRow: {},
rowMeta: {
new: true,
},
})
}
onMounted(async () => { onMounted(async () => {
await loadCalendarMeta() await loadCalendarMeta()
await loadCalendarData() await loadCalendarData()
@ -160,9 +176,25 @@ const headerText = computed(() => {
<GeneralLoader size="xlarge" /> <GeneralLoader size="xlarge" />
</div> </div>
</div> </div>
<LazySmartsheetCalendarSideMenu v-if="!isMobileMode" :visible="showSideMenu" @expand-record="expandRecord" /> <LazySmartsheetCalendarSideMenu
v-if="!isMobileMode"
:visible="showSideMenu"
@expand-record="expandRecord"
@new-record="newRecord"
/>
</div> </div>
<Suspense>
<LazySmartsheetExpandedForm
v-if="expandedFormRow && expandedFormDlg"
v-model="expandedFormDlg"
:meta="meta"
:row="expandedFormRow"
:state="expandedFormRowState"
:view="view"
/>
</Suspense>
<Suspense> <Suspense>
<LazySmartsheetExpandedForm <LazySmartsheetExpandedForm
v-if="expandedFormOnRowIdDlg" v-if="expandedFormOnRowIdDlg"

Loading…
Cancel
Save