Browse Source

feat(nc-gui): add save and exit / stay logic

pull/4436/head
Wing-Kam Wong 2 years ago
parent
commit
f9250b7c95
  1. 38
      packages/nc-gui/components/smartsheet/expanded-form/Header.vue

38
packages/nc-gui/components/smartsheet/expanded-form/Header.vue

@ -25,6 +25,8 @@ const { isUIAllowed } = useUIPermission()
const reloadTrigger = inject(ReloadRowDataHookInj, createEventHook()) const reloadTrigger = inject(ReloadRowDataHookInj, createEventHook())
const saveRowAndStay = ref(0)
const save = async () => { const save = async () => {
if (isNew.value) { if (isNew.value) {
const data = await _save(state.value) const data = await _save(state.value)
@ -34,6 +36,9 @@ const save = async () => {
await _save() await _save()
reloadTrigger?.trigger() reloadTrigger?.trigger()
} }
if (!saveRowAndStay.value) {
emit('cancel')
}
} }
// todo: accept as a prop / inject // todo: accept as a prop / inject
@ -101,14 +106,39 @@ const copyRecordUrl = () => {
</a-tooltip> </a-tooltip>
<a-button class="!text mx-1 nc-expand-form-close-btn" @click="emit('cancel')"> <a-button class="!text mx-1 nc-expand-form-close-btn" @click="emit('cancel')">
<div class="flex items-center">
<MdiCancel class="mr-1" />
<!-- Cancel --> <!-- Cancel -->
{{ $t('general.cancel') }} {{ $t('general.cancel') }}
</div>
</a-button> </a-button>
<a-button :disabled="!isUIAllowed('tableRowUpdate')" type="primary" class="mx-1" @click="save"> <a-dropdown-button type="primary" :disabled="!isUIAllowed('tableRowUpdate')" @click="save">
<!-- Save Row --> <template #overlay>
{{ $t('activity.saveRow') }} <a-menu>
</a-button> <a-menu-item key="0" class="!py-2 flex gap-2" @click="saveRowAndStay = 0">
<div class="flex items-center">
<MdiContentSave class="mr-1" />
{{ $t('activity.saveAndExit') }}
</div>
</a-menu-item>
<a-menu-item key="1" class="!py-2 flex gap-2 items-center" @click="saveRowAndStay = 1">
<div class="flex items-center">
<MdiContentSaveEdit class="mr-1" />
{{ $t('activity.saveAndStay') }}
</div>
</a-menu-item>
</a-menu>
</template>
<div v-if="saveRowAndStay === 0" class="flex items-center">
<MdiContentSave class="mr-1" />
{{ $t('activity.saveAndExit') }}
</div>
<div v-if="saveRowAndStay === 1" class="flex items-center">
<MdiContentSaveEdit class="mr-1" />
{{ $t('activity.saveAndStay') }}
</div>
</a-dropdown-button>
</div> </div>
</template> </template>

Loading…
Cancel
Save