Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
greg
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
it-bott-integrasjoner
greg
Commits
2350e876
Commit
2350e876
authored
3 years ago
by
Tore.Brede
Browse files
Options
Downloads
Patches
Plain Diff
GREG-195: Clearing dirty state on submit
parent
9ffe0bc7
No related branches found
No related tags found
1 merge request
!279
GREG-195: Update end role button
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontend/src/routes/sponsor/guest/guestRoleInfo/index.tsx
+19
-7
19 additions, 7 deletions
frontend/src/routes/sponsor/guest/guestRoleInfo/index.tsx
frontend/src/routes/sponsor/guest/index.tsx
+1
-1
1 addition, 1 deletion
frontend/src/routes/sponsor/guest/index.tsx
with
20 additions
and
8 deletions
frontend/src/routes/sponsor/guest/guestRoleInfo/index.tsx
+
19
−
7
View file @
2350e876
...
@@ -21,7 +21,9 @@ import ConfirmDialog from '../../../../components/confirmDialog'
...
@@ -21,7 +21,9 @@ import ConfirmDialog from '../../../../components/confirmDialog'
interface
GuestRoleInfoProps
{
interface
GuestRoleInfoProps
{
guest
:
Guest
guest
:
Guest
reloadGuest
:
()
=>
void
}
}
const
endPeriodPost
=
(
id
:
string
,
data
:
{
end_date
:
Date
})
=>
{
const
endPeriodPost
=
(
id
:
string
,
data
:
{
end_date
:
Date
})
=>
{
const
payload
=
{
const
payload
=
{
end_date
:
format
(
data
.
end_date
as
Date
,
'
yyyy-MM-dd
'
),
end_date
:
format
(
data
.
end_date
as
Date
,
'
yyyy-MM-dd
'
),
...
@@ -94,7 +96,10 @@ const TableContainer = styled(TableContainerMui)({
...
@@ -94,7 +96,10 @@ const TableContainer = styled(TableContainerMui)({
paddingBottom
:
'
1.5625rem
'
,
paddingBottom
:
'
1.5625rem
'
,
})
})
export
default
function
GuestRoleInfo
({
guest
}:
GuestRoleInfoProps
)
{
export
default
function
GuestRoleInfo
({
guest
,
reloadGuest
,
}:
GuestRoleInfoProps
)
{
const
{
pid
,
id
}
=
useParams
<
GuestRoleInfoParams
>
()
const
{
pid
,
id
}
=
useParams
<
GuestRoleInfoParams
>
()
const
[
t
]
=
useTranslation
(
'
common
'
)
const
[
t
]
=
useTranslation
(
'
common
'
)
const
{
displayContactAtUnit
,
displayComment
}
=
useFeatureContext
()
const
{
displayContactAtUnit
,
displayComment
}
=
useFeatureContext
()
...
@@ -127,6 +132,14 @@ export default function GuestRoleInfo({ guest }: GuestRoleInfoProps) {
...
@@ -127,6 +132,14 @@ export default function GuestRoleInfo({ guest }: GuestRoleInfoProps) {
history
.
push
(
`/sponsor/guest/
${
guest
.
pid
}
`
)
history
.
push
(
`/sponsor/guest/
${
guest
.
pid
}
`
)
}
}
const
{
control
,
handleSubmit
,
setValue
,
reset
,
formState
:
{
isDirty
,
isValid
},
}
=
useForm
<
RoleFormData
>
({
mode
:
'
onChange
'
})
// Submit function for the save button
// Submit function for the save button
const
submit
:
SubmitHandler
<
RoleFormData
>
=
(
data
)
=>
{
const
submit
:
SubmitHandler
<
RoleFormData
>
=
(
data
)
=>
{
const
payload
:
{
start_date
?:
string
;
end_date
:
string
}
=
{
const
payload
:
{
start_date
?:
string
;
end_date
:
string
}
=
{
...
@@ -146,18 +159,17 @@ export default function GuestRoleInfo({ guest }: GuestRoleInfoProps) {
...
@@ -146,18 +159,17 @@ export default function GuestRoleInfo({ guest }: GuestRoleInfoProps) {
if
(
result
!==
null
)
{
if
(
result
!==
null
)
{
console
.
log
(
'
result
'
,
result
)
console
.
log
(
'
result
'
,
result
)
}
}
// Reload the guest so that the information on the overview page is updated
reloadGuest
()
// A submit does not clear the dirty state, so resetting values in the form
// to the values just submitted to clear the dirty-flag
reset
(
data
)
})
})
.
catch
((
error
)
=>
{
.
catch
((
error
)
=>
{
console
.
log
(
'
error
'
,
error
)
console
.
log
(
'
error
'
,
error
)
})
})
}
}
const
{
control
,
handleSubmit
,
setValue
,
formState
:
{
isDirty
,
isValid
},
}
=
useForm
<
RoleFormData
>
({
mode
:
'
onChange
'
})
const
onSubmit
=
handleSubmit
(
submit
)
const
onSubmit
=
handleSubmit
(
submit
)
const
[
showEndRoleConfirmationDialog
,
setShowEndRoleConfirmationDialog
]
=
const
[
showEndRoleConfirmationDialog
,
setShowEndRoleConfirmationDialog
]
=
useState
(
false
)
useState
(
false
)
...
...
This diff is collapsed.
Click to expand it.
frontend/src/routes/sponsor/guest/index.tsx
+
1
−
1
View file @
2350e876
...
@@ -56,7 +56,7 @@ function GuestRoutes({ reloadGuests }: GuestRoutesProps) {
...
@@ -56,7 +56,7 @@ function GuestRoutes({ reloadGuests }: GuestRoutesProps) {
return
(
return
(
<>
<>
<
Route
path
=
"/sponsor/guest/:pid/roles/:id"
>
<
Route
path
=
"/sponsor/guest/:pid/roles/:id"
>
<
GuestRoleInfo
guest
=
{
guestInfo
}
/>
<
GuestRoleInfo
guest
=
{
guestInfo
}
reloadGuest
=
{
reloadGuestInfo
}
/>
</
Route
>
</
Route
>
<
Route
exact
path
=
"/sponsor/guest/:pid/newrole"
>
<
Route
exact
path
=
"/sponsor/guest/:pid/newrole"
>
<
NewGuestRole
guest
=
{
guestInfo
}
reloadGuestInfo
=
{
reloadGuestInfo
}
/>
<
NewGuestRole
guest
=
{
guestInfo
}
reloadGuestInfo
=
{
reloadGuestInfo
}
/>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment