Skip to content

Commit

Permalink
[Unités] Fixe plusieurs glitchs sur la fiche unité (#1103)
Browse files Browse the repository at this point in the history
## Related Pull Requests & Issues

- Resolve #1102

----

- [ ] Tests E2E (Cypress)
  • Loading branch information
ivangabriele authored Jan 4, 2024
2 parents aeaebf9 + 5594e9e commit 6e851ad
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class JpaReportingRepositoryITests : AbstractDBTests() {
existingReportingDTO.reporting.copy(
missionId = 38,
attachedToMissionAtUtc =
ZonedDateTime.parse("2023-04-01T00:00:00Z"),
ZonedDateTime.parse("2023-04-01T00:00:00Z"),
),
)
assertThat(reportingWithMissionDTO.reporting.attachedEnvActionId).isNull()
Expand All @@ -132,7 +132,7 @@ class JpaReportingRepositoryITests : AbstractDBTests() {
jpaReportingRepository.save(
reportingWithMissionDTO.reporting.copy(
attachedEnvActionId =
UUID.fromString("e2257638-ddef-4611-960c-7675a3254c38"),
UUID.fromString("e2257638-ddef-4611-960c-7675a3254c38"),
),
)

Expand Down Expand Up @@ -346,7 +346,7 @@ class JpaReportingRepositoryITests : AbstractDBTests() {
jpaReportingRepository.save(
existingReportingDTO.reporting.copy(
attachedEnvActionId =
UUID.fromString("e2257638-ddef-4611-960c-7675a3254c38"),
UUID.fromString("e2257638-ddef-4611-960c-7675a3254c38"),
),
)
}
Expand All @@ -373,7 +373,7 @@ class JpaReportingRepositoryITests : AbstractDBTests() {
existingReportingDTO.reporting.copy(
missionId = 42,
attachedEnvActionId =
UUID.fromString("e2257638-ddef-4611-960c-7675a3254c38"),
UUID.fromString("e2257638-ddef-4611-960c-7675a3254c38"),
),
)
}
Expand All @@ -398,7 +398,7 @@ class JpaReportingRepositoryITests : AbstractDBTests() {
existingReportingDTO.reporting.copy(
missionId = 100,
attachedToMissionAtUtc =
ZonedDateTime.parse("2023-04-01T00:00:00Z"),
ZonedDateTime.parse("2023-04-01T00:00:00Z"),
),
)
}
Expand All @@ -421,7 +421,7 @@ class JpaReportingRepositoryITests : AbstractDBTests() {
jpaReportingRepository.save(
existingReportingDTO.reporting.copy(
detachedFromMissionAtUtc =
ZonedDateTime.parse("2023-04-01T00:00:00Z"),
ZonedDateTime.parse("2023-04-01T00:00:00Z"),
),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export function FormikNameSelect() {
(nextName: string | undefined) => {
if (nextName === 'SWITCH_TO_CUSTOM_NAME') {
setIsCustomName(true)
helpers.setValue(undefined)

return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function Item({ controlUnitResource, onEdit }: ItemProps) {
<IconButton accent={Accent.TERTIARY} Icon={Icon.Edit} onClick={handleEdit} title="Éditer ce moyen" />
</div>
</InfoBoxHeader>
<p>{controlUnitResource.note}</p>
{controlUnitResource.note && <Note>{controlUnitResource.note}</Note>}
</InfoBox>
</Wrapper>
)
Expand All @@ -51,16 +51,23 @@ const InfoBox = styled.div`

const InfoBoxHeader = styled.div`
display: flex;
margin-bottom: 8px;
color: ${p => p.theme.color.gunMetal};
> div:first-child {
display: flex;
flex-direction: column;
flex-grow: 1;
}
`

const Note = styled.div`
-webkit-box-orient: vertical;
-webkit-line-clamp: 3;
display: -webkit-box;
overflow: hidden;
`

const Name = styled.p`
font-weight: bold;
`
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ export function TextareaForm({ controlUnit, isLabelHidden, label, name, onSubmit
const [isEditing, setIsEditing] = useState(false)
const [value, setValue] = useState<string | undefined>(controlUnit[name])

const cancel = () => {
setIsEditing(false)
setValue(controlUnit[name])
}

const edit = () => {
setIsEditing(true)
}

const moveCursorToEnd = useCallback((event: ChangeEvent<HTMLTextAreaElement>) => {
event.target.setSelectionRange(event.target.value.length, event.target.value.length)
}, [])
Expand All @@ -31,10 +40,6 @@ export function TextareaForm({ controlUnit, isLabelHidden, label, name, onSubmit
setIsEditing(false)
}

const toggleIsEditing = useCallback(() => {
setIsEditing(!isEditing)
}, [isEditing])

if (isEditing) {
return (
<Form onSubmit={updateControlUnit}>
Expand All @@ -51,7 +56,7 @@ export function TextareaForm({ controlUnit, isLabelHidden, label, name, onSubmit
value={value}
/>
<div>
<Button accent={Accent.SECONDARY} onClick={toggleIsEditing}>
<Button accent={Accent.SECONDARY} onClick={cancel}>
Annuler
</Button>
<Button type="submit">Valider</Button>
Expand All @@ -64,7 +69,7 @@ export function TextareaForm({ controlUnit, isLabelHidden, label, name, onSubmit
<>
{!isLabelHidden && <Label>{label}</Label>}
{/* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions */}
<TextBox data-cy={`ControlUnitDialog-${name}`} onClick={toggleIsEditing}>
<TextBox data-cy={`ControlUnitDialog-${name}`} onClick={edit}>
{controlUnit[name]}
</TextBox>
</>
Expand Down

0 comments on commit 6e851ad

Please sign in to comment.