fix: load sections and fields in quick entry layout builder

This commit is contained in:
Shariq Ansari 2024-06-19 15:35:28 +05:30
parent ab1d4644dd
commit 7e3a2f9fb7
2 changed files with 103 additions and 1 deletions

View File

@ -1,3 +1,72 @@
<template>
<div>Quick Entry Layout</div>
<div ref="parentRef" class="flex flex-col p-8 overflow-hidden">
<h2 class="flex gap-2 text-xl font-semibold leading-none h-5 mb-4">
<div>{{ __('Quick Entry Layout') }}</div>
<Badge
v-if="dirty"
:label="__('Not Saved')"
variant="subtle"
theme="orange"
/>
</h2>
<div class="flex-1 flex flex-col justify-between -m-3 p-3 gap-6 overflow-y-auto">
<div class="flex gap-6 items-end">
<FormControl
class="flex-1"
type="select"
v-model="doctype"
:label="__('DocType')"
:options="['CRM Lead', 'CRM Deal', 'Contact', 'CRM Organization']"
@change="reload"
/>
<div class="flex flex-row-reverse gap-2">
<Button
:loading="loading"
:label="__('Save')"
variant="solid"
@click="saveChanges"
/>
<Button :label="__('Reset')" @click="reload" />
</div>
</div>
<div v-if="sections?.data" class="">
<QuickEntryLayoutBuilder :sections="sections.data" :doctype="doctype" />
</div>
</div>
</div>
</template>
<script setup>
import QuickEntryLayoutBuilder from '@/components/Settings/QuickEntryLayoutBuilder.vue'
import { useDebounceFn } from '@vueuse/core'
import { Badge, createResource } from 'frappe-ui'
import { ref, onMounted } from 'vue'
const parentRef = ref(null)
const doctype = ref('CRM Lead')
const loading = ref(false)
const dirty = ref(false)
function getParams() {
return { doctype: doctype.value, type: 'Quick Entry' }
}
const sections = createResource({
url: 'crm.fcrm.doctype.crm_fields_layout.crm_fields_layout.get_fields_layout',
cache: ['quick-entry-sections', doctype.value],
params: getParams(),
onSuccess(data) {
sections.originalData = JSON.parse(JSON.stringify(data))
},
})
onMounted(() => useDebounceFn(reload, 100)())
function reload() {
sections.params = getParams()
sections.reload()
}
function saveChanges() {
// TODO: Save changes
}
</script>

View File

@ -0,0 +1,33 @@
<template>
<div
class="border rounded-xl h-full inline-block w-full transform overflow-hidden bg-white text-left align-middle shadow-xl transition-all"
>
<div class="bg-white px-4 pb-6 pt-5 sm:px-6">
<div class="mb-6 flex items-center justify-between">
<div class="flex items-center space-x-2">
<header>
<h3 class="text-2xl font-semibold leading-6 text-gray-900">
{{ __('Create Lead') }}
</h3>
</header>
</div>
<Button icon="x" disabled variant="ghost" />
</div>
<div>
<div v-for="section in sections">
<div>{{ section.label }}</div>
<div v-for="field in section.fields">
<div>{{ field.label }}</div>
</div>
</div>
</div>
</div>
<!-- <div class="px-4 pb-7 pt-4 sm:px-6">Actions</div> -->
</div>
</template>
<script setup>
const props = defineProps({
sections: Object,
doctype: String,
})
</script>