diff --git a/ui/src/views/list/Grid.tsx b/ui/src/views/list/Grid.tsx index 60b7c266..f3cd8987 100644 --- a/ui/src/views/list/Grid.tsx +++ b/ui/src/views/list/Grid.tsx @@ -52,6 +52,7 @@ import GridFilterDialogs from './GridFilterDialogs' import { addCss, addJs, + autoNumber, controlStyleCondition, GridExtraFilterState, setFormEditingExtraItemValues, @@ -277,19 +278,10 @@ const Grid = (props: GridProps) => { // Grid'den gelen columnFormat'ları kullanarak default değerleri set et if (colFormat.defaultValue != null) { - if (typeof colFormat.defaultValue === 'string' && colFormat.defaultValue === '@AUTONUMBER') { - const now = new Date() - const pad = (n: number, width: number) => n.toString().padStart(width, '0') - - const autoNumber = - `${now.getFullYear()}` + - `${pad(now.getMonth() + 1, 2)}` + - `${pad(now.getDate(), 2)}` + - `${pad(now.getHours(), 2)}` + - `${pad(now.getMinutes(), 2)}` + - `${pad(now.getSeconds(), 2)}` + - `${pad(now.getMilliseconds(), 3)}` - + if ( + typeof colFormat.defaultValue === 'string' && + colFormat.defaultValue === '@AUTONUMBER' + ) { e.data[colFormat.fieldName] = autoNumber } else { e.data[colFormat.fieldName] = colFormat.defaultValue diff --git a/ui/src/views/list/Tree.tsx b/ui/src/views/list/Tree.tsx index 5aeb0fba..61e66c74 100644 --- a/ui/src/views/list/Tree.tsx +++ b/ui/src/views/list/Tree.tsx @@ -46,6 +46,7 @@ import GridFilterDialogs from './GridFilterDialogs' import { addCss, addJs, + autoNumber, controlStyleCondition, GridExtraFilterState, setFormEditingExtraItemValues, @@ -288,8 +289,16 @@ const Tree = (props: TreeProps) => { continue } + // Grid'den gelen columnFormat'ları kullanarak default değerleri set et if (colFormat.defaultValue != null) { - e.data[colFormat.fieldName] = colFormat.defaultValue + if ( + typeof colFormat.defaultValue === 'string' && + colFormat.defaultValue === '@AUTONUMBER' + ) { + e.data[colFormat.fieldName] = autoNumber + } else { + e.data[colFormat.fieldName] = colFormat.defaultValue + } } if (extraFilters.some((f) => f.fieldName === colFormat.fieldName)) { diff --git a/ui/src/views/list/Utils.ts b/ui/src/views/list/Utils.ts index 4c3def6d..46a0c462 100644 --- a/ui/src/views/list/Utils.ts +++ b/ui/src/views/list/Utils.ts @@ -265,3 +265,18 @@ export function buildSeriesDto(seriesList: ChartSeriesDto[]) { valueField: s.name, })) } + +export function autoNumber() { + const now = new Date() + const pad = (n: number, width: number) => n.toString().padStart(width, '0') + + return ( + `${now.getFullYear()}` + + `${pad(now.getMonth() + 1, 2)}` + + `${pad(now.getDate(), 2)}` + + `${pad(now.getHours(), 2)}` + + `${pad(now.getMinutes(), 2)}` + + `${pad(now.getSeconds(), 2)}` + + `${pad(now.getMilliseconds(), 3)}` + ) +}