Merge pull request #1020 from frappe/mergify/bp/main-hotfix/pr-1018

fix: set fieldname to handle bulk edit value modal (backport #1018)
This commit is contained in:
Shariq Ansari 2025-07-10 13:47:16 +05:30 committed by GitHub
commit fab101aa66
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -37,7 +37,13 @@
import Link from '@/components/Controls/Link.vue' import Link from '@/components/Controls/Link.vue'
import Autocomplete from '@/components/frappe-ui/Autocomplete.vue' import Autocomplete from '@/components/frappe-ui/Autocomplete.vue'
import { capture } from '@/telemetry' import { capture } from '@/telemetry'
import { FormControl, call, createResource, TextEditor, DatePicker } from 'frappe-ui' import {
FormControl,
call,
createResource,
TextEditor,
DatePicker,
} from 'frappe-ui'
import { ref, computed, onMounted, h } from 'vue' import { ref, computed, onMounted, h } from 'vue'
const typeCheck = ['Check'] const typeCheck = ['Check']
@ -70,7 +76,7 @@ const fields = createResource({
}, },
transform: (data) => { transform: (data) => {
return data.filter((f) => f.hidden == 0 && f.read_only == 0) return data.filter((f) => f.hidden == 0 && f.read_only == 0)
} },
}) })
onMounted(() => { onMounted(() => {
@ -82,8 +88,8 @@ const recordCount = computed(() => props.selectedValues?.size || 0)
const field = ref({ const field = ref({
label: '', label: '',
type: '', fieldtype: '',
value: '', fieldname: '',
options: '', options: '',
}) })
@ -92,7 +98,7 @@ const loading = ref(false)
function updateValues() { function updateValues() {
let fieldVal = newValue.value let fieldVal = newValue.value
if (field.value.type == 'Check') { if (field.value.fieldtype == 'Check') {
fieldVal = fieldVal == 'Yes' ? 1 : 0 fieldVal = fieldVal == 'Yes' ? 1 : 0
} }
loading.value = true loading.value = true
@ -103,14 +109,14 @@ function updateValues() {
docnames: Array.from(props.selectedValues), docnames: Array.from(props.selectedValues),
action: 'update', action: 'update',
data: { data: {
[field.value.value]: fieldVal || null, [field.value.fieldname]: fieldVal || null,
}, },
} },
).then(() => { ).then(() => {
field.value = { field.value = {
label: '', label: '',
type: '', fieldtype: '',
value: '', fieldname: '',
options: '', options: '',
} }
newValue.value = '' newValue.value = ''
@ -137,9 +143,10 @@ function getSelectOptions(options) {
} }
function getValueComponent(f) { function getValueComponent(f) {
const { type, options } = f const { fieldtype, options } = f
if (typeSelect.includes(type) || typeCheck.includes(type)) { if (typeSelect.includes(fieldtype) || typeCheck.includes(fieldtype)) {
const _options = type == 'Check' ? ['Yes', 'No'] : getSelectOptions(options) const _options =
fieldtype == 'Check' ? ['Yes', 'No'] : getSelectOptions(options)
return h(FormControl, { return h(FormControl, {
type: 'select', type: 'select',
options: _options.map((o) => ({ options: _options.map((o) => ({
@ -148,16 +155,16 @@ function getValueComponent(f) {
})), })),
modelValue: newValue.value, modelValue: newValue.value,
}) })
} else if (typeLink.includes(type)) { } else if (typeLink.includes(fieldtype)) {
if (type == 'Dynamic Link') { if (fieldtype == 'Dynamic Link') {
return h(FormControl, { type: 'text' }) return h(FormControl, { type: 'text' })
} }
return h(Link, { class: 'form-control', doctype: options }) return h(Link, { class: 'form-control', doctype: options })
} else if (typeNumber.includes(type)) { } else if (typeNumber.includes(fieldtype)) {
return h(FormControl, { type: 'number' }) return h(FormControl, { type: 'number' })
} else if (typeDate.includes(type)) { } else if (typeDate.includes(fieldtype)) {
return h(DatePicker) return h(DatePicker)
} else if (typeEditor.includes(type)) { } else if (typeEditor.includes(fieldtype)) {
return h(TextEditor, { return h(TextEditor, {
variant: 'outline', variant: 'outline',
editorClass: editorClass: