Merge pull request #1018 from zaqouttahir/fix-bug-edit-bulk
This commit is contained in:
commit
743d97d690
@ -37,7 +37,13 @@
|
||||
import Link from '@/components/Controls/Link.vue'
|
||||
import Autocomplete from '@/components/frappe-ui/Autocomplete.vue'
|
||||
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'
|
||||
|
||||
const typeCheck = ['Check']
|
||||
@ -70,7 +76,7 @@ const fields = createResource({
|
||||
},
|
||||
transform: (data) => {
|
||||
return data.filter((f) => f.hidden == 0 && f.read_only == 0)
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
@ -82,8 +88,8 @@ const recordCount = computed(() => props.selectedValues?.size || 0)
|
||||
|
||||
const field = ref({
|
||||
label: '',
|
||||
type: '',
|
||||
value: '',
|
||||
fieldtype: '',
|
||||
fieldname: '',
|
||||
options: '',
|
||||
})
|
||||
|
||||
@ -92,7 +98,7 @@ const loading = ref(false)
|
||||
|
||||
function updateValues() {
|
||||
let fieldVal = newValue.value
|
||||
if (field.value.type == 'Check') {
|
||||
if (field.value.fieldtype == 'Check') {
|
||||
fieldVal = fieldVal == 'Yes' ? 1 : 0
|
||||
}
|
||||
loading.value = true
|
||||
@ -103,14 +109,14 @@ function updateValues() {
|
||||
docnames: Array.from(props.selectedValues),
|
||||
action: 'update',
|
||||
data: {
|
||||
[field.value.value]: fieldVal || null,
|
||||
[field.value.fieldname]: fieldVal || null,
|
||||
},
|
||||
}
|
||||
},
|
||||
).then(() => {
|
||||
field.value = {
|
||||
label: '',
|
||||
type: '',
|
||||
value: '',
|
||||
fieldtype: '',
|
||||
fieldname: '',
|
||||
options: '',
|
||||
}
|
||||
newValue.value = ''
|
||||
@ -137,9 +143,10 @@ function getSelectOptions(options) {
|
||||
}
|
||||
|
||||
function getValueComponent(f) {
|
||||
const { type, options } = f
|
||||
if (typeSelect.includes(type) || typeCheck.includes(type)) {
|
||||
const _options = type == 'Check' ? ['Yes', 'No'] : getSelectOptions(options)
|
||||
const { fieldtype, options } = f
|
||||
if (typeSelect.includes(fieldtype) || typeCheck.includes(fieldtype)) {
|
||||
const _options =
|
||||
fieldtype == 'Check' ? ['Yes', 'No'] : getSelectOptions(options)
|
||||
return h(FormControl, {
|
||||
type: 'select',
|
||||
options: _options.map((o) => ({
|
||||
@ -148,16 +155,16 @@ function getValueComponent(f) {
|
||||
})),
|
||||
modelValue: newValue.value,
|
||||
})
|
||||
} else if (typeLink.includes(type)) {
|
||||
if (type == 'Dynamic Link') {
|
||||
} else if (typeLink.includes(fieldtype)) {
|
||||
if (fieldtype == 'Dynamic Link') {
|
||||
return h(FormControl, { type: 'text' })
|
||||
}
|
||||
return h(Link, { class: 'form-control', doctype: options })
|
||||
} else if (typeNumber.includes(type)) {
|
||||
} else if (typeNumber.includes(fieldtype)) {
|
||||
return h(FormControl, { type: 'number' })
|
||||
} else if (typeDate.includes(type)) {
|
||||
} else if (typeDate.includes(fieldtype)) {
|
||||
return h(DatePicker)
|
||||
} else if (typeEditor.includes(type)) {
|
||||
} else if (typeEditor.includes(fieldtype)) {
|
||||
return h(TextEditor, {
|
||||
variant: 'outline',
|
||||
editorClass:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user