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>,
|
||||
) => {
|
||||
if (cellInfo?.value) {
|
||||
|
||||
const text = Array.isArray(cellInfo.value)
|
||||
? cellInfo.value
|
||||
.map((a: any) => {
|
||||
|
|
@ -95,7 +94,7 @@ const useListFormColumns = ({
|
|||
const dialog: any = useDialogContext()
|
||||
const { translate } = useLocalization()
|
||||
const { checkPermission } = usePermission()
|
||||
const isPwaMode = usePWA();
|
||||
const isPwaMode = usePWA()
|
||||
|
||||
const lookupDataSource = (options: any, colData: any, listFormCode: string) => {
|
||||
const { lookupDto } = colData
|
||||
|
|
@ -267,35 +266,38 @@ const useListFormColumns = ({
|
|||
return
|
||||
}
|
||||
|
||||
if ((!(gridDto.gridOptions.editingOptionDto.allowUpdating && checkPermission(gridDto.gridOptions.permissionDto.u))) ||
|
||||
(!(gridDto.gridOptions.editingOptionDto.allowDeleting && checkPermission(gridDto.gridOptions.permissionDto.d))) ||
|
||||
gridDto.gridOptions.commandColumnDto.length == 0) {
|
||||
return
|
||||
const hasUpdate =
|
||||
gridDto.gridOptions.editingOptionDto.allowUpdating &&
|
||||
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
|
||||
}
|
||||
|
||||
const column = {
|
||||
type: 'buttons',
|
||||
width: 'auto',
|
||||
buttons: [] as any
|
||||
buttons: [] as any,
|
||||
}
|
||||
|
||||
if (gridDto.gridOptions.editingOptionDto.allowUpdating && checkPermission(gridDto.gridOptions.permissionDto.u)) {
|
||||
if (hasUpdate) {
|
||||
column.buttons.push('edit')
|
||||
}
|
||||
|
||||
if (gridDto.gridOptions.editingOptionDto.allowDeleting && checkPermission(gridDto.gridOptions.permissionDto.d)) {
|
||||
if (hasDelete) {
|
||||
column.buttons.push('delete')
|
||||
}
|
||||
|
||||
gridDto.gridOptions.commandColumnDto.forEach((action) => {
|
||||
// action.buttonPosition == 0 ise CommandColumn butonudur, burada sadece CommandColumn butonunu eklenir
|
||||
if (action.buttonPosition !== UiCommandButtonPositionTypeEnum.CommandColumn) {
|
||||
return
|
||||
}
|
||||
|
||||
if (!checkPermission(action.authName)) {
|
||||
return
|
||||
}
|
||||
if (action.buttonPosition !== UiCommandButtonPositionTypeEnum.CommandColumn) return
|
||||
if (!checkPermission(action.authName)) return
|
||||
|
||||
const item = {
|
||||
visible: true,
|
||||
|
|
@ -304,21 +306,20 @@ const useListFormColumns = ({
|
|||
text: translate('::' + action.text),
|
||||
onClick: (e: any) => {
|
||||
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) {
|
||||
url = url.replace(`@${field.fieldName}`, e.row.data[field.fieldName])
|
||||
}
|
||||
})
|
||||
|
||||
window.open(url, isPwaMode ? '_self' : action.urlTarget)
|
||||
} else if (action.dialogName) {
|
||||
if (action.dialogParameters) {
|
||||
var dynamicMap = JSON.parse(action.dialogParameters)
|
||||
const dynamicMap = JSON.parse(action.dialogParameters)
|
||||
for (const [key, value] of Object.entries<string>(dynamicMap)) {
|
||||
dynamicMap[key] = value.startsWith('@') ? e.row.data[value.replace('@', '')] : value
|
||||
}
|
||||
|
|
@ -561,4 +562,3 @@ const useListFormColumns = ({
|
|||
}
|
||||
|
||||
export { useListFormColumns }
|
||||
|
||||
|
|
|
|||
|
|
@ -181,16 +181,8 @@ const useGridData = (props: {
|
|||
|
||||
// Set js and css
|
||||
const grdOpt = gridDto.gridOptions
|
||||
if (grdOpt.customJsSources.length) {
|
||||
for (const js of grdOpt.customJsSources) {
|
||||
addJs(js)
|
||||
}
|
||||
}
|
||||
if (grdOpt.customStyleSources.length) {
|
||||
for (const css of grdOpt.customStyleSources) {
|
||||
addCss(css)
|
||||
}
|
||||
}
|
||||
grdOpt.customJsSources.forEach(addJs)
|
||||
grdOpt.customStyleSources.forEach(addCss)
|
||||
|
||||
// Set columns
|
||||
const cols = getBandedColumns()
|
||||
|
|
@ -263,7 +255,7 @@ const useGridData = (props: {
|
|||
if (mode === 'view') {
|
||||
return a.canRead
|
||||
} else if (mode === 'new') {
|
||||
return a.canCreate || a.canCreate
|
||||
return a.canCreate || a.canRead
|
||||
} else if (mode === 'edit') {
|
||||
return a.canUpdate || a.canRead
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue