Browse Source

feat(gui-v2): email me logic

pull/3030/head
Wing-Kam Wong 2 years ago
parent
commit
fc2b4099d9
  1. 30
      packages/nc-gui-v2/components/smartsheet/Form.vue

30
packages/nc-gui-v2/components/smartsheet/Form.vue

@ -73,6 +73,8 @@ const showColumnDropdown = ref(false)
const drag = ref(false) const drag = ref(false)
const emailMe = ref(false)
const submitted = ref(false) const submitted = ref(false)
const activeRow = ref('') const activeRow = ref('')
@ -203,7 +205,15 @@ async function removeAllColumns() {
$e('a:form-view:remove-all') $e('a:form-view:remove-all')
} }
async function checkSMTPStatus() {} async function checkSMTPStatus() {
if (emailMe.value) {
const emailPluginActive = await $api.plugin.status('SMTP')
if (!emailPluginActive) {
emailMe.value = false
toast.info('Please activate SMTP plugin in App store for enabling email notification')
}
}
}
function setFormData() { function setFormData() {
const col = (formColumnData as Record<string, any>)?.value const col = (formColumnData as Record<string, any>)?.value
@ -214,6 +224,17 @@ function setFormData() {
show_blank_form: !!(formViewData?.value?.show_blank_form ?? 0), show_blank_form: !!(formViewData?.value?.show_blank_form ?? 0),
} }
{
// email me
let data: Record<string, boolean> = {}
try {
data = JSON.parse(formViewData.value.email as string) || {}
} catch (e) {}
data[state.user.value?.email as string] = emailMe.value
formViewData.value.email = JSON.stringify(data)
checkSMTPStatus()
}
localColumns.value = col localColumns.value = col
.filter((f: Record<string, any>) => f.show && f.uidt !== UITypes.Rollup && f.uidt !== UITypes.Lookup) .filter((f: Record<string, any>) => f.show && f.uidt !== UITypes.Rollup && f.uidt !== UITypes.Lookup)
.sort((a: Record<string, any>, b: Record<string, any>) => a.order - b.order) .sort((a: Record<string, any>, b: Record<string, any>) => a.order - b.order)
@ -240,6 +261,11 @@ function isRequired(_columnObj: Record<string, any>, required = false) {
return required || (columnObj && columnObj.rqd && !columnObj.cdf) return required || (columnObj && columnObj.rqd && !columnObj.cdf)
} }
function onEmailChange() {
updateView()
checkSMTPStatus()
}
const updateColMeta = useDebounceFn(async (col: Record<string, any>) => { const updateColMeta = useDebounceFn(async (col: Record<string, any>) => {
if (col.id) { if (col.id) {
try { try {
@ -524,7 +550,7 @@ onMounted(async () => {
<span class="ml-4">{{ $t('msg.info.showBlankForm') }}</span> <span class="ml-4">{{ $t('msg.info.showBlankForm') }}</span>
</div> </div>
<div class="my-4"> <div class="my-4">
<a-switch v-model:checked="formViewData.email" v-t="[`a:form-view:email-me`]" @change="updateView" /> <a-switch v-model:checked="emailMe" v-t="[`a:form-view:email-me`]" @change="onEmailChange" />
<!-- Email me at <email> --> <!-- Email me at <email> -->
<span class="ml-4"> <span class="ml-4">
{{ $t('msg.info.emailForm') }} <span class="text-bold text-gray-600">{{ state.user.value?.email }}</span> {{ $t('msg.info.emailForm') }} <span class="text-bold text-gray-600">{{ state.user.value?.email }}</span>

Loading…
Cancel
Save