Browse Source

fix(nc-gui): new record from sidemenu

pull/7611/head
DarkPhoenix2704 7 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
}>()
const emit = defineEmits(['expand-record'])
const emit = defineEmits(['expand-record', 'new-record'])
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" />
</template>
</a-input>
<NcButton type="secondary">
<NcButton type="secondary" @click="emit('new-record')">
<div class="px-4 flex items-center gap-2 justify-center">
<component :is="iconMap.plus" class="h-4 w-4 text-gray-700" />
{{ t('activity.newRecord') }}

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

@ -16,6 +16,7 @@ import {
inject,
provide,
ref,
rowDefaultData,
useI18n,
} from '#imports'
@ -72,8 +73,9 @@ const expandedFormOnRowIdDlg = computed({
const expandedFormDlg = ref(false)
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!)
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 () => {
await loadCalendarMeta()
await loadCalendarData()
@ -160,9 +176,25 @@ const headerText = computed(() => {
<GeneralLoader size="xlarge" />
</div>
</div>
<LazySmartsheetCalendarSideMenu v-if="!isMobileMode" :visible="showSideMenu" @expand-record="expandRecord" />
<LazySmartsheetCalendarSideMenu
v-if="!isMobileMode"
:visible="showSideMenu"
@expand-record="expandRecord"
@new-record="newRecord"
/>
</div>
<Suspense>
<LazySmartsheetExpandedForm
v-if="expandedFormRow && expandedFormDlg"
v-model="expandedFormDlg"
:meta="meta"
:row="expandedFormRow"
:state="expandedFormRowState"
:view="view"
/>
</Suspense>
<Suspense>
<LazySmartsheetExpandedForm
v-if="expandedFormOnRowIdDlg"

Loading…
Cancel
Save