fix: open grid row modal if editable_grid is false
This commit is contained in:
parent
3ef9d783df
commit
97d25835ae
@ -55,6 +55,13 @@
|
||||
<template #item="{ element: row, index }">
|
||||
<div
|
||||
class="grid-row flex cursor-pointer items-center border-b border-outline-gray-modals bg-surface-modals last:rounded-b last:border-b-0"
|
||||
@click.stop="
|
||||
() => {
|
||||
if (!gridSettings.editable_grid) {
|
||||
showRowList[index] = true
|
||||
}
|
||||
}
|
||||
"
|
||||
>
|
||||
<div
|
||||
class="grid-row-checkbox inline-flex h-9.5 items-center bg-surface-white justify-center border-r border-outline-gray-modals p-2 w-12"
|
||||
@ -93,6 +100,7 @@
|
||||
<Checkbox
|
||||
class="cursor-pointer duration-300"
|
||||
v-model="row[field.name]"
|
||||
:disabled="!gridSettings.editable_grid"
|
||||
/>
|
||||
</div>
|
||||
<DatePicker
|
||||
@ -233,7 +241,9 @@ const props = defineProps({
|
||||
},
|
||||
})
|
||||
|
||||
const { getGridSettings, getFields } = getMeta(props.doctype)
|
||||
const { getGridViewSettings, getFields, getGridSettings } = getMeta(
|
||||
props.doctype,
|
||||
)
|
||||
|
||||
const rows = defineModel()
|
||||
const showRowList = ref(new Array(rows.value?.length || []).fill(false))
|
||||
@ -242,11 +252,13 @@ const selectedRows = reactive(new Set())
|
||||
const showGridFieldsEditorModal = ref(false)
|
||||
const showGridRowFieldsModal = ref(false)
|
||||
|
||||
const gridSettings = computed(() => getGridSettings())
|
||||
|
||||
const fields = computed(() => {
|
||||
let gridSettings = getGridSettings(props.parentDoctype)
|
||||
let gridViewSettings = getGridViewSettings(props.parentDoctype)
|
||||
let gridFields = getFields()
|
||||
if (gridSettings.length) {
|
||||
let d = gridSettings.map((gs) =>
|
||||
if (gridViewSettings.length) {
|
||||
let d = gridViewSettings.map((gs) =>
|
||||
getFieldObj(gridFields.find((f) => f.fieldname === gs.fieldname)),
|
||||
)
|
||||
return d
|
||||
@ -269,9 +281,11 @@ function getFieldObj(field) {
|
||||
const gridTemplateColumns = computed(() => {
|
||||
if (!fields.value?.length) return '1fr'
|
||||
// for the checkbox & sr no. columns
|
||||
let gridSettings = getGridSettings(props.parentDoctype)
|
||||
if (gridSettings.length) {
|
||||
return gridSettings.map((gs) => `minmax(0, ${gs.columns || 2}fr)`).join(' ')
|
||||
let gridViewSettings = getGridViewSettings(props.parentDoctype)
|
||||
if (gridViewSettings.length) {
|
||||
return gridViewSettings
|
||||
.map((gs) => `minmax(0, ${gs.columns || 2}fr)`)
|
||||
.join(' ')
|
||||
}
|
||||
return fields.value.map(() => `minmax(0, 2fr)`).join(' ')
|
||||
})
|
||||
|
||||
@ -107,7 +107,7 @@ const props = defineProps({
|
||||
parentDoctype: String,
|
||||
})
|
||||
|
||||
const { userSettings, getFields, getGridSettings, saveUserSettings } = getMeta(
|
||||
const { userSettings, getFields, getGridViewSettings, saveUserSettings } = getMeta(
|
||||
props.doctype,
|
||||
)
|
||||
|
||||
@ -122,10 +122,10 @@ const dirty = computed(() => {
|
||||
|
||||
const oldFields = computed(() => {
|
||||
let _fields = getFields()
|
||||
let gridSettings = getGridSettings(props.parentDoctype)
|
||||
let gridViewSettings = getGridViewSettings(props.parentDoctype)
|
||||
|
||||
if (gridSettings.length) {
|
||||
return gridSettings.map((field) => {
|
||||
if (gridViewSettings.length) {
|
||||
return gridViewSettings.map((field) => {
|
||||
let f = _fields.find((f) => f.fieldname === field.fieldname)
|
||||
if (f) {
|
||||
f.columns = field.columns
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { createResource } from 'frappe-ui'
|
||||
import { formatCurrency, formatNumber } from '@/utils/numberFormat.js'
|
||||
import { ref, reactive } from 'vue'
|
||||
import { reactive } from 'vue'
|
||||
|
||||
const doctypeMeta = reactive({})
|
||||
const userSettings = reactive({})
|
||||
@ -55,7 +55,11 @@ export function getMeta(doctype) {
|
||||
return formatCurrency(doc[fieldname], '', currency, precision)
|
||||
}
|
||||
|
||||
function getGridSettings(parentDoctype, dt = null) {
|
||||
function getGridSettings() {
|
||||
return doctypeMeta[doctype] || {}
|
||||
}
|
||||
|
||||
function getGridViewSettings(parentDoctype, dt = null) {
|
||||
dt = dt || doctype
|
||||
if (!userSettings[parentDoctype]?.['GridView']?.[doctype]) return {}
|
||||
return userSettings[parentDoctype]['GridView'][doctype]
|
||||
@ -106,6 +110,7 @@ export function getMeta(doctype) {
|
||||
userSettings,
|
||||
getFields,
|
||||
getGridSettings,
|
||||
getGridViewSettings,
|
||||
saveUserSettings,
|
||||
getFormattedFloat,
|
||||
getFormattedPercent,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user