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()
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 = [
"Tab 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:
fields.append(field)
if only_required:
fields = [field for field in fields if field.get("reqd")]
if as_array:
return fields

View File

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

View File

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

View File

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