fix: set type based on onlyRequired flag

This commit is contained in:
Shariq Ansari 2025-02-21 14:49:39 +05:30
parent 7294310e84
commit 3c865c37a7
4 changed files with 20 additions and 4 deletions

View File

@ -537,7 +537,7 @@ def get_records_based_on_order(doctype, rows, filters, page_length, order):
@frappe.whitelist() @frappe.whitelist()
def get_fields_meta(doctype, restricted_fieldtypes=None, as_array=False): def get_fields_meta(doctype, restricted_fieldtypes=None, as_array=False, only_required=False):
not_allowed_fieldtypes = [ not_allowed_fieldtypes = [
"Tab Break", "Tab Break",
"Section Break", "Section Break",
@ -572,6 +572,9 @@ def get_fields_meta(doctype, restricted_fieldtypes=None, as_array=False):
if not restricted_fieldtypes or field.get("fieldtype") not in restricted_fieldtypes: if not restricted_fieldtypes or field.get("fieldtype") not in restricted_fieldtypes:
fields.append(field) fields.append(field)
if only_required:
fields = [field for field in fields if field.get("reqd")]
if as_array: if as_array:
return fields return fields

View File

@ -226,6 +226,10 @@ import { ref, computed, watch } from 'vue'
const props = defineProps({ const props = defineProps({
tabs: Object, tabs: Object,
doctype: String, doctype: String,
onlyRequired: {
type: Boolean,
default: false,
},
}) })
const tabIndex = ref(0) const tabIndex = ref(0)
@ -249,6 +253,7 @@ const params = computed(() => {
doctype: props.doctype, doctype: props.doctype,
restricted_fieldtypes: restrictedFieldTypes, restricted_fieldtypes: restrictedFieldTypes,
as_array: true, as_array: true,
only_required: props.onlyRequired,
} }
}) })

View File

@ -35,6 +35,7 @@
v-if="!preview" v-if="!preview"
:tabs="tabs.data" :tabs="tabs.data"
:doctype="_doctype" :doctype="_doctype"
:onlyRequired="onlyRequired"
/> />
<FieldLayout v-else :tabs="tabs.data" :data="{}" :preview="true" /> <FieldLayout v-else :tabs="tabs.data" :data="{}" :preview="true" />
</div> </div>
@ -55,6 +56,10 @@ const props = defineProps({
type: String, type: String,
default: 'CRM Lead', default: 'CRM Lead',
}, },
onlyRequired: {
type: Boolean,
default: false,
},
}) })
const show = defineModel() const show = defineModel()
@ -64,12 +69,13 @@ const dirty = ref(false)
const preview = ref(false) const preview = ref(false)
function getParams() { function getParams() {
return { doctype: _doctype.value, type: 'Quick Entry' } let type = props.onlyRequired ? 'Required Fields' : 'Quick Entry'
return { doctype: _doctype.value, type }
} }
const tabs = createResource({ const tabs = createResource({
url: 'crm.fcrm.doctype.crm_fields_layout.crm_fields_layout.get_fields_layout', url: 'crm.fcrm.doctype.crm_fields_layout.crm_fields_layout.get_fields_layout',
cache: ['QuickEntryModal', _doctype.value], cache: ['QuickEntryModal', _doctype.value, props.onlyRequired],
params: getParams(), params: getParams(),
onSuccess(data) { onSuccess(data) {
tabs.originalData = JSON.parse(JSON.stringify(data)) tabs.originalData = JSON.parse(JSON.stringify(data))
@ -106,11 +112,12 @@ function saveChanges() {
}) })
}) })
loading.value = true loading.value = true
let type = props.onlyRequired ? 'Required Fields' : 'Quick Entry'
call( call(
'crm.fcrm.doctype.crm_fields_layout.crm_fields_layout.save_fields_layout', 'crm.fcrm.doctype.crm_fields_layout.crm_fields_layout.save_fields_layout',
{ {
doctype: _doctype.value, doctype: _doctype.value,
type: 'Quick Entry', type: type,
layout: JSON.stringify(_tabs), layout: JSON.stringify(_tabs),
}, },
).then(() => { ).then(() => {

View File

@ -285,6 +285,7 @@
v-if="showQuickEntryModal" v-if="showQuickEntryModal"
v-model="showQuickEntryModal" v-model="showQuickEntryModal"
doctype="CRM Deal" doctype="CRM Deal"
:onlyRequired="true"
/> />
<FilesUploader <FilesUploader
v-if="lead.data?.name" v-if="lead.data?.name"