Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
b63014ea
Unverified
Commit
b63014ea
authored
Jun 04, 2025
by
Igor Stuev
Committed by
GitHub
Jun 04, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
advanced filter: fix date input (#2763)
parent
43519199
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
18 deletions
+37
-18
AgeFilter.tsx
ui/advancedFilter/filters/AgeFilter.tsx
+37
-18
No files found.
ui/advancedFilter/filters/AgeFilter.tsx
View file @
b63014ea
...
@@ -29,19 +29,40 @@ type Props = {
...
@@ -29,19 +29,40 @@ type Props = {
onClose
?:
()
=>
void
;
onClose
?:
()
=>
void
;
};
};
const
DateInput
=
({
value
,
onChange
,
placeholder
,
max
}:
{
value
:
string
;
onChange
:
(
value
:
string
)
=>
void
;
placeholder
:
string
;
max
:
string
})
=>
{
const
[
tempValue
,
setTempValue
]
=
React
.
useState
(
value
?
dayjs
(
value
).
format
(
'
YYYY-MM-DD
'
)
:
''
);
const
handleChange
=
React
.
useCallback
((
event
:
ChangeEvent
<
HTMLInputElement
>
)
=>
{
setTempValue
(
event
.
target
.
value
);
onChange
(
event
.
target
.
value
);
},
[
onChange
]);
return
(
<
Input
value=
{
tempValue
}
onChange=
{
handleChange
}
placeholder=
{
placeholder
}
type=
"date"
max=
{
max
}
autoComplete=
"off"
size=
"sm"
/>
);
};
const
AgeFilter
=
({
value
=
defaultValue
,
handleFilterChange
,
onClose
}:
Props
)
=>
{
const
AgeFilter
=
({
value
=
defaultValue
,
handleFilterChange
,
onClose
}:
Props
)
=>
{
const
[
currentValue
,
setCurrentValue
]
=
React
.
useState
<
AgeFromToValue
>
({
const
[
currentValue
,
setCurrentValue
]
=
React
.
useState
<
AgeFromToValue
>
({
age
:
value
.
age
,
age
:
value
.
age
||
''
,
from
:
value
.
age
?
''
:
value
.
from
,
from
:
value
.
age
?
''
:
(
value
.
from
||
''
)
,
to
:
value
.
age
?
''
:
value
.
to
,
to
:
value
.
age
?
''
:
(
value
.
to
||
''
)
,
});
});
const
handleFromChange
=
React
.
useCallback
((
event
:
ChangeEvent
<
HTMLInputElement
>
)
=>
{
const
handleFromChange
=
React
.
useCallback
((
newValue
:
string
)
=>
{
setCurrentValue
(
prev
=>
({
age
:
''
,
to
:
prev
.
to
,
from
:
event
.
target
.
v
alue
}));
setCurrentValue
(
prev
=>
({
age
:
''
,
to
:
prev
.
to
,
from
:
newV
alue
}));
},
[]);
},
[]);
const
handleToChange
=
React
.
useCallback
((
event
:
ChangeEvent
<
HTMLInputElement
>
)
=>
{
const
handleToChange
=
React
.
useCallback
((
newValue
:
string
)
=>
{
setCurrentValue
(
prev
=>
({
age
:
''
,
from
:
prev
.
from
,
to
:
event
.
target
.
v
alue
}));
setCurrentValue
(
prev
=>
({
age
:
''
,
from
:
prev
.
from
,
to
:
newV
alue
}));
},
[]);
},
[]);
const
onPresetChange
=
React
.
useCallback
((
age
:
AdvancedFilterAge
)
=>
{
const
onPresetChange
=
React
.
useCallback
((
age
:
AdvancedFilterAge
)
=>
{
...
@@ -64,9 +85,9 @@ const AgeFilter = ({ value = defaultValue, handleFilterChange, onClose }: Props)
...
@@ -64,9 +85,9 @@ const AgeFilter = ({ value = defaultValue, handleFilterChange, onClose }: Props)
}
}
const
from
=
currentValue
.
age
?
const
from
=
currentValue
.
age
?
dayjs
((
dayjs
().
valueOf
()
-
getDurationFromAge
(
currentValue
.
age
))).
toISOString
()
:
dayjs
((
dayjs
().
valueOf
()
-
getDurationFromAge
(
currentValue
.
age
))).
toISOString
()
:
dayjs
(
currentValue
.
from
).
startOf
(
'
day
'
).
toISOString
();
dayjs
(
currentValue
.
from
||
undefined
).
startOf
(
'
day
'
).
toISOString
();
handleFilterChange
(
FILTER_PARAM_FROM
,
from
);
handleFilterChange
(
FILTER_PARAM_FROM
,
from
);
const
to
=
currentValue
.
age
?
dayjs
().
toISOString
()
:
dayjs
(
currentValue
.
to
).
endOf
(
'
day
'
).
toISOString
();
const
to
=
currentValue
.
age
?
dayjs
().
toISOString
()
:
dayjs
(
currentValue
.
to
||
undefined
).
endOf
(
'
day
'
).
toISOString
();
handleFilterChange
(
FILTER_PARAM_TO
,
to
);
handleFilterChange
(
FILTER_PARAM_TO
,
to
);
handleFilterChange
(
FILTER_PARAM_AGE
,
currentValue
.
age
);
handleFilterChange
(
FILTER_PARAM_AGE
,
currentValue
.
age
);
},
[
handleFilterChange
,
currentValue
]);
},
[
handleFilterChange
,
currentValue
]);
...
@@ -75,7 +96,7 @@ const AgeFilter = ({ value = defaultValue, handleFilterChange, onClose }: Props)
...
@@ -75,7 +96,7 @@ const AgeFilter = ({ value = defaultValue, handleFilterChange, onClose }: Props)
<
TableColumnFilter
<
TableColumnFilter
title=
"Set last duration"
title=
"Set last duration"
isFilled=
{
Boolean
(
currentValue
.
from
||
currentValue
.
to
||
currentValue
.
age
)
}
isFilled=
{
Boolean
(
currentValue
.
from
||
currentValue
.
to
||
currentValue
.
age
)
}
isTouched=
{
value
.
age
?
value
.
age
!==
currentValue
.
age
:
!
isEqual
(
currentValue
,
value
)
}
isTouched=
{
currentValue
.
age
?
value
.
age
!==
currentValue
.
age
:
Boolean
(
currentValue
.
from
&&
currentValue
.
to
&&
!
isEqual
(
currentValue
,
value
)
)
}
onFilter=
{
onFilter
}
onFilter=
{
onFilter
}
onReset=
{
onReset
}
onReset=
{
onReset
}
hasReset
hasReset
...
@@ -90,20 +111,18 @@ const AgeFilter = ({ value = defaultValue, handleFilterChange, onClose }: Props)
...
@@ -90,20 +111,18 @@ const AgeFilter = ({ value = defaultValue, handleFilterChange, onClose }: Props)
</
PopoverCloseTriggerWrapper
>
</
PopoverCloseTriggerWrapper
>
</
Flex
>
</
Flex
>
<
Flex
mt=
{
3
}
>
<
Flex
mt=
{
3
}
>
<
Input
<
Date
Input
value=
{
currentValue
.
age
?
''
:
dayjs
(
currentValue
.
from
).
format
(
'
YYYY-MM-DD
'
)
}
value=
{
currentValue
.
age
?
''
:
currentValue
.
from
}
onChange=
{
handleFromChange
}
onChange=
{
handleFromChange
}
placeholder=
"From"
placeholder=
"From"
type=
"date"
max=
{
dayjs
().
format
(
'
YYYY-MM-DD
'
)
}
size=
"sm"
/>
/>
<
Text
mx=
{
3
}
>
{
ndash
}
</
Text
>
<
Text
mx=
{
3
}
>
{
ndash
}
</
Text
>
<
Input
<
Date
Input
value=
{
currentValue
.
age
?
''
:
dayjs
(
currentValue
.
to
).
format
(
'
YYYY-MM-DD
'
)
}
value=
{
currentValue
.
age
?
''
:
currentValue
.
to
}
onChange=
{
handleToChange
}
onChange=
{
handleToChange
}
placeholder=
"To"
placeholder=
"To"
type=
"date"
max=
{
dayjs
().
format
(
'
YYYY-MM-DD
'
)
}
size=
"sm"
/>
/>
</
Flex
>
</
Flex
>
</
TableColumnFilter
>
</
TableColumnFilter
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment