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
Show 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 = {
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
[
currentValue
,
setCurrentValue
]
=
React
.
useState
<
AgeFromToValue
>
({
age
:
value
.
age
,
from
:
value
.
age
?
''
:
value
.
from
,
to
:
value
.
age
?
''
:
value
.
to
,
age
:
value
.
age
||
''
,
from
:
value
.
age
?
''
:
(
value
.
from
||
''
)
,
to
:
value
.
age
?
''
:
(
value
.
to
||
''
)
,
});
const
handleFromChange
=
React
.
useCallback
((
event
:
ChangeEvent
<
HTMLInputElement
>
)
=>
{
setCurrentValue
(
prev
=>
({
age
:
''
,
to
:
prev
.
to
,
from
:
event
.
target
.
v
alue
}));
const
handleFromChange
=
React
.
useCallback
((
newValue
:
string
)
=>
{
setCurrentValue
(
prev
=>
({
age
:
''
,
to
:
prev
.
to
,
from
:
newV
alue
}));
},
[]);
const
handleToChange
=
React
.
useCallback
((
event
:
ChangeEvent
<
HTMLInputElement
>
)
=>
{
setCurrentValue
(
prev
=>
({
age
:
''
,
from
:
prev
.
from
,
to
:
event
.
target
.
v
alue
}));
const
handleToChange
=
React
.
useCallback
((
newValue
:
string
)
=>
{
setCurrentValue
(
prev
=>
({
age
:
''
,
from
:
prev
.
from
,
to
:
newV
alue
}));
},
[]);
const
onPresetChange
=
React
.
useCallback
((
age
:
AdvancedFilterAge
)
=>
{
...
...
@@ -64,9 +85,9 @@ const AgeFilter = ({ value = defaultValue, handleFilterChange, onClose }: Props)
}
const
from
=
currentValue
.
age
?
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
);
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_AGE
,
currentValue
.
age
);
},
[
handleFilterChange
,
currentValue
]);
...
...
@@ -75,7 +96,7 @@ const AgeFilter = ({ value = defaultValue, handleFilterChange, onClose }: Props)
<
TableColumnFilter
title=
"Set last duration"
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
}
onReset=
{
onReset
}
hasReset
...
...
@@ -90,20 +111,18 @@ const AgeFilter = ({ value = defaultValue, handleFilterChange, onClose }: Props)
</
PopoverCloseTriggerWrapper
>
</
Flex
>
<
Flex
mt=
{
3
}
>
<
Input
value=
{
currentValue
.
age
?
''
:
dayjs
(
currentValue
.
from
).
format
(
'
YYYY-MM-DD
'
)
}
<
Date
Input
value=
{
currentValue
.
age
?
''
:
currentValue
.
from
}
onChange=
{
handleFromChange
}
placeholder=
"From"
type=
"date"
size=
"sm"
max=
{
dayjs
().
format
(
'
YYYY-MM-DD
'
)
}
/>
<
Text
mx=
{
3
}
>
{
ndash
}
</
Text
>
<
Input
value=
{
currentValue
.
age
?
''
:
dayjs
(
currentValue
.
to
).
format
(
'
YYYY-MM-DD
'
)
}
<
Date
Input
value=
{
currentValue
.
age
?
''
:
currentValue
.
to
}
onChange=
{
handleToChange
}
placeholder=
"To"
type=
"date"
size=
"sm"
max=
{
dayjs
().
format
(
'
YYYY-MM-DD
'
)
}
/>
</
Flex
>
</
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