Grid üzerinde CustomButton problemi giderildi.
This commit is contained in:
parent
7c5650b680
commit
6723ce4e66
2 changed files with 27 additions and 35 deletions
|
|
@ -23,7 +23,6 @@ const cellTemplateMultiValue = (
|
||||||
cellInfo: DataGridTypes.ColumnCellTemplateData<any, any>,
|
cellInfo: DataGridTypes.ColumnCellTemplateData<any, any>,
|
||||||
) => {
|
) => {
|
||||||
if (cellInfo?.value) {
|
if (cellInfo?.value) {
|
||||||
|
|
||||||
const text = Array.isArray(cellInfo.value)
|
const text = Array.isArray(cellInfo.value)
|
||||||
? cellInfo.value
|
? cellInfo.value
|
||||||
.map((a: any) => {
|
.map((a: any) => {
|
||||||
|
|
@ -95,7 +94,7 @@ const useListFormColumns = ({
|
||||||
const dialog: any = useDialogContext()
|
const dialog: any = useDialogContext()
|
||||||
const { translate } = useLocalization()
|
const { translate } = useLocalization()
|
||||||
const { checkPermission } = usePermission()
|
const { checkPermission } = usePermission()
|
||||||
const isPwaMode = usePWA();
|
const isPwaMode = usePWA()
|
||||||
|
|
||||||
const lookupDataSource = (options: any, colData: any, listFormCode: string) => {
|
const lookupDataSource = (options: any, colData: any, listFormCode: string) => {
|
||||||
const { lookupDto } = colData
|
const { lookupDto } = colData
|
||||||
|
|
@ -267,35 +266,38 @@ const useListFormColumns = ({
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!(gridDto.gridOptions.editingOptionDto.allowUpdating && checkPermission(gridDto.gridOptions.permissionDto.u))) ||
|
const hasUpdate =
|
||||||
(!(gridDto.gridOptions.editingOptionDto.allowDeleting && checkPermission(gridDto.gridOptions.permissionDto.d))) ||
|
gridDto.gridOptions.editingOptionDto.allowUpdating &&
|
||||||
gridDto.gridOptions.commandColumnDto.length == 0) {
|
checkPermission(gridDto.gridOptions.permissionDto.u)
|
||||||
|
|
||||||
|
const hasDelete =
|
||||||
|
gridDto.gridOptions.editingOptionDto.allowDeleting &&
|
||||||
|
checkPermission(gridDto.gridOptions.permissionDto.d)
|
||||||
|
|
||||||
|
const hasCommandButtons = gridDto.gridOptions.commandColumnDto.length > 0
|
||||||
|
|
||||||
|
// Eğer hiçbir buton eklenecek durumda değilse: çık
|
||||||
|
if (!hasUpdate && !hasDelete && !hasCommandButtons) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const column = {
|
const column = {
|
||||||
type: 'buttons',
|
type: 'buttons',
|
||||||
width: 'auto',
|
width: 'auto',
|
||||||
buttons: [] as any
|
buttons: [] as any,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gridDto.gridOptions.editingOptionDto.allowUpdating && checkPermission(gridDto.gridOptions.permissionDto.u)) {
|
if (hasUpdate) {
|
||||||
column.buttons.push('edit')
|
column.buttons.push('edit')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gridDto.gridOptions.editingOptionDto.allowDeleting && checkPermission(gridDto.gridOptions.permissionDto.d)) {
|
if (hasDelete) {
|
||||||
column.buttons.push('delete')
|
column.buttons.push('delete')
|
||||||
}
|
}
|
||||||
|
|
||||||
gridDto.gridOptions.commandColumnDto.forEach((action) => {
|
gridDto.gridOptions.commandColumnDto.forEach((action) => {
|
||||||
// action.buttonPosition == 0 ise CommandColumn butonudur, burada sadece CommandColumn butonunu eklenir
|
if (action.buttonPosition !== UiCommandButtonPositionTypeEnum.CommandColumn) return
|
||||||
if (action.buttonPosition !== UiCommandButtonPositionTypeEnum.CommandColumn) {
|
if (!checkPermission(action.authName)) return
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!checkPermission(action.authName)) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const item = {
|
const item = {
|
||||||
visible: true,
|
visible: true,
|
||||||
|
|
@ -304,21 +306,20 @@ const useListFormColumns = ({
|
||||||
text: translate('::' + action.text),
|
text: translate('::' + action.text),
|
||||||
onClick: (e: any) => {
|
onClick: (e: any) => {
|
||||||
if (typeof e.event?.preventDefault === 'function') {
|
if (typeof e.event?.preventDefault === 'function') {
|
||||||
e?.event?.preventDefault()
|
e.event.preventDefault()
|
||||||
}
|
}
|
||||||
if (action.url) {
|
|
||||||
let url = action.url?.replace('@LISTFORMCODE', listFormCode) // listFormCode özel bir parametredir, ayrica degistirilir
|
|
||||||
|
|
||||||
gridDto.columnFormats.forEach((field: ColumnFormatDto) => {
|
if (action.url) {
|
||||||
|
let url = action.url?.replace('@LISTFORMCODE', listFormCode)
|
||||||
|
gridDto.columnFormats.forEach((field) => {
|
||||||
if (field.fieldName) {
|
if (field.fieldName) {
|
||||||
url = url.replace(`@${field.fieldName}`, e.row.data[field.fieldName])
|
url = url.replace(`@${field.fieldName}`, e.row.data[field.fieldName])
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
window.open(url, isPwaMode ? '_self' : action.urlTarget)
|
window.open(url, isPwaMode ? '_self' : action.urlTarget)
|
||||||
} else if (action.dialogName) {
|
} else if (action.dialogName) {
|
||||||
if (action.dialogParameters) {
|
if (action.dialogParameters) {
|
||||||
var dynamicMap = JSON.parse(action.dialogParameters)
|
const dynamicMap = JSON.parse(action.dialogParameters)
|
||||||
for (const [key, value] of Object.entries<string>(dynamicMap)) {
|
for (const [key, value] of Object.entries<string>(dynamicMap)) {
|
||||||
dynamicMap[key] = value.startsWith('@') ? e.row.data[value.replace('@', '')] : value
|
dynamicMap[key] = value.startsWith('@') ? e.row.data[value.replace('@', '')] : value
|
||||||
}
|
}
|
||||||
|
|
@ -561,4 +562,3 @@ const useListFormColumns = ({
|
||||||
}
|
}
|
||||||
|
|
||||||
export { useListFormColumns }
|
export { useListFormColumns }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -181,16 +181,8 @@ const useGridData = (props: {
|
||||||
|
|
||||||
// Set js and css
|
// Set js and css
|
||||||
const grdOpt = gridDto.gridOptions
|
const grdOpt = gridDto.gridOptions
|
||||||
if (grdOpt.customJsSources.length) {
|
grdOpt.customJsSources.forEach(addJs)
|
||||||
for (const js of grdOpt.customJsSources) {
|
grdOpt.customStyleSources.forEach(addCss)
|
||||||
addJs(js)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (grdOpt.customStyleSources.length) {
|
|
||||||
for (const css of grdOpt.customStyleSources) {
|
|
||||||
addCss(css)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set columns
|
// Set columns
|
||||||
const cols = getBandedColumns()
|
const cols = getBandedColumns()
|
||||||
|
|
@ -263,7 +255,7 @@ const useGridData = (props: {
|
||||||
if (mode === 'view') {
|
if (mode === 'view') {
|
||||||
return a.canRead
|
return a.canRead
|
||||||
} else if (mode === 'new') {
|
} else if (mode === 'new') {
|
||||||
return a.canCreate || a.canCreate
|
return a.canCreate || a.canRead
|
||||||
} else if (mode === 'edit') {
|
} else if (mode === 'edit') {
|
||||||
return a.canUpdate || a.canRead
|
return a.canUpdate || a.canRead
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue