Allow Updating -> Allow Editing ve Allow Detail eklendi.
This commit is contained in:
parent
b43fb07e5b
commit
758d87c983
16 changed files with 282 additions and 216 deletions
|
|
@ -13,7 +13,8 @@ public class GridEditingDto
|
|||
/// <summary>Accepted Values: 'full' | 'reshape' | 'repaint'
|
||||
/// </summary>
|
||||
public string RefreshMode { get; set; } = "full";
|
||||
public bool AllowUpdating { get; set; } = false;
|
||||
public bool AllowEditing { get; set; } = false;
|
||||
public bool AllowDetail { get; set; } = false;
|
||||
public bool AllowDeleting { get; set; } = false;
|
||||
public bool AllowAllDeleting { get; set; } = false;
|
||||
public bool AllowAdding { get; set; } = false;
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ public class SchedulerOptionDto
|
|||
/// <summary>
|
||||
/// Etkinlik güncellemeye izin verilip verilmediğini belirtir
|
||||
/// </summary>
|
||||
public bool AllowUpdating { get; set; } = false;
|
||||
public bool AllowEditing { get; set; } = false;
|
||||
/// <summary>
|
||||
/// Etkinlik eklemeye izin verilip verilmediğini belirtir
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -3998,10 +3998,16 @@
|
|||
},
|
||||
{
|
||||
"resourceName": "Platform",
|
||||
"key": "ListForms.ListFormEdit.EditingAllowUpdating",
|
||||
"key": "ListForms.ListFormEdit.EditingAllowEditing",
|
||||
"en": "Allow Editing",
|
||||
"tr": "Güncellemeye İzin Ver"
|
||||
},
|
||||
{
|
||||
"resourceName": "Platform",
|
||||
"key": "ListForms.ListFormEdit.EditingAllowDetail",
|
||||
"en": "Allow Detail",
|
||||
"tr": "Detaya İzin Ver"
|
||||
},
|
||||
{
|
||||
"resourceName": "Platform",
|
||||
"key": "ListForms.ListFormEdit.EditingAllowDeleting",
|
||||
|
|
@ -10118,9 +10124,9 @@
|
|||
},
|
||||
{
|
||||
"resourceName": "Platform",
|
||||
"key": "ListForms.SchedulerOptions.AllowUpdating",
|
||||
"key": "ListForms.SchedulerOptions.AllowEditing",
|
||||
"tr": "Güncellemeye İzin Ver",
|
||||
"en": "Allow Updating"
|
||||
"en": "Allow Editing"
|
||||
},
|
||||
{
|
||||
"resourceName": "Platform",
|
||||
|
|
@ -10200,6 +10206,12 @@
|
|||
"tr": "Düzenle",
|
||||
"en": "Edit"
|
||||
},
|
||||
{
|
||||
"resourceName": "Platform",
|
||||
"key": "App.Platform.Detail",
|
||||
"tr": "Detay",
|
||||
"en": "Detail"
|
||||
},
|
||||
{
|
||||
"resourceName": "Platform",
|
||||
"key": "App.Platform.Delete",
|
||||
|
|
|
|||
|
|
@ -1153,8 +1153,8 @@ public class ListFormSeeder_Crm : IDataSeedContributor, ITransientDependency
|
|||
{
|
||||
Order = 3, Caption="Supply Card", ColCount = 3, ColSpan = 2, ItemType = "group", Items =
|
||||
[
|
||||
new EditingFormItemDto { Order = 22, DataField = "CustomerTypeId", ColSpan = 1, EditorType2 = EditorTypes.dxSelectBox, EditorOptions=EditorOptionValues.ShowClearButton },
|
||||
new EditingFormItemDto { Order = 23, DataField = "CustomerSegmentId", ColSpan = 1, EditorType2 = EditorTypes.dxSelectBox, EditorOptions=EditorOptionValues.ShowClearButton },
|
||||
new EditingFormItemDto { Order = 22, DataField = "CustomerTypeId", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxSelectBox, EditorOptions=EditorOptionValues.ShowClearButton },
|
||||
new EditingFormItemDto { Order = 23, DataField = "CustomerSegmentId", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxSelectBox, EditorOptions=EditorOptionValues.ShowClearButton },
|
||||
new EditingFormItemDto { Order = 24, DataField = "EmployeeId", ColSpan = 1, EditorType2 = EditorTypes.dxSelectBox, EditorOptions=EditorOptionValues.ShowClearButton },
|
||||
new EditingFormItemDto { Order = 25, DataField = "TeamCode", ColSpan = 1, EditorType2 = EditorTypes.dxSelectBox, EditorOptions=EditorOptionValues.ShowClearButton },
|
||||
new EditingFormItemDto { Order = 26, DataField = "TotalRevenue", ColSpan = 1, EditorType2 = EditorTypes.dxNumberBox, EditorOptions=EditorOptionValues.NumberStandartFormat() },
|
||||
|
|
@ -3321,7 +3321,7 @@ public class ListFormSeeder_Crm : IDataSeedContributor, ITransientDependency
|
|||
new EditingFormItemDto { Order = 10, DataField="ExchangeRate", ColSpan = 1, EditorType2 = EditorTypes.dxNumberBox, EditorOptions = EditorOptionValues.NumberStandartFormat() },
|
||||
new EditingFormItemDto { Order = 11, DataField="DiscountRate", ColSpan = 1, EditorType2 = EditorTypes.dxNumberBox, EditorOptions = EditorOptionValues.NumberStandartFormat() },
|
||||
new EditingFormItemDto { Order = 12, DataField="TaxRate", ColSpan = 1, EditorType2 = EditorTypes.dxNumberBox, EditorOptions = EditorOptionValues.NumberStandartFormat() },
|
||||
new EditingFormItemDto { Order = 13, DataField="SpecialInstructions", ColSpan = 2, EditorType2 = EditorTypes.dxTextArea },
|
||||
new EditingFormItemDto { Order = 13, DataField="SpecialInstructions", ColSpan = 2, EditorType2 = EditorTypes.dxTextBox },
|
||||
new EditingFormItemDto { Order = 14, DataField="Notes", ColSpan = 2, EditorType2 = EditorTypes.dxTextArea },
|
||||
]}
|
||||
}),
|
||||
|
|
@ -3336,8 +3336,8 @@ public class ListFormSeeder_Crm : IDataSeedContributor, ITransientDependency
|
|||
}),
|
||||
CommandColumnJson = JsonSerializer.Serialize(new CommandColumnDto[] {
|
||||
new() {
|
||||
Hint = "Manage",
|
||||
Text ="Manage",
|
||||
Hint = "Items",
|
||||
Text ="Items",
|
||||
UrlTarget="_blank",
|
||||
AuthName = listFormName,
|
||||
Url=$"/admin/form/{SeederUtils.GetDefaultFormCodes(listFormName)}/@Id",
|
||||
|
|
|
|||
|
|
@ -2859,7 +2859,7 @@ public class ListFormSeeder_Maintenance : IDataSeedContributor, ITransientDepend
|
|||
AllowResizing = true,
|
||||
AllowDragging = true,
|
||||
AllowDeleting = true,
|
||||
AllowUpdating = true,
|
||||
AllowEditing = true,
|
||||
AllowAdding = true,
|
||||
}),
|
||||
CultureName = LanguageCodes.En,
|
||||
|
|
|
|||
|
|
@ -35,16 +35,18 @@ public static class SeederDefaults
|
|||
int Height,
|
||||
bool AllowDeleting,
|
||||
bool AllowAdding,
|
||||
bool AllowUpdating,
|
||||
bool AllowEditing,
|
||||
bool ConfirmDelete,
|
||||
bool SendOnlyChangedFormValuesUpdate) => JsonSerializer.Serialize(new GridEditingDto
|
||||
bool SendOnlyChangedFormValuesUpdate,
|
||||
bool AllowDetail = false) => JsonSerializer.Serialize(new GridEditingDto
|
||||
{
|
||||
Popup = new GridEditingPopupDto() { Title = Title, Width = Width, Height = Height },
|
||||
AllowDeleting = AllowDeleting,
|
||||
AllowAdding = AllowAdding,
|
||||
AllowUpdating = AllowUpdating,
|
||||
AllowEditing = AllowEditing,
|
||||
ConfirmDelete = ConfirmDelete,
|
||||
SendOnlyChangedFormValuesUpdate = SendOnlyChangedFormValuesUpdate
|
||||
SendOnlyChangedFormValuesUpdate = SendOnlyChangedFormValuesUpdate,
|
||||
AllowDetail = AllowDetail
|
||||
});
|
||||
|
||||
public static readonly string DefaultFilterJson = "\"IsDeleted\" = 'false'";
|
||||
|
|
|
|||
|
|
@ -429,7 +429,7 @@ export interface SchedulerOptionDto {
|
|||
allowResizing?: boolean
|
||||
allowDragging?: boolean
|
||||
allowDeleting?: boolean
|
||||
allowUpdating?: boolean
|
||||
allowEditing?: boolean
|
||||
allowAdding?: boolean
|
||||
resources?: SchedulerResourceDto[]
|
||||
}
|
||||
|
|
@ -444,7 +444,8 @@ export interface SchedulerResourceDto {
|
|||
export interface GridEditingDto {
|
||||
mode?: GridsEditMode
|
||||
refreshMode?: GridsEditRefreshMode
|
||||
allowUpdating: boolean
|
||||
allowEditing: boolean
|
||||
allowDetail: boolean
|
||||
allowDeleting: boolean
|
||||
allowAllDeleting: boolean
|
||||
allowAdding: boolean
|
||||
|
|
|
|||
|
|
@ -55,18 +55,33 @@ function FormTabEdit(props: FormEditProps & { listFormCode: string }) {
|
|||
/>
|
||||
</FormItem>
|
||||
<FormItem
|
||||
label={translate('::ListForms.ListFormEdit.EditingAllowUpdating')}
|
||||
label={translate('::ListForms.ListFormEdit.EditingAllowEditing')}
|
||||
invalid={
|
||||
errors.editingOptionDto?.allowUpdating && touched.editingOptionDto?.allowUpdating
|
||||
errors.editingOptionDto?.allowEditing && touched.editingOptionDto?.allowEditing
|
||||
}
|
||||
errorMessage={errors.editingOptionDto?.allowUpdating}
|
||||
errorMessage={errors.editingOptionDto?.allowEditing}
|
||||
>
|
||||
<Field
|
||||
name="editingOptionDto.allowUpdating"
|
||||
placeholder={translate('::ListForms.ListFormEdit.EditingAllowUpdating')}
|
||||
name="editingOptionDto.allowEditing"
|
||||
placeholder={translate('::ListForms.ListFormEdit.EditingAllowEditing')}
|
||||
component={Checkbox}
|
||||
/>
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
label={translate('::ListForms.ListFormEdit.EditingAllowDetail')}
|
||||
invalid={
|
||||
errors.editingOptionDto?.allowDetail && touched.editingOptionDto?.allowDetail
|
||||
}
|
||||
errorMessage={errors.editingOptionDto?.allowDetail}
|
||||
>
|
||||
<Field
|
||||
name="editingOptionDto.allowDetail"
|
||||
placeholder={translate('::ListForms.ListFormEdit.EditingAllowDetail')}
|
||||
component={Checkbox}
|
||||
/>
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
label={translate('::ListForms.ListFormEdit.EditingAllowDeleting')}
|
||||
invalid={
|
||||
|
|
|
|||
|
|
@ -354,8 +354,8 @@ function FormTabScheduler(props: FormEditProps) {
|
|||
<Field name="schedulerOptionDto.allowAdding" component={Checkbox} />
|
||||
</FormItem>
|
||||
|
||||
<FormItem label={translate('::ListForms.SchedulerOptions.AllowUpdating')}>
|
||||
<Field name="schedulerOptionDto.allowUpdating" component={Checkbox} />
|
||||
<FormItem label={translate('::ListForms.SchedulerOptions.AllowEditing')}>
|
||||
<Field name="schedulerOptionDto.allowEditing" component={Checkbox} />
|
||||
</FormItem>
|
||||
|
||||
<FormItem label={translate('::ListForms.SchedulerOptions.AllowDeleting')}>
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ function FormFieldTabOptions({
|
|||
>
|
||||
<Field name="visible" component={Checkbox} />
|
||||
</FormItem>
|
||||
<FormItem label={translate('::ListForms.ListFormEdit.EditingAllowUpdating')}>
|
||||
<FormItem label={translate('::ListForms.ListFormEdit.EditingAllowEditing')}>
|
||||
<Field name="columnEditingDto.allowEditing" component={Checkbox} />
|
||||
</FormItem>
|
||||
<FormItem label={translate('::ListForms.ListFormFieldEdit.HeaderingAllowSearch')}>
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ const useGridData = (props: {
|
|||
checkPermission(gridDto?.gridOptions.permissionDto.c),
|
||||
r: checkPermission(gridDto?.gridOptions.permissionDto.r),
|
||||
u:
|
||||
gridDto?.gridOptions.editingOptionDto.allowUpdating === true &&
|
||||
gridDto?.gridOptions.editingOptionDto.allowEditing === true &&
|
||||
checkPermission(gridDto?.gridOptions.permissionDto.u),
|
||||
d:
|
||||
gridDto?.gridOptions.editingOptionDto.allowDeleting === true &&
|
||||
|
|
|
|||
|
|
@ -1151,7 +1151,7 @@ const Grid = (props: GridProps) => {
|
|||
refreshMode={gridDto.gridOptions.editingOptionDto?.refreshMode}
|
||||
mode={smaller.md ? 'form' : gridDto.gridOptions.editingOptionDto?.mode}
|
||||
allowDeleting={gridDto.gridOptions.editingOptionDto?.allowDeleting}
|
||||
allowUpdating={gridDto.gridOptions.editingOptionDto?.allowUpdating}
|
||||
allowUpdating={gridDto.gridOptions.editingOptionDto?.allowEditing}
|
||||
allowAdding={gridDto.gridOptions.editingOptionDto?.allowAdding}
|
||||
useIcons={gridDto.gridOptions.editingOptionDto?.useIcons}
|
||||
confirmDelete={gridDto.gridOptions.editingOptionDto?.confirmDelete}
|
||||
|
|
|
|||
|
|
@ -615,7 +615,7 @@ const SchedulerView = (props: SchedulerViewProps) => {
|
|||
|
||||
<Editing
|
||||
allowAdding={gridDto.gridOptions.schedulerOptionDto?.allowAdding ?? false}
|
||||
allowUpdating={gridDto.gridOptions.schedulerOptionDto?.allowUpdating ?? false}
|
||||
allowUpdating={gridDto.gridOptions.schedulerOptionDto?.allowEditing ?? false}
|
||||
allowDeleting={gridDto.gridOptions.schedulerOptionDto?.allowDeleting ?? false}
|
||||
allowResizing={gridDto.gridOptions.schedulerOptionDto?.allowResizing ?? false}
|
||||
allowDragging={gridDto.gridOptions.schedulerOptionDto?.allowDragging ?? false}
|
||||
|
|
|
|||
|
|
@ -865,7 +865,7 @@ const Tree = (props: TreeProps) => {
|
|||
refreshMode={gridDto.gridOptions.editingOptionDto?.refreshMode}
|
||||
mode={smaller.md ? 'form' : gridDto.gridOptions.editingOptionDto?.mode}
|
||||
allowDeleting={gridDto.gridOptions.editingOptionDto?.allowDeleting}
|
||||
allowUpdating={gridDto.gridOptions.editingOptionDto?.allowUpdating}
|
||||
allowUpdating={gridDto.gridOptions.editingOptionDto?.allowEditing}
|
||||
allowAdding={gridDto.gridOptions.editingOptionDto?.allowAdding}
|
||||
useIcons={gridDto.gridOptions.editingOptionDto?.useIcons}
|
||||
confirmDelete={gridDto.gridOptions.editingOptionDto?.confirmDelete}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import { usePWA } from '@/utils/hooks/usePWA'
|
|||
import { useDialogContext } from '../shared/DialogContext'
|
||||
import { dynamicFetch } from '@/services/form.service'
|
||||
import { GridColumnData } from './GridColumnData'
|
||||
import { useLocation } from 'react-router-dom'
|
||||
import {
|
||||
ColumnFormatDto,
|
||||
EditingFormItemDto,
|
||||
|
|
@ -113,19 +114,20 @@ const MAX_CACHE_SIZE = 100 // Maksimum cache entry sayısı
|
|||
const cachedLoader = (key: string, loader: () => Promise<any[]>) => {
|
||||
const now = Date.now()
|
||||
const cached = __lookupCache.get(key)
|
||||
|
||||
|
||||
// Cache'de var ve süresi dolmamışsa kullan
|
||||
if (cached && (now - cached.timestamp) < CACHE_DURATION) {
|
||||
if (cached && now - cached.timestamp < CACHE_DURATION) {
|
||||
return cached.promise
|
||||
}
|
||||
|
||||
|
||||
// Cache boyutu limitini aşarsa en eskiyi temizle
|
||||
if (__lookupCache.size >= MAX_CACHE_SIZE) {
|
||||
const oldestKey = Array.from(__lookupCache.entries())
|
||||
.sort((a, b) => a[1].timestamp - b[1].timestamp)[0][0]
|
||||
const oldestKey = Array.from(__lookupCache.entries()).sort(
|
||||
(a, b) => a[1].timestamp - b[1].timestamp,
|
||||
)[0][0]
|
||||
__lookupCache.delete(oldestKey)
|
||||
}
|
||||
|
||||
|
||||
const p = Promise.resolve()
|
||||
.then(() => loader())
|
||||
.then((res) => res ?? [])
|
||||
|
|
@ -133,7 +135,7 @@ const cachedLoader = (key: string, loader: () => Promise<any[]>) => {
|
|||
__lookupCache.delete(key) // hata olursa tekrar denenebilsin
|
||||
throw err
|
||||
})
|
||||
|
||||
|
||||
__lookupCache.set(key, { promise: p, timestamp: now })
|
||||
return p
|
||||
}
|
||||
|
|
@ -153,55 +155,59 @@ const useListFormColumns = ({
|
|||
const { translate } = useLocalization()
|
||||
const { checkPermission } = usePermission()
|
||||
const isPwaMode = usePWA()
|
||||
const location = useLocation()
|
||||
|
||||
useEffect(() => {
|
||||
// listFormCode değişince lookup cache temizlensin (farklı form farklı lookuplar)
|
||||
__lookupCache.clear()
|
||||
}, [listFormCode])
|
||||
|
||||
const lookupDataSource = useCallback((options: any, colData: any, listFormCode: string) => {
|
||||
const { lookupDto } = colData
|
||||
const filters = []
|
||||
if (lookupDto.cascadeParentFields) {
|
||||
if (lookupDto.dataSourceType == UiLookupDataSourceTypeEnum.StaticData) {
|
||||
filters.push([
|
||||
lookupDto?.cascadeRelationField,
|
||||
lookupDto?.cascadeFilterOperator,
|
||||
options?.data[lookupDto?.cascadeParentField],
|
||||
])
|
||||
//TODO: Statik data test edilecek
|
||||
} else {
|
||||
const data = options?.data ?? options
|
||||
for (const cascadeParentField of lookupDto.cascadeParentFields.split(',')) {
|
||||
filters.push(data[cascadeParentField])
|
||||
const lookupDataSource = useCallback(
|
||||
(options: any, colData: any, listFormCode: string) => {
|
||||
const { lookupDto } = colData
|
||||
const filters = []
|
||||
if (lookupDto.cascadeParentFields) {
|
||||
if (lookupDto.dataSourceType == UiLookupDataSourceTypeEnum.StaticData) {
|
||||
filters.push([
|
||||
lookupDto?.cascadeRelationField,
|
||||
lookupDto?.cascadeFilterOperator,
|
||||
options?.data[lookupDto?.cascadeParentField],
|
||||
])
|
||||
//TODO: Statik data test edilecek
|
||||
} else {
|
||||
const data = options?.data ?? options
|
||||
for (const cascadeParentField of lookupDto.cascadeParentFields.split(',')) {
|
||||
filters.push(data[cascadeParentField])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//UiLookupDataSourceTypeEnum :
|
||||
// Data = 1 (Statik Data),
|
||||
// Query = 2 (API'den geliyor fakat API query çalıştırıyor)
|
||||
// WebService = 3 (API servisten geliyor)
|
||||
if (lookupDto.dataSourceType == UiLookupDataSourceTypeEnum.StaticData) {
|
||||
return createLookupStaticDataSource(
|
||||
() => JSON.parse(lookupDto?.lookupQuery),
|
||||
filters.length ? filters : null,
|
||||
`static:${listFormCode}:${colData.fieldName}`, // cache key
|
||||
)
|
||||
} else if (lookupDto.dataSourceType == UiLookupDataSourceTypeEnum.Query) {
|
||||
return createLookupQueryDataSource(listFormCode, colData.fieldName, filters)
|
||||
} else if (lookupDto.dataSourceType == UiLookupDataSourceTypeEnum.WebService) {
|
||||
return createLookupApiDataSource(
|
||||
listFormCode,
|
||||
lookupDto?.lookupQuery,
|
||||
filters,
|
||||
colData.lookupDto?.valueExpr?.toLowerCase(),
|
||||
)
|
||||
} else {
|
||||
return {
|
||||
store: [],
|
||||
//UiLookupDataSourceTypeEnum :
|
||||
// Data = 1 (Statik Data),
|
||||
// Query = 2 (API'den geliyor fakat API query çalıştırıyor)
|
||||
// WebService = 3 (API servisten geliyor)
|
||||
if (lookupDto.dataSourceType == UiLookupDataSourceTypeEnum.StaticData) {
|
||||
return createLookupStaticDataSource(
|
||||
() => JSON.parse(lookupDto?.lookupQuery),
|
||||
filters.length ? filters : null,
|
||||
`static:${listFormCode}:${colData.fieldName}`, // cache key
|
||||
)
|
||||
} else if (lookupDto.dataSourceType == UiLookupDataSourceTypeEnum.Query) {
|
||||
return createLookupQueryDataSource(listFormCode, colData.fieldName, filters)
|
||||
} else if (lookupDto.dataSourceType == UiLookupDataSourceTypeEnum.WebService) {
|
||||
return createLookupApiDataSource(
|
||||
listFormCode,
|
||||
lookupDto?.lookupQuery,
|
||||
filters,
|
||||
colData.lookupDto?.valueExpr?.toLowerCase(),
|
||||
)
|
||||
} else {
|
||||
return {
|
||||
store: [],
|
||||
}
|
||||
}
|
||||
}
|
||||
}, [listFormCode])
|
||||
},
|
||||
[listFormCode],
|
||||
)
|
||||
|
||||
const createLookupStaticDataSource = (
|
||||
load: () => any,
|
||||
|
|
@ -247,7 +253,7 @@ const useListFormColumns = ({
|
|||
name: a.Name,
|
||||
group: a.Group,
|
||||
|
||||
...a
|
||||
...a,
|
||||
}))
|
||||
})
|
||||
} catch (error: any) {
|
||||
|
|
@ -312,13 +318,17 @@ const useListFormColumns = ({
|
|||
}
|
||||
|
||||
const hasUpdate =
|
||||
gridDto.gridOptions.editingOptionDto.allowUpdating &&
|
||||
gridDto.gridOptions.editingOptionDto.allowEditing &&
|
||||
checkPermission(gridDto.gridOptions.permissionDto.u)
|
||||
|
||||
const hasDelete =
|
||||
gridDto.gridOptions.editingOptionDto.allowDeleting &&
|
||||
checkPermission(gridDto.gridOptions.permissionDto.d)
|
||||
|
||||
const hasDetail =
|
||||
gridDto.gridOptions.editingOptionDto.allowDetail &&
|
||||
checkPermission(gridDto.gridOptions.permissionDto.u)
|
||||
|
||||
const hasCommandButtons = gridDto.gridOptions.commandColumnDto.length > 0
|
||||
|
||||
// Eğer hiçbir buton eklenecek durumda değilse: çık
|
||||
|
|
@ -328,17 +338,39 @@ const useListFormColumns = ({
|
|||
|
||||
const buttons: any[] = []
|
||||
|
||||
if (hasDetail) {
|
||||
const item = {
|
||||
name: 'detail',
|
||||
text: translate('::App.Platform.Detail'),
|
||||
onClick: (e: any) => {
|
||||
if (typeof e.event?.preventDefault === 'function') {
|
||||
e.event.preventDefault()
|
||||
}
|
||||
|
||||
if (!gridDto.gridOptions.keyFieldName) return
|
||||
|
||||
const url =
|
||||
location.pathname?.replace('/list/', '/form/') +
|
||||
`/${e.row.data[gridDto.gridOptions.keyFieldName]}`
|
||||
|
||||
window.open(url, isPwaMode ? '_self' : '_blank')
|
||||
},
|
||||
}
|
||||
|
||||
buttons.push(item)
|
||||
}
|
||||
|
||||
if (hasUpdate) {
|
||||
buttons.push({
|
||||
name: 'edit',
|
||||
text: translate('::App.Platform.Edit')
|
||||
text: translate('::App.Platform.Edit'),
|
||||
})
|
||||
}
|
||||
|
||||
if (hasDelete) {
|
||||
buttons.push({
|
||||
name: 'delete',
|
||||
text: translate('::App.Platform.Delete')
|
||||
text: translate('::App.Platform.Delete'),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -418,156 +450,159 @@ const useListFormColumns = ({
|
|||
return column as GridColumnData
|
||||
}, [gridDto, checkPermission, translate, listFormCode, isPwaMode, dialog, gridRef])
|
||||
|
||||
const getColumns = useCallback((columnFormats: ColumnFormatDto[]) => {
|
||||
const columns: GridColumnData[] = []
|
||||
const getColumns = useCallback(
|
||||
(columnFormats: ColumnFormatDto[]) => {
|
||||
const columns: GridColumnData[] = []
|
||||
|
||||
if (!gridDto || !columnFormats) {
|
||||
return columns
|
||||
}
|
||||
columnFormats.forEach((colData) => {
|
||||
if (!colData.canRead || !colData.isActive) {
|
||||
return
|
||||
if (!gridDto || !columnFormats) {
|
||||
return columns
|
||||
}
|
||||
const column: GridColumnData = {}
|
||||
column.colData = colData // Onemli: Baska event-callback lerde kullanmak icin eklendi, colData.lookupDto?.editorTemplateType
|
||||
//column.showEditorAlways = true
|
||||
column.dataField = colData.fieldName
|
||||
if (colData.dataType) column.dataType = colData.dataType as DataType
|
||||
if (colData.captionName) column.caption = translate('::' + colData.captionName)
|
||||
if (colData.width > 0) column.width = colData.width
|
||||
column.visible = colData.visible
|
||||
|
||||
column.alignment = colData.alignment
|
||||
column.format = colData.format
|
||||
|
||||
let editorOptions: any = {}
|
||||
if (colData.editorOptions) {
|
||||
try {
|
||||
editorOptions =
|
||||
typeof colData.editorOptions === 'string'
|
||||
? JSON.parse(colData.editorOptions)
|
||||
: colData.editorOptions
|
||||
} catch {
|
||||
editorOptions = {}
|
||||
columnFormats.forEach((colData) => {
|
||||
if (!colData.canRead || !colData.isActive) {
|
||||
return
|
||||
}
|
||||
}
|
||||
const column: GridColumnData = {}
|
||||
column.colData = colData // Onemli: Baska event-callback lerde kullanmak icin eklendi, colData.lookupDto?.editorTemplateType
|
||||
//column.showEditorAlways = true
|
||||
column.dataField = colData.fieldName
|
||||
if (colData.dataType) column.dataType = colData.dataType as DataType
|
||||
if (colData.captionName) column.caption = translate('::' + colData.captionName)
|
||||
if (colData.width > 0) column.width = colData.width
|
||||
column.visible = colData.visible
|
||||
|
||||
column.editorOptions = { ...editorOptions }
|
||||
column.alignment = colData.alignment
|
||||
column.format = colData.format
|
||||
|
||||
// Format bilgisini öncelik sırasına göre ata
|
||||
if (column.editorOptions.displayFormat) {
|
||||
column.format = column.editorOptions.displayFormat
|
||||
} else if (column.editorOptions.format) {
|
||||
column.format = column.editorOptions.format
|
||||
}
|
||||
|
||||
// columnCustomizationDto
|
||||
column.fixed = colData.columnCustomizationDto?.fixed
|
||||
column.fixedPosition = colData.columnCustomizationDto?.fixedPosition as HorizontalEdge
|
||||
column.allowReordering = colData.columnCustomizationDto?.allowReordering
|
||||
|
||||
// sort
|
||||
if (colData.sortIndex >= 0) {
|
||||
column.sortIndex = colData.sortIndex
|
||||
column.sortOrder = colData.sortDirection as SortOrder
|
||||
}
|
||||
|
||||
// filterRow
|
||||
column.allowFiltering = colData.columnFilterDto?.allowFiltering
|
||||
column.selectedFilterOperation = colData.columnFilterDto
|
||||
?.selectedFilterOperation as SelectedFilterOperation
|
||||
column.filterValue = colData.columnFilterDto?.filterValue
|
||||
|
||||
// headerFilter
|
||||
column.allowHeaderFiltering = colData.columnHeaderDto?.allowHeaderFiltering
|
||||
if (column.allowHeaderFiltering == true) {
|
||||
column.headerFilter = {}
|
||||
column.headerFilter.allowSearch = colData.columnHeaderDto?.allowSearch
|
||||
column.headerFilter.dataSource = colData.columnHeaderDto?.dataSource
|
||||
}
|
||||
|
||||
// search
|
||||
column.allowSearch = colData.allowSearch
|
||||
|
||||
//export
|
||||
column.allowExporting = colData.canExport
|
||||
|
||||
// grouping
|
||||
column.allowGrouping = colData.columnGroupingDto?.allowGrouping
|
||||
column.autoExpandGroup = colData.columnGroupingDto?.autoExpandGroup
|
||||
if (colData.columnGroupingDto.groupIndex)
|
||||
column.groupIndex = colData.columnGroupingDto?.groupIndex
|
||||
|
||||
// constsa dinamik olarak css verilerini ekle
|
||||
if (colData.columnCssClass) {
|
||||
column.cssClass = colData.columnCssClass
|
||||
if (colData.columnCssValue) {
|
||||
addCss(colData.columnCssValue)
|
||||
let editorOptions: any = {}
|
||||
if (colData.editorOptions) {
|
||||
try {
|
||||
editorOptions =
|
||||
typeof colData.editorOptions === 'string'
|
||||
? JSON.parse(colData.editorOptions)
|
||||
: colData.editorOptions
|
||||
} catch {
|
||||
editorOptions = {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
column.allowEditing = colData.columnEditingDto?.allowEditing
|
||||
column.editorOptions = { ...editorOptions }
|
||||
|
||||
// #region lookup ayarlari
|
||||
if (colData.lookupDto?.dataSourceType) {
|
||||
// UiColumnEditorTemplateTypeEnum : None:0, Table:1, TagBox:2
|
||||
const allItems = gridDto.gridOptions.editingFormDto.flatMap((group) => group.items)
|
||||
const formItem = allItems.find((a) => a?.dataField === colData.fieldName)
|
||||
if (formItem?.editorType2 === PlatformEditorTypes.dxTagBox) {
|
||||
column.extras = {
|
||||
multiValue: true,
|
||||
editorOptions: formItem.editorOptions,
|
||||
tagBoxOptions: formItem.tagBoxOptions,
|
||||
// Format bilgisini öncelik sırasına göre ata
|
||||
if (column.editorOptions.displayFormat) {
|
||||
column.format = column.editorOptions.displayFormat
|
||||
} else if (column.editorOptions.format) {
|
||||
column.format = column.editorOptions.format
|
||||
}
|
||||
|
||||
// columnCustomizationDto
|
||||
column.fixed = colData.columnCustomizationDto?.fixed
|
||||
column.fixedPosition = colData.columnCustomizationDto?.fixedPosition as HorizontalEdge
|
||||
column.allowReordering = colData.columnCustomizationDto?.allowReordering
|
||||
|
||||
// sort
|
||||
if (colData.sortIndex >= 0) {
|
||||
column.sortIndex = colData.sortIndex
|
||||
column.sortOrder = colData.sortDirection as SortOrder
|
||||
}
|
||||
|
||||
// filterRow
|
||||
column.allowFiltering = colData.columnFilterDto?.allowFiltering
|
||||
column.selectedFilterOperation = colData.columnFilterDto
|
||||
?.selectedFilterOperation as SelectedFilterOperation
|
||||
column.filterValue = colData.columnFilterDto?.filterValue
|
||||
|
||||
// headerFilter
|
||||
column.allowHeaderFiltering = colData.columnHeaderDto?.allowHeaderFiltering
|
||||
if (column.allowHeaderFiltering == true) {
|
||||
column.headerFilter = {}
|
||||
column.headerFilter.allowSearch = colData.columnHeaderDto?.allowSearch
|
||||
column.headerFilter.dataSource = colData.columnHeaderDto?.dataSource
|
||||
}
|
||||
|
||||
// search
|
||||
column.allowSearch = colData.allowSearch
|
||||
|
||||
//export
|
||||
column.allowExporting = colData.canExport
|
||||
|
||||
// grouping
|
||||
column.allowGrouping = colData.columnGroupingDto?.allowGrouping
|
||||
column.autoExpandGroup = colData.columnGroupingDto?.autoExpandGroup
|
||||
if (colData.columnGroupingDto.groupIndex)
|
||||
column.groupIndex = colData.columnGroupingDto?.groupIndex
|
||||
|
||||
// constsa dinamik olarak css verilerini ekle
|
||||
if (colData.columnCssClass) {
|
||||
column.cssClass = colData.columnCssClass
|
||||
if (colData.columnCssValue) {
|
||||
addCss(colData.columnCssValue)
|
||||
}
|
||||
column.editCellTemplate = 'cellEditTagBox'
|
||||
column.calculateFilterExpression = calculateFilterExpressionMultiValue
|
||||
column.cellTemplate = cellTemplateMultiValue
|
||||
} else if (formItem?.editorType2 === PlatformEditorTypes.dxGridBox) {
|
||||
column.extras = {
|
||||
multiValue: false,
|
||||
editorOptions: formItem.editorOptions,
|
||||
gridBoxOptions: formItem.gridBoxOptions,
|
||||
}
|
||||
column.editCellTemplate = 'cellEditGridBox'
|
||||
column.cellTemplate = cellTemplateMultiValue
|
||||
if (formItem.gridBoxOptions?.selectionMode === 'multiple') {
|
||||
}
|
||||
|
||||
column.allowEditing = colData.columnEditingDto?.allowEditing
|
||||
|
||||
// #region lookup ayarlari
|
||||
if (colData.lookupDto?.dataSourceType) {
|
||||
// UiColumnEditorTemplateTypeEnum : None:0, Table:1, TagBox:2
|
||||
const allItems = gridDto.gridOptions.editingFormDto.flatMap((group) => group.items)
|
||||
const formItem = allItems.find((a) => a?.dataField === colData.fieldName)
|
||||
if (formItem?.editorType2 === PlatformEditorTypes.dxTagBox) {
|
||||
column.extras = {
|
||||
multiValue: true,
|
||||
editorOptions: formItem.editorOptions,
|
||||
tagBoxOptions: formItem.tagBoxOptions,
|
||||
}
|
||||
column.editCellTemplate = 'cellEditTagBox'
|
||||
column.calculateFilterExpression = calculateFilterExpressionMultiValue
|
||||
column.extras.multiValue = true
|
||||
column.cellTemplate = cellTemplateMultiValue
|
||||
} else if (formItem?.editorType2 === PlatformEditorTypes.dxGridBox) {
|
||||
column.extras = {
|
||||
multiValue: false,
|
||||
editorOptions: formItem.editorOptions,
|
||||
gridBoxOptions: formItem.gridBoxOptions,
|
||||
}
|
||||
column.editCellTemplate = 'cellEditGridBox'
|
||||
column.cellTemplate = cellTemplateMultiValue
|
||||
if (formItem.gridBoxOptions?.selectionMode === 'multiple') {
|
||||
column.calculateFilterExpression = calculateFilterExpressionMultiValue
|
||||
column.extras.multiValue = true
|
||||
}
|
||||
}
|
||||
|
||||
column.lookup = {
|
||||
valueExpr: colData.lookupDto?.valueExpr?.toLowerCase(),
|
||||
displayExpr: colData.lookupDto?.displayExpr?.toLowerCase(),
|
||||
dataSource: (o) => lookupDataSource(o, colData, listFormCode),
|
||||
}
|
||||
//column.lookup.dataSource = lookupDataSource(null, colData)
|
||||
|
||||
//cascadeEmptyFields verisi dolu ise bu kolon/field bir parent field dir
|
||||
if (colData.lookupDto.cascadeEmptyFields) {
|
||||
// parent field guncellendigi zaman bu fonksiyon cagrilir
|
||||
column.setCellValue = function (rowData: any, value: any) {
|
||||
if (!colData.fieldName) return
|
||||
//console.log({ rowData, value, colData })
|
||||
rowData[colData.fieldName] = Array.isArray(value) ? value[0] : value
|
||||
// cascadeEmptyFields alani aralarinda virgul olacak sekilde bosaltilmak istenen alanlari saklar
|
||||
colData?.lookupDto?.cascadeEmptyFields?.split(',').forEach((emptyField: any) => {
|
||||
rowData[emptyField] = null
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
column.lookup = {
|
||||
valueExpr: colData.lookupDto?.valueExpr?.toLowerCase(),
|
||||
displayExpr: colData.lookupDto?.displayExpr?.toLowerCase(),
|
||||
dataSource: (o) => lookupDataSource(o, colData, listFormCode),
|
||||
// #endregion
|
||||
if (colData.validationRuleDto) {
|
||||
// for server side validation : https://js.devexpress.com/Demos/WidgetsGallery/Demo/DataGrid/DataValidation/jQuery/Light/
|
||||
column.validationRules = colData.validationRuleDto as ValidationRule[]
|
||||
}
|
||||
//column.lookup.dataSource = lookupDataSource(null, colData)
|
||||
|
||||
//cascadeEmptyFields verisi dolu ise bu kolon/field bir parent field dir
|
||||
if (colData.lookupDto.cascadeEmptyFields) {
|
||||
// parent field guncellendigi zaman bu fonksiyon cagrilir
|
||||
column.setCellValue = function (rowData: any, value: any) {
|
||||
if (!colData.fieldName) return
|
||||
//console.log({ rowData, value, colData })
|
||||
rowData[colData.fieldName] = Array.isArray(value) ? value[0] : value
|
||||
// cascadeEmptyFields alani aralarinda virgul olacak sekilde bosaltilmak istenen alanlari saklar
|
||||
colData?.lookupDto?.cascadeEmptyFields?.split(',').forEach((emptyField: any) => {
|
||||
rowData[emptyField] = null
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
// #endregion
|
||||
if (colData.validationRuleDto) {
|
||||
// for server side validation : https://js.devexpress.com/Demos/WidgetsGallery/Demo/DataGrid/DataValidation/jQuery/Light/
|
||||
column.validationRules = colData.validationRuleDto as ValidationRule[]
|
||||
}
|
||||
columns.push(column)
|
||||
})
|
||||
|
||||
columns.push(column)
|
||||
})
|
||||
|
||||
return columns
|
||||
}, [gridDto, lookupDataSource, translate, checkPermission, dialog, isPwaMode, listFormCode])
|
||||
return columns
|
||||
},
|
||||
[gridDto, lookupDataSource, translate, checkPermission, dialog, isPwaMode, listFormCode],
|
||||
)
|
||||
|
||||
const getBandedColumns = useCallback(() => {
|
||||
if (!gridDto) {
|
||||
|
|
|
|||
|
|
@ -312,7 +312,7 @@ const useToolbar = ({
|
|||
|
||||
// batch editing icin kaydet ve geri al butonu
|
||||
if (
|
||||
grdOpt.editingOptionDto?.allowUpdating &&
|
||||
grdOpt.editingOptionDto?.allowEditing &&
|
||||
grdOpt.editingOptionDto?.mode == 'batch' &&
|
||||
checkPermission(grdOpt.permissionDto?.u)
|
||||
) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue