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 }">
|
<template #item="{ element: row, index }">
|
||||||
<div
|
<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"
|
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
|
<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"
|
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
|
<Checkbox
|
||||||
class="cursor-pointer duration-300"
|
class="cursor-pointer duration-300"
|
||||||
v-model="row[field.name]"
|
v-model="row[field.name]"
|
||||||
|
:disabled="!gridSettings.editable_grid"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<DatePicker
|
<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 rows = defineModel()
|
||||||
const showRowList = ref(new Array(rows.value?.length || []).fill(false))
|
const showRowList = ref(new Array(rows.value?.length || []).fill(false))
|
||||||
@ -242,11 +252,13 @@ const selectedRows = reactive(new Set())
|
|||||||
const showGridFieldsEditorModal = ref(false)
|
const showGridFieldsEditorModal = ref(false)
|
||||||
const showGridRowFieldsModal = ref(false)
|
const showGridRowFieldsModal = ref(false)
|
||||||
|
|
||||||
|
const gridSettings = computed(() => getGridSettings())
|
||||||
|
|
||||||
const fields = computed(() => {
|
const fields = computed(() => {
|
||||||
let gridSettings = getGridSettings(props.parentDoctype)
|
let gridViewSettings = getGridViewSettings(props.parentDoctype)
|
||||||
let gridFields = getFields()
|
let gridFields = getFields()
|
||||||
if (gridSettings.length) {
|
if (gridViewSettings.length) {
|
||||||
let d = gridSettings.map((gs) =>
|
let d = gridViewSettings.map((gs) =>
|
||||||
getFieldObj(gridFields.find((f) => f.fieldname === gs.fieldname)),
|
getFieldObj(gridFields.find((f) => f.fieldname === gs.fieldname)),
|
||||||
)
|
)
|
||||||
return d
|
return d
|
||||||
@ -269,9 +281,11 @@ function getFieldObj(field) {
|
|||||||
const gridTemplateColumns = computed(() => {
|
const gridTemplateColumns = computed(() => {
|
||||||
if (!fields.value?.length) return '1fr'
|
if (!fields.value?.length) return '1fr'
|
||||||
// for the checkbox & sr no. columns
|
// for the checkbox & sr no. columns
|
||||||
let gridSettings = getGridSettings(props.parentDoctype)
|
let gridViewSettings = getGridViewSettings(props.parentDoctype)
|
||||||
if (gridSettings.length) {
|
if (gridViewSettings.length) {
|
||||||
return gridSettings.map((gs) => `minmax(0, ${gs.columns || 2}fr)`).join(' ')
|
return gridViewSettings
|
||||||
|
.map((gs) => `minmax(0, ${gs.columns || 2}fr)`)
|
||||||
|
.join(' ')
|
||||||
}
|
}
|
||||||
return fields.value.map(() => `minmax(0, 2fr)`).join(' ')
|
return fields.value.map(() => `minmax(0, 2fr)`).join(' ')
|
||||||
})
|
})
|
||||||
|
|||||||
@ -107,7 +107,7 @@ const props = defineProps({
|
|||||||
parentDoctype: String,
|
parentDoctype: String,
|
||||||
})
|
})
|
||||||
|
|
||||||
const { userSettings, getFields, getGridSettings, saveUserSettings } = getMeta(
|
const { userSettings, getFields, getGridViewSettings, saveUserSettings } = getMeta(
|
||||||
props.doctype,
|
props.doctype,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -122,10 +122,10 @@ const dirty = computed(() => {
|
|||||||
|
|
||||||
const oldFields = computed(() => {
|
const oldFields = computed(() => {
|
||||||
let _fields = getFields()
|
let _fields = getFields()
|
||||||
let gridSettings = getGridSettings(props.parentDoctype)
|
let gridViewSettings = getGridViewSettings(props.parentDoctype)
|
||||||
|
|
||||||
if (gridSettings.length) {
|
if (gridViewSettings.length) {
|
||||||
return gridSettings.map((field) => {
|
return gridViewSettings.map((field) => {
|
||||||
let f = _fields.find((f) => f.fieldname === field.fieldname)
|
let f = _fields.find((f) => f.fieldname === field.fieldname)
|
||||||
if (f) {
|
if (f) {
|
||||||
f.columns = field.columns
|
f.columns = field.columns
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { createResource } from 'frappe-ui'
|
import { createResource } from 'frappe-ui'
|
||||||
import { formatCurrency, formatNumber } from '@/utils/numberFormat.js'
|
import { formatCurrency, formatNumber } from '@/utils/numberFormat.js'
|
||||||
import { ref, reactive } from 'vue'
|
import { reactive } from 'vue'
|
||||||
|
|
||||||
const doctypeMeta = reactive({})
|
const doctypeMeta = reactive({})
|
||||||
const userSettings = reactive({})
|
const userSettings = reactive({})
|
||||||
@ -55,7 +55,11 @@ export function getMeta(doctype) {
|
|||||||
return formatCurrency(doc[fieldname], '', currency, precision)
|
return formatCurrency(doc[fieldname], '', currency, precision)
|
||||||
}
|
}
|
||||||
|
|
||||||
function getGridSettings(parentDoctype, dt = null) {
|
function getGridSettings() {
|
||||||
|
return doctypeMeta[doctype] || {}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getGridViewSettings(parentDoctype, dt = null) {
|
||||||
dt = dt || doctype
|
dt = dt || doctype
|
||||||
if (!userSettings[parentDoctype]?.['GridView']?.[doctype]) return {}
|
if (!userSettings[parentDoctype]?.['GridView']?.[doctype]) return {}
|
||||||
return userSettings[parentDoctype]['GridView'][doctype]
|
return userSettings[parentDoctype]['GridView'][doctype]
|
||||||
@ -106,6 +110,7 @@ export function getMeta(doctype) {
|
|||||||
userSettings,
|
userSettings,
|
||||||
getFields,
|
getFields,
|
||||||
getGridSettings,
|
getGridSettings,
|
||||||
|
getGridViewSettings,
|
||||||
saveUserSettings,
|
saveUserSettings,
|
||||||
getFormattedFloat,
|
getFormattedFloat,
|
||||||
getFormattedPercent,
|
getFormattedPercent,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user